Owner: @Youngjoon Lee
<aside> 💬
Reference: Ethereum Beacon Chain - Checkpoint Sync
The sync protocol is not defined in the Ethereum consensus specifications. Instead, it is client-specific. https://lighthouse-book.sigmaprime.io/checkpoint-sync.html https://docs.prylabs.network/docs/prysm-usage/checkpoint-sync
All the following mechanisms were obtained by: Code Investigation: https://github.com/sigp/lighthouse. </aside>
Full sync: Syncing blocks from the genesis by re-executing every transaction.
Range Sync: A mechanism used internally by Full Sync and Checkpoint Sync.
Checkpoint sync: Fetching a recently finalized checkpoint, including the associated block and anything necessary (e.g. state), from a trusted node (or via file import), and starting syncing forward to the head of the chain.
When the lighthouse process is started, if the --checkpoint-sync-url
is set,
https://github.com/sigp/lighthouse/blob/029b4f21047c37d1ffde51c554737b1aa0880f97/beacon_node/client/src/builder.rs#L385-L385
head_slot
as well as head_root
. Also, finalized_epoch
and finalized_root
.peer.head_slot > local.head_slot + 32
, we consider that the peer is sufficient ahead from us and start a range sync: https://github.com/sigp/lighthouse/blob/bf955c7543dac8911a6f6c334b5b3ca4ef728d9c/beacon_node/network/src/sync/manager.rs#L378-L378
peer.finalized_epoch > local.finalized_epoch
, also start a range sync but with a different type.RangeSync
struct: https://github.com/sigp/lighthouse/blob/029b4f21047c37d1ffde51c554737b1aa0880f97/beacon_node/network/src/sync/range_sync/range.rs#L67-L67.
SyncingChain
struct, which is held in the RangeSync
struct: https://github.com/sigp/lighthouse/blob/029b4f21047c37d1ffde51c554737b1aa0880f97/beacon_node/network/src/sync/range_sync/range.rs#L67-L67.
SyncingChain
struct contains all meaningful methods.
SyncingChain
), shuffle the peers, distribute the batch requests across them, and merge responses. The length of a batch is 2-epoch. Each peer is requested for a single batch: https://github.com/sigp/lighthouse/blob/029b4f21047c37d1ffde51c554737b1aa0880f97/beacon_node/network/src/sync/range_sync/chain.rs#L1098req.start_slot + req.count
because some requests are not for syncing to the chain head.