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