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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
use super::packet::Sequence;
use crate::core::ics02_client::error as client_error;
use crate::core::ics03_connection::error as connection_error;
use crate::core::ics04_channel::channel::State;
use crate::core::ics24_host::error::ValidationError;
use crate::core::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
use crate::prelude::*;
use crate::proofs::ProofError;
use crate::timestamp::Timestamp;
use crate::Height;
use flex_error::{define_error, TraceError};
use tendermint_proto::Error as TendermintError;
define_error! {
#[derive(Debug, PartialEq, Eq)]
Error {
Ics03Connection
[ connection_error::Error ]
| _ | { "ics03 connection error" },
UnknownState
{ state: i32 }
| e | { format_args!("channel state unknown: {}", e.state) },
Identifier
[ ValidationError ]
| _ | { "identifier error" },
UnknownOrderType
{ type_id: String }
| e | { format_args!("channel order type unknown: {}", e.type_id) },
InvalidConnectionHopsLength
{ expected: usize, actual: usize }
| e | {
format_args!(
"invalid connection hops length: expected {0}; actual {1}",
e.expected, e.actual)
},
InvalidPacketCounterparty
{ port_id: PortId, channel_id: ChannelId }
| e | {
format_args!(
"packet destination port {} and channel {} doesn't match the counterparty's port/channel",
e.port_id, e.channel_id)
},
InvalidVersion
[ TraceError<TendermintError> ]
| _ | { "invalid version" },
EmptyVersion
| _ | { "empty version string" },
InvalidSigner
| _ | { "invalid signer address" },
InvalidProof
[ ProofError ]
| _ | { "invalid proof" },
MissingHeight
| _ | { "invalid proof: missing height" },
MissingNextRecvSeq
{ port_channel_id: (PortId, ChannelId) }
| e | {
format_args!("Missing sequence number for receiving packets on port {0} and channel {1}",
e.port_channel_id.0,
e.port_channel_id.1)
},
ZeroPacketSequence
| _ | { "packet sequence cannot be 0" },
ZeroPacketData
| _ | { "packet data bytes cannot be empty" },
ZeroPacketTimeout
| _ | { "packet timeout height and packet timeout timestamp cannot both be 0" },
InvalidTimeoutHeight
| _ | { "invalid timeout height for the packet" },
InvalidPacket
| _ | { "invalid packet" },
MissingPacket
| _ | { "there is no packet in this message" },
PacketAlreadyReceived
{ sequence: Sequence }
| e | {
format_args!(
"Packet with the sequence number {0} has been already received",
e.sequence)
},
MissingCounterparty
| _ | { "missing counterparty" },
NoCommonVersion
| _ | { "no commong version" },
MissingChannel
| _ | { "missing channel end" },
NoPortCapability
{ port_id: PortId }
| e | {
format_args!(
"the port {0} has no capability associated",
e.port_id)
},
InvalidPortCapability
| _ | { "the module associated with the port does not have the capability it needs" },
InvalidVersionLengthConnection
| _ | { "single version must be negociated on connection before opening channel" },
ChannelFeatureNotSuportedByConnection
| _ | { "the channel ordering is not supported by connection" },
ChannelNotFound
{ port_id: PortId, channel_id: ChannelId }
| e | {
format_args!(
"the channel end ({0}, {1}) does not exist",
e.port_id, e.channel_id)
},
ChannelMismatch
{ channel_id: ChannelId }
| e | {
format_args!(
"a different channel exists (was initialized) already for the same channel identifier {0}",
e.channel_id)
},
ConnectionNotOpen
{ connection_id: ConnectionId }
| e | {
format_args!(
"the associated connection {0} is not OPEN",
e.connection_id)
},
UndefinedConnectionCounterparty
{ connection_id: ConnectionId }
| e | {
format_args!(
"Undefined counterparty connection for {0}",
e.connection_id)
},
PacketVerificationFailed
{ sequence: Sequence }
[ client_error::Error ]
| e | {
format_args!(
"Verification fails for the packet with the sequence number {0}",
e.sequence)
},
VerifyChannelFailed
[ client_error::Error ]
| _ | {
"Error verifying channel state"
},
InvalidAcknowledgement
| _ | { "Acknowledgment cannot be empty" },
AcknowledgementExists
{ sequence: Sequence }
| e | {
format_args!(
"Packet acknowledgement exists for the packet with the sequence {0}",
e.sequence)
},
MissingNextSendSeq
{ port_channel_id: (PortId, ChannelId) }
| e | {
format_args!("Missing sequence number for sending packets on port {0} and channel {1}",
e.port_channel_id.0,
e.port_channel_id.1)
},
InvalidStringAsSequence
{ value: String }
[ TraceError<core::num::ParseIntError> ]
| e | {
format_args!(
"String {0} cannot be converted to packet sequence",
e.value)
},
InvalidPacketSequence
{
given_sequence: Sequence,
next_sequence: Sequence
}
| e | {
format_args!(
"Invalid packet sequence {0} ≠ next send sequence {1}",
e.given_sequence, e.next_sequence)
},
LowPacketHeight
{
chain_height: Height,
timeout_height: Height
}
| e | {
format_args!(
"Receiving chain block height {0} >= packet timeout height {1}",
e.chain_height, e.timeout_height)
},
PacketTimeoutHeightNotReached
{
timeout_height: Height,
chain_height: Height,
}
| e | {
format_args!(
"Packet timeout height {0} > chain height {1}",
e.timeout_height, e.chain_height)
},
PacketTimeoutTimestampNotReached
{
timeout_timestamp: Timestamp,
chain_timestamp: Timestamp,
}
| e | {
format_args!(
"Packet timeout timestamp {0} > chain timestamp {1}",
e.timeout_timestamp, e.chain_timestamp)
},
LowPacketTimestamp
| _ | { "Receiving chain block timestamp >= packet timeout timestamp" },
InvalidPacketTimestamp
[ crate::timestamp::ParseTimestampError ]
| _ | { "Invalid packet timeout timestamp value" },
ErrorInvalidConsensusState
| _ | { "Invalid timestamp in consensus state; timestamp must be a positive value" },
FrozenClient
{ client_id: ClientId }
| e | {
format_args!(
"Client with id {0} is frozen",
e.client_id)
},
InvalidCounterpartyChannelId
[ ValidationError ]
| _ | { "Invalid channel id in counterparty" },
InvalidChannelState
{ channel_id: ChannelId, state: State }
| e | {
format_args!(
"Channel {0} should not be state {1}",
e.channel_id, e.state)
},
ChannelClosed
{ channel_id: ChannelId }
| e | {
format_args!(
"Channel {0} is Closed",
e.channel_id)
},
ChanOpenAckProofVerification
| _ | { "Handshake proof verification fails at ChannelOpenAck" },
PacketCommitmentNotFound
{ sequence: Sequence }
| e | {
format_args!(
"Commitment for the packet {0} not found",
e.sequence)
},
IncorrectPacketCommitment
{ sequence: Sequence }
| e | {
format_args!(
"The stored commitment of the packet {0} is incorrect",
e.sequence)
},
PacketReceiptNotFound
{ sequence: Sequence }
| e | {
format_args!(
"Receipt for the packet {0} not found",
e.sequence)
},
PacketAcknowledgementNotFound
{ sequence: Sequence }
| e | {
format_args!(
"Acknowledgment for the packet {0} not found",
e.sequence)
},
MissingNextAckSeq
{ port_channel_id: (PortId, ChannelId) }
| e | {
format_args!("Missing sequence number for ack packets on port {0} and channel {1}",
e.port_channel_id.0,
e.port_channel_id.1)
},
ImplementationSpecific
| _ | { "implementation specific error" },
}
}
impl Error {
pub fn chan_open_confirm_proof_verification(e: Error) -> Error {
e.add_trace(&"Handshake proof verification fails at ChannelOpenConfirm")
}
}