arb_node/
error.rs

1//! Error types for the arb-node launcher and genesis flows.
2//!
3//! Replaces the historical `Result<_, String>` plumbing through the
4//! persistence-thread channel, the parallel-state-root callback, and the
5//! genesis initializer with concrete typed variants.
6
7use arbos::arbos_state::ArbosStateError;
8use reth_storage_errors::provider::ProviderError;
9use reth_trie_parallel::root::ParallelStateRootError;
10
11/// Errors surfaced by the `arb-node` launcher infrastructure.
12#[derive(Debug, thiserror::Error)]
13pub enum LauncherError {
14    /// Failure originating in the wider arbreth error chain.
15    #[error(transparent)]
16    Arb(#[from] arb_errors::ArbError),
17
18    /// A reth provider operation (open RW handle, save blocks, commit,
19    /// rollback) failed against the on-disk database.
20    #[error(transparent)]
21    Provider(#[from] ProviderError),
22
23    /// Parallel state-root computation failed.
24    #[error(transparent)]
25    ParallelStateRoot(#[from] ParallelStateRootError),
26
27    /// The parallel state-root callback was queried before the launcher
28    /// finished wiring it up. This indicates a startup-ordering bug.
29    #[error("parallel state root callback not initialized")]
30    ParallelStateRootNotInitialized,
31
32    /// ArbOS genesis initialization failed.
33    #[error(transparent)]
34    Genesis(#[from] GenesisError),
35}
36
37/// Errors surfaced while initializing ArbOS genesis state.
38#[derive(Debug, thiserror::Error)]
39pub enum GenesisError {
40    /// `initialize_arbos_state` was called against a database that already
41    /// contains a non-zero ArbOS version.
42    #[error("ArbOS state already initialized")]
43    AlreadyInitialized,
44
45    /// A backing-storage write performed during the slot-bootstrap phase
46    /// (initial version, chain ID, network-fee account, chain config) failed.
47    #[error("failed to write genesis slot ({what}): {source}")]
48    StorageWrite {
49        /// Short label describing which slot was being written.
50        what: &'static str,
51        /// The underlying storage failure.
52        #[source]
53        source: arb_storage_errors::StorageError,
54    },
55
56    /// An ArbOS subsystem refused to initialize cleanly during bootstrap.
57    #[error("failed to initialize {subsystem}: {source}")]
58    InitSubsystem {
59        /// Subsystem name (e.g. `"retryables"`, `"chain owners"`).
60        subsystem: &'static str,
61        /// The underlying ArbOS error.
62        #[source]
63        source: ArbosStateError,
64    },
65
66    /// Stepping the ArbOS version upward from `1` to the target failed.
67    #[error("failed to upgrade ArbOS to version {target}: {source}")]
68    Upgrade {
69        /// Target ArbOS version requested by the chain spec.
70        target: u64,
71        /// The underlying upgrade failure.
72        #[source]
73        source: ArbosStateError,
74    },
75}