From f316a5814e0bfb39a151c7a9f12fee9d222395e5 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Mon, 25 Dec 2023 23:56:47 +0800 Subject: [PATCH 1/2] feat: improve balance check --- miner/worker.go | 6 ++++++ params/version.go | 2 +- rollup/fees/rollup_fee.go | 13 +++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 38c5a2b70414..c832043064c2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -80,6 +80,8 @@ const ( // staleThreshold is the maximum depth of the acceptable stale block. staleThreshold = 7 + + txRetryTimes = 15 ) var ( @@ -1233,6 +1235,10 @@ loop: w.checkCurrentTxNumWithCCC(w.current.tcount) break loop + case (errors.Is(err, core.ErrInsufficientFunds) || errors.Is(errors.Unwrap(err), core.ErrInsufficientFunds)): + log.Trace("Skipping account with insufficient funds", "sender", from) + txs.Pop() + default: // Strange error, discard the transaction and get the next in line (note, the // nonce-too-high clause will prevent us from executing in vain). diff --git a/params/version.go b/params/version.go index 56de5b79e275..f11cad7830d6 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 1 // Minor version component of the current release - VersionPatch = 7 // Patch version component of the current release + VersionPatch = 8 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) diff --git a/rollup/fees/rollup_fee.go b/rollup/fees/rollup_fee.go index 81e427d631a2..6e21042de685 100644 --- a/rollup/fees/rollup_fee.go +++ b/rollup/fees/rollup_fee.go @@ -202,18 +202,19 @@ func VerifyFee(signer types.Signer, tx *types.Transaction, state StateDB) error } balance := state.GetBalance(from) - l2Fee := calculateL2Fee(tx) - l1DataFee, err := CalculateL1DataFee(tx, state) - if err != nil { - return fmt.Errorf("invalid transaction: %w", err) - } - cost := tx.Value() + + l2Fee := calculateL2Fee(tx) cost = cost.Add(cost, l2Fee) if balance.Cmp(cost) < 0 { return errors.New("invalid transaction: insufficient funds for gas * price + value") } + l1DataFee, err := CalculateL1DataFee(tx, state) + if err != nil { + return fmt.Errorf("invalid transaction: %w", err) + } + cost = cost.Add(cost, l1DataFee) if balance.Cmp(cost) < 0 { return errors.New("invalid transaction: insufficient funds for l1fee + gas * price + value") From 1127c0e02a8876a9cc7a6ecde22839603e7e4835 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Mon, 25 Dec 2023 23:58:11 +0800 Subject: [PATCH 2/2] clean up --- miner/worker.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index c832043064c2..6e625a11ee09 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -80,8 +80,6 @@ const ( // staleThreshold is the maximum depth of the acceptable stale block. staleThreshold = 7 - - txRetryTimes = 15 ) var (