Skip to content

op-chain-ops: check SDM traced gas against receipts in conformance - #24195

Open
geoknee wants to merge 2 commits into
developfrom
geoknee/sdm-trace-gas-check
Open

geoknee wants to merge 2 commits into
developfrom
geoknee/sdm-trace-gas-check

Conversation

@geoknee

@geoknee geoknee commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

On SDM blocks, an op-reth whose RPC replay skips the refund settlement traces refunded transactions at their pre-refund gas, while receipts and state are correct (protocol-team#485). The existing SDM conformance checks compare receipts and debug_replaySDMBlock, so they pass on such a node.

ValidatePostExecConformance now also requires callTracer traces to report receipt gasUsed:

  • every row of debug_traceBlockByHash, which covers the refunded transactions, the transactions after them and the 0x7D row;
  • debug_traceTransaction of the last refunded transaction, whose replay includes every earlier refund.

ValidateVerifierAgreement runs the same check on the verifier, which is the stock op-reth serving public RPC.

This is a smaller alternative to #23795. ValidatePostExecConformance is shared by check-lagoon sdm and the SDM acceptance tests (op-acceptance-tests/tests/sdm/helpers_test.go), so one check runs against live networks and in CI on every PR. The full method-by-method replay coverage is in op-reth's rpc_replay_settlement integration tests from #23942. This check detects the defect from the outside, using two methods the public RPC whitelist allows.

Behaviour change:

  • check-lagoon sdm now fails against images without the replay fix. Nodes on reth op-v2.6.0-4 or later pass.
  • --sdm-l2-verifier now needs the debug_ namespace; it previously needed only eth_.
  • The devstack op-reth nodes already enable debug and trace on both sequencer and verifier (buildMixedOpRethNode).

Validation:

  • New unit cases fail with the check disabled and pass with it enabled. They cover pre-refund gas in both traces, a later transaction mistraced, the 0x7D row, trace errors, a short trace list and RPC errors, on both producer and verifier. go test ./op-chain-ops/pkg/sdm/ ./op-chain-ops/cmd/check-lagoon/... and go vet (including op-acceptance-tests/tests/sdm) pass.
  • Live positive control, with the shipped tracer config (callTracer, onlyTopCall): on public sdm-net-0 block 9599713, all seven debug_traceBlockByHash rows match receipts (deposit 0xb44e, four refunded 0x6195, 0x7D 0x0), and so does debug_traceTransaction for each refunded transaction. The negative control is the Nov 7 run on protocol-team#485: pre-fix images traced 66981 against receipt 24981 on the same methods.
  • The acceptance tests were not run locally. CI's SDM acceptance job exercises the new check against op-reth.

🤖 Generated with Claude Code

geoknee and others added 2 commits November 16, 2026 17:02
ValidatePostExecConformance now requires debug_traceBlockByHash to report
receipt gasUsed for every transaction, and debug_traceTransaction to do so
for the last refunded transaction, using the callTracer. Verifier agreement
runs the same check on the verifier. A node whose RPC replay omits the SDM
refund settlement (protocol-team#485) reports pre-refund gas and fails.

The function is shared by check-lagoon and the SDM acceptance tests, so the
check runs against live networks and in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@geoknee
geoknee marked this pull request as ready for review November 19, 2026 20:31
@geoknee
geoknee requested a review from a team as a code owner November 19, 2026 20:31
@nonsense

Copy link
Copy Markdown
Contributor

Claude: Could we extend this to check balances as well as gas, and on the other replay paths too? As it stands, it would miss two narrower regressions:

  • A different replay path. Several RPC methods replay through different code in reth. For example, the parity block methods use trace_block_until_with_inspector, not DebugApi::trace_block. A regression in just one of them would pass.
  • Gas settled, balances not. Settlement also credits the sender and debits the fee vaults, and callTracer gas shows neither. So tracing the last refunded transaction doesn't confirm that the earlier refunds were applied: its gas is the same either way.

Suggested additions:

  1. Debug balances: add prestateTracer with diffMode to the same two calls, and check the balances of the refunded senders, the coinbase and the fee vaults.
  2. Parity balances: add trace_replayBlockTransactions, and trace_replayTransaction on the last refunded transaction, both with stateDiff. Parity gasUsed isn't receipt gas, so balances are the only signal on this path.
  3. Balances after the last refund: use a state override to deploy a contract that returns the BALANCE of each of those addresses. Call it through debug_traceCall at txIndex = last refunded index + 1, eth_callMany and debug_traceCallMany.
  4. Execution status: require each callTracer frame's error to be set exactly when the receipt status is 0, since a later transaction can depend on a refunded balance.
  5. Row identity: check that each debug_traceBlockByHash row's txHash matches the block.

For the expected balances, debug_accountAt replays through the block executor. Each call replays the block up to its index, though, so use it only for the checks on the last refunded transaction. For the block-wide traces, start from the parent-block balance (eth_getBalance), apply each row's diff and require the committed balance at the end.

This needs the trace_ namespace plus debug_accountAt, debug_traceCall and eth_callMany. Devstack op-reth serves all of them. For check-lagoon, the verifier may need to skip whichever methods its public endpoint refuses.

@nonsense
nonsense self-requested a review November 20, 2026 09:59

This branch has not been deployed

No deployments
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