diff --git a/state/executor.go b/state/executor.go index ffd007c662..04a3718d5e 100644 --- a/state/executor.go +++ b/state/executor.go @@ -469,6 +469,9 @@ func (t *Transition) subGasLimitPrice(msg *types.Transaction) error { balanceCheck := new(big.Int).Set(upfrontGasCost) if msg.Type() == types.DynamicFeeTx { balanceCheck.Add(balanceCheck, msg.Value()) + balanceCheck.SetUint64(msg.Gas()) + balanceCheck = balanceCheck.Mul(balanceCheck, msg.GasFeeCap()) + balanceCheck.Add(balanceCheck, msg.Value()) } if have, want := t.state.GetBalance(msg.From()), balanceCheck; have.Cmp(want) < 0 { diff --git a/state/transition_test.go b/state/transition_test.go index c683538071..dc1bc5512c 100644 --- a/state/transition_test.go +++ b/state/transition_test.go @@ -60,7 +60,7 @@ func TestSubGasLimitPrice(t *testing.T) { gas: 10, gasPrice: 10, // should return ErrNotEnoughFundsForGas when state.SubBalance returns ErrNotEnoughFunds - expectedErr: ErrNotEnoughFundsForGas, + expectedErr: ErrInsufficientFunds, }, } @@ -78,7 +78,12 @@ func TestSubGasLimitPrice(t *testing.T) { err := transition.subGasLimitPrice(msg) - assert.Equal(t, tt.expectedErr, err) + if tt.expectedErr != nil { + assert.ErrorContains(t, err, tt.expectedErr.Error()) + } else { + assert.NoError(t, err) + } + if err == nil { // should reduce cost for gas from balance reducedAmount := new(big.Int).Mul(msg.GasPrice(), big.NewInt(int64(msg.Gas())))