core/txpool: some minot nitpick polishes and unified error formats

This commit is contained in:
Péter Szilágyi 2024-02-26 10:42:16 +02:00
parent 398d860a8a
commit 63242de55c

View file

@ -101,18 +101,17 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
return err
}
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 gasprice is high enough to cover the requirement of the calling
// pool and/or block producer
// Ensure the gasprice is high enough to cover the requirement of the calling pool
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.BlobTxType {
// Ensure the blob fee cap cap satisfies the minimum blob gas price
// Ensure the blob fee cap satisfies the minimum blob gas price
minBlobGasPrice := big.NewInt(params.BlobTxMinBlobGasprice)
if tx.BlobGasFeeCapIntCmp(minBlobGasPrice) < 0 {
return fmt.Errorf("%w: blob transaction has too low BlobFeeCap: %v, need: %v", ErrUnderpriced, tx.BlobGasFeeCap(), minBlobGasPrice)
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrUnderpriced, tx.BlobGasFeeCap(), minBlobGasPrice)
}
sidecar := tx.BlobTxSidecar()
if sidecar == nil {
@ -127,7 +126,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
if len(hashes) > params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
}
// Ensure commitments, proofs, & hashes are valid
// Ensure commitments, proofs and hashes are valid
if err := validateBlobSidecar(hashes, sidecar); err != nil {
return err
}