apollo_consensus_orchestrator: fail sync gracefully instead of panicking on missing recorder data - #14968
apollo_consensus_orchestrator: fail sync gracefully instead of panicking on missing recorder data#14968gkaempfer wants to merge 1 commit into
Conversation
…ing on missing recorder data try_sync panicked when the centralized recorder had no accessed-keys data yet for a synced block, even though this is a documented, normal response from a network-reachable service (recorder lag, restart, or partition), not a programmer invariant. Treat it the same as other recoverable sync failures in this function: log and return false so the caller retries, instead of crashing the node. Co-Authored-By: Claude Opus 4.8 (1M context)
PR SummaryMedium Risk Overview The regression test was renamed and updated to expect Reviewed by Cursor Bugbot for commit 7ed3be5. Bugbot is set up for automated code reviews on this repo. Configure here. |
itamar-starkware
left a comment
There was a problem hiding this comment.
@itamar-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on yoavGrs).
Security scan finding
This is a fix for a vulnerability found while scanning #14826 (merged), which introduced fetching accessed-keys data from the centralized recorder in
try_sync.Vulnerability
In
SequencerConsensusContext::try_sync(crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs), whenfetch_accessed_keys_from_centralizedis enabled, aNoneresponse fromcende_ambassador.get_accessed_keys_inputtriggers apanic!:get_accessed_keys_inputis an HTTP GET to the recorder service, and its own doc comment states plainly: "ReturnsNonewhen the recorder does not have the block." That is a documented, normal response from a network-reachable dependency (the recorder can legitimately lag behind state sync, restart, or be temporarily unreachable/partitioned) — not a programmer invariant. Every other failure path in the same function (Err(e)from the same call, block-not-found, timestamp validation) is handled by logging andreturn false, letting the caller retry. Only this branch crashes the process instead.Impact: any node with
fetch_accessed_keys_from_centralized: truecan be crashed during sync whenever the recorder briefly doesn't have accessed-keys data for the block being synced — this can happen from ordinary recorder lag/restarts, and also gives a compromised or misbehaving recorder a trivial, repeatable way to take down every consensus node relying on it. This violates this repo's own mandatory practice ("Never panic on data reachable from requests" in.claude/rules/code-style.md).Fix
Treat
Ok(None)the same way as theErr(e)branch immediately below it: log andreturn false, so the sync attempt is retried instead of crashing the node.Test
Updated
try_sync_panics_when_recorder_has_no_accessed_keys(previously asserted a panic via#[should_panic]) intotry_sync_fails_gracefully_when_recorder_has_no_accessed_keys, which assertstry_syncreturnsfalseandadd_sync_blockis never called, instead of panicking.Verification
cargo build -p apollo_consensus_orchestrator --tests— passesSEED=0 cargo test -p apollo_consensus_orchestrator --lib try_sync— 3/3 pass (including the new regression test)scripts/rust_fmt.sh --check— cleancargo clippy -p apollo_consensus_orchestrator --tests --all-features -- -D warnings— cleanGenerated by Claude Code