Skip to content

Commit df1724e

Browse files
committed
core: fix pre-check for account balance under EIP-1559 (ethereum#23244)
1 parent 953f1ce commit df1724e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

core/state_processor_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestStateProcessorErrors(t *testing.T) {
120120
txs: []*types.Transaction{
121121
makeTx(0, common.Address{}, big.NewInt(1000000000000000000), params.TxGas, big.NewInt(875000000), nil),
122122
},
123-
want: "insufficient funds for transfer: address xdc71562b71999873DB5b286dF957af199Ec94617F7",
123+
want: "insufficient funds for gas * price + value: address xdc71562b71999873DB5b286dF957af199Ec94617F7",
124124
},
125125
{ // ErrInsufficientFunds
126126
txs: []*types.Transaction{

core/state_transition.go

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func (st *StateTransition) buyGas() error {
186186
if st.gasFeeCap != nil {
187187
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
188188
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
189+
balanceCheck.Add(balanceCheck, st.value)
189190
}
190191
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
191192
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)

0 commit comments

Comments
 (0)