Skip to content

feat(spec-specs, spec-tests): add EIP-7778 block gas accounting without refunds#2840

Open
LouisTsai-Csie wants to merge 14 commits into
forks/amsterdamfrom
eips/amsterdam/eip-7778
Open

feat(spec-specs, spec-tests): add EIP-7778 block gas accounting without refunds#2840
LouisTsai-Csie wants to merge 14 commits into
forks/amsterdamfrom
eips/amsterdam/eip-7778

Conversation

@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie commented May 12, 2026

🗒️ Description

Merge changes necessary for implementing EIP-7778 into the forks/amsterdam branch.

This PR targets the EIP-7778 spec from ethereum/EIPs@3929b1a.

🔗 Related Issues or PRs

✅ Checklist

  • All: Ran fast static checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    just static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@LouisTsai-Csie LouisTsai-Csie changed the title Eips/amsterdam/eip 7778 feat(specs-spec, tests): merge eip-7778 into forks/amsterdam May 12, 2026
@LouisTsai-Csie LouisTsai-Csie added the A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) label May 12, 2026
@LouisTsai-Csie LouisTsai-Csie changed the title feat(specs-spec, tests): merge eip-7778 into forks/amsterdam feat(spec-specs, tests): merge eip-7778 into forks/amsterdam May 12, 2026
@LouisTsai-Csie LouisTsai-Csie added the C-feat Category: an improvement or new feature label May 12, 2026
@LouisTsai-Csie LouisTsai-Csie changed the title feat(spec-specs, tests): merge eip-7778 into forks/amsterdam feat(spec-specs, spec-tests): add EIP-7778 block gas accounting without refunds May 13, 2026
@LouisTsai-Csie LouisTsai-Csie marked this pull request as ready for review May 13, 2026 05:29
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.01%. Comparing base (87c52b4) to head (9d88e40).
⚠️ Report is 1 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #2840   +/-   ##
================================================
  Coverage            90.01%   90.01%           
================================================
  Files                  539      539           
  Lines                32618    32621    +3     
  Branches              3030     3030           
================================================
+ Hits                 29361    29364    +3     
  Misses                2699     2699           
  Partials               558      558           
Flag Coverage Δ
unittests 90.01% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

nerolation and others added 11 commits May 13, 2026 13:56
…unds (#1401)

* feat(specs): add eip-7778 implementation

* fix(specs) spliting receipt gas from block gas

* revert receipt_gas_used

* make sure that the calldata floor cost overwrites the tx gas before refund

* receipt gas used after refunds

* clarify variable naming @gurukamath

* revert to using gas used after refunds for cumulative gas in receipt and add gasSpent to receipt

* spec(amsterdam): fix code formatting

---------

Co-authored-by: Guruprasad Kamath <guru241987@gmail.com>
* fix(tests): fix legacy tests to run with eip-7778

* fix(tests): check gas_spent and gas_used after Amsterdam
* feat(spec-tests): add eip-7778 for calldata checks

* feat(spec-tests): post review - use code gas_cost function

Co-authored-by: Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>

* Apply suggestions from code review

---------

Co-authored-by: Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: Mario Vega <marioevz@gmail.com>
The set iteration in `build_refund_tx` is non-deterministic due to
Python's hash randomization, causing fixture output to vary between
runs. Sort by enum value to ensure reproducible fixtures.
@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator Author

I want to do a follow-up PR to remove expected_benchmark_gas_used in BenchmarkTest. This is not required anymore, as we introduce expected_gas_used in BlockchainTest.

env: Environment = Field(default_factory=Environment)

@LouisTsai-Csie LouisTsai-Csie force-pushed the eips/amsterdam/eip-7778 branch from 8ec956b to dc52b58 Compare May 13, 2026 06:38
@LouisTsai-Csie
Copy link
Copy Markdown
Collaborator Author

LouisTsai-Csie commented May 13, 2026

Some missing cases that we could do as follow-up PRs:

  • Refund tx OOG, revert the refund
  • refund quauls/exceeds gas_used_pre_refund // max_refund_quotient
  • storage x->y->0 refund (we have storage x->x->0 refund)
  • behavior at fork transition
  • successful at top frame but fails at subcall.
  • delegate to a contract that does the storage refund (two refunds)
  • authority do multiple authorization in same tx, resulting in cumulative refunds

@danceratopz danceratopz added the A-spec-tests Area: tests for specifications e.g. json_infra label May 13, 2026
Copy link
Copy Markdown
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Couple of small comments.

Comment thread docs/writing_tests/test_markers.md Outdated
authorization_list=authorization_list,
expected_receipt={
"gas_used": refund_tx_gas_used,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is currently only a no-op. It only effects fill verification; the fixtures remain unchanged.

Suggested change
},
expected_receipt={
"cumulative_gas_used": refund_tx_gas_used,
},

The gas_used field does not exist in the transition tool:

@slotted_freezable
@dataclass
class Receipt:
"""
Result of a transaction execution. Receipts are included in the receipts
trie.
"""
succeeded: bool
"""
Whether the transaction execution was successful.
"""
cumulative_gas_used: Uint
"""
Total gas used in the block up to and including this transaction.
This is the gas used after refunds, paid by the user.
"""
bloom: Bloom
"""
Bloom filter for logs generated by this transaction. This is a 2048-byte
bit array that allows for efficient filtering of logs.
"""
logs: Tuple[Log, ...]
"""
A tuple of logs generated by this transaction. Each log contains the
address of the contract that emitted it, a tuple of topics, and the data
payload.
"""
def encode_receipt(tx: Transaction, receipt: Receipt) -> Bytes | Receipt:
r"""
Encodes a transaction receipt based on the transaction type.

This requires a follow-up issue to detect in the helper. I will follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry the diff is off.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure if i fully understand this issue, could you please create an issue for tracking?

Comment on lines +305 to +307
expected_receipt={
"gas_used": refund_tx_gas_used + extra_tx_intrinsic_gas_cost,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same issue here as above:

Suggested change
expected_receipt={
"gas_used": refund_tx_gas_used + extra_tx_intrinsic_gas_cost,
},
"cumulative_gas_used": (
refund_tx_gas_used + extra_tx_intrinsic_gas_cost
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) A-spec-tests Area: tests for specifications e.g. json_infra C-feat Category: an improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants