Repository navigation
fix(node): retry transient boot-time chain reads instead of exiting - #2160
Conversation
A single transient JSON-RPC error (e.g. code 1 "no available upstreams", code 19 "Temporary internal error") during any of the four fail-closed boot reads propagated out of run() and exited the daemon, turning every restart against a flaky provider into a crash-loop. - New chain_events::boot_retry::BootRetry: each bootstrap (CapacityBond registry, slash enumeration, PaymentPool usdc() self-check, blacklist enumeration + enforcement) retries its read phase on the watcher backoff (1 s doubling to 60 s) under one shared 10-minute boot deadline. Each retry logs a WARN and bumps decdn_chain_boot_read_retries_total. - Deterministic faults stay fatal at once: no contract (ZeroData), ABI mismatch, revert, -32600..-32602, HTTP 4xx other than 408/429, a registry page/active length mismatch, a local eviction error at boot. - Shared classifier in decdn-client (provider::is_permanent_contract_error / is_permanent_rpc_error), a denylist of deterministic failures; client registry discovery uses it too, so provider outages are retried there. - SharedHead keeps the typed provider error through its cache; slash boot reads are pinned to the snapshot block; registry/slash/usdc() reads carry the per-call RPC timeout. - Startup stays fail-closed: the ALPN router still waits on the blacklist enumeration and a clean enforcement pass. - ADR 019 gains a boot-time chain reads section; ADR 012, the observability appendix, runbook and CHANGELOG are updated. Closes #2159 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Moderate issues remain in blacklist failure precedence, retry-pass duration, and enforcement of the shared deadline; provider documentation also needs correction.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR adds fail-closed retries for transient boot-time chain reads, preventing provider failures from causing daemon crash loops.
Changes:
- Adds shared retry/backoff, deadlines, error classification, and metrics.
- Applies retries to registry, slash, settlement, and blacklist bootstraps.
- Updates tests, client discovery, documentation, ADRs, and changelog.
The review leaves three moderate issues involving blacklist failure handling and deadline enforcement, plus one provider-classifier documentation nit.
| File | Summary |
|---|---|
docs/runbook.md |
Documents boot retry behavior |
crates/node/tests/anvil_settlement_e2e.rs |
Updates settlement test setup |
crates/node/src/slash_watcher.rs |
Adds pinned, retryable slash reads |
crates/node/src/runtime/mod.rs |
Wires the shared boot retry budget |
crates/node/src/payment_settlement.rs |
Retries the PaymentPool self-check |
crates/node/src/metrics.rs |
Adds boot retry metrics |
crates/node/src/dht/node_address.rs |
Updates bootstrap documentation |
crates/node/src/dht/capacity_bond_registry.rs |
Adds retryable registry bootstrap |
crates/node/src/chain_events/shared_head.rs |
Preserves typed head-read errors |
crates/node/src/chain_events/mod.rs |
Exposes the retry module |
crates/node/src/chain_events/boot_retry.rs |
Implements shared retry and classification |
crates/node/src/buyer_channel.rs |
Clarifies bootstrap behavior |
crates/node/src/blacklist_watcher.rs |
Retries blacklist enumeration and enforcement |
crates/client/tests/snapshots/public_api__public_api.snap |
Updates the public API snapshot |
crates/client/src/provider.rs |
Adds shared RPC error classification |
crates/client/src/discovery.rs |
Reuses the shared classifier |
CHANGELOG.md |
Records the fix |
adr/appendix-observability.md |
Documents the new metric |
adr/019-node-onboarding.md |
Specifies boot-time retry behavior |
adr/012-client.md |
Documents classifier behavior |
💡 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 7fa83f5 in the Show a line coverage summary of the most impacted files.
Updated |
PaymentPool.feeRouter() is immutable, so a single transient error at boot left the fee-shares watcher unregistered and the operator share on the floor for the life of the process. The reads also had no per-call timeout and logged unsanitized alloy errors (the RPC URL can carry an API key). Move the reads into fee_shares::seed_from_chain: both retry transient errors through BootRetry on the shared boot deadline, carry the per-call timeout, and log with sanitize_err_chain. They stay non-fatal: a deterministic error or an exhausted budget seeds the floor share, and a failed getShares() still keeps the router so the watcher's re-read can recover the share. ADR 019 and the CHANGELOG entry cover the change. Refs #2159 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Cap the best-effort fee-share reads at a 1-minute sub-budget of the boot deadline (BootRetry::capped) so a flapping provider cannot spend the time the later fail-closed usdc() and blacklist reads need. - Blacklist boot enforcement stops at its first failed scope read, and the attempt's cause prefers an eviction (disk) failure over a scope failure, so a disk fault is not hidden behind an RPC blip. Each scope_check caller logs what the failure means on its path; eviction logs carry the full I/O cause. - New decdn_fee_shares_watcher_unregistered gauge: 1 when the startup feeRouter() read failed and the watcher never started. - The fee-shares watcher's periodic getShares() carries the per-call timeout and logs a sanitized error. - Extract the PaymentPool usdc() self-check so it is testable. - Tests: stalled-provider bounds for the slash, registry and fee reads; registry bootstrap retry wiring; slash reads pinned to the snapshot block (stub + wiremock block-tag check); permanent head error fails boot at once; eviction error at boot is a permanent BootFault; a reverting scope read fails at once; the boot pass stops at the first scope failure; a failed live enforcement forces a prompt rescan; a failed scope read on HashRemoved keeps the deny; capped sub-budget; usdc() self-check. - Docs: retry-counter scope, HeadSource/SharedHead docs, the serve gate comment, enforcement-failure metric wording, ADR 019/012 STE fixes and the 4xx/Retry-After/JSON-body nuance, runbook, CHANGELOG. Refs #2159 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- provider.rs: state that alloy reports a 4xx carrying Retry-After as HttpErrorWithRetryAfter, which the classifier treats as transient, and pin it with a test. - boot_retry.rs: explain why the boot deadline bounds retry sleeps but not a running attempt: a failing attempt ends at its first timed read, so only a slow but healthy provider can stretch one, and fail-closed rests on the enforcement gate, not the deadline. Refs #2159 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical and moderate blacklist-enforcement correctness findings remain unresolved, with an additional documentation nit.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1



