Skip to content

feat(fork-types): add ExecutionGas and StateGas NewType wrappers to amsterdam EVM - #3121

Open
mandeepmourya007 wants to merge 1 commit into
ethereum:forks/amsterdamfrom
mandeepmourya007:refactor/gas-newtypes
Open

feat(fork-types): add ExecutionGas and StateGas NewType wrappers to amsterdam EVM#3121
mandeepmourya007 wants to merge 1 commit into
ethereum:forks/amsterdamfrom
mandeepmourya007:refactor/gas-newtypes

Conversation

@mandeepmourya007

@mandeepmourya007 mandeepmourya007 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

Applies the ExecutionGas and StateGas NewType wrappers (introduced in
fork_types.py by #3037) to all EVM gas fields and constants across the
amsterdam fork, preventing accidental mixing of state gas with execution gas
at the type level.

Changes:

  • All GasCosts constants typed as ExecutionGas (blob-fee, byte-count and
    block-limit constants stay Uint); StateGasCosts already typed as
    StateGas
  • GasMeter fields typed: gas_left, state_gas_left,
    state_gas_baseline, state_gas_spilled, state_gas_committed_spill
  • Message, TransactionEnvironment, MessageCallOutput, GenericCall,
    MessageCallGas and ExtendMemory gas fields typed
  • EvmGasAllocation and the per-dimension TransactionGasSettlement fields
    typed
  • Signatures updated: the gas-meter helpers (charge_state_gas, spill
    commit/restore, withhold_create_gas, drain_state_gas_reservoir,
    restore_child_gas, tx_state_gas_used), max_message_call_gas,
    calculate_delegation_cost and settle_transaction_gas

Rebased onto forks/amsterdam after the regular→execution gas rename
(#3238, #3263) and the GasMeter refactor, so the wrapper is now named
ExecutionGas and the typing covers the meter and settlement helpers.

Related Issues or PRs

Closes #3015. Follows on from #3037.

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <title>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Typing cat

@spencer-tb
spencer-tb force-pushed the refactor/gas-newtypes branch from 546a7e6 to 356a1a8 Compare July 30, 2026 12:59
@spencer-tb spencer-tb changed the title feat(fork-types): add RegularGas and StateGas NewType wrappers to ams… feat(fork-types): add ExecutionGas and StateGas NewType wrappers to amsterdam EVM Jul 30, 2026
@spencer-tb
spencer-tb requested a review from gurukamath July 30, 2026 14:35
@spencer-tb

Copy link
Copy Markdown
Contributor

@gurukamath I updated this PR with the execution naming change, what do you think?

Should we add this and do we need to backport the execution gas change?

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.42197% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.42%. Comparing base (3e27f98) to head (356a1a8).

Files with missing lines Patch % Lines
src/ethereum/forks/amsterdam/vm/gas.py 99.38% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3121   +/-   ##
================================================
  Coverage            93.42%   93.42%           
================================================
  Files                  625      625           
  Lines                37032    37033    +1     
  Branches              3385     3385           
================================================
+ Hits                 34597    34598    +1     
  Misses                1666     1666           
  Partials               769      769           
Flag Coverage Δ
unittests 93.42% <99.42%> (+<0.01%) ⬆️

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.

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.

Add newtype wrappers for StateGas and RegularGas

2 participants