Skip to content

Commit 833f904

Browse files
feat: improve balance check (#607)
* feat: improve balance check * clean up
1 parent b235afb commit 833f904

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

miner/worker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,10 @@ loop:
12331233
w.checkCurrentTxNumWithCCC(w.current.tcount)
12341234
break loop
12351235

1236+
case (errors.Is(err, core.ErrInsufficientFunds) || errors.Is(errors.Unwrap(err), core.ErrInsufficientFunds)):
1237+
log.Trace("Skipping account with insufficient funds", "sender", from)
1238+
txs.Pop()
1239+
12361240
default:
12371241
// Strange error, discard the transaction and get the next in line (note, the
12381242
// nonce-too-high clause will prevent us from executing in vain).

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 1 // Minor version component of the current release
27-
VersionPatch = 7 // Patch version component of the current release
27+
VersionPatch = 8 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/fees/rollup_fee.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,19 @@ func VerifyFee(signer types.Signer, tx *types.Transaction, state StateDB) error
202202
}
203203

204204
balance := state.GetBalance(from)
205-
l2Fee := calculateL2Fee(tx)
206-
l1DataFee, err := CalculateL1DataFee(tx, state)
207-
if err != nil {
208-
return fmt.Errorf("invalid transaction: %w", err)
209-
}
210-
211205
cost := tx.Value()
206+
207+
l2Fee := calculateL2Fee(tx)
212208
cost = cost.Add(cost, l2Fee)
213209
if balance.Cmp(cost) < 0 {
214210
return errors.New("invalid transaction: insufficient funds for gas * price + value")
215211
}
216212

213+
l1DataFee, err := CalculateL1DataFee(tx, state)
214+
if err != nil {
215+
return fmt.Errorf("invalid transaction: %w", err)
216+
}
217+
217218
cost = cost.Add(cost, l1DataFee)
218219
if balance.Cmp(cost) < 0 {
219220
return errors.New("invalid transaction: insufficient funds for l1fee + gas * price + value")

0 commit comments

Comments
 (0)