@@ -34,6 +34,8 @@ use crate::inner_forest::{InnerForestError, WitnessError};
3434// DATABASE ERRORS
3535// =================================================================================================
3636
37+ /// Errors that can occur during database operations — reads, writes, queries, and type
38+ /// conversions. Used as a common error type across most store operations.
3739#[ derive( Debug , Error ) ]
3840pub enum DatabaseError {
3941 // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES
@@ -102,6 +104,9 @@ impl From<DatabaseError> for Status {
102104// INITIALIZATION ERRORS
103105// =================================================================================================
104106
107+ /// Errors that can occur while initialising the store's in-memory state at startup, including
108+ /// loading or rebuilding the account tree, nullifier tree, and forest from the database and
109+ /// on-disk storage.
105110#[ derive( Error , Debug ) ]
106111pub enum StateInitializationError {
107112 #[ error( "account tree IO error: {0}" ) ]
@@ -139,6 +144,8 @@ pub enum StateInitializationError {
139144 AccountToDeltaConversionFailed ( String ) ,
140145}
141146
147+ /// Errors that can occur when loading or applying the genesis block to bootstrap a fresh store
148+ /// database.
142149#[ derive( Debug , Error ) ]
143150pub enum GenesisError {
144151 // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES
@@ -157,6 +164,8 @@ pub enum GenesisError {
157164
158165// ENDPOINT ERRORS
159166// =================================================================================================
167+ /// Errors that indicate a submitted block is structurally or cryptographically invalid. Returned
168+ /// by block validation during [`State::apply_block`].
160169#[ derive( Error , Debug ) ]
161170pub enum InvalidBlockError {
162171 #[ error( "duplicated nullifiers {0:?}" ) ]
@@ -188,6 +197,8 @@ pub enum InvalidBlockError {
188197 FailedToBuildNoteTree ( String ) ,
189198}
190199
200+ /// Errors that can occur when applying a proven block to the store — including database writes,
201+ /// tree mutations, and cross-task coordination failures.
191202#[ derive( Error , Debug ) ]
192203pub enum ApplyBlockError {
193204 // ERRORS WITH AUTOMATIC CONVERSIONS FROM NESTED ERROR TYPES
@@ -225,6 +236,8 @@ impl From<ApplyBlockError> for Status {
225236 }
226237}
227238
239+ /// Errors that can occur when retrieving a block header by block number, optionally including its
240+ /// MMR proof.
228241#[ derive( Error , Debug , GrpcError ) ]
229242pub enum GetBlockHeaderError {
230243 #[ error( "database error" ) ]
@@ -235,6 +248,8 @@ pub enum GetBlockHeaderError {
235248 MmrError ( #[ from] MmrError ) ,
236249}
237250
251+ /// Errors that can occur when retrieving the inputs needed to prove a block — including account
252+ /// states, nullifiers, note proofs, and batch reference block headers.
238253#[ derive( Error , Debug ) ]
239254pub enum GetBlockInputsError {
240255 #[ error( "failed to select note inclusion proofs" ) ]
@@ -250,6 +265,8 @@ pub enum GetBlockInputsError {
250265 } ,
251266}
252267
268+ /// Errors that can occur during a `SyncState` operation, which returns the latest account, note,
269+ /// and nullifier state changes from a given block onwards.
253270#[ derive( Error , Debug ) ]
254271pub enum StateSyncError {
255272 #[ error( "database error" ) ]
@@ -260,6 +277,8 @@ pub enum StateSyncError {
260277 FailedToBuildMmrDelta ( #[ from] MmrError ) ,
261278}
262279
280+ /// Errors that can occur when syncing the chain MMR, which provides the MMR peaks and proofs
281+ /// needed by clients to authenticate historical block headers.
263282#[ derive( Error , Debug , GrpcError ) ]
264283pub enum SyncChainMmrError {
265284 #[ error( "invalid block range" ) ]
@@ -279,6 +298,8 @@ impl From<diesel::result::Error> for StateSyncError {
279298 }
280299}
281300
301+ /// Errors that can occur during a `SyncNotes` operation, which returns notes matching a set of
302+ /// note tags from a given block onwards.
282303#[ derive( Error , Debug , GrpcError ) ]
283304pub enum NoteSyncError {
284305 #[ error( "database error" ) ]
@@ -305,6 +326,8 @@ impl From<diesel::result::Error> for NoteSyncError {
305326 }
306327}
307328
329+ /// Errors that can occur when retrieving the current chain tip header and its corresponding MMR
330+ /// peaks for unauthenticated transaction execution.
308331#[ derive( Error , Debug ) ]
309332pub enum GetCurrentBlockchainDataError {
310333 #[ error( "failed to retrieve block header" ) ]
@@ -313,6 +336,8 @@ pub enum GetCurrentBlockchainDataError {
313336 InvalidPeaks ( MmrError ) ,
314337}
315338
339+ /// Errors that can occur when retrieving the inputs needed to prove a transaction batch —
340+ /// including note inclusion proofs and reference block headers.
316341#[ derive( Error , Debug ) ]
317342pub enum GetBatchInputsError {
318343 #[ error( "failed to select note inclusion proofs" ) ]
@@ -333,6 +358,8 @@ pub enum GetBatchInputsError {
333358// SYNC NULLIFIERS ERRORS
334359// ================================================================================================
335360
361+ /// Errors that can occur during a `SyncNullifiers` operation, which returns spent nullifiers
362+ /// within a block range matching a set of 16-bit prefix filters.
336363#[ derive( Debug , Error , GrpcError ) ]
337364pub enum SyncNullifiersError {
338365 #[ error( "database error" ) ]
@@ -349,6 +376,8 @@ pub enum SyncNullifiersError {
349376// SYNC ACCOUNT VAULT ERRORS
350377// ================================================================================================
351378
379+ /// Errors that can occur when syncing an account's asset vault, returning fungible and
380+ /// non-fungible asset changes over a block range.
352381#[ derive( Debug , Error , GrpcError ) ]
353382pub enum SyncAccountVaultError {
354383 #[ error( "database error" ) ]
@@ -365,6 +394,8 @@ pub enum SyncAccountVaultError {
365394// SYNC STORAGE MAPS ERRORS
366395// ================================================================================================
367396
397+ /// Errors that can occur when syncing an account's storage map slots, returning key-value changes
398+ /// for named storage maps over a block range.
368399#[ derive( Debug , Error , GrpcError ) ]
369400pub enum SyncAccountStorageMapsError {
370401 #[ error( "database error" ) ]
@@ -383,6 +414,8 @@ pub enum SyncAccountStorageMapsError {
383414// GET NETWORK ACCOUNT IDS
384415// ================================================================================================
385416
417+ /// Errors that can occur when retrieving the IDs of all network accounts created within a given
418+ /// block range.
386419#[ derive( Debug , Error , GrpcError ) ]
387420pub enum GetNetworkAccountIdsError {
388421 #[ error( "database error" ) ]
@@ -397,6 +430,7 @@ pub enum GetNetworkAccountIdsError {
397430// GET BLOCK BY NUMBER ERRORS
398431// ================================================================================================
399432
433+ /// Errors that can occur when retrieving a full signed block by its block number.
400434#[ derive( Debug , Error , GrpcError ) ]
401435pub enum GetBlockByNumberError {
402436 #[ error( "database error" ) ]
@@ -409,6 +443,8 @@ pub enum GetBlockByNumberError {
409443// GET ACCOUNT ERRORS
410444// ================================================================================================
411445
446+ /// Errors that can occur when retrieving the state and Merkle proof for an account at a specific
447+ /// block number.
412448#[ derive( Debug , Error , GrpcError ) ]
413449pub enum GetAccountError {
414450 #[ error( "database error" ) ]
@@ -429,6 +465,7 @@ pub enum GetAccountError {
429465// GET NOTES BY ID ERRORS
430466// ================================================================================================
431467
468+ /// Errors that can occur when retrieving one or more notes by their IDs.
432469#[ derive( Debug , Error , GrpcError ) ]
433470pub enum GetNotesByIdError {
434471 #[ error( "database error" ) ]
@@ -445,6 +482,7 @@ pub enum GetNotesByIdError {
445482// GET NOTE SCRIPT BY ROOT ERRORS
446483// ================================================================================================
447484
485+ /// Errors that can occur when retrieving a note script by its MAST root.
448486#[ derive( Debug , Error , GrpcError ) ]
449487pub enum GetNoteScriptByRootError {
450488 #[ error( "database error" ) ]
@@ -459,6 +497,7 @@ pub enum GetNoteScriptByRootError {
459497// CHECK NULLIFIERS ERRORS
460498// ================================================================================================
461499
500+ /// Errors that can occur when checking whether a set of nullifiers has been spent.
462501#[ derive( Debug , Error , GrpcError ) ]
463502pub enum CheckNullifiersError {
464503 #[ error( "database error" ) ]
@@ -471,6 +510,8 @@ pub enum CheckNullifiersError {
471510// SYNC TRANSACTIONS ERRORS
472511// ================================================================================================
473512
513+ /// Errors that can occur during a `SyncTransactions` operation, which returns transactions and
514+ /// their account witnesses within a block range.
474515#[ derive( Debug , Error , GrpcError ) ]
475516pub enum SyncTransactionsError {
476517 #[ error( "database error" ) ]
@@ -486,6 +527,8 @@ pub enum SyncTransactionsError {
486527 WitnessError ( #[ from] WitnessError ) ,
487528}
488529
530+ /// Errors that can occur when retrieving Merkle witnesses for account vault assets or storage map
531+ /// values.
489532#[ derive( Debug , Error , GrpcError ) ]
490533pub enum GetWitnessesError {
491534 #[ error( "malformed request" ) ]
0 commit comments