ic_memory/runtime/
error.rs1use crate::{
2 LedgerCommitError, PolicyIdentity, StableCellLedgerError, requests::MemoryDeclarationError,
3};
4
5#[non_exhaustive]
14#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
15pub enum RuntimeGrowError {
16 #[error("virtual memory page count overflows")]
18 ArithmeticOverflow,
19 #[error("growth requires {required_buckets} buckets, exceeding capacity {capacity}")]
21 BucketExhausted {
22 required_buckets: u64,
23 capacity: u16,
24 },
25 #[error("backing memory refused growth by {additional_pages} pages")]
27 BackingRefused { additional_pages: u64 },
28 #[error("runtime memory growth is already in progress")]
30 ReentrantAccess,
31}
32
33#[non_exhaustive]
41#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
42pub enum RuntimeConstructionError {
43 #[error(transparent)]
45 Growth(#[from] RuntimeGrowError),
46 #[error("bucket size must be nonzero")]
48 InvalidBucketSize,
49 #[error("persisted bucket size {persisted} pages differs from requested {requested}")]
51 BucketSizeMismatch { persisted: u16, requested: u16 },
52 #[error(transparent)]
54 Layout(#[from] super::MemoryManagerLayoutError),
55 #[error(
57 "nonempty backing memory is not an ic-stable-structures MemoryManager \
58 (expected magic 'MGR', found bytes {observed_magic:?})"
59 )]
60 ForeignMemory {
61 observed_magic: [u8; 3],
63 },
64 #[error(
66 "unsupported ic-stable-structures MemoryManager layout version {observed}; \
67 expected {supported}"
68 )]
69 UnsupportedMemoryManagerVersion {
70 observed: u8,
72 supported: u8,
74 },
75}
76
77#[non_exhaustive]
84#[derive(Debug, thiserror::Error)]
85pub enum RuntimeBootstrapError<P> {
86 #[error(transparent)]
88 Admission(#[from] super::BootstrapAdmissionError),
89 #[error("bootstrap admission policy rejected recovered allocation metadata")]
91 AdmissionPolicy(P),
92 #[error(transparent)]
93 Resolution(#[from] MemoryResolutionError),
94 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
96 DeclarationSnapshotMismatch,
97 #[error("runtime allocation pool differs from the established host policy")]
99 AllocationPoolMismatch,
100 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
102 PolicyIdentityMismatch {
103 established: PolicyIdentity,
105 requested: PolicyIdentity,
107 },
108 #[error(transparent)]
110 LedgerCommit(#[from] crate::LedgerCommitError),
111 #[error(transparent)]
113 StableCellLedger(#[from] StableCellLedgerError),
114 #[error("stable-cell ledger record size {value_size} cannot be written to stable memory")]
116 StableCellLedgerWriteTooLarge {
117 value_size: usize,
119 },
120 #[error(transparent)]
122 LedgerGrowth(#[from] RuntimeGrowError),
123 #[error(transparent)]
125 Validation(#[from] crate::AllocationValidationError<P>),
126 #[error(transparent)]
128 Staging(#[from] crate::AllocationStageError),
129}
130
131#[non_exhaustive]
138#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
139pub enum RuntimeOpenError {
140 #[error("MemoryManager ID {id} already has a live allocation lease")]
142 AlreadyOpen { id: u8 },
143 #[error("ic-memory runtime has not completed bootstrap validation")]
145 NotBootstrapped,
146 #[error(transparent)]
148 StableKey(#[from] crate::StableKeyError),
149 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
151 StableKeyNotCommitted(String),
152 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
154 ReservedStableKey {
155 stable_key: String,
157 },
158}
159
160#[non_exhaustive]
167#[derive(Debug, thiserror::Error)]
168pub enum RuntimeDiagnosticError {
169 #[error(transparent)]
171 Construction(#[from] RuntimeConstructionError),
172 #[error("ic-memory runtime has not completed bootstrap validation")]
174 NotBootstrapped,
175 #[error("runtime memory growth is already in progress")]
177 ReentrantAccess,
178 #[error(transparent)]
180 LedgerCommit(#[from] LedgerCommitError),
181 #[error(transparent)]
183 StableCellLedger(#[from] StableCellLedgerError),
184}
185
186#[non_exhaustive]
193#[derive(Debug, thiserror::Error)]
194pub enum MemoryResolutionError {
195 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
197 UnmanagedAllocation { id: u8 },
198 #[error("no eligible free slot for {stable_key} under authority {authority}")]
199 Exhausted {
200 stable_key: crate::StableKey,
201 authority: String,
202 },
203 #[error(transparent)]
204 Pool(#[from] crate::MemoryAllocationPoolError),
205 #[error(transparent)]
206 Declarations(#[from] MemoryDeclarationError),
207}