Skip to content

fix(eip-7778): use separate accumulators for receipt and block gas#33765

Closed
qu0b wants to merge 1 commit intoethereum:bal-devnet-2from
qu0b:qu0b/fix/eip-7778-cumulative-gas
Closed

fix(eip-7778): use separate accumulators for receipt and block gas#33765
qu0b wants to merge 1 commit intoethereum:bal-devnet-2from
qu0b:qu0b/fix/eip-7778-cumulative-gas

Conversation

@qu0b
Copy link
Copy Markdown
Contributor

@qu0b qu0b commented Feb 5, 2026

Summary

Fixes EIP-7778 gas accounting in the parallel state processor after the rebase in 1509dd2.

The parallel processor was using receipt.GasUsed (pre-refund, MaxUsedGas for Amsterdam) for both CumulativeGasUsed and block gas accounting. This causes receipt root mismatches because CumulativeGasUsed must be post-refund.

The Bug

In prepareExecResult:

// BEFORE (broken):
receipt.CumulativeGasUsed = cumulativeGasUsed + receipt.GasUsed  // receipt.GasUsed = MaxUsedGas (pre-refund)!
cumulativeGasUsed += receipt.GasUsed

Since receipt.GasUsed is MaxUsedGas (pre-refund for Amsterdam), CumulativeGasUsed was incorrectly using pre-refund gas.

The Fix

Use separate accumulators:

  • cumulativeGasUsed: accumulates receipt.CumulativeGasUsed (post-refund from execTx)
  • blockGasUsed: accumulates receipt.GasUsed (pre-refund for Amsterdam)
// AFTER (fixed):
cumulativeGasUsed += receipt.CumulativeGasUsed  // post-refund
receipt.CumulativeGasUsed = cumulativeGasUsed
blockGasUsed += receipt.GasUsed                  // pre-refund for block

Test plan

  • Built local geth image with fix
  • Tested in Kurtosis network (geth + lodestar vs besu + lighthouse)
  • Verified block hashes match between clients (slot 15+, block 15+)
  • Verified receipts roots match between clients
  • No INVALID payloads or errors in logs

🤖 Generated with Claude Code

The parallel state processor was using receipt.GasUsed (pre-refund,
MaxUsedGas for Amsterdam) for both CumulativeGasUsed and block gas.
This caused receipt root mismatches because CumulativeGasUsed must
be post-refund.

The fix:
- cumulativeGasUsed: accumulates receipt.CumulativeGasUsed (post-refund
  from execTx) for proper receipt CumulativeGasUsed
- blockGasUsed: accumulates receipt.GasUsed (pre-refund for Amsterdam)
  for block header GasUsed and gas limit validation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@qu0b qu0b force-pushed the qu0b/fix/eip-7778-cumulative-gas branch from 7051429 to aec81c6 Compare February 5, 2026 13:32
Copy link
Copy Markdown
Member

@gballet gballet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please read the coding guidelines

@qu0b qu0b closed this Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants