mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
core/txpool: improve transaction validate (#1921)
This commit is contained in:
parent
86cbf4a897
commit
939225bd87
1 changed files with 8 additions and 10 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue