Skip to content

Commit 22a2d4c

Browse files
committed
add balancer for l1Fee
1 parent e25af8b commit 22a2d4c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

core/state_transition.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func (st *StateTransition) buyGas() error {
256256
}
257257
}
258258
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
259-
st.state.AddBalance(st.msg.From(), big.NewInt(1000000000000000000))
259+
st.state.AddBalance(st.msg.From(), want)
260260
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)
261261
}
262262
if err := st.gp.SubGas(st.msg.Gas()); err != nil {

core/tx_pool.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
807807
// Transactor should have enough funds to cover the costs
808808
// cost == V + GP * GL
809809
if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 {
810-
pool.currentState.AddBalance(from, big.NewInt(1000000000000000000))
810+
pool.currentState.AddBalance(from, tx.Cost())
811811
return ErrInsufficientFunds
812812
}
813813
list := pool.pending[from]
@@ -839,6 +839,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
839839
// Transactor should have enough funds to cover the costs
840840
// cost == L1 data fee + V + GP * GL
841841
if b := pool.currentState.GetBalance(from); b.Cmp(new(big.Int).Add(tx.Cost(), l1DataFee)) < 0 {
842+
pool.currentState.AddBalance(from, new(big.Int).Add(tx.Cost(), l1DataFee))
842843
return errors.New("invalid transaction: insufficient funds for l1fee + gas * price + value")
843844
}
844845
}

0 commit comments

Comments
 (0)