refactor: apply simplify-review cleanups across core, common, and the binaries - #170
refactor: apply simplify-review cleanups across core, common, and the binaries#170flyq wants to merge 2 commits into
Conversation
… binaries Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude review status
🛠️ Review did not finish Attempted head This round did not publish: MODEL_ACTION_FAILED in phase review_retry. Anything listed below is from the last round that did. Re-run the workflow or push a new commit to try again. |
Codecov Report❌ Patch coverage is ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fef0bd2ef4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| tokio::task::spawn_blocking(move || { | ||
| verify_block_integrity(&block)?; | ||
| Ok(block) | ||
| }) | ||
| .await |
There was a problem hiding this comment.
Keep block verification out of the RPC attempt timeout
When skip_block_verification=false and a large full block takes longer than per_attempt_timeout to verify, this spawn_blocking join is now inside round_robin_with_backoff's per-provider timeout; the retry loop can classify a healthy provider as stalled, retry the same block, and leave the blocking verification task running in the background. This affects the validator's default get_block(..., full_txs=true) path even without an overall deadline, because per-attempt timeouts are always applied. Consider fetching inside the timed RPC attempt but running the blocking integrity check after a successful fetch, or otherwise excluding the join from the provider-stall timeout.
Useful? React with 👍 / 👎.
/simplify pass over the PR: the `metas` recycling was a vestigial half-collapse — a loop-level buffer threaded through mem::take, a tuple return, and a destructuring assignment purely to reuse one small Vec allocation per batch, next to multi-ms blocking disk work. Build it locally inside the spawn_blocking closure and return only the batch; the advanced count reads batch.len(), which it always equalled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Two
/simplifyreview passes (4 review agents each: reuse, simplification, efficiency, altitude) overstateless-coreandbin/stateless-validator, with the surviving findings applied — net −73 lines. No functional change on canonical-block paths; behavior-adjacent changes are called out below.stateless-core
ChainSpec::from_genesis:MegaethGenesisHardforks::into_vec()already yields canonical activation order (its literal is now documented as the single source of that order), and the "unknown fork" append branch was unreachable; the unusedmega_mainnet_hardforks()template is gone with it.trace_writerparameter threaded throughreplay_block/verify_and_replay/validate_block/validate_block_deriving_updates(no caller here or in mega-reth ever passedSome), which also deletes therun_plainclosure + cfg dance. mega-reth impact: its call sites drop a trailingNoneat the next version bump.WitnessExternalEnv::new/from_light_witnessnow share onefrom_metadata_kvsbody; deadLightWitnessExecutor::kvs()accessor and a doubled doc block oncreate_evm_envremoved.BLOB_BASE_FEE_UPDATE_FRACTION_CANCUNinstead of a hand-copied consensus constant;gas_usedreadsBlockExecutionResult::gas_usedinstead of recomputing from the last receipt.WitnessDatabasereads use salt'sfind()+ in-place decode and stack-allocated key encodings (pub(crate)helpersencode()also delegates to) — two heap allocations per witnessed state read and one perbucket_id_for_*call removed; dropped a per-missSaltValueclone inLightWitness::metadata.chain_advancerrunspre_advance+advance_chainunderspawn_blockingso redb commits (and the trace server's multi-MB block-data writes) no longer pin an async runtime worker; panics still propagate unchanged viaresume_unwind. Also removed thein_flight_blocksmirror set, themetaslockstep vector, and the dead_reasonparameter.ChainStoreno longer carries theContractStoresupertrait (nothing consumed contracts through it); the forced stubs on the pipeline mock and the trace server'sStubBlockStoreare deleted.stateless-validator + shared crates
RpcClientas placeholder witness endpoints: the constructor accepts an empty witness list, and a witness call with zero providers panics with a structural message instead of silently retryingmega_getBlockWitnessagainst data endpoints. The trace server is unaffected (clap already enforces a witness source at startup).BackoffPolicy::schedule()/BackoffSchedulein stateless-common now own the jittered-doubling arithmetic previously duplicated between the RPC round-robin loop and the R2 GET loop; both consume it (fastranddep dropped from the bin).install_prometheus_exporterhoisted intostateless_common::metrics; both binaries call it and themetrics-exporter-prometheusdep moved from the bins into common.BlockMeta::from_headeradded in core, replacing the three defaulting header→meta projections (validator + two in debug-trace-server); the strict anchor-init site inapp.rskeeps its explicit missing-withdrawals-root error by design.verify_block_integritynow runs on the blocking pool and encodes each tx exactly once (keccak of that encoding checks the hash, the same bytes feed the transactions-root trie) — previously 2 clones + 2 encodes per tx inline on runtime threads.on_remote_heightfn-pointer injection removed;run_with_signalstakesreport_validation: boolinstead of anOption<String>it only ever.is_some()'d; phantometh_getTransactionByHashmetric series dropped; test-onlyset_anchor_blockdeleted (the roundtrip test now exercisesreset_to_anchor);workers.rsrenamed torunner.rs(docs updated); integration mock handlers deduped onto shared lookup helpers (also fixing a drifted bareunwrapon malformed params);make_block_metatest fixture unified.Testing
cargo fmt/clippy --workspace --all-targets --all-features(0 warnings) /cargo sortclean; full workspace suite 328 passed / 0 failed; no-std check and no-std test compile (--no-default-features) pass.Notes
RpcClientconstructor check (startup rejection → loud panic at first misuse); the constructor test pins the new contract.replay_blockand the trace server'sTracingEnv::new, resolving theirBlockLimitsdrift.🤖 Generated with Claude Code