Skip to content

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

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

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

Conversation

@geoknee

@geoknee geoknee commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the reth side of ethereum-optimism/protocol-team#485.

The RPC helpers that replay a block's own transactions ran them on a bare EVM, skipping per-transaction logic that lives in the block executor. On OP Stack SDM (0x7D) blocks that logic is the refund settlement, so debug_trace*, trace_*, eth_callMany / debug_traceCall at an index / debug_traceCallMany, debug_intermediateRoots and otterscan reported pre-refund gas and unsettled balances, and the last intermediate root never matched the header.

Prefix replays now go through executor_for_block. Traced transactions run on a single executor built over the inspected EVM (Trace::inspected_block_executor) with execute_transaction_without_commit, so tracers see the settled ResultAndState. One executor replays from tx 0 because the OP executor finds each refund by the transaction's position in the block. alloy-evm's TxTracer can't be driven by an executor (its 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.

Behaviour changes:

  • inspect_transaction_in_block drops its target_tx_env argument and traces the block's own transaction at the index. No caller in optimism or optimism-premium.
  • A transaction error in trace_block_until_with_inspector now fails the call instead of silently truncating the results.
  • debug_traceRawBlock / debug_traceBadBlock hit 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, so their RPC error codes change.

Rebase note for the v2.6.0 pin (#15): its BAL shortcut is fine for replay_block_until (the cached BAL is executor-settled state). On inspect_transaction_in_block and spawn_replay_transaction, though, it runs the target on a bare EVM, which brings the bug back on any block with a cached BAL; a fresh executor started at the target would look up the refund at index 0. The new trace_chain_block there is another bare-EVM replay to port.

Regression test: 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 with this branch. reth-rpc, reth-rpc-eth-api, reth-node-ethereum and reth-rpc-e2e-tests tests pass.

Fork CI: act-lint-deny (no OIDC token under act) and act-compact.yml (the "Read vectors" step) fail the same way on #15–#17 and are not caused by this change. Locally, nightly clippy and rustdoc with -D warnings are clean for reth-rpc and reth-rpc-eth-api.

🤖 Generated with Claude Code

emmajam and others added 14 commits August 12, 2026 11:11
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
…yz#26750)

Co-authored-by: Matthias Seitz <19890894+mattsse@users.noreply.github.com>
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Squash the fork CI support from 04e73b7 and push-event support from b0d194c into one replayable maintenance commit.

Preserve release action pins and advisory policy when resolving the replay. Select the book build job without entering Pages deployment. Refresh the standalone lockfile to patched h2 and rustls releases instead of suppressing RUSTSEC-2026-0258 and RUSTSEC-2026-0285; rustls requires the updated AWS-LC backend.

Co-authored-by: Josh Klopfenstein <git@joshklop.com>
Co-authored-by: falcorocks <14293929+falcorocks@users.noreply.github.com>
Maintenance CI: Compare optimism push vectors against v2.5.2, retaining actual PR and merge-queue bases.:
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.

Ref: ethereum-optimism/protocol-team#485

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

geoknee commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@joshklop @sebastianst this is the reth half of the fix for ethereum-optimism/protocol-team#485. On SDM blocks, every RPC path that replays a block's own transactions reports pre-refund gas and unsettled balances, because settlement only happens in the block executor and these helpers ran on a bare EVM. Explorers and indexers ingest these numbers, so we'd like it in the op-reth release that carries Lagoon.

What we need from you:

  1. Review and merge into optimism. I know the CI commit has to stay last on that branch, so landing this will give a new SHA. op-reth: settle SDM refunds on RPC replay paths optimism#23465 pins ca905873 for now and is green; I'll repin it, and optimism-premium's reth pin, to whatever SHA you land.
  2. Ordering with reth v2.6.0 fork pin for op-reth #15 (v2.6.0 pin). Josh, the two conflict in inspect_transaction_in_block, replay_block_until and spawn_replay_transaction. More importantly, the BAL shortcut in reth v2.6.0 fork pin for op-reth #15 brings the bug back: on a block with a cached BAL, inspect_transaction_in_block and spawn_replay_transaction run the target on a bare EVM, and a fresh executor started at the target would look up the SDM refund at index 0 (resume_at_tx_index isn't on the BlockExecutor trait). The BAL shortcut in replay_block_until is fine, since the cached BAL is executor-settled state. The new trace_chain_block there is one more bare-EVM replay to port. Would you rather land this first and carry it through the rebase, or have me rebase it onto reth v2.6.0 fork pin for op-reth #15 once that lands?

On CI: act-lint-deny and act-compact.yml (and so reth-act) fail here exactly as they do on #15–#17. Everything else passes, and nightly clippy and rustdoc with -D warnings are clean locally.

@geoknee
geoknee changed the base branch from optimism to op-v2.6.0 October 20, 2026 14:25
@geoknee

geoknee commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

in favour of #23

@geoknee geoknee closed this Oct 20, 2026
@sebastianst
sebastianst deleted the geoknee/sdm-settled-rpc-replay branch October 21, 2026 08:41
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.

8 participants