Skip to content

fix(eip-8141): account block execution gas before refund - #3443

Open
chugarchugarr wants to merge 3 commits into
ethereum:eips/amsterdam/eip-8141from
chugarchugarr:fix/eip-8141-eip-7778-block-gas
Open

fix(eip-8141): account block execution gas before refund#3443
chugarchugarr wants to merge 3 commits into
ethereum:eips/amsterdam/eip-8141from
chugarchugarr:fix/eip-8141-eip-7778-block-gas

Conversation

@chugarchugarr

@chugarchugarr chugarchugarr commented Aug 26, 2026

Copy link
Copy Markdown

Description

Fix EIP-8141 frame-transaction block gas accounting so storage refunds reduce payer-facing gas without reducing block execution gas, as required by EIP-7778.

The payer and receipt remain post-refund. At the block-processing boundary, the execution dimension is reconstructed from gas_used_before_refund, reduced only by the transaction's net state-gas dimension, and held to the calldata floor:

  • payer fee and receipt cumulative gas: post-refund
  • block execution gas: pre-refund
  • block state gas: net after state-gas refills

The storage-clear regression now pins the split through both the expected receipt and block header.

Verification

  • uv run fill -q tests/amsterdam/eip8141_frame_transactions/test_gas_settlement.py --fork Bogota --clean -n 0 — 9 passed
  • Ruff check and format check — passed
  • git diff --check — passed

Base

eips/amsterdam/eip-8141 at 6798542ebd017b683b688489d770bf206c8bd3ba.

@gurukamath
gurukamath force-pushed the eips/amsterdam/eip-8141 branch 2 times, most recently from 8adc4c8 to 6798542 Compare August 26, 2026 10:38
@chugarchugarr
chugarchugarr force-pushed the fix/eip-8141-eip-7778-block-gas branch from 9f0f995 to 9f2e228 Compare August 26, 2026 11:40

@chugarchugarr chugarchugarr left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@spencer-tb @gurukamath @LouisTsai-Csie — this catches an EIP-8141 × EIP-7778 accounting interaction where storage refunds were also reducing block execution gas.

The payer/receipt remain post-refund; block execution gas remains pre-refund. Regression coverage is included, and the PR is currently waiting on fork-workflow approval before upstream CI can run.

Would one of you mind approving the workflows / taking a look at the accounting boundary?

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (eips/amsterdam/eip-8141@6798542). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-8141    #3443   +/-   ##
==========================================================
  Coverage                           ?   93.41%           
==========================================================
  Files                              ?      576           
  Lines                              ?    33091           
  Branches                           ?     2911           
==========================================================
  Hits                               ?    30911           
  Misses                             ?     1533           
  Partials                           ?      647           
Flag Coverage Δ
unittests 93.41% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Author

Status update: I closed my unrelated open execution-specs contributions, so this is now my sole active upstream PR here. Head 9f2e228 is mergeable and its Python Specification, docs, render, and modified-line coverage checks are green.

@spencer-tb @gurukamath @LouisTsai-Csie — requesting one narrow human review of the accounting boundary: payer/receipt gas remains post-refund while block execution gas remains pre-refund under EIP-7778. A direct rejection or narrowing is as useful as approval; I am making no acceptance claim before that review.

@gurukamath gurukamath left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an implementation of the spec update that was recently merged. See PR

We need to bump the spec commit hash under tests/amsterdam/eip8141_frame_transactions/spec.py to 7d1c8bfb945cbb53479217df3bf1da67b3aa445b

settlement.state_gas_used
)

# EIP-7778 keeps storage refunds out of block gas accounting. The

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we just add gas_used to the FrameTransactionGasSettlement and derive these within settle_frame_transaction_gas rather than inline here?

# state dimension is already net; only execution is reconstructed
# from pre-refund usage and held to the calldata floor.
gas_used_before_refund = frame_context.standard_gas_limit - tx_unused_gas
block_execution_gas_used = ExecutionGas(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be worth a test here. With the frame declaring no state gas, as test_storage_refund_settlement does, both clamps compare directly against the floor and split into three cases:

  1. gas_used_after_refund > floor — payer settles at gas_used_after_refund, block at gas_used_before_refund. Already covered by test_storage_refund_settlement
  2. gas_used_before_refund > floor > gas_used_after_refund — payer settles at floor, block at gas_used_before_refund. Not covered.
  3. floor > gas_used_before_refund — both settle at floor. Not covered.

Copy link
Copy Markdown
Author

@gurukamath — pinned tests/amsterdam/eip8141_frame_transactions/spec.py to the merged EIP update commit 7d1c8bfb945cbb53479217df3bf1da67b3aa445b in d670546.

The fork workflows were reset by the new commit and are awaiting approval again. I’m keeping the two inline suggestions (move the derivation into settle_frame_transaction_gas and add the two calldata-floor boundary cases) as the remaining review items rather than mixing unrelated changes into the spec-pin fix.

@chugarchugarr
chugarchugarr force-pushed the fix/eip-8141-eip-7778-block-gas branch from 00f2cf1 to ce7e32f Compare August 28, 2026 14:07
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