fix(core/txpool): clarify tx validation error messages #29081 (#2163)

Adjust txpool validation error wording to report actual and minimum values consistently.

- intrinsic gas error now reports: gas <actual>, minimum needed <required>

- underpriced tip error now reports: gas tip cap <actual>, minimum needed <required>

No transaction validation logic is changed in this commit; only error message text is updated.
This commit is contained in:
Daniel Liu 2026-03-17 13:46:44 +08:00 committed by GitHub
parent df8c94ce5b
commit 5b0e2e4bf0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,7 +100,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
// Skip further validation for special transactions // Skip further validation for special transactions
if tx.IsSpecialTransaction() { if tx.IsSpecialTransaction() {
if opts.NotSigner(from) { if opts.NotSigner(from) {
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap()) return fmt.Errorf("%w: gas tip cap %v, minimum needed %v", ErrUnderpriced, tx.GasTipCap(), opts.MinTip)
} }
return nil return nil
} }
@ -115,7 +115,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
return err return err
} }
if tx.Gas() < intrGas { if tx.Gas() < intrGas {
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas()) return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
} }
// Ensure the transaction can cover floor data gas. // Ensure the transaction can cover floor data gas.
if rules.IsPrague { if rules.IsPrague {
@ -129,7 +129,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
} }
// Ensure the gas price is high enough to cover the requirement of the calling pool // Ensure the gas price is high enough to cover the requirement of the calling pool
if tx.GasTipCapIntCmp(opts.MinTip) < 0 { if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap()) return fmt.Errorf("%w: gas tip cap %v, minimum needed %v", ErrUnderpriced, tx.GasTipCap(), opts.MinTip)
} }
if tx.Type() == types.SetCodeTxType { if tx.Type() == types.SetCodeTxType {
if len(tx.SetCodeAuthorizations()) == 0 { if len(tx.SetCodeAuthorizations()) == 0 {