kona_executor/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! Errors for the `kona-executor` crate.

use alloc::string::String;
use kona_mpt::TrieNodeError;
use revm::primitives::EVMError;

/// The error type for the [StatelessL2BlockExecutor].
///
/// [StatelessL2BlockExecutor]: crate::StatelessL2BlockExecutor
#[derive(derive_more::Display, Debug)]
pub enum ExecutorError {
    /// Missing gas limit in the payload attributes.
    #[display("Gas limit not provided in payload attributes")]
    MissingGasLimit,
    /// Missing transactions in the payload attributes.
    #[display("Transactions not provided in payload attributes")]
    MissingTransactions,
    /// Missing EIP-1559 parameters in execution payload post-Holocene.
    #[display("Missing EIP-1559 parameters in execution payload post-Holocene")]
    MissingEIP1559Params,
    /// Missing parent beacon block root in the payload attributes.
    #[display("Parent beacon block root not provided in payload attributes")]
    MissingParentBeaconBlockRoot,
    /// Invalid `extraData` field in the block header.
    #[display("Invalid `extraData` field in the block header")]
    InvalidExtraData,
    /// Block gas limit exceeded.
    #[display("Block gas limit exceeded")]
    BlockGasLimitExceeded,
    /// Unsupported transaction type.
    #[display("Unsupported transaction type: {_0}")]
    UnsupportedTransactionType(u8),
    /// Trie DB error.
    #[display("Trie error: {_0}")]
    TrieDBError(TrieDBError),
    /// Execution error.
    #[display("Execution error: {_0}")]
    ExecutionError(EVMError<TrieDBError>),
    /// Signature error.
    #[display("Signature error: {_0}")]
    SignatureError(alloy_primitives::SignatureError),
    /// RLP error.
    #[display("RLP error: {_0}")]
    RLPError(alloy_eips::eip2718::Eip2718Error),
}

impl From<TrieDBError> for ExecutorError {
    fn from(err: TrieDBError) -> Self {
        Self::TrieDBError(err)
    }
}

impl From<TrieNodeError> for ExecutorError {
    fn from(err: TrieNodeError) -> Self {
        Self::TrieDBError(TrieDBError::TrieNode(err))
    }
}

impl core::error::Error for ExecutorError {
    fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
        match self {
            Self::TrieDBError(err) => Some(err),
            _ => None,
        }
    }
}

/// A [Result] type for the [ExecutorError] enum.
pub type ExecutorResult<T> = Result<T, ExecutorError>;

/// A [Result] type alias where the error is [TrieDBError].
pub type TrieDBResult<T> = Result<T, TrieDBError>;

/// An error type for [TrieDB] operations.
///
/// [TrieDB]: crate::TrieDB
#[derive(derive_more::Display, Debug, PartialEq, Eq)]
pub enum TrieDBError {
    /// Trie root node has not been blinded.
    #[display("Trie root node has not been blinded")]
    RootNotBlinded,
    /// Missing account info for bundle account.
    #[display("Missing account info for bundle account.")]
    MissingAccountInfo,
    /// Trie node error.
    #[display("Trie node error: {_0}")]
    TrieNode(TrieNodeError),
    /// Trie provider error.
    #[display("Trie provider error: {_0}")]
    Provider(String),
}

impl core::error::Error for TrieDBError {
    fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
        match self {
            Self::TrieNode(err) => Some(err),
            _ => None,
        }
    }
}

impl From<TrieNodeError> for TrieDBError {
    fn from(err: TrieNodeError) -> Self {
        Self::TrieNode(err)
    }
}