Repository navigation
fix(sync): judge the sync gate against peers' Status heads - #791
Draft
MegaRedHand wants to merge 1 commit into
Draft
MegaRedHand wants to merge 1 commit into
MegaRedHand wants to merge 1 commit into
Conversation
A node reported itself synced while far behind (#559): the tracker took the freshest block the network knows from the node's own imported chain, which trails the head during a catch-up, so its network-stall override fired and the node attested and proposed on a stale head. The beacon follower had the same bug and reported synced through whole catch-ups. Follow Lighthouse and Prysm instead: a node is syncing only when its head trails the wall clock and the head its peers report in Status is ahead of its own. P2P keeps each connected peer's latest Status head (re-requested every few slots, dropped on disconnect, a head past the clock ignored) and publishes the second-highest of three or more on the Store. Thresholds are per chain: leanSpec's 4/2 on lean, Lighthouse's two epochs of clock lag and one epoch of peer lead on beacon.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description / Motivation
The sync gate reported Synced while a node was far behind (#559), so it attested and proposed on a stale head. It took the freshest block the network knows from the node's own imported chain, which trails the head during a catch-up, so the network-stall override fired. The beacon follower had the same bug:
docs/beacon_wire.mdrecords it reporting synced through a 10-minute catch-up up to 98 slots behind.This follows Lighthouse and Prysm: a node is syncing only when its head trails the wall clock and the head its peers report in
Statusis ahead of its own. Peers decide "behind vs. stalled"; the clock keeps any peer claim from idling a node that is current.What Changed
crates/blockchain/src/sync_status.rs: new rule with per-chainSyncThresholds. Lean keeps leanSpec ci: add a Commit-Boost check to the kurtosis battery #708's 4/2. Beacon uses Lighthouse's numbers: 2 epochs of clock lag (DEFAULT_SYNC_TOLERANCE_EPOCHS, also Prysm'sshouldReSync) and 1 epoch of peer lead (SLOT_IMPORT_TOLERANCE). There is also a bounded startup hold before the firstStatus(lean 8 slots, beacon 1 epoch).crates/net/p2p/src/peer_heads.rs(new): each connected peer's latestStatushead, dropped on disconnect.FUTURE_SLOT_TOLERANCE).Store::network_head.Statusis re-requested every 4 slots (lean) or every half epoch (beacon, Prysm's cadence). A refresh answer starts range sync only beyond the threshold lead, so it never races gossip.crates/blockchain/src/lib.rs: the tracker readsStore::network_head, and the beacon fork guard is kept.spec_deviations.mdentry (lean departs from leanSpec ci: add a Commit-Boost check to the kurtosis battery #708), plus updates toarchitecture.md,rpc.mdandbeacon_wire.md.Correctness / Behavior Guarantees
Tests Added / Run
Store::network_headsharing, and the beacon follower cases.make fmt,make lintandmake testall pass (2,934 tests).is_syncing=false, 2 peers, duty endpoints 200, and the VC attests, aggregates and does sync-committee duties every slot.Related Issues / PRs
✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(test-consensusplustest-node, atrelease-fast) — all passing