Skip to content

Commit

Permalink
core: fix pre-check for account balance under EIP-1559 (ethereum#23244)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Oct 31, 2024
1 parent e31066d commit 09b6960
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestStateProcessorErrors(t *testing.T) {
txs: []*types.Transaction{
makeTx(0, common.Address{}, big.NewInt(1000000000000000000), params.TxGas, big.NewInt(875000000), nil),
},
want: "insufficient funds for transfer: address xdc71562b71999873DB5b286dF957af199Ec94617F7",
want: "insufficient funds for gas * price + value: address xdc71562b71999873DB5b286dF957af199Ec94617F7",
},
{ // ErrInsufficientFunds
txs: []*types.Transaction{
Expand Down
1 change: 1 addition & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (st *StateTransition) buyGas() error {
if st.gasFeeCap != nil {
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
balanceCheck.Add(balanceCheck, st.value)
}
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)
Expand Down

0 comments on commit 09b6960

Please sign in to comment.