{"eip":8116,"title":"Replace cumulative receipt fields","description":"Replace cumulativeGasUsed with gasUsed in on-chain receipt","authors":["Etan Kissling (@etan-status)","Gajinder Singh (@g11tech)"],"status":"Draft","type":"Standards Track","category":"Core","created":"2025-12-30","discussionsTo":"https://ethereum-magicians.org/t/eip-8116-replace-cumulative-receipt-fields/27359","repo":"EIPs","label":"EIP-8116","officialUrl":"https://eips.ethereum.org/EIPS/eip-8116","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8116.md","url":"https://eips.huatuo.xyz/eip-8116/","tldr":{"en":"Changes on-chain receipts to record each transaction's own gasUsed instead of a running block total, and makes RPC logIndex count per receipt, so receipts become independent of one another.","ja":"オンチェーンのレシートが、ブロックの累計ではなく各トランザクション自身の gasUsed を記録するように変更し、RPC の logIndex もレシートごとにカウントするようにして、レシート同士を互いに独立にする。","ko":"온체인 영수증이 블록 누적 합계 대신 각 트랜잭션 자체의 gasUsed를 기록하도록 바꾸고, RPC의 logIndex도 영수증별로 세게 해서 영수증이 서로 독립적이 되게 한다.","zh":"将链上收据改为记录每笔交易自身的 gasUsed，而不是区块内的累计总量，并让 RPC 的 logIndex 按每个收据单独计数，使收据彼此独立。"},"tags":["receipts","gas","json-rpc","core"],"explainers":{"en":{"lang":"en","tldr":"Changes on-chain receipts to record each transaction's own gasUsed instead of a running block total, and makes RPC logIndex count per receipt, so receipts become independent of one another.","tags":["receipts","gas","json-rpc","core"],"related":[658,2718,7745,7919],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8116/","markdown":"## What problem does it solve?\n\nEvery transaction receipt stored in a block today carries `cumulativeGasUsed`: the running total of gas consumed by all transactions in the block up to and including this one. The gas a single transaction actually used is not stored directly; you get it by subtracting the previous receipt's cumulative value.\n\nThat design has two costs:\n\n- **Verification is awkward.** An RPC client that wants to prove \"this transaction used X gas\" must fetch and verify two consecutive receipts and subtract.\n- **Receipts are stateful.** Each receipt depends on every transaction before it, even when those transactions touched completely unrelated state. That gets in the way of building receipts in parallel.\n\nThe JSON-RPC `logIndex` field has the same flavour of problem: it counts logs across the whole block, so a log's index depends on all earlier transactions.\n\n## How it works\n\nThe proposal makes two small changes, both replacing a block-level running counter with a per-transaction value:\n\n1. **Receipt construction (consensus change).** After activation, the receipt committed in the block's receipts trie stores the individual transaction's `gasUsed` in the slot where `cumulativeGasUsed` used to be.\n2. **JSON-RPC (API change).** Inside a receipt's `logs`, `logIndex` becomes the position of the log *within that receipt* (starting again for each transaction) rather than within the whole block.\n\nThe rationale is to align on-chain data with what applications actually consume over RPC: most users want \"gas used by my transaction\", not the running block total.\n\n## Sample code\n\nBefore and after, for a block with three transactions using 21,000, 50,000 and 30,000 gas:\n\n```text\n                 before (cumulativeGasUsed)   after (gasUsed)\ntx 0             21000                         21000\ntx 1             71000                         50000\ntx 2            101000                         30000\n```\n\nCode that derived per-transaction gas from consecutive receipts must switch to reading the value directly once the fork is active. If you still need a block-wide ordering key for logs, the spec suggests this approximation:\n\n```ts\n// Preserves the old relative ordering; absolute values may be larger than before.\nfunction legacyOrderKey(log: { transactionIndex: number; logIndex: number }): number {\n  return log.transactionIndex * 4 + log.logIndex;\n}\n```\n\n## Things to know\n\n- **Status: Draft.** It is not scheduled for any network upgrade, and details may change.\n- Indexers, explorers and light clients that verify `cumulativeGasUsed` or rely on block-level `logIndex` must handle both semantics: old receipts keep the cumulative meaning, receipts after activation use the per-transaction one.\n- The `logIndex` change is RPC-only; logs themselves are unchanged on-chain.\n- Receipt types and envelopes come from [EIP-2718](/eip-2718/); the receipt status field came from [EIP-658](/eip-658/). Related \"make Ethereum data easier to consume\" work is gathered under [EIP-7919](/eip-7919/) (Pureth Meta, currently Stagnant).\n"},"ja":{"lang":"ja","tldr":"オンチェーンのレシートが、ブロックの累計ではなく各トランザクション自身の gasUsed を記録するように変更し、RPC の logIndex もレシートごとにカウントするようにして、レシート同士を互いに独立にする。","tags":["receipts","gas","json-rpc","core"],"related":[658,2718,7745,7919],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8116/","markdown":"## 何を解決するのか\n\n現在ブロックに保存されているすべてのトランザクションレシートは、`cumulativeGasUsed` を持っています。これは、そのトランザクションまでを含め、ブロック内のすべてのトランザクションが消費した gas の累計です。個々のトランザクションが実際に使った gas は直接保存されておらず、1 つ前のレシートの累計値を引くことで求めます。\n\nこの設計には 2 つのコストがあります。\n\n- **検証が面倒。** 「このトランザクションは X gas を使った」ことを証明したい RPC クライアントは、連続する 2 つのレシートを取得・検証して、引き算をしなければなりません。\n- **レシートがステートフル。** 各レシートは、それ以前のすべてのトランザクションに依存します。それらがまったく無関係な状態に触れていてもです。これは、レシートを並列に構築する妨げになります。\n\nJSON-RPC の `logIndex` フィールドにも同種の問題があります。ブロック全体にわたってログを数えるため、ログのインデックスは、それ以前のすべてのトランザクションに依存します。\n\n## 仕組み\n\nこの提案は 2 つの小さな変更を行います。どちらも、ブロックレベルの累計カウンターを、トランザクションごとの値に置き換えるものです。\n\n1. **レシートの構築（コンセンサスの変更）。** アクティベーション後、ブロックのレシートトライにコミットされるレシートは、`cumulativeGasUsed` があった場所に、個々のトランザクションの `gasUsed` を保存します。\n2. **JSON-RPC（API の変更）。** レシートの `logs` の中で、`logIndex` は、ブロック全体ではなく、*そのレシート内*でのログの位置になります（トランザクションごとに最初から数え直します）。\n\nその理由は、オンチェーンのデータを、アプリケーションが RPC 経由で実際に利用するものに合わせることです。ほとんどのユーザーが欲しいのは、ブロックの累計ではなく「自分のトランザクションが使った gas」です。\n\n## サンプルコード\n\n21,000、50,000、30,000 gas を使う 3 つのトランザクションを含むブロックの、変更前と変更後:\n\n```text\n                 before (cumulativeGasUsed)   after (gasUsed)\ntx 0             21000                         21000\ntx 1             71000                         50000\ntx 2            101000                         30000\n```\n\n連続するレシートからトランザクションごとの gas を導出していたコードは、フォークが有効になったら、値を直接読む方式に切り替える必要があります。ログのためにブロック全体の順序キーがまだ必要な場合、仕様は次の近似を提案しています。\n\n```ts\n// Preserves the old relative ordering; absolute values may be larger than before.\nfunction legacyOrderKey(log: { transactionIndex: number; logIndex: number }): number {\n  return log.transactionIndex * 4 + log.logIndex;\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** どのネットワークアップグレードにも予定されておらず、詳細は変わる可能性があります。\n- `cumulativeGasUsed` を検証したり、ブロックレベルの `logIndex` に依存したりするインデクサー、エクスプローラー、ライトクライアントは、両方の意味に対応する必要があります。古いレシートは累計の意味のまま、アクティベーション後のレシートはトランザクションごとの意味を使います。\n- `logIndex` の変更は RPC のみに限られ、ログ自体はオンチェーンで変わりません。\n- レシートのタイプとエンベロープは [EIP-2718](/eip-2718/) に由来し、レシートのステータスフィールドは [EIP-658](/eip-658/) に由来します。「Ethereum のデータを使いやすくする」関連の取り組みは、[EIP-7919](/eip-7919/)（Pureth Meta、現在 Stagnant）にまとめられています。\n"},"ko":{"lang":"ko","tldr":"온체인 영수증이 블록 누적 합계 대신 각 트랜잭션 자체의 gasUsed를 기록하도록 바꾸고, RPC의 logIndex도 영수증별로 세게 해서 영수증이 서로 독립적이 되게 한다.","tags":["receipts","gas","json-rpc","core"],"related":[658,2718,7745,7919],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8116/","markdown":"## 어떤 문제를 해결하나요?\n\n현재 블록에 저장되는 모든 트랜잭션 영수증에는 `cumulativeGasUsed`가 들어 있습니다. 이는 이 트랜잭션까지 포함해 블록 안의 모든 트랜잭션이 소비한 gas의 누적 합계입니다. 개별 트랜잭션이 실제로 사용한 gas는 직접 저장되지 않으며, 이전 영수증의 누적 값을 빼서 구합니다.\n\n이 설계에는 두 가지 비용이 있습니다.\n\n- **검증이 번거롭습니다.** \"이 트랜잭션이 X gas를 사용했다\"를 증명하려는 RPC 클라이언트는 연속된 두 영수증을 가져와 검증하고 뺄셈을 해야 합니다.\n- **영수증이 상태를 가집니다.** 각 영수증은 그 앞의 모든 트랜잭션에 의존하며, 그 트랜잭션들이 완전히 무관한 상태를 건드렸더라도 마찬가지입니다. 이는 영수증을 병렬로 만드는 데 걸림돌이 됩니다.\n\nJSON-RPC의 `logIndex` 필드에도 같은 종류의 문제가 있습니다. 블록 전체에 걸쳐 로그를 세기 때문에 로그의 인덱스가 이전의 모든 트랜잭션에 의존합니다.\n\n## 어떻게 동작하나요?\n\n이 제안은 두 가지 작은 변경을 합니다. 둘 다 블록 수준의 누적 카운터를 트랜잭션별 값으로 바꾸는 것입니다.\n\n1. **영수증 구성(컨센서스 변경).** 활성화 이후 블록의 영수증 트라이에 커밋되는 영수증은 `cumulativeGasUsed`가 있던 자리에 개별 트랜잭션의 `gasUsed`를 저장합니다.\n2. **JSON-RPC(API 변경).** 영수증의 `logs` 안에서 `logIndex`는 블록 전체가 아니라 *그 영수증 내*에서의 로그 위치가 됩니다(트랜잭션마다 처음부터 다시 셉니다).\n\n그 이유는 온체인 데이터를 애플리케이션이 RPC로 실제 소비하는 것에 맞추기 위해서입니다. 대부분의 사용자는 블록 누적 합계가 아니라 \"내 트랜잭션이 사용한 gas\"를 원합니다.\n\n## 샘플 코드\n\n21,000, 50,000, 30,000 gas를 사용하는 세 트랜잭션이 있는 블록의 변경 전과 후:\n\n```text\n                 before (cumulativeGasUsed)   after (gasUsed)\ntx 0             21000                         21000\ntx 1             71000                         50000\ntx 2            101000                         30000\n```\n\n연속된 영수증에서 트랜잭션별 gas를 도출하던 코드는 포크가 활성화되면 값을 직접 읽도록 바꿔야 합니다. 로그에 대해 블록 전체의 정렬 키가 여전히 필요하다면, 사양은 다음과 같은 근사를 제안합니다.\n\n```ts\n// Preserves the old relative ordering; absolute values may be larger than before.\nfunction legacyOrderKey(log: { transactionIndex: number; logIndex: number }): number {\n  return log.transactionIndex * 4 + log.logIndex;\n}\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 어떤 네트워크 업그레이드에도 예정되어 있지 않으며 세부 사항은 바뀔 수 있습니다.\n- `cumulativeGasUsed`를 검증하거나 블록 수준 `logIndex`에 의존하는 인덱서, 익스플로러, 라이트 클라이언트는 두 의미를 모두 처리해야 합니다. 오래된 영수증은 누적 의미를 유지하고, 활성화 이후의 영수증은 트랜잭션별 의미를 사용합니다.\n- `logIndex` 변경은 RPC에만 해당하며, 로그 자체는 온체인에서 바뀌지 않습니다.\n- 영수증 타입과 엔벨로프는 [EIP-2718](/eip-2718/)에서, 영수증 status 필드는 [EIP-658](/eip-658/)에서 왔습니다. \"이더리움 데이터를 더 쉽게 쓸 수 있게 만들기\" 관련 작업은 [EIP-7919](/eip-7919/)(Pureth Meta, 현재 Stagnant) 아래에 모여 있습니다.\n"},"zh":{"lang":"zh","tldr":"将链上收据改为记录每笔交易自身的 gasUsed，而不是区块内的累计总量，并让 RPC 的 logIndex 按每个收据单独计数，使收据彼此独立。","tags":["receipts","gas","json-rpc","core"],"related":[658,2718,7745,7919],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8116/","markdown":"## 它解决什么问题？\n\n如今区块中存储的每个交易收据都带有 `cumulativeGasUsed`：区块中截至并包括这笔交易的所有交易所消耗 gas 的累计总量。单笔交易实际使用的 gas 并没有直接存储，需要用当前收据的累计值减去前一个收据的累计值才能得到。\n\n这种设计有两个代价：\n\n- **验证很麻烦。** 想证明\"这笔交易使用了 X gas\"的 RPC 客户端，必须获取并验证两个连续的收据，然后做减法。\n- **收据是有状态的。** 每个收据都依赖它之前的每一笔交易，即使这些交易触及的状态完全无关。这妨碍了并行构建收据。\n\nJSON-RPC 的 `logIndex` 字段也有同类问题：它在整个区块范围内为日志计数，因此一条日志的索引取决于之前所有的交易。\n\n## 它如何运作\n\n该提案做了两个小改动，都是把区块级的累计计数器替换为每笔交易自己的值：\n\n1. **收据构造（共识变更）。** 激活之后，提交到区块收据树中的收据，会在原本存放 `cumulativeGasUsed` 的位置存放该笔交易自己的 `gasUsed`。\n2. **JSON-RPC（API 变更）。** 在收据的 `logs` 中，`logIndex` 变为日志在*该收据内*的位置（每笔交易重新从头开始），而不是在整个区块中的位置。\n\n这样做的理由是让链上数据与应用通过 RPC 实际使用的内容保持一致：大多数用户想要的是\"我这笔交易使用的 gas\"，而不是区块的累计总量。\n\n## 示例代码\n\n变更前后对比，区块中有三笔交易，分别使用 21,000、50,000 和 30,000 gas：\n\n```text\n                 before (cumulativeGasUsed)   after (gasUsed)\ntx 0             21000                         21000\ntx 1             71000                         50000\ntx 2            101000                         30000\n```\n\n原先通过连续收据推算每笔交易 gas 的代码，在分叉激活后必须改为直接读取该值。如果你仍然需要用于日志的区块级排序键，规范建议使用下面的近似方法：\n\n```ts\n// Preserves the old relative ordering; absolute values may be larger than before.\nfunction legacyOrderKey(log: { transactionIndex: number; logIndex: number }): number {\n  return log.transactionIndex * 4 + log.logIndex;\n}\n```\n\n## 需要注意\n\n- **状态：Draft。** 它没有排入任何网络升级，细节可能会变化。\n- 验证 `cumulativeGasUsed` 或依赖区块级 `logIndex` 的索引器、浏览器和轻客户端必须同时处理两种语义：旧收据保持累计含义，激活之后的收据使用每笔交易的含义。\n- `logIndex` 的变更仅限于 RPC；日志本身在链上不变。\n- 收据类型和信封来自 [EIP-2718](/eip-2718/)；收据状态字段来自 [EIP-658](/eip-658/)。相关的\"让以太坊数据更易于使用\"的工作汇集在 [EIP-7919](/eip-7919/)（Pureth Meta，目前为 Stagnant）之下。\n"}},"requiredBy":[6466]}
