Skip to content

Commit 88b3e5e

Browse files
committed
docs: document UnknownBlockSync vs UnknownChainSync split
Medium issue ChainSafe#9 from REVIEW.md: two overlapping unknown-block mechanisms existed without clear documentation of which to use when. Add detailed module-level doc to unknown_block.zig explaining: - UnknownBlockSync: triggered by gossip blocks with unknown parent; stores full block bytes; resolves by parent chain walk + recursive import - UnknownChainSync: triggered by unknown roots from attestations/status; no block bytes, only roots; resolves by backwards header chain to fork choice, then triggers forward range sync - The key distinction: UnknownBlockSync has the block, UnknownChainSync does not. They are complementary, not redundant. 🤖 Generated with AI assistance
1 parent b0e7838 commit 88b3e5e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/sync/unknown_block.zig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@
1010
//! - Peer balancing for root requests
1111
//! - Proper cleanup of resolved/expired entries
1212
//!
13+
//! ## Split with unknown_chain/
14+
//!
15+
//! There are TWO mechanisms for handling unknown block roots. They serve
16+
//! distinct use cases and should not be merged:
17+
//!
18+
//! ### UnknownBlockSync (this module)
19+
//! - Triggered by: gossip blocks with an unknown *parent* root
20+
//! - Has full block bytes in hand; only the parent chain is missing
21+
//! - Stores: full block bytes ([]const u8) per pending block
22+
//! - Resolves by: walking the parent chain by root until reaching a known block,
23+
//! then recursively importing children
24+
//! - Use case: filling in the gap for a gossip block that arrived out of order
25+
//!
26+
//! ### UnknownChainSync (unknown_chain/)
27+
//! - Triggered by: unknown roots from attestations, peer status, getHeader
28+
//! - Has only the root; no block bytes at all
29+
//! - Stores: minimal headers (slot + parent_root) to reconstruct chain order
30+
//! - Resolves by: building a backward header chain until it links to fork choice,
31+
//! then triggering forward range sync via SyncService
32+
//! - Use case: bootstrapping from a completely unknown chain tip (e.g. attestations
33+
//! to a block we have never seen)
34+
//!
35+
//! The key distinction: UnknownBlockSync has the block, UnknownChainSync does not.
36+
//! TS Lodestar is migrating from the former to the latter (PR #8221), but both
37+
//! co-exist here as they address different edge cases.
38+
//!
1339
//! Reference: Lodestar `packages/beacon-node/src/sync/unknownBlock.ts`
1440

1541
const std = @import("std");

0 commit comments

Comments
 (0)