Skip to main content

ethrex_common/
errors.rs

1use crate::types::{InvalidBlockBodyError, InvalidBlockHeaderError};
2
3/// Errors that occur during block validation.
4///
5/// These are validation errors that don't require storage access to detect.
6#[derive(Debug, thiserror::Error)]
7pub enum InvalidBlockError {
8    #[error("Requests hash does not match the one in the header after executing")]
9    RequestsHashMismatch,
10    #[error("Block access list hash does not match the one in the header after executing")]
11    BlockAccessListHashMismatch,
12    #[error("Block access list contains index {index} exceeding max valid index {max}")]
13    BlockAccessListIndexOutOfBounds { index: u32, max: u32 },
14    #[error("Block access list exceeds gas limit, {items} items exceeds limit of {max_items}")]
15    BlockAccessListSizeExceeded { items: u64, max_items: u64 },
16    #[error("World State Root does not match the one in the header after executing")]
17    StateRootMismatch,
18    #[error("Receipts Root does not match the one in the header after executing")]
19    ReceiptsRootMismatch,
20    #[error("Logs bloom does not match the one in the header after executing")]
21    LogsBloomMismatch,
22    #[error("Invalid Header, validation failed pre-execution: {0}")]
23    InvalidHeader(#[from] InvalidBlockHeaderError),
24    #[error("Invalid Body, validation failed pre-execution: {0}")]
25    InvalidBody(#[from] InvalidBlockBodyError),
26    #[error("Exceeded MAX_BLOB_GAS_PER_BLOCK")]
27    ExceededMaxBlobGasPerBlock,
28    #[error("Exceeded MAX_BLOB_NUMBER_PER_BLOCK")]
29    ExceededMaxBlobNumberPerBlock,
30    #[error("Gas used doesn't match value in header. Used: {0}, Expected: {1}")]
31    GasUsedMismatch(u64, u64),
32    #[error("Blob gas used doesn't match value in header")]
33    BlobGasUsedMismatch,
34    #[error("Invalid transaction: {0}")]
35    InvalidTransaction(String),
36    #[error("Maximum block size exceeded: Maximum is {0} MiB, but block was {1} MiB")]
37    MaximumRlpSizeExceeded(u64, u64),
38    #[error("Invalid block fork")]
39    InvalidBlockFork,
40    #[error("Transaction type {0:#x} is not allowed in an L1 block")]
41    UnsupportedTransactionType(u8),
42    #[error("Transaction has invalid chain id: have {have}, want {want}")]
43    InvalidTransactionChainId { have: u64, want: u64 },
44}