Skip to content

refactor: single-executor tracing with TracerKind deduplication#94

Open
krabat-l wants to merge 6 commits intomainfrom
krabat/refactor/tracing-executor-dedup
Open

refactor: single-executor tracing with TracerKind deduplication#94
krabat-l wants to merge 6 commits intomainfrom
krabat/refactor/tracing-executor-dedup

Conversation

@krabat-l
Copy link
Collaborator

@krabat-l krabat-l commented Feb 28, 2026

Summary

  • Bugfix: Bump mega-evm to commit 00336e7d which fixes GasInspector::call_end zeroing gas.remaining() before rescue_gas reads it in frame_return_result. This caused DTS and validator gas divergence (e.g., block 3021764 tx[9]).
  • Refactor: Rewrite tracing_executor.rs to use a single-executor pattern per block, preserving the DynamicGasCost bucket cache across transactions. The previous per-tx executor approach called on_new_block() each time, resetting state beyond DGC.
  • Deduplication: Introduce TracerKind enum to unify CallTracer, PreStateTracer, FlatCallTracer, and default struct logger into shared trace_block_with_tracing_inspector / trace_tx_with_tracing_inspector helpers. Add replay_error(), make_tx_ctx(), setup_executor! and replay_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 to 00336e7d (fix/inspector-rescue-gas)
  • crates/validator-core/src/tracing_executor.rs:
    • Single-executor pattern + TracerKind enum deduplication
    • replay_error() helper to simplify verbose ValidationError::BlockReplayFailed(BlockExecutionError::msg(...)) construction (~10 call sites)
    • make_tx_ctx() helper for TransactionContext construction from TransactionInfo
    • setup_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-server
  • cargo fmt --all / cargo clippy --package validator-core --lib
  • cargo test --package validator-core --lib — 24/24 unit tests passed
  • cargo 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)

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.
@krabat-l krabat-l force-pushed the krabat/refactor/tracing-executor-dedup branch from 8cee1b7 to 924f27c Compare February 28, 2026 06:41
…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.
@krabat-l krabat-l requested review from Troublor and flyq February 28, 2026 06:50
@krabat-l krabat-l changed the title fix: single-executor tracing with TracerKind deduplication refactor: single-executor tracing with TracerKind deduplication Feb 28, 2026
Copy link
Member

@flyq flyq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants