Skip to content

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

Merged
gurukamath merged 7 commits into
ethereum:eips/amsterdam/eip-8141from
chugarchugarr:fix/eip-8141-eip-7778-block-gas
Sep 1, 2026
Merged

fix(eip-8141): account block execution gas before refund#3443
gurukamath merged 7 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:

  • payer fee and receipt cumulative gas: post-refund
  • block execution gas: pre-refund
  • block state gas: net after state-gas refills
  • the calldata floor is applied independently to the payer-facing and block-accounted totals

Reviewer-requested changes incorporated

Current head: ce7e32f8f7ac6e7cbdfaf87779b787c6f4e40406.

All three items from @gurukamath's review are incorporated:

  1. tests/amsterdam/eip8141_frame_transactions/spec.py is pinned to merged EIP update commit 7d1c8bfb945cbb53479217df3bf1da67b3aa445b.
  2. Payer-facing gas_used is derived inside settle_frame_transaction_gas and carried by FrameTransactionGasSettlement rather than reconstructed inline in process_frame_transaction.
  3. test_storage_refund_settlement covers all three calldata-floor orderings: post-refund above floor, floor between pre/post refund, and floor above pre-refund.

The two inline review threads have been answered and resolved, and re-review has been requested. No acceptance claim is being made before that review completes.

Verification state

The earlier focused validation (9 passed, Ruff check/format check, and git diff --check) predates the final reviewer-requested refinements and is preserved as prior evidence rather than represented as exact-current-head CI.

On current head, the upstream fork-triggered render, Python Specification, and Build Docs workflow runs are all action_required; they require upstream authorization before they can execute. There is therefore no author-side CI action remaining on this head.

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

Comment thread src/ethereum/forks/amsterdam/frame_processing.py Outdated
Comment thread src/ethereum/forks/amsterdam/frame_processing.py Outdated

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

Copy link
Copy Markdown
Author

Both outstanding inline review points are now answered and resolved on current head ce7e32f8f7ac6e7cbdfaf87779b787c6f4e40406:

  • payer-facing gas_used now lives in FrameTransactionGasSettlement and is derived inside settle_frame_transaction_gas;
  • the storage-refund regression now covers all three calldata-floor orderings requested in review.

The spec pin was also updated earlier to the merged EIP commit. Requesting re-review of the current head; no acceptance claim until that happens.

@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.

@gurukamath — all three review items are now incorporated on head ce7e32f8f7ac6e7cbdfaf87779b787c6f4e40406: (1) the spec pin is 7d1c8bfb945cbb53479217df3bf1da67b3aa445b; (2) payer-facing gas_used is derived inside settle_frame_transaction_gas and carried by FrameTransactionGasSettlement; and (3) the storage-refund settlement test covers all three calldata-floor orderings you listed. The PR is mergeable. The only current blocker is that the fork-triggered render, Python Specification, and Build Docs runs on this head are action_required, so they need upstream authorization before CI can execute. Ready for re-review.

[
pytest.param(0, "below_post_refund", id="post_refund_above_floor"),
pytest.param(
768,

@gurukamath gurukamath Sep 1, 2026

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.

Can we derive these calldata lengths on the fly, like we do in tests/amsterdam/eip7778_block_gas_accounting_without_refunds/test_gas_accounting.py::test_varying_calldata_costs?

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.

Updated in afb204ec: test_storage_refund_settlement now derives the calldata for each of the three floor orderings on the fly instead of hard-coding padding lengths, following the existing EIP-7778 test pattern. The commit changes only this test file; the new upstream workflows are awaiting authorization.

@gurukamath
gurukamath self-requested a review September 1, 2026 12:54
@gurukamath
gurukamath merged commit 7591080 into ethereum:eips/amsterdam/eip-8141 Sep 1, 2026
25 checks passed
gurukamath added a commit that referenced this pull request Sep 2, 2026
This implements the spec updates from this PR - ethereum/EIPs#12226

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

* test(eip-8141): bump reference spec for EIP-7778 integration

* fix(eip-8141): settle refund and floor accounting together

* test(eip-8141): derive refund floor cases dynamically

* style(test): format gas settlement test

* fix(tests): static checks

* fix(tests): pin search transaction nonce


---------

Co-authored-by: Guruprasad Kamath <guru241987@gmail.com>
gurukamath added a commit that referenced this pull request Sep 3, 2026
This implements the spec updates from this PR - ethereum/EIPs#12226

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

* test(eip-8141): bump reference spec for EIP-7778 integration

* fix(eip-8141): settle refund and floor accounting together

* test(eip-8141): derive refund floor cases dynamically

* style(test): format gas settlement test

* fix(tests): static checks

* fix(tests): pin search transaction nonce


---------

Co-authored-by: Guruprasad Kamath <guru241987@gmail.com>
gurukamath added a commit that referenced this pull request Sep 3, 2026
This implements the spec updates from this PR - ethereum/EIPs#12226

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

* test(eip-8141): bump reference spec for EIP-7778 integration

* fix(eip-8141): settle refund and floor accounting together

* test(eip-8141): derive refund floor cases dynamically

* style(test): format gas settlement test

* fix(tests): static checks

* fix(tests): pin search transaction nonce


---------

Co-authored-by: Guruprasad Kamath <guru241987@gmail.com>
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