refactor: single-executor tracing with TracerKind deduplication#94
Open
refactor: single-executor tracing with TracerKind deduplication#94
Conversation
Refactor tracing_executor.rs to use a single-executor pattern per block, preserving the DynamicGasCost bucket cache across transactions. Introduce TracerKind enum to unify CallTracer, PreStateTracer, FlatCallTracer, and default struct logger into shared trace_block/trace_tx helper functions, reducing ~180 lines of duplicated boilerplate. Bump mega-evm to commit 00336e7d which fixes GasInspector rescue_gas ordering.
…boilerplate Add replay_error(), make_tx_ctx(), setup_executor! and replay_preceding_txs! to eliminate repeated executor setup, error construction, and tx replay patterns across all tracer branches (FourByte, Mux, JS, Parity). Reduces file from 1248 to 1112 lines while preserving identical behavior.
8cee1b7 to
924f27c
Compare
…ByHash Reverts the change that replaced eth_getHeaderBy* RPCs with get_block(full_txs=false). The header-only RPCs avoid transferring the transaction hash list, which matters at high TPS.
flyq
approved these changes
Mar 1, 2026
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
00336e7dwhich fixesGasInspector::call_endzeroinggas.remaining()beforerescue_gasreads it inframe_return_result. This caused DTS and validator gas divergence (e.g., block 3021764 tx[9]).tracing_executor.rsto use a single-executor pattern per block, preserving the DynamicGasCost bucket cache across transactions. The previous per-tx executor approach calledon_new_block()each time, resetting state beyond DGC.TracerKindenum to unify CallTracer, PreStateTracer, FlatCallTracer, and default struct logger into sharedtrace_block_with_tracing_inspector/trace_tx_with_tracing_inspectorhelpers. Addreplay_error(),make_tx_ctx(),setup_executor!andreplay_preceding_txs!macros to further reduce boilerplate across FourByte, Mux, JS, and Parity tracer branches (1438 → 1112 lines).Changes
Cargo.toml/Cargo.lock: Bump mega-evm to00336e7d(fix/inspector-rescue-gas)crates/validator-core/src/tracing_executor.rs:TracerKindenum deduplicationreplay_error()helper to simplify verboseValidationError::BlockReplayFailed(BlockExecutionError::msg(...))construction (~10 call sites)make_tx_ctx()helper forTransactionContextconstruction fromTransactionInfosetup_executor!macro for executor creation + pre-execution setup (~10 call sites)replay_preceding_txs!macro for replaying preceding transactions in tx-level tracers (~5 call sites)Test plan
cargo check --package validator-core --package debug-trace-servercargo fmt --all/cargo clippy --package validator-core --libcargo test --package validator-core --lib— 24/24 unit tests passedcargo test --package validator-core --test dts_trace_3021764 -- --ignored— 9/9 passed (block 3021764, all tracers)cargo test --package debug-trace-server --test consistency_test -- --ignored— 9/9 passed (95 consistency tests, 63 send-and-trace, 27 continuous tx+trace, all tracer types consistent with mega-reth)