core/txpool: add nonce eip-2681 check

This commit is contained in:
jsvisa 2025-09-24 10:44:01 +08:00
parent 2872242045
commit 308f7a3dbc

View file

@ -116,6 +116,10 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
if _, err := types.Sender(signer, tx); err != nil { if _, err := types.Sender(signer, tx); err != nil {
return fmt.Errorf("%w: %v", ErrInvalidSender, err) return fmt.Errorf("%w: %v", ErrInvalidSender, err)
} }
// Limit nonce to 2^64-1 per EIP-2681
if tx.Nonce()+1 < tx.Nonce() {
return core.ErrNonceMax
}
// Ensure the transaction has more gas than the bare minimum needed to cover // Ensure the transaction has more gas than the bare minimum needed to cover
// the transaction metadata // the transaction metadata
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, true, rules.IsIstanbul, rules.IsShanghai) intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, true, rules.IsIstanbul, rules.IsShanghai)