Skip to content

fix(rpc): replay block transactions through the block executor - #23

Closed
geoknee wants to merge 2 commits into
op-v2.6.0from
geoknee/sdm-settled-rpc-replay-v2.6.0
Closed

geoknee wants to merge 2 commits into
op-v2.6.0from
geoknee/sdm-settled-rpc-replay-v2.6.0

Conversation

@geoknee

@geoknee geoknee commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Superseded by #24, which keeps the cached-BAL paths and raw/bad-block tracing as upstream has them.

Supersedes #18, which targeted optimism; this is the same change ported onto op-v2.6.0.

The RPC helpers that replay a block's own transactions (replay_block_until, inspect_transaction_in_block, trace_block_until_with_inspector, spawn_replay_transaction, and the trace_block, trace_chain_block and debug_intermediateRoots loops in debug.rs) ran them on a bare EVM, so anything the block executor does per transaction outside the EVM was skipped. On OP Stack that is the SDM refund settlement for blocks carrying a post-exec (0x7D) transaction: debug_trace*, trace_*, eth_callMany / debug_traceCall / debug_traceCallMany at a transaction index, debug_intermediateRoots and ots_* reported pre-refund gas and unsettled balances, and the last intermediate root didn't match the header's state root. Ref ethereum-optimism/protocol-team#485.

These paths now go through the executor. Prefix replays use executor_for_block and execute_transaction, and traced transactions run on an executor built over the inspected EVM (Trace::inspected_block_executor) with execute_transaction_without_commit, so tracers see the executor's settled ResultAndState. One executor replays from transaction 0 because the OP executor derives a transaction's position, and with it the refund, from the number of transactions it has committed. alloy-evm's TxTracer can't drive an executor (TracingCtx has private fields), so trace_block_until_with_inspector has its own loop and a local TracingCtx with the same public surface; callers are unchanged. trace_chain_block keeps reporting a failing transaction as a TraceResult::Error instead of failing the range.

replay_block_until keeps the cached-BAL shortcut. inspect_transaction_in_block and spawn_replay_transaction drop it, because attaching the BAL runs the target transaction on a bare EVM. That drop isn't needed for OP: op-reth rejects the BAL cache options and serves none of the BAL RPCs, so no BAL is ever cached on an OP node. (An earlier version of this description said --rpc-cache.prewarm-bals would bring the bug back on OP; it can't, since op-reth refuses that flag.)

Behavior changes: inspect_transaction_in_block drops its target_tx_env and bal arguments and always traces the block's transaction at the index; nothing in optimism or optimism-premium calls it. A transaction error in trace_block_until_with_inspector now fails the call instead of silently truncating the results. debug_traceRawBlock and debug_traceBadBlock run the executor's per-transaction checks (cumulative gas, DA footprint, SDM entry validation), so a block failing one of them errors instead of tracing. Replay errors map through BlockExecutionError instead of from_evm_err, which changes their RPC error codes.

On Ethereum the executor only adds the block gas checks, receipt building and gas accounting on top of transact, so traces and intermediate roots of valid blocks are unchanged there. This continues paradigmxyz#26614, which moved the same endpoints onto one EVM for downstream EVMs with block-scoped state; here the per-transaction state lives in the executor instead.

ethereum-optimism/optimism#23465 (rust/op-reth/crates/node/tests/it/debug_trace_post_exec.rs) sequences a real SDM block and checks every path against the receipt, the committed balances and the header; it fails on 0fbe4285 and passes on the pre-rebase version of this change (ca905873, #18); it hasn't been re-run against the op-v2.6.0 port yet. On the port, reth-rpc, reth-rpc-eth-api, reth-node-ethereum (including its 72 e2e tests) and reth-rpc-e2e-tests tests pass, and nightly fmt, clippy and rustdoc with -D warnings are clean for reth-rpc and reth-rpc-eth-api.

🤖 Generated with Claude Code

The RPC helpers that replay a block's own transactions (debug_trace*,
trace_*, eth_callMany/debug_traceCall at an index/debug_traceCallMany,
debug_intermediateRoots, ots) ran them on a bare EVM. Per-transaction
logic that lives in the block executor was skipped, so on OP Stack SDM
blocks traces reported pre-refund gas and unsettled balances, and the
intermediate roots never reached the header's state root.

Prefix replays now go through `executor_for_block`, and traced
transactions run on an executor built over the inspected EVM via
`execute_transaction_without_commit`. alloy-evm's `TxTracer` is replaced
by an executor loop with a local `TracingCtx` of the same public shape.
`trace_chain_block` is ported the same way and still reports a failing
transaction as a per-transaction error.

`replay_block_until` keeps the cached-BAL shortcut, since computed BALs
are built by the executor and hold settled state.
`inspect_transaction_in_block` and `spawn_replay_transaction` no longer
use it: attaching the BAL ran the target on a bare EVM, and
`--rpc-cache.prewarm-bals` caches a BAL for every canonical block on any
chain.

Ref: ethereum-optimism/protocol-team#485

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@geoknee

geoknee commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Upstream: paradigmxyz#28047 (draft, ported onto upstream main).

@geoknee

geoknee commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #24, which routes the same replays through the executor but keeps the cached-BAL paths and raw/bad-block tracing as upstream has them.

@geoknee geoknee closed this Oct 23, 2026
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