Repository navigation
fix(node): pin boot enumeration snapshots below the reported head - #2165
Merged
Merged
Conversation
) A load-balanced RPC reports its freshest upstream's head, then routes each pinned eth_call to any upstream. Upstreams behind that head reject it, and every BootRetry attempt re-reads a fresh head, so boot never converges and spends its whole budget. The slash and blacklist enumerations now pin their reads at head - SNAPSHOT_LAG_MARGIN_BLOCKS (256, ~64s on Arbitrum). The CapacityBond registry seeds its cursor there too, which also closes a gap: its `latest` reads can resolve below the reported head on a lagging upstream. Each tail cursor is seeded at the snapshot block and every sink is idempotent, so the first tick replays the margin harmlessly. The e2e ChainFixture and the bring-up e2e mine past the margin, because anvil holds no state at or below a loaded head. Closes #2164 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical snapshot consistency issues remain in blacklist re-enumeration and registry boot reads, plus a deployment-floor issue.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
This PR makes boot-time chain enumeration resilient to lagging load-balanced RPC upstreams by using a 256-block snapshot margin.
Changes:
- Adds shared snapshot calculation and tests.
- Updates slash, blacklist, and registry cursor initialization.
- Adjusts Anvil E2E fixtures to mine beyond the margin.
| File | Summary |
|---|---|
crates/node/tests/anvil_bringup_shutdown_e2e.rs |
Mines beyond the snapshot margin after deployment. |
crates/node/src/slash_watcher.rs |
Pins slash enumeration to the lagged snapshot. |
crates/node/src/dht/capacity_bond_registry.rs |
Seeds the cursor below head; registry reads may still precede that cursor. |
crates/node/src/chain_events/shared_head.rs |
Adds snapshot margin logic; saturation can precede contract deployment. |
crates/node/src/chain_events/resumable_watcher.rs |
Updates cursor documentation. |
crates/node/src/blacklist_watcher.rs |
Pins blacklist enumeration; periodic re-enumeration can replace newer tail state. |
crates/e2e/src/time.rs |
Adds multi-block mining support. |
crates/e2e/src/chain.rs |
Mines beyond the margin after state loading. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit b317a0b in the Show a line coverage summary of the most impacted files.
Updated |
…ry pages; deploy-floor fallback - The blacklist periodic re-enumeration pins the head again (SnapshotPin::Head). Its fold replaces the origin set wholesale, so a snapshot from the lag margin would drop an origin the tail had already blacklisted inside it. Only the boot pass takes the lagged block. - The CapacityBond registry boot enumeration pins every getRegisteredNodes page to the snapshot block, so the pages agree with each other and with the seeded cursor even on an upstream lagging past the margin. - boot_snapshot_block checks eth_getCode at the lagged block and pins the head when the contract has no code there (deployed inside the margin), so a dev-deploy.sh chain or a boot right after a deploy no longer decodes an empty return and fails boot. The bring-up e2e now boots without mining to exercise that path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The blacklist, registry and slash periodic resyncs read the same lagged snapshot block as boot, so they no longer fail on every attempt behind a load-balanced RPC. Each sink records the block of its latest tail change per key, and the fold keeps every change above the snapshot block on top of the snapshot: blacklist origins and removed hash entries, every registry projection of a changed node, and every tail-seen slash. The fold is correct for any snapshot block, including one below blocks the tail has already applied when the reported head goes backwards. - snapshot_block (renamed from boot_snapshot_block) logs when it falls back to head for a contract younger than the margin, and documents that the margin is a block count sized for Arbitrum. - New counters decdn_blacklist_reenumeration_failures_total and decdn_slash_resync_failures_total, with ADR rows and alert rules. - Tests: registry boot pins its pages and cursor to the snapshot block; registry, blacklist and slash folds keep tail changes above the block; a stalled slash contract read times out; the slash boot seeds its cursor at the pinned block. - Prose: ADR 011 and ADR 019 describe the snapshot block and the fold; stale "at head" / `latest` wording and an off-by-one replay range fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.


Summary
Boot enumeration snapshots pinned every
eth_callto the exact head fromHeadSource::head(). A load-balanced RPC such as dRPC reports its freshest upstream's head, then routes each pinned call to any upstream. Upstreams that lag by 40–200 blocks reject the call, and eachBootRetryattempt re-reads a fresh head, so boot spent its 600s budget and exited.SNAPSHOT_LAG_MARGIN_BLOCKS = 256(about 64s on Arbitrum) andsnapshot_block()inchain_events::shared_head.snapshot_blockcheckseth_getCode(contract, head − 256). If there's no code there, the contract was deployed inside the margin (adev-deploy.shchain, or a boot right after a deploy), so it pins at head instead and logs it.getRegisteredNodespage) to that block, and seed their tail cursors there. The tail replays[snapshot, head]; every sink is idempotent.decdn_blacklist_reenumeration_failures_totalanddecdn_slash_resync_failures_total, with ADR appendix rows and alert rules. Before this, those failures only logged awarn!.head − 256, and the first tail tick enforces a takedown inside that window.anvil_loadStatehead, and errors rather than returning empty code there. SoChainFixture::launchminesmargin + 1blocks after the load.anvil_bringup_shutdown_e2eboots a fresh anvil without mining, which exercises the getCode fallback.The margin is a constant, not a config knob. 256 would have passed every probe in the issue.
Test plan
snapshot_block: the margin below head when the contract has code there, and head when it doesn't.head − 256.head − 256, and so is the cursor seed.cargo nextest run -p decdn-node: 1363/1363anvil_bringup_shutdown_e2epassed on a fresh anvil with no mining (the getCode fallback)decdn-e2e --features anvil-e2e: 69/69.node_pull_pool_adoptfailed once under the parallel suite, then passed 4/4 in isolation.--features anvil-e2e), rustdoc-D warnings, pre-commit hooksslash enumeration complete, and thatdecdn_*_resync_failures_total/decdn_blacklist_reenumeration_failures_totalstay flatCloses #2164
🤖 Generated with Claude Code