mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Documents and simplifies syncing code (#738)
* Add duplication prevention to gossipsub * Clean up topic logs * Add content addressed messages for gossip * Support BlocksByRange step parameter * Add initial docs to syncing * Adds documentation and simplify code in sync * Remove unnecessary comment * Fix fmt issue * Add batch log to sync
This commit is contained in:
@@ -16,36 +16,11 @@
|
||||
//! further peers connect, this process is run in parallel with those peers, until our head is
|
||||
//! within `SLOT_IMPORT_TOLERANCE` of all connected peers.
|
||||
//!
|
||||
//! Batch Syncing
|
||||
//! ## Batch Syncing
|
||||
//!
|
||||
//! This syncing process start by requesting `BLOCKS_PER_REQUEST` blocks from a peer with an
|
||||
//! unknown chain (with a greater slot height) starting from our current head slot. If the earliest
|
||||
//! block returned is known to us, then the group of blocks returned form part of a known chain,
|
||||
//! and we process this batch of blocks, before requesting more batches forward and processing
|
||||
//! those in turn until we reach the peer's chain's head. If the first batch doesn't contain a
|
||||
//! block we know of, we must iteratively request blocks backwards (until our latest finalized head
|
||||
//! slot) until we find a common ancestor before we can start processing the blocks. If no common
|
||||
//! ancestor is found, the peer has a chain which is not part of our finalized head slot and we
|
||||
//! drop the peer and the downloaded blocks.
|
||||
//! Once we are fully synced with all known peers, the state of the manager becomes `Regular` which
|
||||
//! then allows for parent lookups of propagated blocks.
|
||||
//! See `RangeSync` for further details.
|
||||
//!
|
||||
//! A schematic version of this logic with two chain variations looks like the following.
|
||||
//!
|
||||
//! |----------------------|---------------------------------|
|
||||
//! ^finalized head ^current local head ^remotes head
|
||||
//!
|
||||
//!
|
||||
//! An example of the remotes chain diverging before our current head.
|
||||
//! |---------------------------|
|
||||
//! ^---------------------------------------------|
|
||||
//! ^chain diverges |initial batch| ^remotes head
|
||||
//!
|
||||
//! In this example, we cannot process the initial batch as it is not on a known chain. We must
|
||||
//! then backwards sync until we reach a common chain to begin forwarding batch syncing.
|
||||
//!
|
||||
//!
|
||||
//! Parent Lookup
|
||||
//! ## Parent Lookup
|
||||
//!
|
||||
//! When a block with an unknown parent is received and we are in `Regular` sync mode, the block is
|
||||
//! queued for lookup. A round-robin approach is used to request the parent from the known list of
|
||||
|
||||
Reference in New Issue
Block a user