arbos/programs/error.rs
1use arb_storage::StorageError;
2
3/// Errors raised by the Stylus programs subsystem.
4#[derive(Clone, thiserror::Error, Debug)]
5pub enum ProgramsError {
6 /// Underlying storage failure.
7 #[error(transparent)]
8 Storage(#[from] StorageError),
9
10 /// `open_program_at` was called for a code hash that has not been
11 /// activated (its stored version is `0`).
12 #[error("program is not activated")]
13 NotActivated,
14
15 /// The program's stored version does not match the version recorded in
16 /// the current Stylus params.
17 #[error("program version mismatch: program={program} params={params}")]
18 VersionMismatch {
19 /// Version recorded on the program itself.
20 program: u64,
21 /// Version expected by the active Stylus params.
22 params: u64,
23 },
24
25 /// The program's age exceeds the configured expiry window.
26 #[error("program has expired")]
27 Expired,
28
29 /// `upgrade_to_version` / `upgrade_to_arbos_version` was called from a
30 /// state that does not satisfy the required precondition (e.g. trying to
31 /// upgrade past a version that hasn't been reached).
32 #[error("invalid stylus params upgrade: {0}")]
33 InvalidParamsUpgrade(&'static str),
34
35 /// `activate_program` was invoked for a program that is already at the
36 /// current Stylus version and within its expiry window.
37 #[error("program is already up to date")]
38 UpToDate,
39
40 /// `program_keepalive` was invoked before enough time has elapsed since
41 /// the last activation/keepalive.
42 #[error("program keepalive called too soon")]
43 KeepaliveTooSoon,
44
45 /// The program's stored version is older than the active Stylus version
46 /// and an upgrade is required before this operation.
47 #[error("program needs upgrade before this operation")]
48 NeedsUpgrade,
49
50 /// A Stylus call was attempted with insufficient gas to cover the call
51 /// cost (memory + init/cached gas).
52 #[error("insufficient gas for stylus call: need {needed}, have {have}")]
53 InsufficientGas {
54 /// Gas required to cover the call cost.
55 needed: u64,
56 /// Gas available at the call site.
57 have: u64,
58 },
59
60 /// The Stylus call returned data whose EVM-equivalent memory cost
61 /// exceeds the gas that was available at call entry. All remaining gas
62 /// is consumed.
63 #[error("stylus call out of gas (return data exceeds available)")]
64 ReturnDataOutOfGas,
65
66 /// The prover-machine activation step (WASM compile/validate) failed
67 /// with a runtime-supplied diagnostic.
68 #[error("stylus activation failed: {reason}")]
69 Activation {
70 /// Diagnostic message preserved from the activation backend.
71 reason: String,
72 },
73
74 /// The user-supplied call dispatcher reported a runtime error (e.g. a
75 /// trap or non-success outcome).
76 #[error("stylus call execution failed: {reason}")]
77 Execution {
78 /// Diagnostic message preserved from the Stylus runtime.
79 reason: String,
80 },
81}