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("ic-memory runtime has not completed bootstrap validation")]
88 NotBootstrapped,
89 #[error(transparent)]
91 Admission(#[from] super::BootstrapAdmissionError),
92 #[error("bootstrap admission policy rejected recovered allocation metadata")]
94 AdmissionPolicy(P),
95 #[error(transparent)]
96 Resolution(#[from] MemoryResolutionError),
97 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
99 DeclarationSnapshotMismatch,
100 #[error("runtime allocation pool differs from the established host policy")]
102 AllocationPoolMismatch,
103 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
105 PolicyIdentityMismatch {
106 established: PolicyIdentity,
108 requested: PolicyIdentity,
110 },
111 #[error(transparent)]
113 LedgerCommit(#[from] crate::LedgerCommitError),
114 #[error(transparent)]
116 StableCellLedger(#[from] StableCellLedgerError),
117 #[error("stable-cell ledger record size {value_size} cannot be written to stable memory")]
119 StableCellLedgerWriteTooLarge {
120 value_size: usize,
122 },
123 #[error(transparent)]
125 LedgerGrowth(#[from] RuntimeGrowError),
126 #[error(transparent)]
128 Validation(#[from] crate::AllocationValidationError<P>),
129 #[error(transparent)]
131 Staging(#[from] crate::AllocationStageError),
132}
133
134#[non_exhaustive]
141#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
142pub enum RuntimeOpenError {
143 #[error("MemoryManager ID {id} already has a live allocation lease")]
145 AlreadyOpen { id: u8 },
146 #[error("ic-memory runtime has not completed bootstrap validation")]
148 NotBootstrapped,
149 #[error(transparent)]
151 StableKey(#[from] crate::StableKeyError),
152 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
154 StableKeyNotCommitted(String),
155 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
157 ReservedStableKey {
158 stable_key: String,
160 },
161}
162
163#[non_exhaustive]
170#[derive(Debug, thiserror::Error)]
171pub enum RuntimeDiagnosticError {
172 #[error(transparent)]
174 Construction(#[from] RuntimeConstructionError),
175 #[error("ic-memory runtime has not completed bootstrap validation")]
177 NotBootstrapped,
178 #[error("runtime memory growth is already in progress")]
180 ReentrantAccess,
181 #[error(transparent)]
183 LedgerCommit(#[from] LedgerCommitError),
184 #[error(transparent)]
186 StableCellLedger(#[from] StableCellLedgerError),
187}
188
189#[non_exhaustive]
196#[derive(Debug, thiserror::Error)]
197pub enum MemoryResolutionError {
198 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
200 UnmanagedAllocation { id: u8 },
201 #[error("no eligible free slot for {stable_key} under authority {authority}")]
202 Exhausted {
203 stable_key: crate::StableKey,
204 authority: String,
205 },
206 #[error(transparent)]
207 Pool(#[from] crate::MemoryAllocationPoolError),
208 #[error(transparent)]
209 Declarations(#[from] MemoryDeclarationError),
210}