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(transparent)]
18 Layout(#[from] super::MemoryManagerLayoutError),
19 #[error("virtual memory page count overflows")]
21 ArithmeticOverflow,
22 #[error("growth requires {required_buckets} buckets, exceeding capacity {capacity}")]
24 BucketExhausted {
25 required_buckets: u64,
26 capacity: u16,
27 },
28 #[error("backing memory refused growth by {additional_pages} pages")]
30 BackingRefused { additional_pages: u64 },
31 #[error("runtime memory growth is already in progress")]
33 ReentrantAccess,
34}
35
36#[non_exhaustive]
44#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
45pub enum RuntimeConstructionError {
46 #[error("stable backing already has a live runtime or allocation handle")]
48 BackingAlreadyClaimed,
49 #[error(transparent)]
51 Growth(#[from] RuntimeGrowError),
52 #[error("bucket size must be nonzero")]
54 InvalidBucketSize,
55 #[error("persisted bucket size {persisted} pages differs from requested {requested}")]
57 BucketSizeMismatch { persisted: u16, requested: u16 },
58 #[error(transparent)]
60 Layout(#[from] super::MemoryManagerLayoutError),
61 #[error(
63 "nonempty backing memory is not an ic-stable-structures MemoryManager \
64 (expected magic 'MGR', found bytes {observed_magic:?})"
65 )]
66 ForeignMemory {
67 observed_magic: [u8; 3],
69 },
70 #[error(
72 "unsupported ic-stable-structures MemoryManager layout version {observed}; \
73 expected {supported}"
74 )]
75 UnsupportedMemoryManagerVersion {
76 observed: u8,
78 supported: u8,
80 },
81}
82
83#[non_exhaustive]
90#[derive(Debug, thiserror::Error)]
91pub enum RuntimeBootstrapError<P> {
92 #[error(transparent)]
94 ManagerLayout(#[from] super::MemoryManagerLayoutError),
95 #[error("ic-memory runtime has not completed bootstrap validation")]
97 NotBootstrapped,
98 #[error(transparent)]
100 Admission(#[from] super::BootstrapAdmissionError),
101 #[error("bootstrap admission policy rejected recovered allocation metadata")]
103 AdmissionPolicy(P),
104 #[error(transparent)]
105 Resolution(#[from] MemoryResolutionError),
106 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
108 DeclarationSnapshotMismatch,
109 #[error("runtime allocation pool differs from the established host policy")]
111 AllocationPoolMismatch,
112 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
114 PolicyIdentityMismatch {
115 established: PolicyIdentity,
117 requested: PolicyIdentity,
119 },
120 #[error(transparent)]
122 LedgerCommit(#[from] crate::LedgerCommitError),
123 #[error(transparent)]
125 StableCellLedger(#[from] StableCellLedgerError),
126 #[error("stable-cell ledger encoding failed: {0}")]
128 StableCellLedgerEncode(#[source] ic_wire::Error),
129 #[error(transparent)]
131 LedgerGrowth(#[from] RuntimeGrowError),
132 #[error(transparent)]
134 Validation(#[from] crate::AllocationValidationError<P>),
135 #[error(transparent)]
137 Staging(#[from] crate::AllocationStageError),
138}
139
140#[non_exhaustive]
147#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
148pub enum RuntimeOpenError {
149 #[error(transparent)]
151 Layout(#[from] super::MemoryManagerLayoutError),
152 #[error("MemoryManager ID {id} already has a live allocation lease")]
154 AlreadyOpen { id: u8 },
155 #[error("ic-memory runtime has not completed bootstrap validation")]
157 NotBootstrapped,
158 #[error(transparent)]
160 StableKey(#[from] crate::StableKeyError),
161 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
163 StableKeyNotCommitted(String),
164 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
166 ReservedStableKey {
167 stable_key: String,
169 },
170}
171
172#[non_exhaustive]
179#[derive(Debug, thiserror::Error)]
180pub enum RuntimeDiagnosticError {
181 #[error(transparent)]
183 Construction(#[from] RuntimeConstructionError),
184 #[error("ic-memory runtime has not completed bootstrap validation")]
186 NotBootstrapped,
187 #[error("runtime memory growth is already in progress")]
189 ReentrantAccess,
190 #[error(transparent)]
192 LedgerCommit(#[from] LedgerCommitError),
193 #[error(transparent)]
195 StableCellLedger(#[from] StableCellLedgerError),
196}
197
198#[non_exhaustive]
205#[derive(Debug, thiserror::Error)]
206pub enum MemoryResolutionError {
207 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
209 UnmanagedAllocation { id: u8 },
210 #[error("no eligible free slot for {stable_key} under authority {authority}")]
211 Exhausted {
212 stable_key: crate::StableKey,
213 authority: String,
214 },
215 #[error(transparent)]
216 Pool(#[from] crate::MemoryAllocationPoolError),
217 #[error(transparent)]
218 Declarations(#[from] MemoryDeclarationError),
219}