miden_client/store/
errors.rs1use alloc::string::String;
2use core::num::TryFromIntError;
3
4use miden_protocol::account::AccountId;
5use miden_protocol::asset::AssetId;
6use miden_protocol::block::BlockNumber;
7use miden_protocol::crypto::merkle::MerkleError;
8use miden_protocol::crypto::merkle::mmr::MmrError;
9use miden_protocol::crypto::merkle::smt::SmtProofError;
10use miden_protocol::errors::{
11 AccountDeltaError,
12 AccountError,
13 AccountIdError,
14 AccountPatchError,
15 AddressError,
16 AssetError,
17 AssetVaultError,
18 NoteError,
19 StorageMapError,
20};
21use miden_protocol::utils::HexParseError;
22use miden_protocol::utils::serde::DeserializationError;
23use miden_protocol::{MastForestScriptError, Word, WordError};
24use miden_tx::DataStoreError;
25use thiserror::Error;
26
27use super::note_record::NoteRecordError;
28
29#[derive(Debug, Error)]
34#[allow(clippy::large_enum_variant)]
35pub enum StoreError {
36 #[error("protocol configuration {0} is not stored; sync the client to get it from the node")]
37 ProtocolConfigNotFound(Word),
38 #[error("stored protocol configuration does not match commitment {0}")]
39 ProtocolConfigCommitmentMismatch(Word),
40 #[error("asset error")]
41 AssetError(#[from] AssetError),
42 #[error("asset vault error")]
43 AssetVaultError(#[from] AssetVaultError),
44 #[error("account code data with root {0} not found")]
45 AccountCodeDataNotFound(Word),
46 #[error("account data wasn't found for account id {0}")]
47 AccountDataNotFound(AccountId),
48 #[error("account delta error")]
49 AccountDeltaError(#[from] AccountDeltaError),
50 #[error("account patch error")]
51 AccountPatchError(#[from] AccountPatchError),
52 #[error("account error")]
53 AccountError(#[from] AccountError),
54 #[error("address error")]
55 AddressError(#[from] AddressError),
56 #[error("invalid account ID")]
57 AccountIdError(#[from] AccountIdError),
58 #[error("stored account commitment does not match the expected commitment for account {0}")]
59 AccountCommitmentMismatch(AccountId),
60 #[error("account storage data with root {0} not found")]
61 AccountStorageRootNotFound(Word),
62 #[error("account storage data with index {0} not found")]
63 AccountStorageIndexNotFound(usize),
64 #[error("block header for block {0} not found")]
65 BlockHeaderNotFound(BlockNumber),
66 #[error("partial blockchain node at index {0} not found")]
67 PartialBlockchainNodeNotFound(u64),
68 #[error("failed to deserialize data from the store")]
69 DataDeserializationError(#[from] DeserializationError),
70 #[error("database-related non-query error: {0}")]
71 DatabaseError(String),
72 #[error("transient database error, the operation can be retried: {0}")]
73 DatabaseTransientError(String),
74 #[error("permanent database error: {0}")]
75 DatabasePermanentError(String),
76 #[error("failed to parse hex value")]
77 HexParseError(#[from] HexParseError),
78 #[error("integer conversion failed")]
79 InvalidInt(#[from] TryFromIntError),
80 #[error("note record error")]
81 NoteRecordError(#[from] NoteRecordError),
82 #[error("merkle store error")]
83 MerkleStoreError(#[from] MerkleError),
84 #[error("failed to construct Merkle Mountain Range (MMR)")]
85 MmrError(#[from] MmrError),
86 #[error("failed to create note inclusion proof")]
87 NoteInclusionProofError(#[from] NoteError),
88 #[error("note tag {0} is already being tracked")]
89 NoteTagAlreadyTracked(u64),
90 #[error("note script with root {0} not found")]
91 NoteScriptNotFound(String),
92 #[error("failed to parse data retrieved from the database: {0}")]
93 ParsingError(String),
94 #[error("failed to retrieve data from the database: {0}")]
95 QueryError(String),
96 #[error("sparse merkle tree proof error")]
97 SmtProofError(#[from] SmtProofError),
98 #[error("account storage map error")]
99 StorageMapError(#[from] StorageMapError),
100 #[error("failed to instantiate a script from its mast forest")]
101 MastForestScriptError(#[from] MastForestScriptError),
102 #[error("account vault data for root {0} not found")]
103 VaultDataNotFound(Word),
104 #[error("vault key {0:?} (hashed to {1}) is not tracked in the vault")]
105 VaultKeyNotTracked(AssetId, Word),
106 #[error("failed to parse word")]
107 WordError(#[from] WordError),
108}
109
110impl From<StoreError> for DataStoreError {
111 fn from(value: StoreError) -> Self {
112 match value {
113 StoreError::AccountDataNotFound(account_id) => {
114 DataStoreError::AccountNotFound(account_id)
115 },
116 err => DataStoreError::other_with_source("store error", err),
117 }
118 }
119}