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, derive_more::Display)]
8pub enum InvalidTransactionError {
9 /// The sender does not have enough funds to cover the transaction fees
10 #[display(
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 #[display("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 #[display("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 #[display("transaction's chain ID does not match")]
29 ChainIdMismatch,
30 /// The transaction requires EIP-2930 which is not enabled currently.
31 #[display("EIP-2930 transactions are disabled")]
32 Eip2930Disabled,
33 /// The transaction requires EIP-1559 which is not enabled currently.
34 #[display("EIP-1559 transactions are disabled")]
35 Eip1559Disabled,
36 /// The transaction requires EIP-4844 which is not enabled currently.
37 #[display("EIP-4844 transactions are disabled")]
38 Eip4844Disabled,
39 /// The transaction requires EIP-7702 which is not enabled currently.
40 #[display("EIP-7702 transactions are disabled")]
41 Eip7702Disabled,
42 /// Thrown if a transaction is not supported in the current network configuration.
43 #[display("transaction type not supported")]
44 TxTypeNotSupported,
45 /// The calculated gas of the transaction exceeds `u64::MAX`.
46 #[display("gas overflow (maximum of u64)")]
47 GasUintOverflow,
48 /// The transaction is specified to use less gas than required to start the invocation.
49 #[display("intrinsic gas too low")]
50 GasTooLow,
51 /// The transaction gas exceeds the limit
52 #[display("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 #[display("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 #[display("max fee per gas less than block base fee")]
60 FeeCapTooLow,
61 /// Thrown if the sender of a transaction is a contract.
62 #[display("transaction signer has bytecode set")]
63 SignerAccountHasBytecode,
64}
65
66impl core::error::Error for InvalidTransactionError {}
67
68/// Represents error variants that can happen when trying to convert a transaction to pooled
69/// transaction.
70#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display, derive_more::Error)]
71pub enum TransactionConversionError {
72 /// This error variant is used when a transaction cannot be converted into a pooled transaction
73 /// because it is not supported for P2P network.
74 #[display("Transaction is not supported for p2p")]
75 UnsupportedForP2P,
76}
77
78/// Represents error variants than can happen when trying to convert a recovered transaction.
79#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display)]
80pub enum TryFromRecoveredTransactionError {
81 /// Thrown if the transaction type is unsupported.
82 #[display("Unsupported transaction type: {_0}")]
83 UnsupportedTransactionType(u8),
84 /// This error variant is used when a blob sidecar is missing.
85 #[display("Blob sidecar missing for an EIP-4844 transaction")]
86 BlobSidecarMissing,
87}
88
89impl core::error::Error for TryFromRecoveredTransactionError {}