arb_storage_errors/storage.rs
1use alloy_primitives::U256;
2
3use crate::DatabaseError;
4
5/// Errors raised by the arb-storage layer.
6///
7/// `Database(...)` is an infrastructure failure that must abort the calling
8/// block. The remaining variants signal that the stored bytes do not match
9/// the layout the type expects, which indicates either corrupted state or a
10/// version skew between layout code and on-chain data; both abort the block.
11#[derive(Clone, Debug, thiserror::Error)]
12pub enum StorageError {
13 /// The underlying state database returned an error.
14 #[error(transparent)]
15 Database(#[from] DatabaseError),
16
17 /// A stored value violated the layout invariants of its typed wrapper
18 /// (e.g. an address slot whose upper 12 bytes are non-zero).
19 #[error("invalid storage layout at slot {slot}: {reason}")]
20 InvalidLayout {
21 /// The slot whose layout is invalid.
22 slot: U256,
23 /// Short description of the broken invariant.
24 reason: &'static str,
25 },
26
27 /// A storage container detected a broken structural invariant (e.g. a
28 /// queue read past `next_put`).
29 #[error("storage invariant violated: {0}")]
30 Invariant(&'static str),
31}