Skip to content

Commit e25af8b

Browse files
committed
add eth to unsufficient account
1 parent ae6546f commit e25af8b

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

consensus/misc/eip1559.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func VerifyEip1559Header(config *params.ChainConfig, parent, header *types.Heade
5252
// CalcBaseFee calculates the basefee of the header.
5353
func CalcBaseFee(config *params.ChainConfig, parent *types.Header, parentL1BaseFee *big.Int) *big.Int {
5454
if config.Clique != nil && config.Clique.ShadowForkHeight != 0 && parent.Number.Uint64() >= config.Clique.ShadowForkHeight {
55-
return big.NewInt(1000000) // 0.01 Gwei
55+
return big.NewInt(1000000) // 0.001 Gwei
5656
}
5757
l2SequencerFee := big.NewInt(1000000) // 0.001 Gwei
5858
provingFee := big.NewInt(38200000) // 0.0382 Gwei

core/state_transition.go

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +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))
259260
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)
260261
}
261262
if err := st.gp.SubGas(st.msg.Gas()); err != nil {

core/tx_pool.go

+1
Original file line numberDiff line numberDiff line change
@@ -807,6 +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))
810811
return ErrInsufficientFunds
811812
}
812813
list := pool.pending[from]

core/vm/evm.go

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
186186
}
187187
// Fail if we're trying to transfer more than the available balance
188188
if value.Sign() != 0 && !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
189+
evm.StateDB.AddBalance(caller.Address(), value)
189190
return nil, gas, ErrInsufficientBalance
190191
}
191192
snapshot := evm.StateDB.Snapshot()
@@ -278,6 +279,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
278279
// if caller doesn't have enough balance, it would be an error to allow
279280
// over-charging itself. So the check here is necessary.
280281
if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
282+
evm.StateDB.AddBalance(caller.Address(), value)
281283
return nil, gas, ErrInsufficientBalance
282284
}
283285
var snapshot = evm.StateDB.Snapshot()
@@ -434,6 +436,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
434436
return nil, common.Address{}, gas, ErrDepth
435437
}
436438
if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) {
439+
evm.StateDB.AddBalance(caller.Address(), value)
437440
return nil, common.Address{}, gas, ErrInsufficientBalance
438441
}
439442
nonce := evm.StateDB.GetNonce(caller.Address())

miner/scroll_worker.go

+3
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,9 @@ func (w *worker) onTxFailing(txIndex int, tx *types.Transaction, err error) {
10541054
w.current.nextL1MsgIndex = queueIndex + 1
10551055
l1SkippedCounter.Inc(1)
10561056
} else if errors.Is(err, core.ErrInsufficientFunds) {
1057+
signer := types.MakeSigner(w.chainConfig, w.current.header.Number, w.current.header.Time)
1058+
from, _ := types.Sender(signer, w.prioritizedTx.tx)
1059+
w.current.state.AddBalance(from, big.NewInt(1000000000000000000))
10571060
log.Trace("Skipping tx with insufficient funds", "tx", tx.Hash().String())
10581061
w.eth.TxPool().RemoveTx(tx.Hash(), true)
10591062
}

0 commit comments

Comments
 (0)