From 0f40778274219ba2be63e821b81edf110143b4b8 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Sun, 5 Apr 2026 21:22:48 -0400 Subject: [PATCH] core: post-Amsterdam, don't subtract tx gas limit from GasPool before starting execution --- core/state_transition.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index b69bff85d1..c6bbb3467c 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -309,8 +309,16 @@ func (st *stateTransition) buyGas() error { if have, want := st.state.GetBalance(st.msg.From), balanceCheckU256; have.Cmp(want) < 0 { return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From.Hex(), have, want) } - if err := st.gp.SubGas(st.msg.GasLimit); err != nil { - return err + + // post-amsterdam the regular/state gas used determines how a transaction + // contributes to the fullness of the block's bottleneck resource. + // It isn't drawn from the pool, and it isn't returned as ReturnAmsterdamGas + // would suggest (TODO: jwasinger I changed ReturnGasAmsterdam and now the name doesn't match what it does) + isAmsterdam := st.evm.ChainConfig().IsAmsterdam(st.evm.Context.BlockNumber, st.evm.Context.Time) + if !isAmsterdam { + if err := st.gp.SubGas(st.msg.GasLimit); err != nil { + return err + } } if st.evm.Config.Tracer != nil && st.evm.Config.Tracer.OnGasChange != nil { @@ -320,7 +328,7 @@ func (st *stateTransition) buyGas() error { // After Amsterdam we limit the regular gas to 16k, the data gas to the transaction limit limit := st.msg.GasLimit - if st.evm.ChainConfig().IsAmsterdam(st.evm.Context.BlockNumber, st.evm.Context.Time) { + if isAmsterdam { limit = min(st.msg.GasLimit, params.MaxTxGas) } st.initialGas = vm.GasCosts{RegularGas: limit, StateGas: st.msg.GasLimit - limit}