Insert block to shard chain process in Goquarkchain

There are 4 ways to add shard blocks.

  1. Synchronizer that download blocks starting from a given header going backward to the latest known block in local db

  2. blocks broadcasted from peers: This path is mainly for propagating new blocks mined across the network.

  3. Master to download and add missing shard blocks when syncing root blocks

  4. Create Block: adding block generate shard

    Ultimately they follow the same path.
    Each step starts after the previous one completes (i.e. all the RPCs returned).

  5. The shard validates the block, updating the local shard chain, EVM state, and put the block in db.

  6. The shard broadcasts the block (header hash, [xshard tx]) ( CrossShardTransactionDeposits ) to all its neighbor shards in parallel.

  7. The shard sends the block header to root chain and the root chain will persist the header in its db.

This process guarantees that if the root chain has a shard block then this exact shard block must have been known to all the shards reaching a consistent cluster state - all the processes in the cluster have this shard block. This guarantee is required for adding root block (as described below) to succeed.

  1. Syncing Root Blocks
  2. Syncing Shard Blocks
  3. Blocks broadcasted from peers
  4. Create Block