-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy patherrors.rs
More file actions
152 lines (115 loc) · 4.52 KB
/
Copy patherrors.rs
File metadata and controls
152 lines (115 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// lint-long-file-override allow-max-lines=250
use std::{error::Error as StdError, fmt, num::ParseIntError, path::PathBuf};
use crate::sync;
use contextful::Contextful;
use element::Element;
use libp2p::PeerId;
use node_interface::RpcError;
use primitives::{block_height::BlockHeight, hash::CryptoHash};
#[derive(Debug)]
pub struct TracingInitError(Box<dyn StdError + Send + Sync>);
impl fmt::Display for TracingInitError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
impl StdError for TracingInitError {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
Some(&*self.0)
}
}
impl From<Box<dyn StdError + Send + Sync>> for TracingInitError {
fn from(inner: Box<dyn StdError + Send + Sync>) -> Self {
Self(inner)
}
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("[node] rpc error: {0}")]
Rpc(#[from] Contextful<RpcError>),
#[error("[node] invalid snapshot chunk, peer mismatch - accepted {accepted}, got {got}")]
SnapshotChunkPeerMismatch {
accepted: Box<PeerId>,
got: Box<PeerId>,
},
#[error("[node] note already spent: 0x{spent_note:x}")]
NoteAlreadySpent {
spent_note: Element,
failing_txn_hash: Element,
},
#[error(
"[node] leaf 0x{inserted_leaf} was already inserted in the same block in transaction 0x{txn_hash}"
)]
LeafAlreadyInsertedInTheSameBlock {
inserted_leaf: Element,
txn_hash: Element,
failing_txn_hash: Element,
},
#[error("[node] element is not in any transaction of block {block_height}")]
ElementNotInTxn {
element: Element,
block_height: BlockHeight,
},
#[error("[node] block height {block} not found")]
BlockNotFound { block: BlockHeight },
#[error("[node] block hash {block} not found")]
BlockHashNotFound { block: CryptoHash },
#[error("[node] invalid mint or burn leaves")]
InvalidMintOrBurnLeaves,
#[error("[node] invalid mint or burn leaves")]
InvalidSignature,
#[error("[node] invalid transaction '{txn}'")]
InvalidTransaction { txn: Element },
#[error("[node] invalid block root, got: {got}, expected: {expected}")]
InvalidBlockRoot { got: Element, expected: Element },
/// A mint references a chain that is not configured on this node.
#[error("[node] unsupported chain id {chain_id}")]
UnsupportedChain { chain_id: u64 },
#[error("[node] transaction contains locked element {locked_element}")]
TransactionContainsLockedElement { locked_element: Element },
#[error("[node] invalid element: {element}")]
FailedToParseElement {
element: String,
#[source]
source: ParseIntError,
},
#[error("[node] invalid hash: {hash}")]
FailedToParseHash {
hash: String,
#[source]
source: rustc_hex::FromHexError,
},
#[error("[node] failed to get eth block number: {0}")]
FailedToGetEthBlockNumber(#[from] Contextful<web3::Error>),
#[error("[node] secp256k1 error: {0}")]
Secp256k1(#[from] Contextful<secp256k1::Error>),
#[error("[node] web3 secp256k1 error: {0}")]
Web3Secp256k1(#[from] Contextful<web3::signing::SigningError>),
#[error("[node] tracing setup error: {0}")]
Tracing(#[from] Contextful<TracingInitError>),
#[error("[node] config error: {0}")]
Config(#[from] Contextful<figment::Error>),
#[error("[node] doomslug error: {0}")]
Doomslug(#[from] Contextful<doomslug::Error>),
#[error("[node] sync error: {0}")]
Sync(#[from] Contextful<sync::Error>),
#[error("[node] network error: {0}")]
Network(#[from] Contextful<p2p2::Error>),
#[error("[node] block store error: {0}")]
BlockStore(#[from] Contextful<block_store::Error>),
#[error("[node] smirk error: {0}")]
Smirk(#[from] Contextful<smirk::storage::Error>),
#[error("[node] contracts error: {0}")]
Contracts(#[from] Contextful<contracts::Error>),
#[error("[node] io error: {0}")]
Io(#[from] Contextful<std::io::Error>),
#[error("[node] unable to resolve home directory for path {path:?}")]
ConfigMissingHomeDir { path: PathBuf },
#[error("[node] smirk collision error: {0}")]
Collision(#[from] Contextful<smirk::CollisionError>),
#[error("[node] missing primary chain configuration")]
MissingPrimaryChainConfig,
#[error("[node] missing rollup contract for primary chain {chain_id}")]
MissingPrimaryRollupContract { chain_id: u64 },
}