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>
This commit is contained in:
HAOYUatHZ 2024-08-13 10:11:18 +08:00 committed by GitHub
parent 2f828ecdb3
commit 763bc05eba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View file

@ -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
}

View file

@ -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 {