Skip to content

EIP-8037: State Creation Gas Cost Increase#10712

Merged
benaadams merged 17 commits into
bal-devnet-3from
eip-8037
Mar 6, 2026
Merged

EIP-8037: State Creation Gas Cost Increase#10712
benaadams merged 17 commits into
bal-devnet-3from
eip-8037

Conversation

@benaadams

Copy link
Copy Markdown
Member

Changes

  • Implement EIP-8037

Types of changes

What types of changes does your code introduce?

  • New feature (a non-breaking change that adds functionality)

Testing

Requires testing

  • Yes

If yes, did you write tests?

  • Yes

Notes on testing

Bal-devnet 3

Copilot AI 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.

Pull request overview

Implements EIP-8037 (“State Creation Gas Cost Increase”) by introducing an EIP-8037 enablement flag in specs/chainspecs and plumbing two-dimensional (regular + state) gas metering through transaction processing and EVM execution.

Changes:

  • Add IsEip8037Enabled to release specs/forks and make it configurable via chainspec transition timestamps.
  • Introduce/extend two-dimensional gas accounting in IGasPolicy/EthereumGasPolicy and update opcode dispatch + CREATE/CALL/SSTORE/SELFDESTRUCT/deposit paths to charge/consume state gas.
  • Update refund/block-gas accounting and add tests covering intrinsic split, code-deposit split, and state reservoir mechanics.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Nethermind/Nethermind.Specs/ReleaseSpec.cs Adds EIP-8037 enablement flag to specs.
src/Nethermind/Nethermind.Specs/Forks/25_Amsterdam.cs Enables EIP-8037 for Amsterdam fork.
src/Nethermind/Nethermind.Specs/ChainSpecStyle/Json/ChainSpecParamsJson.cs Adds chainspec transition timestamp field for EIP-8037.
src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs Loads Eip8037TransitionTimestamp from JSON into chain parameters.
src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs Enables EIP-8037 per-release based on transition timestamp.
src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainParameters.cs Stores Eip8037TransitionTimestamp in chain parameters.
src/Nethermind/Nethermind.Specs.Test/OverridableReleaseSpec.cs Allows overriding IsEip8037Enabled in tests.
src/Nethermind/Nethermind.Evm/VirtualMachine.cs Splits code-deposit into regular/state components and attempts dual-dimension charging.
src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs Adjusts intrinsic validation, top-level code deploy charging, and refund/block-gas accounting for EIP-8037.
src/Nethermind/Nethermind.Evm/TransactionProcessing/GasConsumed.cs Formatting update to record struct declaration.
src/Nethermind/Nethermind.Evm/RefundOf.cs Adds EIP-8037-specific refund constants.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.cs Routes opcode implementations through EIP-8037-aware generic variants.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Storage.cs Adds EIP-8037 handling to SSTORE net-metering/refunds.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Eof.cs Adds EIP-8037 handling to EOF call/create gas frame setup and new-account charging.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Create.cs Splits CREATE cost into regular/state components under EIP-8037.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.ControlFlow.cs Adds EIP-8037 handling to SELFDESTRUCT new-account charging.
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Call.cs Adds EIP-8037 handling to CALL new-account charging and child frame gas creation.
src/Nethermind/Nethermind.Evm/GasPolicy/IGasPolicy.cs Introduces state reservoir/state usage helpers and state+regular combined consumption helper.
src/Nethermind/Nethermind.Evm/GasPolicy/EthereumGasPolicy.cs Implements state reservoir, state gas usage accounting, intrinsic split, and child-frame state transfer.
src/Nethermind/Nethermind.Evm/GasCostOf.cs Adds EIP-8037 gas constants (devnet-3 values).
src/Nethermind/Nethermind.Evm/CodeDepositHandler.cs Splits code-deposit costs into regular/state components and adds overloads.
src/Nethermind/Nethermind.Evm.Test/IntrinsicGasCalculatorTests.cs Adds intrinsic split test for authorization list under EIP-8037.
src/Nethermind/Nethermind.Evm.Test/Eip7928Tests.cs Disables EIP-8037 for BAL tests to stabilize gas expectations.
src/Nethermind/Nethermind.Evm.Test/Eip2200Tests.cs Adds tests for EIP-8037 constants, code-deposit split, and state reservoir behavior.
src/Nethermind/Nethermind.Core/Specs/ReleaseSpecDecorator.cs Exposes IsEip8037Enabled through decorator.
src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs Adds IsEip8037Enabled to the spec interface.
Comments suppressed due to low confidence (1)

src/Nethermind/Nethermind.Evm/VirtualMachine.cs:546

  • Same issue as the EOF-create path: on code-deposit failure this drains only regular gas via Consume(..., gasAvailableForCodeDeposit), which can leave a non-zero state reservoir when EIP-8037 is enabled. For an exceptional out-of-gas on code deposit, gas should be exhausted across both dimensions.

