Skip to content

Conversation

@fselmo
Copy link
Contributor

@fselmo fselmo commented Dec 11, 2025

🗒️ Description

I went back through and refactored the specs to be more succinct wrt gas accounting, in an effort to move these changes out of this branch and into its own PR to be applied across all forks.

  • Check all static gas we can before state accesses
  • Early exit on static access checks

I have similar changes without the BAL tracking in its own branch and I think this will make it easier to agree on here, refactor there, and then eventually to rebase these changes back into here once we agree on a good design.

A good idea for reviewers here is to diff against forks/amsterdam instead of eips/amsterdam-eip-7928 so we can see the minimal set of changes required to the underlying base spec.


Note: This is still a WIP as I'm going to look back over and make sure I didn't miss anything but putting it here early so we can have eyes on it.

🔗 Related Issues or PRs

N/A.

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx tox -e static
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

Cute Animal Picture

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

@fselmo fselmo added A-spec-specs Area: Specification—The Ethereum specification itself (eg. `src/ethereum/*`) C-refactor Category: refactor labels Dec 11, 2025
@fselmo fselmo force-pushed the refactor/gas-accounting branch 2 times, most recently from ed12ccc to 6740794 Compare December 11, 2025 00:32
gas_cost = GAS_COLD_SLOAD if is_cold_access else GAS_WARM_ACCESS

charge_gas(evm, gas_cost)
if (evm.message.current_target, key) in evm.accessed_storage_keys:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually brings the changes back to what it used to be (no changes once PR'd to forks/amsterdam) as there is no need to alter the logic here.

current_value = get_storage(state, evm.message.current_target, key)

if is_cold_access:
gas_cost = Uint(0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also returns the logic to what it is, no need to change this unless we want the is_cold_access check on all operations. I think we can decide this on the isolated PR as well. I'd rather not alter too much of the underlying code in our changes so we can more easily rebase up to eip-7928.

code_address = final_address
disable_precompiles = is_delegated

if is_delegated:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much more succinct. All opcodes here should have a similar flow.

return True, address, delegated_address, delegation_gas_cost


def read_delegation_target(evm: Evm, delegated_address: Address) -> Bytes:
Copy link
Contributor Author

@fselmo fselmo Dec 11, 2025

Choose a reason for hiding this comment

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

This is unnecessary. By the time we get code for the code_address, we already have either the original address or the delegated address as the code_address, so we can simply call get_account(state, code_address).code, essentially.

@fselmo fselmo requested a review from gurukamath December 11, 2025 00:35
@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

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

Additional details and impacted files
@@                    Coverage Diff                     @@
##             eips/amsterdam/eip-7928    #1897   +/-   ##
==========================================================
  Coverage                           ?   86.25%           
==========================================================
  Files                              ?      538           
  Lines                              ?    34561           
  Branches                           ?     3224           
==========================================================
  Hits                               ?    29809           
  Misses                             ?     4165           
  Partials                           ?      587           
Flag Coverage Δ
unittests 86.25% <ø> (?)

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fselmo fselmo force-pushed the eips/amsterdam/eip-7928 branch 2 times, most recently from be73122 to ba0eec1 Compare December 17, 2025 22:12
@fselmo fselmo force-pushed the refactor/gas-accounting branch from 3da8833 to 187483e Compare December 30, 2025 20:47
@fselmo fselmo marked this pull request as ready for review December 30, 2025 20:50
@fselmo
Copy link
Contributor Author

fselmo commented Dec 30, 2025

I'm going to merge this as it's in a much cleaner state than the current specs and actually fixes a bug for CALL in static context where we should do this static check as early as we can, once value is popped from the stack, and before any state access.

I added a test here for this as well. We should put up a subsequent PR if we'd like to make any amendments to this design before we factor out these changes into its own changeset to PR against forks/amsterdam.

We should make sure to reference these changes when reviewing a subsequent PR.

@fselmo fselmo merged commit 60fcfcc into ethereum:eips/amsterdam/eip-7928 Dec 30, 2025
8 of 10 checks passed
@fselmo fselmo deleted the refactor/gas-accounting branch December 30, 2025 20:57
Carsons-Eels pushed a commit to Carsons-Eels/execution-specs that referenced this pull request Jan 6, 2026
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/*`) C-refactor Category: refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant