Skip to content

Conversation

@jwasinger
Copy link
Contributor

@jwasinger jwasinger commented Dec 9, 2025

EIP-7928 brings state reads into consensus by recording accounts and storage accessed during execution in the block access list. As part of the spec, we need to check that there is enough gas available to cover the cost component which doesn't depend on looking up state. If this component can't be covered by the available gas, we exit immediately.

The portion of the call dynamic cost which doesn't depend on state lookups:

  • EIP2929 call costs
  • value transfer cost
  • memory expansion cost

This PR:

  • breaks up the "inner" gas calculation for each call variant into a pair of stateless/stateful cost methods
  • modifies the gas calculation logic of calls to check stateless cost component first, and go out of gas immediately if it is not covered.

// - 63/64ths rule
gas, err := oldCalculator(evm, contract, stack, mem, memorySize)
if warmAccess || err != nil {
return gas, err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

returning old here in the case of an error doesn't have any special meaning. If the dynamic gas calculator returns an error, the returned gas is ignored in the interpreter loop here

Copy link
Member

@gballet gballet left a comment

Choose a reason for hiding this comment

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

doing this, you are very likely to break a ton of use cases from the verkle/UBT stuff

} else if !evm.StateDB.Exist(address) {
gas += params.CallNewAccountGas
}
if transfersValue && !evm.chainRules.IsEIP4762 {
Copy link
Member

Choose a reason for hiding this comment

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

Don't change the order here, you are guaranteed to break some tests. We can't generate the fixutres because the execution-spec-tests rewrite is still incomplete, so you don't see it... but it's going to break them.

@jwasinger jwasinger force-pushed the call-gas-revamp branch 2 times, most recently from 161a6f6 to 675d675 Compare December 23, 2025 23:36
…enough gas to cover cost component that doesn't depend on state lookups
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.

2 participants