Blockchain Synchronization - zoobc/zoobc-core Wiki

Blockchain Synchronization

Blockchain Synchronization is a mechanism to make sure that the states of all the nodes in the network are the same and synchronized. By the stes mentioned in this context is the Blocks, Transactions and other data stored in the individual nodes. It works on the basis of Eventual Consistency by which it means the nodes in the networks are allowed to diverge and have different opnion about the blockchain's state once in a while that may be caused by the network latency, rogue nodes, corrupted data, etc; but will eventually agree upon one state accross the network.

  1. The node will try to connect to his peers.
  2. Then the node will try to download all of the spine blocks from its peers.
  3. After the download of the spine blocks completed, the node will start applying a snapshot from the latest snapshot the spine chain has.
  4. After that the mainchain will be downloaded from the blockheight for which the snapshot was applied.
  5. After the process finishes, the blockchain will continue either by receiving blocks from his peers, or catching up the chain of his peers (and resolving forks).

When the node restarted:

  1. The node will try to connect to his peers.
  2. Then the node will try to sync his spine chain with his peers. If the spine chain is out of sync for more than MaxRollbackHeight, it will exit the program and print the error message regarding that. Otherwise the node will try to sync the spine chain.
  3. After the syncing of spine chain finishes, the node will flush the data in his mainchain, and apply the latest snapshot contained in the spine chain.
  4. After that the mainchain will be downloaded from the blockheight for which the snapshot was applied.
  5. After the process finishes, the blockchain will continue either by receiving blocks from his peers, or catching up the chain of his peers (and resolving forks).

Blockchain Synchronization have 2 portion of mechanism: