Skip to main content

sp1_core_executor/
errors.rs

1//! Error types for the SP1 executor.
2
3use serde::{Deserialize, Serialize};
4use thiserror::Error;
5
6use crate::Opcode;
7
8/// Errors that the executor can throw.
9#[derive(Error, Debug, Serialize, Deserialize, PartialEq, Eq)]
10pub enum ExecutionError {
11    /// The execution failed with an invalid memory access.
12    #[error("invalid memory access for opcode {0} and address {1}")]
13    InvalidMemoryAccess(Opcode, u64),
14
15    /// The address for a untrusted program instruction is not aligned to 4 bytes.
16    #[error("invalid memory access for untrusted program at address {0}, not aligned to 4 bytes")]
17    InvalidMemoryAccessUntrustedProgram(u64),
18
19    /// The execution failed with an unimplemented syscall.
20    #[error("unimplemented syscall {0}")]
21    UnsupportedSyscall(u32),
22
23    /// The execution failed with a breakpoint.
24    #[error("breakpoint encountered")]
25    Breakpoint(),
26
27    /// The execution failed with an exceeded cycle limit.
28    #[error("exceeded cycle limit of {0}")]
29    ExceededCycleLimit(u64),
30
31    /// The execution failed because the syscall was called in unconstrained mode.
32    #[error("syscall called in unconstrained mode")]
33    InvalidSyscallUsage(u64),
34
35    /// The execution failed with an unimplemented feature.
36    #[error("got unimplemented as opcode")]
37    Unimplemented(),
38
39    /// The program ended in unconstrained mode.
40    #[error("program ended in unconstrained mode")]
41    EndInUnconstrained(),
42
43    /// The unconstrained cycle limit was exceeded.
44    #[error("unconstrained cycle limit exceeded")]
45    UnconstrainedCycleLimitExceeded(u64),
46
47    /// The program ended with an unexpected status code.
48    #[error("Unexpected exit code: {0}")]
49    UnexpectedExitCode(u32),
50
51    /// Page protect is off, and the instruction is not found.
52    #[error("Instruction not found, page protect/ untrusted program set to off")]
53    InstructionNotFound(),
54
55    /// The sharding state is invalid.
56    #[error("Running executor in non-sharding state, but got a shard boundary or trace end")]
57    InvalidShardingState(),
58
59    /// A generic error.
60    #[error("{0}")]
61    Other(String),
62}