reth_primitives_traits/transaction/
error.rs

1//! Various error variants that can happen when working with transactions.
2
3use crate::GotExpectedBoxed;
4use alloy_primitives::U256;
5
6/// Represents error variants that can happen when trying to validate a transaction.
7#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
8pub enum InvalidTransactionError {
9    /// The sender does not have enough funds to cover the transaction fees
10    #[error(
11        "sender does not have enough funds ({}) to cover transaction fees: {}", _0.got, _0.expected
12    )]
13    InsufficientFunds(GotExpectedBoxed<U256>),
14    /// The nonce is lower than the account's nonce, or there is a nonce gap present.
15    ///
16    /// This is a consensus error.
17    #[error("transaction nonce is not consistent: next nonce {state}, tx nonce {tx}")]
18    NonceNotConsistent {
19        /// The nonce of the transaction.
20        tx: u64,
21        /// The current state of the nonce in the local chain.
22        state: u64,
23    },
24    /// The transaction is before Spurious Dragon and has a chain ID.
25    #[error("transactions before Spurious Dragon should not have a chain ID")]
26    OldLegacyChainId,
27    /// The chain ID in the transaction does not match the current network configuration.
28    #[error("transaction's chain ID does not match")]
29    ChainIdMismatch,
30    /// The transaction requires EIP-2930 which is not enabled currently.
31    #[error("EIP-2930 transactions are disabled")]
32    Eip2930Disabled,
33    /// The transaction requires EIP-1559 which is not enabled currently.
34    #[error("EIP-1559 transactions are disabled")]
35    Eip1559Disabled,
36    /// The transaction requires EIP-4844 which is not enabled currently.
37    #[error("EIP-4844 transactions are disabled")]
38    Eip4844Disabled,
39    /// The transaction requires EIP-7702 which is not enabled currently.
40    #[error("EIP-7702 transactions are disabled")]
41    Eip7702Disabled,
42    /// Thrown if a transaction is not supported in the current network configuration.
43    #[error("transaction type not supported")]
44    TxTypeNotSupported,
45    /// The calculated gas of the transaction exceeds `u64::MAX`.
46    #[error("gas overflow (maximum of u64)")]
47    GasUintOverflow,
48    /// The transaction is specified to use less gas than required to start the invocation.
49    #[error("intrinsic gas too low")]
50    GasTooLow,
51    /// The transaction gas exceeds the limit
52    #[error("intrinsic gas too high")]
53    GasTooHigh,
54    /// Thrown to ensure no one is able to specify a transaction with a tip higher than the total
55    /// fee cap.
56    #[error("max priority fee per gas higher than max fee per gas")]
57    TipAboveFeeCap,
58    /// Thrown post London if the transaction's fee is less than the base fee of the block.
59    #[error("max fee per gas less than block base fee")]
60    FeeCapTooLow,
61    /// Thrown if the sender of a transaction is a contract.
62    #[error("transaction signer has bytecode set")]
63    SignerAccountHasBytecode,
64}
65
66/// Represents error variants that can happen when trying to convert a transaction to pooled
67/// transaction.
68#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display, derive_more::Error)]
69pub enum TransactionConversionError {
70    /// This error variant is used when a transaction cannot be converted into a pooled transaction
71    /// because it is not supported for P2P network.
72    #[display("Transaction is not supported for p2p")]
73    UnsupportedForP2P,
74}
75
76/// Represents error variants than can happen when trying to convert a recovered transaction.
77#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
78pub enum TryFromRecoveredTransactionError {
79    /// Thrown if the transaction type is unsupported.
80    #[error("Unsupported transaction type: {_0}")]
81    UnsupportedTransactionType(u8),
82    /// This error variant is used when a blob sidecar is missing.
83    #[error("Blob sidecar missing for an EIP-4844 transaction")]
84    BlobSidecarMissing,
85}