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(
17        "Block access list code change for {address:?} is {size} bytes, above the maximum code size {max}"
18    )]
19    BlockAccessListCodeTooLarge {
20        address: crate::Address,
21        size: usize,
22        max: u64,
23    },
24    #[error("World State Root does not match the one in the header after executing")]
25    StateRootMismatch,
26    #[error("Receipts Root does not match the one in the header after executing")]
27    ReceiptsRootMismatch,
28    #[error("Logs bloom does not match the one in the header after executing")]
29    LogsBloomMismatch,
30    #[error("Invalid Header, validation failed pre-execution: {0}")]
31    InvalidHeader(#[from] InvalidBlockHeaderError),
32    #[error("Invalid Body, validation failed pre-execution: {0}")]
33    InvalidBody(#[from] InvalidBlockBodyError),
34    #[error("Exceeded MAX_BLOB_GAS_PER_BLOCK")]
35    ExceededMaxBlobGasPerBlock,
36    #[error("Exceeded MAX_BLOB_NUMBER_PER_BLOCK")]
37    ExceededMaxBlobNumberPerBlock,
38    #[error("Gas used doesn't match value in header. Used: {0}, Expected: {1}")]
39    GasUsedMismatch(u64, u64),
40    #[error("Blob gas used doesn't match value in header")]
41    BlobGasUsedMismatch,
42    #[error("Invalid transaction: {0}")]
43    InvalidTransaction(String),
44    #[error("Maximum block size exceeded: Maximum is {0} MiB, but block was {1} MiB")]
45    MaximumRlpSizeExceeded(u64, u64),
46    #[error("Invalid block fork")]
47    InvalidBlockFork,
48    #[error("Transaction type {0:#x} is not allowed in an L1 block")]
49    UnsupportedTransactionType(u8),
50    #[error("Transaction has invalid chain id: have {have}, want {want}")]
51    InvalidTransactionChainId { have: u64, want: u64 },
52}