drive_proof_verifier/block_proof/error.rs
1/// Why a Tenderdash block proof, or what an answer says about the block, was refused.
2#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
3pub enum BlockProofError {
4 /// The proof carries no header
5 #[error("the block proof has no header")]
6 MissingHeader,
7
8 /// The proof carries no block id
9 #[error("the block proof has no block id")]
10 MissingBlockId,
11
12 /// The header is not the one the signed block hash stands for
13 #[error("the header of block {height} does not hash to its block id")]
14 HeaderHashMismatch {
15 /// The height the header names
16 height: u64,
17 },
18
19 /// The header is not the one the signed state id stands for
20 #[error("the header of block {height} does not hash to its state id")]
21 StateIdMismatch {
22 /// The height the header names
23 height: u64,
24 },
25
26 /// The header's time is before 1970 or too large to count in milliseconds
27 #[error("block {height} has a time outside the range of a state id")]
28 TimeOutOfRange {
29 /// The height the header names
30 height: u64,
31 },
32
33 /// Tenderdash's state id hashing failed
34 #[error("the state id of block {height} could not be hashed")]
35 StateIdNotHashed {
36 /// The height the header names
37 height: u64,
38 },
39
40 /// A height, round or quorum type no vote can carry
41 #[error("block {height} has a {field} outside the range of a vote")]
42 VoteFieldOutOfRange {
43 /// The height the header names
44 height: u64,
45 /// Which field is out of range
46 field: &'static str,
47 },
48
49 /// A transaction is said to be at a position its block does not have
50 #[error("position {index} is outside a block of {total} transactions")]
51 IndexOutOfRange {
52 /// The position the proof names
53 index: u32,
54 /// How many transactions the proof says the block holds
55 total: u32,
56 },
57
58 /// A Merkle path has the wrong number of hashes for its position, or an entry that is
59 /// not a hash
60 #[error("the Merkle path of position {index} in a block of {total} transactions is malformed")]
61 MalformedPath {
62 /// The position the proof names
63 index: u32,
64 /// How many transactions the proof says the block holds
65 total: u32,
66 },
67
68 /// A transaction's path does not lead to the header's `data_hash`
69 #[error("the transaction at position {index} is not under the data hash of block {height}")]
70 TransactionNotInBlock {
71 /// The height the header names
72 height: u64,
73 /// The position the proof names
74 index: u32,
75 },
76
77 /// A result's path does not lead to the header's `results_hash`
78 #[error(
79 "the result of the transaction at position {index} is not under the results hash of block {height}"
80 )]
81 ResultNotInBlock {
82 /// The height the header names
83 height: u64,
84 /// The position the proof names
85 index: u32,
86 },
87
88 /// A block's transactions do not hash to the header's `data_hash`
89 #[error("the transactions of block {height} do not hash to the root in its header")]
90 TransactionsRootMismatch {
91 /// The height the header names
92 height: u64,
93 },
94
95 /// A block's results do not hash to the header's `results_hash`
96 #[error("the results of block {height} do not hash to the root in its header")]
97 ResultsRootMismatch {
98 /// The height the header names
99 height: u64,
100 },
101
102 /// The proved block is not the one that was asked for
103 #[error("asked for block {requested} but the proof is of block {proved}")]
104 WrongBlock {
105 /// The height the request names
106 requested: u64,
107 /// The height the proved header names
108 proved: u64,
109 },
110
111 /// More blocks came back than were asked for
112 #[error("asked for {requested} blocks but {returned} came back")]
113 TooManyBlocks {
114 /// The count the request names
115 requested: u32,
116 /// How many blocks the answer holds
117 returned: usize,
118 },
119
120 /// A field a block repeats from its header differs from the signed header
121 #[error("the {field} of block {height} is not the one in its signed header")]
122 FieldMismatch {
123 /// The height the header names
124 height: u64,
125 /// Which field differs
126 field: &'static str,
127 },
128
129 /// A transaction comes without the hash Tenderdash knows it by
130 #[error("the hash of transaction {position} of block {height} is not its SHA-256")]
131 TransactionHashMismatch {
132 /// The height the header names
133 height: u64,
134 /// The transaction's place in the answer
135 position: usize,
136 },
137
138 /// A transaction of a proved answer comes without its Merkle paths
139 #[error("transaction {position} of block {height} has no proof")]
140 MissingTransactionProof {
141 /// The height the header names
142 height: u64,
143 /// The transaction's place in the answer
144 position: usize,
145 },
146
147 /// The transactions of an answer disagree on the size of their block
148 #[error("the transactions of block {height} disagree on how many it holds")]
149 InconsistentTotal {
150 /// The height the header names
151 height: u64,
152 },
153
154 /// The transactions of an answer are not in block order, or one is there twice
155 #[error("the transactions of block {height} are not in block order")]
156 NotInBlockOrder {
157 /// The height the header names
158 height: u64,
159 },
160
161 /// A transaction of the answer belongs to someone else, or to no one
162 #[error("transaction {position} of block {height} is not the requested owner's")]
163 NotTheOwners {
164 /// The height the header names
165 height: u64,
166 /// The transaction's place in the answer
167 position: usize,
168 },
169}