From 763bc05eba8dd7d0629dd0b319ba83a5233c1322 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:11:18 +0800 Subject: [PATCH] fix txpool underpriced check (#964) * fix txpool underpriced check * Update core/txpool/legacypool/legacypool.go Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> --------- Co-authored-by: colin <102356659+colinlyguo@users.noreply.github.com> --- core/txpool/legacypool/legacypool.go | 5 +++-- core/txpool/validation.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 8624a59ed7..f42bae42ce 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -746,8 +746,9 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e // If the transaction pool is full, discard underpriced transactions if uint64(pool.all.Slots()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue { // If the new transaction is underpriced, don't accept it - if !isLocal && pool.priced.Underpriced(tx) { - log.Trace("Discarding underpriced transaction", "hash", hash, "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap()) + // if !isLocal && pool.priced.Underpriced(tx) { + if !isLocal && tx.GasFeeCapIntCmp(pool.gasTip.Load()) < 0 { + log.Trace("Discarding underpriced transaction", "hash", hash, "gasTipCap", tx.GasTipCap(), "gasFeeCap", tx.GasFeeCap(), "txPoolGasTip", pool.gasTip.Load()) underpricedTxMeter.Mark(1) return false, txpool.ErrUnderpriced } diff --git a/core/txpool/validation.go b/core/txpool/validation.go index bce24d415f..3b09ee3ec1 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -106,8 +106,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types } // Ensure the gasprice is high enough to cover the requirement of the calling // pool and/or block producer - if tx.GasTipCapIntCmp(opts.MinTip) < 0 { - return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap()) + if tx.GasFeeCapIntCmp(opts.MinTip) < 0 { + return fmt.Errorf("%w: fee needed %v, fee permitted %v", ErrUnderpriced, opts.MinTip, tx.GasFeeCap()) } // Ensure blob transactions have valid commitments if tx.Type() == types.BlobTxType {