Skip to content

Fix cumulativeGasUsed: use per-transaction cumulative gas, not block total #4921

@BartoszSolkaBD

Description

@BartoszSolkaBD

Description

Problem

cumulativeGasUsed in transaction receipts is currently set to the total gas used in the block (block_gas_used) for every receipt in that block. It should instead be the cumulative gas used in the block up to and including that transaction, as defined in the Ethereum Yellow Paper.

Expected behavior (Yellow Paper)

"the cumulative gas used in the block containing the transaction receipt as of immediately after the transaction has happened"

So for a block with 3 transactions using 1000, 2000, and 3000 gas:

  • Tx 0: cumulativeGasUsed = 1000
  • Tx 1: cumulativeGasUsed = 3000 (1000 + 2000)
  • Tx 2: cumulativeGasUsed = 6000 (1000 + 2000 + 3000)

Current behavior

Every receipt in the block gets the same value: the block’s total gas (e.g. 6000 for all three in the example above). This comes from using receiptResponse.block_gas_used (mirror node: “The total gas used in the block”) for cumulativeGasUsed.

Steps to reproduce

  1. Pick a block with multiple receipts, e.g. 0x56e7e72.
  2. Call eth_getBlockReceipts for that block.
  3. Observe that every receipt in the response has the same cumulativeGasUsed value, which equals the block’s total gas used, instead of increasing per transaction as defined in the Ethereum Yellow Paper.

Additional context

No response

Hedera network

No response

Version

0.74.1 and main branch

Operating system

None

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions