From 939225bd87378f57dcc9fa95d68621da45fcf82a Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Fri, 16 Jan 2026 18:15:07 +0800 Subject: [PATCH] core/txpool: improve transaction validate (#1921) --- core/txpool/validation.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core/txpool/validation.go b/core/txpool/validation.go index daf5b106a0..609bb152bd 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -93,24 +93,22 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types if tx.Nonce()+1 < tx.Nonce() { return core.ErrNonceMax } - isSpecial := tx.IsSpecialTransaction() - // Ensure the gasprice is high enough to cover the requirement of - // the calling pool and/or block producer - if tx.GasTipCapIntCmp(opts.MinTip) < 0 { - // For special transactions, only check if the sender is not a signer - // For regular transactions, always check (to preserve old logic) - if !isSpecial || opts.NotSigner(from) { + // Skip further validation for special transactions + if tx.IsSpecialTransaction() { + if opts.NotSigner(from) { return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap()) } - } - // Skip further checks for special transactions - if isSpecial { return nil } // Check zero gas price. if tx.GasPrice().Sign() == 0 { return ErrZeroGasPrice } + // Ensure the gas price 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()) + } // Ensure the transaction has more gas than the bare minimum needed to // cover the transaction metadata intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, true, opts.Config.IsEIP1559(head.Number))