{"eip":3155,"title":"EVM trace specification","description":"A JSON format for EVM traces","authors":["Martin Holst Swende (@holiman)","Marius van der Wijden (@MariusVanDerWijden)"],"status":"Last Call","type":"Standards Track","category":"Interface","created":"2020-12-07","discussionsTo":"https://ethereum-magicians.org/t/eip-3155-create-evm-trace-specification/5007","repo":"EIPs","label":"EIP-3155","officialUrl":"https://eips.ethereum.org/EIPS/eip-3155","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3155.md","url":"https://eips.huatuo.xyz/eip-3155/","tldr":{"en":"A common JSON-lines format for step-by-step EVM execution traces, so the output of different clients can be diffed directly for debugging and differential fuzzing.","ja":"ステップごとの EVM 実行トレースのための共通の JSON Lines 形式。異なるクライアントの出力を直接 diff でき、デバッグや差分ファジングに使える。","ko":"단계별 EVM 실행 트레이스를 위한 공통 JSON Lines 형식. 서로 다른 클라이언트의 출력을 바로 diff할 수 있어 디버깅과 차등 퍼징에 쓸 수 있다.","zh":"为逐步的 EVM 执行跟踪定义的通用 JSON Lines 格式，使不同客户端的输出可以直接比对（diff），用于调试和差分模糊测试。"},"tags":["evm","tracing","debugging","testing","clients"],"explainers":{"en":{"lang":"en","tldr":"A common JSON-lines format for step-by-step EVM execution traces, so the output of different clients can be diffed directly for debugging and differential fuzzing.","tags":["evm","tracing","debugging","testing","clients"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3155/","markdown":"## What problem does it solve?\n\nTo find consensus bugs, client developers run the same state test or transaction through several EVM implementations and compare what happens at every step. Geth, Besu, Nethermind and OpenEthereum each had a tool that printed such traces in a roughly common JSON format, but the format was never precisely defined. Small differences (null vs empty arrays, decimal vs hex numbers, field order) made automated comparison unreliable.\n\nEIP-3155 writes the format down, settles the corner cases, and gives sample output. With every client emitting identical lines, a **differential fuzzer** can feed random inputs to all EVMs and flag the first step where they disagree, which also helps diagnose chain splits quickly.\n\n## How it works\n\nThe client under test prints **one JSON object per executed opcode**, then one **summary** object at the end.\n\nRequired per-step fields:\n\n| Field | Type | Meaning |\n| --- | --- | --- |\n| `pc` | number | Program counter |\n| `op` | number | Opcode byte |\n| `gas` | hex | Gas left *before* this op |\n| `gasCost` | hex | Cost of this op |\n| `memSize` | number | Memory size |\n| `stack` | array of hex | Stack *before* this op |\n| `depth` | number | Call depth |\n| `returnData` | hex string | Data returned by the last call |\n| `refund` | number | Global gas refund counter |\n\nOptional: `opName`, `error`, `memory`, `storage`. Arrays must be `[]`, never `null`. `memSize` is always present even if memory is not traced, and fields should appear in the listed order. Clients should allow storage tracing to be turned off.\n\nThe summary line must contain `stateRoot`, `output`, `gasUsed` and `pass`, and may include `time` (nanoseconds) and `fork`.\n\n## Sample code\n\nOutput from Besu's `evmtool`, as given in the spec (trimmed):\n\n```bash\nevmtool --code 0x604080536040604055604060006040600060025afa6040f3\n```\n\n```json\n{\"pc\":0,\"op\":96,\"gas\":\"0x2540be400\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[],\"depth\":1,\"refund\":0,\"opName\":\"PUSH1\"}\n{\"pc\":2,\"op\":128,\"gas\":\"0x2540be3fd\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"DUP1\"}\n{\"pc\":3,\"op\":83,\"gas\":\"0x2540be3fa\",\"gasCost\":\"0xc\",\"memSize\":0,\"stack\":[\"0x40\",\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"MSTORE8\"}\n{\"stateRoot\":\"0x8fa0dcc7f1d2383c89e5737c2843632db881c0946e80b71fe7175365e6538797\",\"output\":\"0x40\",\"gasUsed\":\"0x515c\",\"pass\":true,\"fork\":\"Istanbul\"}\n```\n\nFinding the first divergence between two clients' traces (TypeScript, Node):\n\n```ts\nimport { readFileSync } from \"node:fs\";\n\nconst KEYS = [\"pc\", \"op\", \"gas\", \"gasCost\", \"stack\", \"depth\"];\nconst load = (f: string) =\u003e readFileSync(f, \"utf8\").trim().split(\"\\n\").map((l) =\u003e JSON.parse(l));\nconst [a, b] = [load(\"geth.jsonl\"), load(\"besu.jsonl\")];\n\nconst i = a.findIndex((s, n) =\u003e KEYS.some((k) =\u003e JSON.stringify(s[k]) !== JSON.stringify(b[n]?.[k])));\nconsole.log(i === -1 ? \"traces match\" : { step: i, a: a[i], b: b[i] });\n```\n\n## Things to know\n\n- Status is **Last Call**: the text may still change before becoming Final.\n- This is a tooling format, not a consensus change. Clients are free not to implement it, but those that do can join cross-client fuzzing.\n- Tracing is expensive. Exposing trace endpoints publicly can be a denial-of-service vector, so keep them behind a separate flag.\n- The spec has small inconsistencies: `memory` is described as an array of hex strings while the examples print one hex string, and the summary example shows `pass` as the string `\"true\"` in one place and a boolean in another. Compare semantically rather than byte-for-byte where these differ.\n"},"ja":{"lang":"ja","tldr":"ステップごとの EVM 実行トレースのための共通の JSON Lines 形式。異なるクライアントの出力を直接 diff でき、デバッグや差分ファジングに使える。","tags":["evm","tracing","debugging","testing","clients"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3155/","markdown":"## 何を解決するのか\n\nコンセンサスのバグを見つけるため、クライアント開発者は同じステートテストやトランザクションを複数の EVM 実装で実行し、各ステップで何が起きるかを比較します。Geth、Besu、Nethermind、OpenEthereum はそれぞれ、おおむね共通の JSON 形式でこのようなトレースを出力するツールを持っていましたが、形式は厳密には定義されていませんでした。小さな違い（null と空配列、10 進数と 16 進数、フィールドの順序）のせいで、自動比較は信頼できませんでした。\n\nEIP-3155 はこの形式を明文化し、細かいケースに決着をつけ、サンプル出力を示します。すべてのクライアントが同一の行を出力すれば、**差分ファザー**がランダムな入力をすべての EVM に与え、最初に結果が食い違うステップを検出できます。これはチェーン分岐の迅速な診断にも役立ちます。\n\n## 仕組み\n\nテスト対象のクライアントは、**実行された各オペコードにつき 1 つの JSON オブジェクト**を出力し、最後に 1 つの**サマリー**オブジェクトを出力します。\n\nステップごとの必須フィールド:\n\n| フィールド | 型 | 意味 |\n| --- | --- | --- |\n| `pc` | number | プログラムカウンター |\n| `op` | number | オペコードのバイト |\n| `gas` | hex | この op の*実行前*の残りガス |\n| `gasCost` | hex | この op のコスト |\n| `memSize` | number | メモリサイズ |\n| `stack` | array of hex | この op の*実行前*のスタック |\n| `depth` | number | コールの深さ |\n| `returnData` | hex string | 直前のコールが返したデータ |\n| `refund` | number | グローバルなガス払い戻しカウンター |\n\n任意: `opName`、`error`、`memory`、`storage`。配列は常に `[]` とし、`null` にしてはなりません。`memSize` は、メモリをトレースしない場合でも常に存在します。フィールドは記載された順序で出力すべきです。クライアントはストレージのトレースを無効にできるようにすべきです。\n\nサマリー行には `stateRoot`、`output`、`gasUsed`、`pass` を含める必要があり、`time`（ナノ秒）と `fork` を含めてもかまいません。\n\n## サンプルコード\n\n仕様に示されている Besu の `evmtool` の出力（抜粋）:\n\n```bash\nevmtool --code 0x604080536040604055604060006040600060025afa6040f3\n```\n\n```json\n{\"pc\":0,\"op\":96,\"gas\":\"0x2540be400\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[],\"depth\":1,\"refund\":0,\"opName\":\"PUSH1\"}\n{\"pc\":2,\"op\":128,\"gas\":\"0x2540be3fd\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"DUP1\"}\n{\"pc\":3,\"op\":83,\"gas\":\"0x2540be3fa\",\"gasCost\":\"0xc\",\"memSize\":0,\"stack\":[\"0x40\",\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"MSTORE8\"}\n{\"stateRoot\":\"0x8fa0dcc7f1d2383c89e5737c2843632db881c0946e80b71fe7175365e6538797\",\"output\":\"0x40\",\"gasUsed\":\"0x515c\",\"pass\":true,\"fork\":\"Istanbul\"}\n```\n\n2 つのクライアントのトレースで最初に食い違う箇所を見つける例（TypeScript、Node）:\n\n```ts\nimport { readFileSync } from \"node:fs\";\n\nconst KEYS = [\"pc\", \"op\", \"gas\", \"gasCost\", \"stack\", \"depth\"];\nconst load = (f: string) =\u003e readFileSync(f, \"utf8\").trim().split(\"\\n\").map((l) =\u003e JSON.parse(l));\nconst [a, b] = [load(\"geth.jsonl\"), load(\"besu.jsonl\")];\n\nconst i = a.findIndex((s, n) =\u003e KEYS.some((k) =\u003e JSON.stringify(s[k]) !== JSON.stringify(b[n]?.[k])));\nconsole.log(i === -1 ? \"traces match\" : { step: i, a: a[i], b: b[i] });\n```\n\n## 知っておくべきこと\n\n- ステータスは **Last Call** です。Final になる前に本文が変更される可能性があります。\n- これはツール用の形式であり、コンセンサスの変更ではありません。クライアントは実装しなくてもかまいませんが、実装すればクライアント間のファジングに参加できます。\n- トレースは高コストです。トレース用のエンドポイントを公開すると、サービス拒否攻撃の経路になり得るため、別のフラグの背後に置いてください。\n- 仕様には小さな不整合があります。`memory` は 16 進文字列の配列と説明されていますが、例では 1 つの 16 進文字列を出力しており、サマリーの例では `pass` がある箇所では文字列 `\"true\"`、別の箇所では真偽値になっています。これらが食い違う場合は、バイト単位ではなく意味で比較してください。\n"},"ko":{"lang":"ko","tldr":"단계별 EVM 실행 트레이스를 위한 공통 JSON Lines 형식. 서로 다른 클라이언트의 출력을 바로 diff할 수 있어 디버깅과 차등 퍼징에 쓸 수 있다.","tags":["evm","tracing","debugging","testing","clients"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3155/","markdown":"## 어떤 문제를 해결하나요?\n\n합의 버그를 찾기 위해 클라이언트 개발자들은 같은 상태 테스트나 트랜잭션을 여러 EVM 구현에서 실행하고, 매 단계에서 일어나는 일을 비교합니다. Geth, Besu, Nethermind, OpenEthereum은 각각 대체로 비슷한 JSON 형식으로 이런 트레이스를 출력하는 도구를 갖고 있었지만, 그 형식은 정확히 정의된 적이 없었습니다. 작은 차이(null과 빈 배열, 10진수와 16진수, 필드 순서) 때문에 자동 비교는 신뢰하기 어려웠습니다.\n\nEIP-3155는 이 형식을 문서로 정리하고, 애매한 경우를 정리하며, 예시 출력을 제공합니다. 모든 클라이언트가 똑같은 줄을 출력하면 **차등 퍼저(differential fuzzer)**가 무작위 입력을 모든 EVM에 넣고 처음으로 결과가 갈리는 단계를 표시할 수 있으며, 이는 체인 분기를 빠르게 진단하는 데도 도움이 됩니다.\n\n## 어떻게 동작하나요?\n\n테스트 대상 클라이언트는 **실행된 옵코드마다 JSON 객체 하나**를 출력하고, 마지막에 **요약** 객체 하나를 출력합니다.\n\n단계별 필수 필드:\n\n| 필드 | 타입 | 의미 |\n| --- | --- | --- |\n| `pc` | number | 프로그램 카운터 |\n| `op` | number | 옵코드 바이트 |\n| `gas` | hex | 이 op *실행 전* 남은 gas |\n| `gasCost` | hex | 이 op의 비용 |\n| `memSize` | number | 메모리 크기 |\n| `stack` | array of hex | 이 op *실행 전*의 스택 |\n| `depth` | number | 호출 깊이 |\n| `returnData` | hex string | 마지막 호출이 반환한 데이터 |\n| `refund` | number | 전역 gas 환급 카운터 |\n\n선택: `opName`, `error`, `memory`, `storage`. 배열은 반드시 `[]`여야 하며 `null`이어서는 안 됩니다. `memSize`는 메모리를 트레이스하지 않아도 항상 존재하며, 필드는 나열된 순서대로 나와야 합니다. 클라이언트는 스토리지 트레이싱을 끌 수 있도록 해야 합니다.\n\n요약 줄에는 `stateRoot`, `output`, `gasUsed`, `pass`가 반드시 있어야 하고, `time`(나노초)과 `fork`를 포함할 수 있습니다.\n\n## 샘플 코드\n\n명세에 나온 Besu `evmtool`의 출력(일부 생략):\n\n```bash\nevmtool --code 0x604080536040604055604060006040600060025afa6040f3\n```\n\n```json\n{\"pc\":0,\"op\":96,\"gas\":\"0x2540be400\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[],\"depth\":1,\"refund\":0,\"opName\":\"PUSH1\"}\n{\"pc\":2,\"op\":128,\"gas\":\"0x2540be3fd\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"DUP1\"}\n{\"pc\":3,\"op\":83,\"gas\":\"0x2540be3fa\",\"gasCost\":\"0xc\",\"memSize\":0,\"stack\":[\"0x40\",\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"MSTORE8\"}\n{\"stateRoot\":\"0x8fa0dcc7f1d2383c89e5737c2843632db881c0946e80b71fe7175365e6538797\",\"output\":\"0x40\",\"gasUsed\":\"0x515c\",\"pass\":true,\"fork\":\"Istanbul\"}\n```\n\n두 클라이언트의 트레이스에서 처음으로 갈라지는 지점 찾기(TypeScript, Node):\n\n```ts\nimport { readFileSync } from \"node:fs\";\n\nconst KEYS = [\"pc\", \"op\", \"gas\", \"gasCost\", \"stack\", \"depth\"];\nconst load = (f: string) =\u003e readFileSync(f, \"utf8\").trim().split(\"\\n\").map((l) =\u003e JSON.parse(l));\nconst [a, b] = [load(\"geth.jsonl\"), load(\"besu.jsonl\")];\n\nconst i = a.findIndex((s, n) =\u003e KEYS.some((k) =\u003e JSON.stringify(s[k]) !== JSON.stringify(b[n]?.[k])));\nconsole.log(i === -1 ? \"traces match\" : { step: i, a: a[i], b: b[i] });\n```\n\n## 알아둘 점\n\n- 상태는 **Last Call**입니다. Final이 되기 전에 본문이 바뀔 수 있습니다.\n- 이것은 도구용 형식이며 합의 변경이 아닙니다. 클라이언트가 구현하지 않아도 되지만, 구현하면 클라이언트 간 퍼징에 참여할 수 있습니다.\n- 트레이싱은 비용이 큽니다. 트레이스 엔드포인트를 공개하면 서비스 거부 공격의 경로가 될 수 있으므로 별도의 플래그 뒤에 두세요.\n- 명세에는 작은 불일치가 있습니다. `memory`는 16진수 문자열 배열로 설명되지만 예시는 16진수 문자열 하나를 출력하고, 요약 예시에서 `pass`는 한 곳에서는 문자열 `\"true\"`, 다른 곳에서는 불리언입니다. 이런 차이가 있는 곳에서는 바이트 단위가 아니라 의미를 기준으로 비교하세요.\n"},"zh":{"lang":"zh","tldr":"为逐步的 EVM 执行跟踪定义的通用 JSON Lines 格式，使不同客户端的输出可以直接比对（diff），用于调试和差分模糊测试。","tags":["evm","tracing","debugging","testing","clients"],"related":[1474],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3155/","markdown":"## 它解决什么问题？\n\n为了发现共识漏洞，客户端开发者会让同一个状态测试或交易在多种 EVM 实现中运行，并比较每一步发生了什么。Geth、Besu、Nethermind 和 OpenEthereum 各自都有一个以大致通用的 JSON 格式输出这类跟踪的工具，但这个格式从未被精确定义。一些细小的差异（null 与空数组、十进制与十六进制数字、字段顺序）使自动比较变得不可靠。\n\nEIP-3155 把这个格式写了下来，敲定了各种边角情况，并给出示例输出。当每个客户端都输出相同的行时，**差分模糊测试器**就可以把随机输入喂给所有 EVM，并标出它们最先出现分歧的那一步，这也有助于快速诊断链分叉。\n\n## 它如何运作\n\n被测客户端为**每个执行的操作码输出一个 JSON 对象**，最后再输出一个**摘要**对象。\n\n每一步必需的字段：\n\n| 字段 | 类型 | 含义 |\n| --- | --- | --- |\n| `pc` | number | 程序计数器 |\n| `op` | number | 操作码字节 |\n| `gas` | hex | 执行该 op *之前*剩余的 gas |\n| `gasCost` | hex | 该 op 的成本 |\n| `memSize` | number | 内存大小 |\n| `stack` | array of hex | 执行该 op *之前*的栈 |\n| `depth` | number | 调用深度 |\n| `returnData` | hex string | 上一次调用返回的数据 |\n| `refund` | number | 全局 gas 退款计数器 |\n\n可选字段：`opName`、`error`、`memory`、`storage`。数组必须是 `[]`，绝不能是 `null`。即使不跟踪内存，`memSize` 也始终存在，字段应按列出的顺序出现。客户端应允许关闭存储跟踪。\n\n摘要行必须包含 `stateRoot`、`output`、`gasUsed` 和 `pass`，也可以包含 `time`（纳秒）和 `fork`。\n\n## 示例代码\n\n规范中给出的 Besu `evmtool` 的输出（已精简）：\n\n```bash\nevmtool --code 0x604080536040604055604060006040600060025afa6040f3\n```\n\n```json\n{\"pc\":0,\"op\":96,\"gas\":\"0x2540be400\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[],\"depth\":1,\"refund\":0,\"opName\":\"PUSH1\"}\n{\"pc\":2,\"op\":128,\"gas\":\"0x2540be3fd\",\"gasCost\":\"0x3\",\"memSize\":0,\"stack\":[\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"DUP1\"}\n{\"pc\":3,\"op\":83,\"gas\":\"0x2540be3fa\",\"gasCost\":\"0xc\",\"memSize\":0,\"stack\":[\"0x40\",\"0x40\"],\"depth\":1,\"refund\":0,\"opName\":\"MSTORE8\"}\n{\"stateRoot\":\"0x8fa0dcc7f1d2383c89e5737c2843632db881c0946e80b71fe7175365e6538797\",\"output\":\"0x40\",\"gasUsed\":\"0x515c\",\"pass\":true,\"fork\":\"Istanbul\"}\n```\n\n找出两个客户端跟踪之间的第一处分歧（TypeScript，Node）：\n\n```ts\nimport { readFileSync } from \"node:fs\";\n\nconst KEYS = [\"pc\", \"op\", \"gas\", \"gasCost\", \"stack\", \"depth\"];\nconst load = (f: string) =\u003e readFileSync(f, \"utf8\").trim().split(\"\\n\").map((l) =\u003e JSON.parse(l));\nconst [a, b] = [load(\"geth.jsonl\"), load(\"besu.jsonl\")];\n\nconst i = a.findIndex((s, n) =\u003e KEYS.some((k) =\u003e JSON.stringify(s[k]) !== JSON.stringify(b[n]?.[k])));\nconsole.log(i === -1 ? \"traces match\" : { step: i, a: a[i], b: b[i] });\n```\n\n## 需要注意\n\n- 状态为 **Last Call**：在成为 Final 之前，文本仍可能改动。\n- 这是一种工具格式，而不是共识变更。客户端可以不实现它，但实现了的客户端可以参与跨客户端的模糊测试。\n- 跟踪的开销很大。公开暴露跟踪端点可能成为拒绝服务的途径，因此应把它们放在单独的开关之后。\n- 规范存在一些小的不一致：`memory` 被描述为十六进制字符串数组，而示例中输出的是单个十六进制字符串；摘要示例中的 `pass` 在一处是字符串 `\"true\"`，在另一处是布尔值。在这些地方存在差异时，请按语义而不是逐字节进行比较。\n"}},"requiredBy":[7756]}
