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("Zakura header-sync anchor_height and anchor_hash must be configured together")]
15 IncompleteAnchor,
16}
17
18#[derive(Debug, Error)]
20pub enum HeaderSyncWireError {
21 #[error("Zakura header-sync payload length {actual} exceeds cap {max}")]
23 OversizedPayload {
24 actual: usize,
26 max: usize,
28 },
29
30 #[error("Zakura header-sync header count {actual} exceeds cap {max}")]
32 HeaderCountLimit {
33 actual: usize,
35 max: usize,
37 },
38
39 #[error("Zakura header-sync Headers body-size count {body_sizes} does not match header count {headers}")]
41 BodySizeCountMismatch {
42 headers: usize,
44 body_sizes: usize,
46 },
47
48 #[error("Zakura header-sync Headers tree-aux root count {roots} does not match header count {headers}")]
50 TreeAuxRootCountMismatch {
51 headers: usize,
53 roots: usize,
55 },
56
57 #[error(
59 "Zakura header-sync Headers tree-aux root height {root_height:?} does not match \
60 expected height {expected_height:?} at offset {offset} \
61 (first={first_root_height:?}, last={last_root_height:?})"
62 )]
63 TreeAuxRootHeightMismatch {
64 offset: usize,
66 expected_height: block::Height,
68 root_height: block::Height,
70 first_root_height: block::Height,
72 last_root_height: block::Height,
74 },
75
76 #[error("Zakura header-sync {field} marker has invalid value {value}")]
78 InvalidBoolMarker {
79 field: &'static str,
81 value: u8,
83 },
84
85 #[error("Zakura header-sync Headers included tree-aux roots for an opt-out request")]
87 UnrequestedTreeAuxRoots,
88
89 #[error("unsolicited Zakura header-sync Headers response")]
91 UnsolicitedHeaders,
92
93 #[error("Zakura header-sync v7 {message} message is missing a request ID")]
95 MissingRequestId {
96 message: &'static str,
98 },
99
100 #[error("Zakura header-sync GetHeaders count must be non-zero")]
102 ZeroHeaderRequestCount,
103
104 #[error("Zakura header-sync height {0} exceeds supported range")]
106 HeightOutOfRange(u32),
107
108 #[error("unknown Zakura header-sync message type {0}")]
110 UnknownMessageType(u8),
111
112 #[error("unknown Zakura header-sync frame message type {0}")]
114 UnknownFrameMessageType(u16),
115
116 #[error("unsupported Zakura header-sync frame flags {0}")]
118 UnsupportedFlags(u16),
119
120 #[error("Zakura header-sync frame type {frame} disagrees with payload type {payload}")]
122 MismatchedFrameMessageType {
123 frame: u16,
125 payload: u8,
127 },
128
129 #[error("trailing bytes in Zakura header-sync payload")]
131 TrailingBytes,
132
133 #[error("non-contiguous Zakura header-sync header run")]
135 NonContiguousHeaders,
136
137 #[error("first Zakura header-sync range header does not link to anchor")]
139 FirstHeaderDoesNotLink,
140
141 #[error("Zakura header-sync Equihash solution size does not match the active network")]
143 WrongEquihashSolutionSize,
144
145 #[error("invalid Zakura header-sync compact difficulty threshold")]
147 InvalidDifficultyThreshold,
148
149 #[error("Zakura header-sync hash {hash:?} exceeds difficulty threshold {threshold:?}")]
151 DifficultyFilter {
152 hash: block::Hash,
154 threshold: ExpandedDifficulty,
156 },
157
158 #[error("numeric overflow while encoding Zakura header-sync {0}")]
160 NumericOverflow(&'static str),
161
162 #[error("Zakura header-sync wire I/O error: {0}")]
164 Io(#[from] io::Error),
165
166 #[error("Zakura header-sync Zcash serialization error: {0}")]
168 Serialization(#[from] SerializationError),
169
170 #[error(transparent)]
172 Time(#[from] BlockTimeError),
173
174 #[error(transparent)]
176 Equihash(#[from] equihash::Error),
177
178 #[error("Zakura header-sync blocking validation task failed: {0}")]
180 BlockingTask(#[from] JoinError),
181}