Summary
Fixes #2159. A transient JSON-RPC error during a boot-time chain read exited the daemon, so a flaky shared provider turned every restart into a crash-loop (2–87 restarts per node per deploy).
BootRetry(crates/node/src/chain_events/boot_retry.rs): the four fail-closed bootstraps — CapacityBond registry, slash enumeration, PaymentPoolusdc()self-check, blacklist enumeration + enforcement — retry their read phase on the watcher backoff (1 s → 60 s) under one shared 10-minute boot deadline. Each retry logsboot chain read failed; retrying after backoffand bumps the newdecdn_chain_boot_read_retries_total.deterministic failure, not retried):ZeroData, ABI mismatch, revert,-32600..-32602, HTTP 4xx except 408/429 (a 4xx withRetry-After, or with a JSON-RPC error body, is judged as retryable / by its JSON-RPC code), registry page/active length mismatch (BootFault), local eviction error at boot.decdn-client(provider::is_permanent_contract_error/is_permanent_rpc_error) — a denylist, since alloy'sis_retry_errallowlists miss outage codes like 1 and 19. Client registry discovery uses it too (public-API snapshot updated; ADR 012 updated).SharedHeadkeeps the typed provider error through its cache (so the first read of every bootstrap is classifiable); slash boot reads are pinned to the snapshot block (a lagging LB backend now answers "header not found" instead of a fatal revert); registry/slash/usdc()reads get the 10 s per-call timeout.fee_shares::seed_from_chain):PaymentPool.feeRouter()/FeeRouter.getShares()retry on a 1-minute sub-budget of the boot deadline (BootRetry::capped, so they cannot starve the later fail-closed reads), carry the per-call timeout and log sanitized errors. A newdecdn_fee_shares_watcher_unregisteredgauge reads 1 iffeeRouter()still fails and the watcher never starts. They stay non-fatal (floor share fallback), but a transientfeeRouter()error — immutable on-chain — no longer leaves the fee-shares watcher unregistered for the life of the process.Test plan
cargo clippy --workspace --all-targets -- -D warnings(+--features anvil-e2ebuild)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo fmt -- --checkcargo nextest run -p decdn-node -p decdn-client— 1730 passed--features public-api-test)anvil_bringup_shutdown_e2e+anvil_settlement_e2eagainst a rebuiltdecdn-nodeBootRetry(retry-until-success, permanent not retried, shared budget across reads, 543 s dead-endpoint cap, real emptyeth_call→ZeroData); blacklist bootstrap (transient retried, permanent keeps gate shut with 0 retries, unclean enforcement retried before gate opens, exhausted budget keeps gate shut); registry length-mismatchBootFault; slash bootstrap retry;SharedHeadtyped-cause propagation; stalled-provider bounds for slash/registry/fee reads; slash reads pinned to the snapshot block (stub + wiremock); permanent head error fails boot at once; boot eviction error is a permanentBootFault; boot pass stops at first scope failure; failed live enforcement forces a prompt rescan;usdc()self-check; fee-share seed (transientfeeRouter()retried,ZeroDatafalls back at once, failedgetShares()keeps the router).🤖 Generated with Claude Code