Consider using SetOutOfGas(ref _currentState.Gas) (or equivalent) when FailOnOutOfGasCodeDeposit is in effect so state reservoir is also cleared.

        if (!chargedCodeDeposit && (spec.FailOnOutOfGasCodeDeposit || invalidCode) && (invalidCode || outOfGasOnCodeDeposit))
        {
            // Consume all remaining gas allocated for the code deposit.
            TGasPolicy.Consume(ref _currentState.Gas, gasAvailableForCodeDeposit);


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Storage.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Storage.cs Outdated
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

EVM Opcode Benchmark Diff

Aggregated runs: base=3, pr=3
Noisy rerun opcodes: MULMOD

Regressions (1)

Opcode Base Median (ns) PR Median (ns) Delta Abs Δ (ns) Base CV PR CV Threshold Uncertainty Effective
MULMOD 240.980 1035.660 +329.77% 794.680 80.2% 15.9% ±5.0% ±136.9% ±160.3%

Copilot AI 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.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs Outdated

@LukaszRozmej LukaszRozmej left a comment

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.

On one side GasPolicy makes it painful to implement.
On the other there is a lot of AI sloppiness in this PR visible. Please make it tight!

Comment thread src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip2200Tests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip7954Tests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/IntrinsicGasCalculatorTests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/IntrinsicGasCalculatorTests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/CodeDepositHandler.cs
Comment thread src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated
Comment thread src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V6.cs Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs Outdated
The hasEnoughGas check is only a pre-check gate; the actual gas
charge goes through TryConsumeStateAndRegularGas on a copy.
When the pre-check is too permissive, the real charge fails and
the CREATE fails anyway. Both code paths produce identical behavior.
The hasEnoughGas pre-check used child-only gas but
TryConsumeStateAndRegularGas charged the merged parent+child pool.
When state deposit cost spills into regular gas, the spill was
taken from the parent's retained gas instead of the child's.

Tighten the pre-check to account for state spill so the charge
is never attempted when the child alone can't afford it.

Add VM-level regression test that fails without this fix.
@benaadams

Copy link
Copy Markdown
Member Author

Raised EEST test gaps ethereum/execution-specs#2426

@benaadams

Copy link
Copy Markdown
Member Author

PR to add eest tests ethereum/execution-specs#2427

@LukaszRozmej LukaszRozmej left a comment

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 kind of hate this EIP complexity.

Made some refactors to make tests better in: #10737 , please merge if you like it first

Comment thread src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.ControlFlow.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated
@benaadams benaadams merged commit 346efec into bal-devnet-3 Mar 6, 2026
157 of 159 checks passed
@benaadams benaadams deleted the eip-8037 branch March 6, 2026 12:47
@AnkushinDaniil

AnkushinDaniil commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

I'd like to suggest an architectural refinement that could simplify the implementation and improve long-term maintainability.

The PR introduces several new fields to EthereumGasPolicy and new methods to IGasPolicy. I see these issues with this approach:

  1. Future EIPs adding gas dimensions will require more fields
  2. Every IGasPolicy implementation must implement dimension-specific methods
  3. Adding a third dimension means more fields, more methods, more complexity

Suggested approach: Vector-based gas with enum Indexing

  public enum GasDimension : byte
  {
      Regular = 0,  // Execution gas
      State = 1,    // EIP-8037 state creation gas
      // Future EIPs can add dimensions here
  }

  [InlineArray(2)]
  public struct GasVector
  {
      private long _element0;
  }

  public struct MultiDimensionalGas
  {
      private GasVector _gas;

      public void Charge(GasDimension dim, long cost)
          => _gas[(int)dim] -= cost;

      public long Get(GasDimension dim)
          => _gas[(int)dim];
      ...

  }

Refactoring EthereumGasPolicy:

  public struct EthereumGasPolicy : IGasPolicy<EthereumGasPolicy>
  {
      private MultiDimensionalGas _gas;
      
      // Wrapper methods handle dimension assignment internally
      public static bool ConsumeNewAccountCreation(ref EthereumGasPolicy gas, IReleaseSpec spec)
      {
          if (gas._gas.Get(GasDimension.Regular) < GasCostOf.NewAccount)
              return false;
          gas._gas.Charge(GasDimension.Regular, GasCostOf.NewAccount);

          if (spec.IsEip8037Enabled)
              ChargeFromReservoir(ref gas, GasCostOf.Eip8037NewAccount);

          return true;
      }
  }

These key principles can be defined:

  1. Vector-based storage - GasVector indexed by enum, not separate fields
  2. IGasPolicy methods handle categorization — ConsumeNewAccountCreation knows which dimension to charge. IGasPolicy must avoid cost as a parameter.
  3. Less new interface methods needed, existing methods like ConsumeNewAccountCreation evolve internally

Benefits

Aspect Current PR Suggested Approach
Adding future dimensions Add fields + methods Add enum value, expand GasVector
Interface stability Breaking changes per EIP Stable IGasPolicy

Upd
I also thought that potentially SIMD can be applied for multidimensional gas calculation as some point but it requires a research

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants