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("persisted bucket size {persisted} pages differs from requested {requested}")]
54 BucketSizeMismatch { persisted: u16, requested: u16 },
55 #[error(transparent)]
57 Layout(#[from] super::MemoryManagerLayoutError),
58 #[error(
60 "nonempty backing memory is not an ic-stable-structures MemoryManager \
61 (expected magic 'MGR', found bytes {observed_magic:?})"
62 )]
63 ForeignMemory {
64 observed_magic: [u8; 3],
66 },
67 #[error(
69 "unsupported ic-stable-structures MemoryManager layout version {observed}; \
70 expected {supported}"
71 )]
72 UnsupportedMemoryManagerVersion {
73 observed: u8,
75 supported: u8,
77 },
78}
79
80#[non_exhaustive]
87#[derive(Debug, thiserror::Error)]
88pub enum RuntimeBootstrapError<P> {
89 #[error(transparent)]
91 ManagerLayout(#[from] super::MemoryManagerLayoutError),
92 #[error("ic-memory runtime has not completed bootstrap validation")]
94 NotBootstrapped,
95 #[error(transparent)]
97 Admission(#[from] super::BootstrapAdmissionError),
98 #[error("bootstrap admission policy rejected recovered allocation metadata")]
100 AdmissionPolicy(P),
101 #[error(transparent)]
102 Resolution(#[from] MemoryResolutionError),
103 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
105 DeclarationSnapshotMismatch,
106 #[error("runtime allocation pool differs from the established host policy")]
108 AllocationPoolMismatch,
109 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
111 PolicyIdentityMismatch {
112 established: PolicyIdentity,
114 requested: PolicyIdentity,
116 },
117 #[error(transparent)]
119 LedgerCommit(#[from] crate::LedgerCommitError),
120 #[error(transparent)]
122 StableCellLedger(#[from] StableCellLedgerError),
123 #[error("stable-cell ledger encoding failed: {0}")]
125 StableCellLedgerEncode(#[source] ic_wire::Error),
126 #[error(transparent)]
128 LedgerGrowth(#[from] RuntimeGrowError),
129 #[error(transparent)]
131 Validation(#[from] crate::AllocationValidationError<P>),
132 #[error(transparent)]
134 Staging(#[from] crate::AllocationStageError),
135}
136
137#[non_exhaustive]
144#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
145pub enum RuntimeOpenError {
146 #[error(transparent)]
148 Layout(#[from] super::MemoryManagerLayoutError),
149 #[error("MemoryManager ID {id} already has a live allocation lease")]
151 AlreadyOpen { id: u8 },
152 #[error("ic-memory runtime has not completed bootstrap validation")]
154 NotBootstrapped,
155 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
157 StableKeyNotCommitted(String),
158 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
160 ReservedStableKey {
161 stable_key: String,
163 },
164}
165
166#[non_exhaustive]
173#[derive(Debug, thiserror::Error)]
174pub enum RuntimeDiagnosticError {
175 #[error(transparent)]
177 Construction(#[from] RuntimeConstructionError),
178 #[error("ic-memory runtime has not completed bootstrap validation")]
180 NotBootstrapped,
181 #[error("runtime memory growth is already in progress")]
183 ReentrantAccess,
184 #[error(transparent)]
186 LedgerCommit(#[from] LedgerCommitError),
187 #[error(transparent)]
189 StableCellLedger(#[from] StableCellLedgerError),
190}
191
192#[non_exhaustive]
199#[derive(Debug, thiserror::Error)]
200pub enum MemoryResolutionError {
201 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
203 UnmanagedAllocation { id: u8 },
204 #[error("no eligible free slot for {stable_key} under authority {authority}")]
205 Exhausted {
206 stable_key: crate::StableKey,
207 authority: String,
208 },
209 #[error(transparent)]
210 Pool(#[from] crate::MemoryAllocationPoolError),
211 #[error(transparent)]
212 Declarations(#[from] MemoryDeclarationError),
213}