Skip to content

fix(rpc)!: follow the trace costs and names of execution-apis 32fae20 - #5342

Merged
tcoratger merged 1 commit into
ethereum:masterfrom
tcoratger:rpc-sync-1
Dec 2, 2026
Merged

tcoratger merged 1 commit into
ethereum:masterfrom
tcoratger:rpc-sync-1

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

The opcode trace now reports the step costs and the opcode names that execution-apis fixes at 32fae20, and the pin of execution-apis moves to that commit.
The change follows ethereum/execution-apis#986; #967 and #855 follow in their own pull requests.

The problem

opcode-tracer.yaml left gasCost open, so EthLib picked a rule of its own (stepCost in Execution/Rpc/Trace.lean).
#986 fixes the field, and EthLib disagreed with it in four places:

  • a step that halts its frame exceptionally reported all the gas left, where the source asks for 0;
  • CREATE and CREATE2 counted the gas that they pass on to the initcode, which the source leaves out;
  • a call that starts no message, because of its value or its depth, counted only its price, where the source counts the gas it would pass on, without the stipend;
  • every byte that is no opcode was named INVALID, where the source names it opcode 0x<byte> not defined and keeps INVALID for 0xfe.

The idea

stepCost reads the result of the step:

  • a halt (the same test as the error field, stepError) costs 0;
  • a creation is the message with no target, and its cost is the gas it paid less the gas of that message;
  • a call that starts no message gets its grant and stipend back in the same step.
    returnedGas reads them from stepWithCharges, the step of the interpreter that also gives the charges of a call, and adds them back.

mnemonicOf takes the byte of the opcode, so it can name a byte that is no opcode.
The EIP-3155 lines read the same entries, so they change in the same way.

Example

The account OTHER holds 1 wei and calls itself with 2 wei and 4096 gas, at Prague (test_call_without_message).

CALL pays: warm access 100 + value 9000 + passed gas 4096 = 13196
CALL gets back: passed gas 4096 + stipend 2300 = 6396
before: gasCost = 13196 - 6396 = 6800  (the gas that left the frame)
after:  gasCost = 13196                (the stipend, never paid, is not counted)
next step: gas = gas at CALL - 6800

For reviewers

  • returnedGas runs the step a second time, only for a call-family opcode that gave the next frame.
    Every other step costs nothing more.
  • From Glamsterdam the meter also holds state gas; the costs stay those of the execution gas, as the source asks.
  • The pin move brings other upstream changes.
    The new eth_simulateV1 and eth_estimateGas fixtures pass.
    The Engine examples of engine_newPayloadV5 and engine_getPayloadV6 now decode, since upstream fixed their access list and their blob.
    The bindings read no payload status of version 2, so the new examples of engine_newPayloadV6 and engine_forkchoiceUpdatedV5 stay out of the status tests.
  • The trace test now ignores the text of a step error, as the source and its own fixture script do: the fixture writes out of gas: write protection where EthLib writes write protection.
  • The calltracer-* fixtures and the debug_traceCall directory are not vendored yet; the call-tracer pull request adds them.
  • TransactionInfo.lean now cites the merged text of proof(consensus): state which block an invalid payload removes #1008 instead of the open report.
  • Two points of feat(consensus): run the Gloas block #986 stay open, recorded in SOUNDNESS.md:
    • a CREATE whose address collides still counts the gas of its message, since the step does not expose it (#5340);
    • refund still leaves out the refund of EIP-7702 authorizations, which the counter of the transaction holds (#5341).

Checks

  • lake build EthLib.Execution.Rpc EthLib.Execution.Proofs.Rpc --wfail: success.
  • lake exe check-decls EthLib.Execution.Rpc EthLib.Execution.Proofs.Rpc: 0 findings, 0 new, 0 stale.
  • lake exe proof-coverage --check: no change.
  • uv run pytest -n 8 (whole suite, bindings of this branch): 76481 passed, 674 skipped, 13 xfailed.
  • After the review fixes, pytest on tests/rpc, tests/engine, tests/transactions and test_opcode_coverage.py: 6317 passed, 264 skipped.
  • check_lean_layout.py --all --rule wrap, soundness_facts.py --check, check_fixture_pins.py, sha256sum -c SHA256SUMS: clean.
  • ruff check, ruff format --check, ty check, check_python_comments.py, check_docstrings.py on the changed tests: clean.

🤖 Generated with Claude Code

The pin of ethereum/execution-apis moves from 166e334 to 32fae20.
At that commit, ethereum/execution-apis#986 fixes the gasCost and the op
of a step of the opcode logger, where EthLib had picked its own rule:

- a step that halts its frame exceptionally reports 0, not all the gas
  left;
- CREATE and CREATE2 leave out the gas that they pass on to the
  initcode;
- a call that starts no message, for its value or its depth, counts
  the gas that it would pass on, without the stipend;
- a byte that is no opcode at the fork is named "opcode 0x<byte> not
  defined", and only 0xfe is INVALID.

The debug traces and the lines of EIP-3155 share these entries, so both
change. Two points stay open: a CREATE whose address collides still
counts the gas of its message (ethereum#5340), and refund still leaves out the
refund of EIP-7702 authorizations (ethereum#5341). The suite vendors the opcode-logger fixtures that the new pin
adds or changes, and compares a trace value for value apart from the
error text, which the source leaves to the client. The call-tracer
fixtures wait for the call tracer.

The Engine OpenRPC examples move to the same commit. The examples of
engine_newPayloadV5 and engine_getPayloadV6 now decode, since upstream
fixed their access list and their blob. The bindings read no payload
status of version 2, so the status tests leave out the new Bogota
examples of engine_newPayloadV6 and engine_forkchoiceUpdatedV5.

BREAKING CHANGE: the gasCost and the op of trace entries change as
above, in the debug traces and in the EIP-3155 lines. In Lean,
mnemonicOf takes the byte of the opcode after the fork.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tcoratger
tcoratger merged commit 626b559 into ethereum:master Dec 2, 2026
tcoratger added a commit that referenced this pull request Dec 2, 2026
At 32fae20, ethereum/execution-apis#967 adds to the error groups: a
server must not include data unless the spec declares a data schema for
that error, also for -32602 and -32000, and human-readable detail goes
in the message. Only the revert, code 3, declares data.

EthLib put the reason of an invalid parameter, of an invalid request
and of most codes of the execution API in data. ErrorCode.toRpcError
now takes the detail as a string and writes it after the message of
the code, and RpcError.invalidParams and invalidRequest do the same.
The revert keeps its output as data. The Engine API keeps its own
null data. The errors of the Python readers are no JSON-RPC answer, so
they keep the reason alone as their message.

SOUNDNESS.md also drops the notes on the Engine examples that the pin
move of #5342 fixed upstream, and the reader of bytes cites the pattern
of ethereum/execution-apis#1023, which now asks for two digits a byte.

BREAKING CHANGE: error objects of the execution API lose their data,
except the revert, and their message carries the detail. In Lean,
ErrorCode.toRpcError takes an Option String instead of an Option Json.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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