Skip to content

refactor(rpc): expose block replay hooks - #28233

Closed
einar-oplabs wants to merge 2 commits into
paradigmxyz:mainfrom
einar-oplabs:einar/rpc-replay-hooks
Closed

einar-oplabs wants to merge 2 commits into
paradigmxyz:mainfrom
einar-oplabs:einar/rpc-replay-hooks

Conversation

@einar-oplabs

Copy link
Copy Markdown

Moves the debug_traceBlock*, debug_traceChain and debug_intermediateRoots loops out of DebugApi, and the trace_* block loop out of Trace::trace_block_until_with_inspector, into defaulted Trace methods, and adds Trace::inspect_canonical_transaction_in_block for replaying the signed transaction recorded at an index. Behavior is unchanged: the loop bodies move verbatim and the defaults call each other exactly as the inlined code did, including the cached-BAL positioning and cancellation checks.

This lets a downstream network change how a block is replayed without copying the RPC handlers. op-reth needs it because its block execution settles gas refunds after each transaction (the SDM feature of the Lagoon hardfork), so replaying a block through the bare EVM reports pre-settlement gas and balances on every trace and replay endpoint while receipts and committed state are correct. With these hooks op-reth replays canonical blocks and transactions through its block executor, and keeps debug_traceBlock (raw) and debug_traceBadBlock on the permissive bare-EVM path, which is why canonical and unvalidated block tracing are separate methods.

The one new error path, a transaction index past the end of the block in the canonical hook, has a unit test. Alternative to #28047, which routes every chain's replay through the block executor. The same change on the v2.6.0 release line is ethereum-optimism#26.

🤖 Generated with Claude Code

Moves the debug_traceBlock*, debug_traceChain and debug_intermediateRoots
loops out of DebugApi, and the trace_* block loop out of
Trace::trace_block_until_with_inspector, into defaulted Trace methods, and
adds Trace::inspect_canonical_transaction_in_block for replaying the signed
transaction recorded at an index. Behavior is unchanged; the loop bodies
move verbatim.

Networks whose block execution changes state beyond the transactions
themselves can override these to replay through their block executor
without copying the RPC handlers, while raw and bad blocks keep the
permissive bare-EVM path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@einar-oplabs

Copy link
Copy Markdown
Author

Superseded by the executor routing approach in #28266

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.

1 participant