You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
3.0 KiB

  1. ---
  2. order: 1
  3. parent:
  4. title: Block Sync
  5. order: 6
  6. ---
  7. # Block Sync
  8. *Formerly known as Fast Sync*
  9. In a proof of work blockchain, syncing with the chain is the same
  10. process as staying up-to-date with the consensus: download blocks, and
  11. look for the one with the most total work. In proof-of-stake, the
  12. consensus process is more complex, as it involves rounds of
  13. communication between the nodes to determine what block should be
  14. committed next. Using this process to sync up with the blockchain from
  15. scratch can take a very long time. It's much faster to just download
  16. blocks and check the merkle tree of validators than to run the real-time
  17. consensus gossip protocol.
  18. ## Using Block Sync
  19. To support faster syncing, Tendermint offers a `blocksync` mode, which
  20. is enabled by default, and can be toggled in the `config.toml` or via
  21. `--blocksync.enable=false`.
  22. In this mode, the Tendermint daemon will sync hundreds of times faster
  23. than if it used the real-time consensus process. Once caught up, the
  24. daemon will switch out of Block Sync and into the normal consensus mode.
  25. After running for some time, the node is considered `caught up` if it
  26. has at least one peer and it's height is at least as high as the max
  27. reported peer height. See [the IsCaughtUp
  28. method](https://github.com/tendermint/tendermint/blob/b467515719e686e4678e6da4e102f32a491b85a0/blockchain/pool.go#L128).
  29. Note: There are multiple versions of Block Sync. Please use v0 as the other versions are no longer supported.
  30. If you would like to use a different version you can do so by changing the version in the `config.toml`:
  31. ```toml
  32. #######################################################
  33. ### Block Sync Configuration Connections ###
  34. #######################################################
  35. [blocksync]
  36. # If this node is many blocks behind the tip of the chain, BlockSync
  37. # allows them to catchup quickly by downloading blocks in parallel
  38. # and verifying their commits
  39. enable = true
  40. # Block Sync version to use:
  41. # 1) "v0" (default) - the standard Block Sync implementation
  42. # 2) "v2" - DEPRECATED, please use v0
  43. version = "v0"
  44. ```
  45. If we're lagging sufficiently, we should go back to block syncing, but
  46. this is an [open issue](https://github.com/tendermint/tendermint/issues/129).
  47. ## The Block Sync event
  48. When the tendermint blockchain core launches, it might switch to the `block-sync`
  49. mode to catch up the states to the current network best height. the core will emits
  50. a fast-sync event to expose the current status and the sync height. Once it catched
  51. the network best height, it will switches to the state sync mechanism and then emit
  52. another event for exposing the fast-sync `complete` status and the state `height`.
  53. The user can query the events by subscribing `EventQueryBlockSyncStatus`
  54. Please check [types](https://pkg.go.dev/github.com/tendermint/tendermint/types?utm_source=godoc#pkg-constants) for the details.
  55. ## Implementation
  56. To read more on the implamentation please see the [reactor doc](./reactor.md) and the [implementation doc](./implementation.md)