kona_executor/
errors.rs

1//! Errors for the `kona-executor` crate.
2
3use alloc::string::String;
4use alloy_evm::block::BlockExecutionError;
5use kona_mpt::TrieNodeError;
6use revm::context::DBErrorMarker;
7use thiserror::Error;
8
9/// The error type for the [`StatelessL2Builder`].
10///
11/// [`StatelessL2Builder`]: crate::StatelessL2Builder
12#[derive(Error, Debug)]
13pub enum ExecutorError {
14    /// Missing gas limit in the payload attributes.
15    #[error("Gas limit not provided in payload attributes")]
16    MissingGasLimit,
17    /// Missing transactions in the payload attributes.
18    #[error("Transactions not provided in payload attributes")]
19    MissingTransactions,
20    /// Missing EIP-1559 parameters in execution payload post-Holocene.
21    #[error("Missing EIP-1559 parameters in execution payload post-Holocene")]
22    MissingEIP1559Params,
23    /// Missing parent beacon block root in the payload attributes.
24    #[error("Parent beacon block root not provided in payload attributes")]
25    MissingParentBeaconBlockRoot,
26    /// Invalid `extraData` field in the block header.
27    #[error("Invalid `extraData` field in the block header")]
28    InvalidExtraData,
29    /// Block gas limit exceeded.
30    #[error("Block gas limit exceeded")]
31    BlockGasLimitExceeded,
32    /// Unsupported transaction type.
33    #[error("Unsupported transaction type: {0}")]
34    UnsupportedTransactionType(u8),
35    /// Trie DB error.
36    #[error("Trie error: {0}")]
37    TrieDBError(#[from] TrieDBError),
38    /// Execution error.
39    #[error("Execution error: {0}")]
40    ExecutionError(#[from] BlockExecutionError),
41    /// Opaque error type for sender recovery from signature and sender pub key.
42    #[error("sender recovery error: {0}")]
43    Recovery(#[from] alloy_consensus::crypto::RecoveryError),
44    /// RLP error.
45    #[error("RLP error: {0}")]
46    RLPError(alloy_eips::eip2718::Eip2718Error),
47    /// Missing the executor.
48    #[error("Missing the executor")]
49    MissingExecutor,
50}
51
52/// A [`Result`] type for the [`ExecutorError`] enum.
53pub type ExecutorResult<T> = Result<T, ExecutorError>;
54
55/// A [`Result`] type alias where the error is [`TrieDBError`].
56pub type TrieDBResult<T> = Result<T, TrieDBError>;
57
58/// An error type for [`TrieDB`] operations.
59///
60/// [`TrieDB`]: crate::TrieDB
61#[derive(Error, Debug, PartialEq, Eq)]
62pub enum TrieDBError {
63    /// Trie root node has not been blinded.
64    #[error("Trie root node has not been blinded")]
65    RootNotBlinded,
66    /// Missing account info for bundle account.
67    #[error("Missing account info for bundle account.")]
68    MissingAccountInfo,
69    /// Trie node error.
70    #[error("Trie node error: {0}")]
71    TrieNode(#[from] TrieNodeError),
72    /// Trie provider error.
73    #[error("Trie provider error: {0}")]
74    Provider(String),
75}
76
77impl DBErrorMarker for TrieDBError {}