zakura_network/zakura/header_sync/
error.rs1use super::*;
2
3#[derive(Debug, Error)]
5pub enum HeaderSyncStartError {
6 #[error("invalid Zakura header-sync anchor at height {anchor:?}")]
8 InvalidAnchor {
9 anchor: (block::Height, block::Hash),
11 },
12
13 #[error(
15 "Zakura header-sync anchor height {anchor_height:?} is above the verified block tip \
16 {verified_block_tip:?}"
17 )]
18 AnchorAboveVerifiedBlockTip {
19 anchor_height: block::Height,
21 verified_block_tip: block::Height,
23 },
24
25 #[error("Zakura header-sync anchor_height and anchor_hash must be configured together")]
27 IncompleteAnchor,
28}
29
30#[derive(Debug, Error)]
32pub enum HeaderSyncWireError {
33 #[error("Zakura header-sync payload length {actual} exceeds cap {max}")]
35 OversizedPayload {
36 actual: usize,
38 max: usize,
40 },
41
42 #[error("Zakura header-sync header count {actual} exceeds cap {max}")]
44 HeaderCountLimit {
45 actual: usize,
47 max: usize,
49 },
50
51 #[error("Zakura header-sync Headers body-size count {body_sizes} does not match header count {headers}")]
53 BodySizeCountMismatch {
54 headers: usize,
56 body_sizes: usize,
58 },
59
60 #[error("Zakura header-sync Headers tree-aux root count {roots} does not match header count {headers}")]
62 TreeAuxRootCountMismatch {
63 headers: usize,
65 roots: usize,
67 },
68
69 #[error(
71 "Zakura header-sync Headers tree-aux root height {root_height:?} does not match \
72 expected height {expected_height:?} at offset {offset} \
73 (first={first_root_height:?}, last={last_root_height:?})"
74 )]
75 TreeAuxRootHeightMismatch {
76 offset: usize,
78 expected_height: block::Height,
80 root_height: block::Height,
82 first_root_height: block::Height,
84 last_root_height: block::Height,
86 },
87
88 #[error("Zakura header-sync {field} marker has invalid value {value}")]
90 InvalidBoolMarker {
91 field: &'static str,
93 value: u8,
95 },
96
97 #[error("Zakura header-sync Headers included tree-aux roots for an opt-out request")]
99 UnrequestedTreeAuxRoots,
100
101 #[error("unsolicited Zakura header-sync Headers response")]
103 UnsolicitedHeaders,
104
105 #[error("Zakura header-sync v7 {message} message is missing a request ID")]
107 MissingRequestId {
108 message: &'static str,
110 },
111
112 #[error("Zakura header-sync GetHeaders count must be non-zero")]
114 ZeroHeaderRequestCount,
115
116 #[error("Zakura header-sync height {0} exceeds supported range")]
118 HeightOutOfRange(u32),
119
120 #[error("unknown Zakura header-sync message type {0}")]
122 UnknownMessageType(u8),
123
124 #[error("unknown Zakura header-sync frame message type {0}")]
126 UnknownFrameMessageType(u16),
127
128 #[error("unsupported Zakura header-sync frame flags {0}")]
130 UnsupportedFlags(u16),
131
132 #[error("Zakura header-sync frame type {frame} disagrees with payload type {payload}")]
134 MismatchedFrameMessageType {
135 frame: u16,
137 payload: u8,
139 },
140
141 #[error("trailing bytes in Zakura header-sync payload")]
143 TrailingBytes,
144
145 #[error("non-contiguous Zakura header-sync header run")]
147 NonContiguousHeaders,
148
149 #[error("first Zakura header-sync range header does not link to anchor")]
151 FirstHeaderDoesNotLink,
152
153 #[error("Zakura header-sync Equihash solution size does not match the active network")]
155 WrongEquihashSolutionSize,
156
157 #[error("invalid Zakura header-sync compact difficulty threshold")]
159 InvalidDifficultyThreshold,
160
161 #[error("Zakura header-sync hash {hash:?} exceeds difficulty threshold {threshold:?}")]
163 DifficultyFilter {
164 hash: block::Hash,
166 threshold: ExpandedDifficulty,
168 },
169
170 #[error("numeric overflow while encoding Zakura header-sync {0}")]
172 NumericOverflow(&'static str),
173
174 #[error("Zakura header-sync wire I/O error: {0}")]
176 Io(#[from] io::Error),
177
178 #[error("Zakura header-sync Zcash serialization error: {0}")]
180 Serialization(#[from] SerializationError),
181
182 #[error(transparent)]
184 Time(#[from] BlockTimeError),
185
186 #[error(transparent)]
188 Equihash(#[from] equihash::Error),
189
190 #[error("Zakura header-sync blocking validation task failed: {0}")]
192 BlockingTask(#[from] JoinError),
193}