From 5b7079b3a4bbe0e68e1e117ad70718f03c47bb81 Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Tue, 26 Dec 2023 10:12:26 +0800 Subject: [PATCH] fix(tx-pool): consider L1 data fee in validateTx (#609) * fix(tx-pool): consider L1 data fee in validateTx * bump version --- core/tx_pool.go | 7 ++++++- params/version.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index e9a8894af3f8..af7f5a991de1 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -658,9 +658,14 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if pool.currentState.GetNonce(from) > tx.Nonce() { return ErrNonceTooLow } + // Get L1 data fee in current state + l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState) + if err != nil { + return fmt.Errorf("failed to calculate L1 data fee, err: %w", err) + } // Transactor should have enough funds to cover the costs // cost == V + GP * GL - if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 { + if pool.currentState.GetBalance(from).Cmp(new(big.Int).Add(tx.Cost(), l1DataFee)) < 0 { return ErrInsufficientFunds } // Ensure the transaction has more gas than the basic tx fee. diff --git a/params/version.go b/params/version.go index fa86e3bcd142..b0051b97eb20 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 = 9 // Patch version component of the current release + VersionPatch = 10 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )