{"eip":7756,"title":"EOF/EVM Trace Specification","description":"Updates EIP-3155 tracing to add EOF support","authors":["Martin Holst Swende (@holiman)","Marius van der Wijden (@MariusVanDerWijden)","Danno Ferrin (@shemnon)"],"status":"Stagnant","type":"Standards Track","category":"Interface","created":"2024-08-13","requires":[3155,4750],"discussionsTo":"https://ethereum-magicians.org/t/eip-7756-eof-evm-trace-specification/20806","repo":"EIPs","label":"EIP-7756","officialUrl":"https://eips.ethereum.org/EIPS/eip-7756","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7756.md","url":"https://eips.huatuo.xyz/eip-7756/","tldr":{"en":"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.","ja":"EIP-3155 の JSON Lines 形式の EVM トレースを更新し、クライアントが EOF コード（セクション、関数の深さ、即値）をレガシーコントラクトと一緒に、一貫した出力でトレースできるようにする。","ko":"EIP-3155의 JSON Lines EVM 트레이스 형식을 갱신해, 클라이언트가 EOF 코드(섹션, 함수 깊이, 즉값)를 기존 컨트랙트와 함께 하나의 일관된 출력으로 트레이싱할 수 있게 한다.","zh":"更新 EIP-3155 的 JSON-lines EVM 追踪格式，使客户端能在同一种一致的输出中同时追踪 EOF 代码（代码段、函数深度、立即数）和传统合约。"},"tags":["tracing","eof","debugging","interface","stagnant"],"explainers":{"en":{"lang":"en","tldr":"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.","tags":["tracing","eof","debugging","interface","stagnant"],"related":[3155,7692,4750,3540],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7756/","markdown":"## What problem does it solve?\n\n[EIP-3155](/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.\n\nThe EVM Object Format ([EIP-7692](/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.\n\n## How it works\n\nThe client prints **one JSON object per executed opcode**, then an optional summary line.\n\nRequired fields on each line: `pc`, `op`, `opName`, `gas`, `stack`, `depth`, `error` (omitted when not applicable).\n\nRecommended: `gasCost`, `memSize` (in bytes), `returnData`, `refund`.\n\nOptional (if omitted, omitted for the whole trace): `section`, `immediate`, `functionDepth`, `memory`, `storage`.\n\nWhat is new for EOF:\n\n- `section`: which EOF code section is running; only present for EOF code.\n- `functionDepth`: depth of the [EIP-4750](/eip-4750/) `CALLF` return stack; starts at 1 and may be omitted when 1.\n- `immediate`: the immediate bytes of an instruction, so traces can be read without the bytecode.\n- 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`.\n\nNumber 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.\n\nThe summary line can include `stateRoot`, `output`, `gasUsed`, `pass`, and optionally `time` and `fork`.\n\n## Sample code\n\nTrace lines entering an EOF function via `CALLF` (adapted from the spec's test case):\n\n```json\n{\"pc\":25,\"section\":0,\"op\":\"0xe3\",\"immediate\":\"0x0001\",\"gas\":49195500,\"gasCost\":5,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"CALLF\"}\n{\"pc\":29,\"section\":1,\"op\":\"0xe4\",\"gas\":49195495,\"gasCost\":3,\"memSize\":0,\"stack\":[],\"depth\":2,\"functionDepth\":2,\"refund\":0,\"opName\":\"RETF\"}\n{\"pc\":28,\"section\":0,\"op\":\"0x00\",\"gas\":49195492,\"gasCost\":0,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"STOP\"}\n```\n\nA tiny consumer that tolerates both number styles:\n\n```ts\nconst toBig = (v: number | string) =\u003e (typeof v === \"string\" ? BigInt(v) : BigInt(v));\nfor (const line of traceText.trim().split(\"\\n\")) {\n  const t = JSON.parse(line);\n  if (\"pc\" in t) console.log(t.depth, t.section ?? \"-\", t.opName, toBig(t.gas));\n}\n```\n\n## Things to know\n\n- **Status: Stagnant**, and the EOF meta EIP it supports ([EIP-7692](/eip-7692/)) is also Stagnant. [EIP-3155](/eip-3155/) remains the base format for legacy tracing.\n- Differences from EIP-3155: `gas`, `gasCost` and `gasUsed` become Number types, and `op` becomes a Hex-Number.\n- Legacy (non-EOF) traces remain compatible apart from those type changes.\n- 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.\n"},"ja":{"lang":"ja","tldr":"EIP-3155 の JSON Lines 形式の EVM トレースを更新し、クライアントが EOF コード（セクション、関数の深さ、即値）をレガシーコントラクトと一緒に、一貫した出力でトレースできるようにする。","tags":["tracing","eof","debugging","interface","stagnant"],"related":[3155,7692,4750,3540],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7756/","markdown":"## 何を解決するのか\n\n[EIP-3155](/eip-3155/) は、Geth、Besu、Nethermind、evmone、EthereumJS、Reth などのクライアントがステートテストで出力する、opcode ごとの標準的な JSON トレースを定義しました。このトレースは現在、ライブのブロックトレースやクライアント間の差分ファジングにも使われており、不一致があればコンセンサスバグが見つかる可能性があります。\n\nEVM Object Format（[EIP-7692](/eip-7692/)）は、コードセクション、コード内の関数（`CALLF`/`RETF`）、即値引数を持つ多くの命令を追加します。従来のトレース形式ではこれらを表現できません。EIP-7756 は、EOF 対応を加えてトレース仕様全体を書き直し、EIP-3155 の曖昧な点を明確にします。\n\n## 仕組み\n\nクライアントは**実行した opcode ごとに JSON オブジェクトを 1 つ**出力し、その後に任意でサマリー行を出力します。\n\n各行の必須フィールド: `pc`、`op`、`opName`、`gas`、`stack`、`depth`、`error`（該当しない場合は省略）。\n\n推奨: `gasCost`、`memSize`（バイト単位）、`returnData`、`refund`。\n\n任意（省略する場合はトレース全体で省略）: `section`、`immediate`、`functionDepth`、`memory`、`storage`。\n\nEOF 向けの新要素:\n\n- `section`: 実行中の EOF コードセクション。EOF コードの場合のみ存在します。\n- `functionDepth`: [EIP-4750](/eip-4750/) の `CALLF` リターンスタックの深さ。1 から始まり、1 の場合は省略できます。\n- `immediate`: 命令の即値バイト。バイトコードなしでトレースを読めるようにします。\n- EOF では、`pc` はコンテナの先頭から数えます（バイト 0 は `0xEF` のマジック）。そのため最初の行は `pc: 0` ではなく、最初のコードセクションの先頭バイトになります。\n\n数値の扱いも明確化されています。2^53 - 1 を超える値は 16 進文字列でなければならず、コンシューマーは数値が期待される箇所で JSON の数値と 16 進文字列のどちらも受け入れるべきです。\n\nサマリー行には、`stateRoot`、`output`、`gasUsed`、`pass`、および任意で `time` と `fork` を含められます。\n\n## サンプルコード\n\n`CALLF` で EOF 関数に入るトレース行（仕様のテストケースを改変）:\n\n```json\n{\"pc\":25,\"section\":0,\"op\":\"0xe3\",\"immediate\":\"0x0001\",\"gas\":49195500,\"gasCost\":5,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"CALLF\"}\n{\"pc\":29,\"section\":1,\"op\":\"0xe4\",\"gas\":49195495,\"gasCost\":3,\"memSize\":0,\"stack\":[],\"depth\":2,\"functionDepth\":2,\"refund\":0,\"opName\":\"RETF\"}\n{\"pc\":28,\"section\":0,\"op\":\"0x00\",\"gas\":49195492,\"gasCost\":0,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"STOP\"}\n```\n\nどちらの数値表記も受け入れる小さなコンシューマー:\n\n```ts\nconst toBig = (v: number | string) =\u003e (typeof v === \"string\" ? BigInt(v) : BigInt(v));\nfor (const line of traceText.trim().split(\"\\n\")) {\n  const t = JSON.parse(line);\n  if (\"pc\" in t) console.log(t.depth, t.section ?? \"-\", t.opName, toBig(t.gas));\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant**。これが支える EOF のメタ EIP（[EIP-7692](/eip-7692/)）も Stagnant です。レガシーのトレースでは、[EIP-3155](/eip-3155/) が引き続き基本形式です。\n- EIP-3155 との違い: `gas`、`gasCost`、`gasUsed` は Number 型になり、`op` は Hex-Number になります。\n- レガシー（非 EOF）のトレースは、これらの型変更を除いて互換性が保たれます。\n- 仕様のセキュリティ上の注意: トレースは CPU と帯域を大量に消費します。トレース用のエンドポイントはデフォルトで無効にし、特にバリデーターノードではアクセスを制限すべきです。\n"},"ko":{"lang":"ko","tldr":"EIP-3155의 JSON Lines EVM 트레이스 형식을 갱신해, 클라이언트가 EOF 코드(섹션, 함수 깊이, 즉값)를 기존 컨트랙트와 함께 하나의 일관된 출력으로 트레이싱할 수 있게 한다.","tags":["tracing","eof","debugging","interface","stagnant"],"related":[3155,7692,4750,3540],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7756/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-3155](/eip-3155/)는 Geth, Besu, Nethermind, evmone, EthereumJS, Reth 같은 클라이언트가 상태 테스트에서 출력하는 opcode별 표준 JSON 트레이스를 정의했습니다. 이 트레이스는 이제 실시간 블록 트레이싱과 클라이언트 간 차분 퍼징에도 쓰이며, 불일치가 있으면 합의 버그가 드러날 수 있습니다.\n\nEVM Object Format([EIP-7692](/eip-7692/))은 코드 섹션, 코드 내 함수(`CALLF`/`RETF`), 즉값 인자를 갖는 많은 명령어를 추가합니다. 기존 트레이스 형식으로는 이를 표현할 수 없습니다. EIP-7756은 EOF 지원을 더해 트레이스 명세 전체를 다시 쓰고, EIP-3155의 모호한 부분을 명확히 합니다.\n\n## 어떻게 동작하나요?\n\n클라이언트는 **실행된 opcode마다 JSON 객체 하나**를 출력하고, 마지막에 선택적으로 요약 줄을 출력합니다.\n\n각 줄의 필수 필드: `pc`, `op`, `opName`, `gas`, `stack`, `depth`, `error`(해당하지 않으면 생략).\n\n권장: `gasCost`, `memSize`(바이트 단위), `returnData`, `refund`.\n\n선택(생략하면 트레이스 전체에서 생략): `section`, `immediate`, `functionDepth`, `memory`, `storage`.\n\nEOF를 위해 새로 생긴 것:\n\n- `section`: 실행 중인 EOF 코드 섹션. EOF 코드에만 있습니다.\n- `functionDepth`: [EIP-4750](/eip-4750/) `CALLF` 리턴 스택의 깊이. 1에서 시작하며 1일 때는 생략할 수 있습니다.\n- `immediate`: 명령어의 즉값 바이트. 바이트코드 없이도 트레이스를 읽을 수 있게 합니다.\n- EOF에서는 `pc`가 컨테이너의 시작부터 셉니다(0번 바이트는 `0xEF` 매직). 따라서 첫 줄은 `pc: 0`이 아니라 첫 번째 코드 섹션의 첫 바이트입니다.\n\n숫자 처리도 명확해졌습니다. 2^53 - 1보다 큰 값은 16진수 문자열이어야 하며, 소비자는 숫자가 올 자리에 JSON 숫자와 16진수 문자열을 모두 받아들여야 합니다.\n\n요약 줄에는 `stateRoot`, `output`, `gasUsed`, `pass`, 그리고 선택적으로 `time`과 `fork`를 넣을 수 있습니다.\n\n## 샘플 코드\n\n`CALLF`로 EOF 함수에 들어가는 트레이스 줄(명세의 테스트 케이스를 수정):\n\n```json\n{\"pc\":25,\"section\":0,\"op\":\"0xe3\",\"immediate\":\"0x0001\",\"gas\":49195500,\"gasCost\":5,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"CALLF\"}\n{\"pc\":29,\"section\":1,\"op\":\"0xe4\",\"gas\":49195495,\"gasCost\":3,\"memSize\":0,\"stack\":[],\"depth\":2,\"functionDepth\":2,\"refund\":0,\"opName\":\"RETF\"}\n{\"pc\":28,\"section\":0,\"op\":\"0x00\",\"gas\":49195492,\"gasCost\":0,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"STOP\"}\n```\n\n두 가지 숫자 표기를 모두 받아들이는 작은 소비자 코드:\n\n```ts\nconst toBig = (v: number | string) =\u003e (typeof v === \"string\" ? BigInt(v) : BigInt(v));\nfor (const line of traceText.trim().split(\"\\n\")) {\n  const t = JSON.parse(line);\n  if (\"pc\" in t) console.log(t.depth, t.section ?? \"-\", t.opName, toBig(t.gas));\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant**이며, 이 EIP가 지원하는 EOF 메타 EIP([EIP-7692](/eip-7692/))도 Stagnant입니다. 기존 트레이싱에서는 [EIP-3155](/eip-3155/)가 여전히 기본 형식입니다.\n- EIP-3155와의 차이: `gas`, `gasCost`, `gasUsed`는 Number 타입이 되고, `op`는 Hex-Number가 됩니다.\n- 기존(비 EOF) 트레이스는 이런 타입 변경을 제외하면 호환됩니다.\n- 명세의 보안 참고: 트레이싱은 CPU와 대역폭을 많이 사용합니다. 트레이싱 엔드포인트는 기본적으로 꺼 두고 접근을 제한해야 하며, 특히 검증자 노드에서는 그렇습니다.\n"},"zh":{"lang":"zh","tldr":"更新 EIP-3155 的 JSON-lines EVM 追踪格式，使客户端能在同一种一致的输出中同时追踪 EOF 代码（代码段、函数深度、立即数）和传统合约。","tags":["tracing","eof","debugging","interface","stagnant"],"related":[3155,7692,4750,3540],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7756/","markdown":"## 它解决什么问题？\n\n[EIP-3155](/eip-3155/) 定义了按 opcode 输出的标准 JSON 追踪，Geth、Besu、Nethermind、evmone、EthereumJS 和 Reth 等客户端在运行状态测试时都会打印这种追踪。如今这些追踪还被用于实时区块追踪以及客户端之间的差分模糊测试，任何不一致都可能暴露共识 bug。\n\nEVM 对象格式（[EIP-7692](/eip-7692/)）引入了代码段、代码内函数（`CALLF`/`RETF`）以及许多带立即数参数的指令。旧的追踪格式无法表达这些内容。EIP-7756 在加入 EOF 支持的基础上重述了整个追踪规范，并澄清了 EIP-3155 中含糊的地方。\n\n## 它如何运作\n\n客户端为**每个执行的 opcode 输出一个 JSON 对象**，最后可以再输出一行摘要。\n\n每行的必填字段：`pc`、`op`、`opName`、`gas`、`stack`、`depth`、`error`（不适用时省略）。\n\n推荐字段：`gasCost`、`memSize`（以字节计）、`returnData`、`refund`。\n\n可选字段（若省略，则整个追踪都省略）：`section`、`immediate`、`functionDepth`、`memory`、`storage`。\n\nEOF 带来的新内容：\n\n- `section`：当前运行的 EOF 代码段；仅 EOF 代码才有。\n- `functionDepth`：[EIP-4750](/eip-4750/) 的 `CALLF` 返回栈深度；从 1 开始，为 1 时可省略。\n- `immediate`：指令的立即数字节，这样无需字节码就能读懂追踪。\n- 对于 EOF，`pc` 从容器起始处开始计数（第 0 字节是 `0xEF` 魔数），因此第一行位于第一个代码段的第一个字节，而不是 `pc: 0`。\n\n数字的处理方式也得到澄清：大于 2^53 - 1 的值必须使用十六进制字符串，在期望数字的地方，消费方应同时接受 JSON 数字和十六进制字符串。\n\n摘要行可以包含 `stateRoot`、`output`、`gasUsed`、`pass`，以及可选的 `time` 和 `fork`。\n\n## 示例代码\n\n通过 `CALLF` 进入 EOF 函数的追踪行（改编自规范中的测试用例）：\n\n```json\n{\"pc\":25,\"section\":0,\"op\":\"0xe3\",\"immediate\":\"0x0001\",\"gas\":49195500,\"gasCost\":5,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"CALLF\"}\n{\"pc\":29,\"section\":1,\"op\":\"0xe4\",\"gas\":49195495,\"gasCost\":3,\"memSize\":0,\"stack\":[],\"depth\":2,\"functionDepth\":2,\"refund\":0,\"opName\":\"RETF\"}\n{\"pc\":28,\"section\":0,\"op\":\"0x00\",\"gas\":49195492,\"gasCost\":0,\"memSize\":0,\"stack\":[],\"depth\":2,\"refund\":0,\"opName\":\"STOP\"}\n```\n\n一个同时兼容两种数字写法的简单消费方：\n\n```ts\nconst toBig = (v: number | string) =\u003e (typeof v === \"string\" ? BigInt(v) : BigInt(v));\nfor (const line of traceText.trim().split(\"\\n\")) {\n  const t = JSON.parse(line);\n  if (\"pc\" in t) console.log(t.depth, t.section ?? \"-\", t.opName, toBig(t.gas));\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant**，它所支持的 EOF 元 EIP（[EIP-7692](/eip-7692/)）同样是 Stagnant。传统追踪仍以 [EIP-3155](/eip-3155/) 为基础格式。\n- 与 EIP-3155 的差异：`gas`、`gasCost` 和 `gasUsed` 改为 Number 类型，`op` 改为 Hex-Number。\n- 除上述类型变化外，传统（非 EOF）追踪保持兼容。\n- 规范中的安全提示：追踪对 CPU 和带宽消耗很大。追踪端点应默认关闭并限制访问，尤其是在验证者节点上。\n"}}}
