EIPs Explained

EIP-7756 · Stagnant · Interface · 2024-08-13

EIP-7756: EOF/EVM Trace Specification

Updates the EIP-3155 JSON-lines EVM trace format so clients can trace EOF code (sections, function depth, immediates) alongside legacy contracts in one consistent output.

What problem does it solve?

EIP-3155 defined the standard per-opcode JSON trace that clients such as Geth, Besu, Nethermind, evmone, EthereumJS and Reth print for state tests. Those traces are now also used for live block tracing and differential fuzzing between clients, where any mismatch can reveal a consensus bug.

The EVM Object Format (EIP-7692) adds code sections, in-code functions (CALLF/RETF) and many instructions with immediate arguments. The old trace format cannot express these. EIP-7756 restates the whole trace spec with EOF support and clarifies ambiguities in EIP-3155.

How it works

The client prints one JSON object per executed opcode, then an optional summary line.

Required fields on each line: pc, op, opName, gas, stack, depth, error (omitted when not applicable).

Recommended: gasCost, memSize (in bytes), returnData, refund.

Optional (if omitted, omitted for the whole trace): section, immediate, functionDepth, memory, storage.

What is new for EOF:

  • section: which EOF code section is running; only present for EOF code.
  • functionDepth: depth of the EIP-4750 CALLF return stack; starts at 1 and may be omitted when 1.
  • immediate: the immediate bytes of an instruction, so traces can be read without the bytecode.
  • For EOF, pc counts from the start of the container (byte 0 is the 0xEF magic), so the first line is at the first byte of the first code section, not pc: 0.

Number handling is also clarified: values above 2^53 - 1 must be hex strings, and consumers should accept either JSON numbers or hex strings where one is expected.

The summary line can include stateRoot, output, gasUsed, pass, and optionally time and fork.

Sample code

Trace lines entering an EOF function via CALLF (adapted from the spec's test case):

{"pc":25,"section":0,"op":"0xe3","immediate":"0x0001","gas":49195500,"gasCost":5,"memSize":0,"stack":[],"depth":2,"refund":0,"opName":"CALLF"}
{"pc":29,"section":1,"op":"0xe4","gas":49195495,"gasCost":3,"memSize":0,"stack":[],"depth":2,"functionDepth":2,"refund":0,"opName":"RETF"}
{"pc":28,"section":0,"op":"0x00","gas":49195492,"gasCost":0,"memSize":0,"stack":[],"depth":2,"refund":0,"opName":"STOP"}

A tiny consumer that tolerates both number styles:

const toBig = (v: number | string) => (typeof v === "string" ? BigInt(v) : BigInt(v));
for (const line of traceText.trim().split("\n")) {
  const t = JSON.parse(line);
  if ("pc" in t) console.log(t.depth, t.section ?? "-", t.opName, toBig(t.gas));
}

Things to know

  • Status: Stagnant, and the EOF meta EIP it supports (EIP-7692) is also Stagnant. EIP-3155 remains the base format for legacy tracing.
  • Differences from EIP-3155: gas, gasCost and gasUsed become Number types, and op becomes a Hex-Number.
  • Legacy (non-EOF) traces remain compatible apart from those type changes.
  • Security note from the spec: tracing is CPU- and bandwidth-heavy. Tracing endpoints should be off by default and access-restricted, especially on validator nodes.

#tracing #eof #debugging #interface #stagnant

Details

Authors
Martin Holst Swende (@holiman), Marius van der Wijden (@MariusVanDerWijden), Danno Ferrin (@shemnon)
Status
Stagnant
Type
Standards Track / Interface
Created
2024-08-13
Requires

Machine-readable: Markdown · JSON