fix: bound retries for empty-bytecode RPC responses instead of halting#128
Closed
flyq wants to merge 2 commits into
Closed
fix: bound retries for empty-bytecode RPC responses instead of halting#128flyq wants to merge 2 commits into
flyq wants to merge 2 commits into
Conversation
|
The PR currently has no labels, but based on the diff and description it should have the The PR title uses the |
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
Fixes a validator halt triggered when the upstream RPC node returns empty bytecode (
0x) for a non-empty codehash — a common condition during rpc-node restart / cold start, where mega-reth'seth_getCodeByHashdoesunwrap_or_default()on a missing-from-state lookup and silently returns empty bytes. Previously this surfaced asVerificationFailure(keccak of0x≠ requested hash) and halted the validator. Now it's a typedBytecodeUnavailablevariant that the RPC client retries in-place against therpc_retryschedule, bounded by a 5-minute budget. If upstream is still empty after the budget, the validator halts — a longer outage is operator-visible and shouldn't be hidden behind silent retries.Changes
crates/stateless-common/src/rpc_client.rsCodeFetchError::BytecodeUnavailable { requested }variant — distinct fromVerificationFailure(non-empty wrong bytes, real divergence).RpcClientConfiggainsbytecode_unavailable_retry_budget: Duration(default 5 min). Total cap on the in-place retry loop for empty-bytes responses; tunable per-test for fast assertions.get_codes_with_deadlinenow wraps each per-hash fetch in a retry loop:get_code_with_deadline(unchanged).rpc_retryexponential schedule (500ms → 30s cap), retry until the configured budget elapses, then surfaceBytecodeUnavailable.VerificationFailure, never retried.CodeFetchErrorandget_codes_with_deadlinerewritten: all variants are now caller-visible halt signals; the transient "upstream not synced yet" condition is absorbed inside the client.bin/stateless-validator/src/chain_sync.rsValidatorProcessormapsBytecodeUnavailabletotransient=false(halt) — same asVerificationFailure. No more cycle restart for this condition; if it surfaces here, the 5-minute budget is already exhausted.get_codes.bin/debug-trace-server/src/data_provider.rsFrom<CodeFetchError> for DataProviderErrorextended to handleBytecodeUnavailable(folded into the sameeyre-wrapped path asVerificationFailure; trace server has no halt-vs-retry split).Test coverage
test_get_codes_verify_empty_bytecode_signals_unavailableinrpc_client.rs: starts a mock RPC that returns empty bytes for any codehash, drivesget_codes(verify=true)with a 10ms budget, asserts the result isBytecodeUnavailable(notVerificationFailure).Test plan
cargo test --workspace(passes locally — 17 tests instateless-common, allstateless-validator/debug-trace-serverlib tests green)cargo clippy --workspace --all-targets --all-features(clean)cargo fmt --all --check(clean)