@@ -37,8 +37,14 @@ pub fn recv_packet_execute<ExecCtx>(
37
37
where
38
38
ExecCtx : ExecutionContext ,
39
39
{
40
- let chan_end_path_on_b =
41
- ChannelEndPath :: new ( & msg. packet . port_id_on_b , & msg. packet . chan_id_on_b ) ;
40
+ let packet = & msg. packet ;
41
+ let payload = & packet. payloads [ 0 ] ;
42
+
43
+ let port_id_on_b = & payload. header . target_port . 1 ;
44
+ let channel_id_on_b = & packet. header . target_client ;
45
+ let seq_on_a = & packet. header . seq_on_a ;
46
+
47
+ let chan_end_path_on_b = ChannelEndPath :: new ( port_id_on_b, channel_id_on_b) ;
42
48
let chan_end_on_b = ctx_b. channel_end ( & chan_end_path_on_b) ?;
43
49
44
50
// Check if another relayer already relayed the packet.
@@ -48,19 +54,16 @@ where
48
54
// Note: ibc-go doesn't make the check for `Order::None` channels
49
55
Order :: None => false ,
50
56
Order :: Unordered => {
51
- let packet = & msg. packet ;
52
- let receipt_path_on_b =
53
- ReceiptPath :: new ( & packet. port_id_on_b , & packet. chan_id_on_b , packet. seq_on_a ) ;
57
+ let receipt_path_on_b = ReceiptPath :: new ( port_id_on_b, channel_id_on_b, * seq_on_a) ;
54
58
ctx_b. get_packet_receipt ( & receipt_path_on_b) ?. is_ok ( )
55
59
}
56
60
Order :: Ordered => {
57
- let seq_recv_path_on_b =
58
- SeqRecvPath :: new ( & msg. packet . port_id_on_b , & msg. packet . chan_id_on_b ) ;
61
+ let seq_recv_path_on_b = SeqRecvPath :: new ( port_id_on_b, channel_id_on_b) ;
59
62
let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
60
63
61
64
// the sequence number has already been incremented, so
62
65
// another relayer already relayed the packet
63
- msg . packet . seq_on_a < next_seq_recv
66
+ seq_on_a < & next_seq_recv
64
67
}
65
68
} ;
66
69
@@ -77,26 +80,21 @@ where
77
80
match chan_end_on_b. ordering {
78
81
Order :: Unordered => {
79
82
let receipt_path_on_b = ReceiptPath {
80
- port_id : msg . packet . port_id_on_b . clone ( ) ,
81
- channel_id : msg . packet . chan_id_on_b . clone ( ) ,
82
- sequence : msg . packet . seq_on_a ,
83
+ port_id : port_id_on_b. clone ( ) ,
84
+ channel_id : channel_id_on_b . clone ( ) ,
85
+ sequence : * seq_on_a,
83
86
} ;
84
87
85
88
ctx_b. store_packet_receipt ( & receipt_path_on_b, Receipt :: Ok ) ?;
86
89
}
87
90
Order :: Ordered => {
88
- let seq_recv_path_on_b =
89
- SeqRecvPath :: new ( & msg. packet . port_id_on_b , & msg. packet . chan_id_on_b ) ;
91
+ let seq_recv_path_on_b = SeqRecvPath :: new ( port_id_on_b, channel_id_on_b) ;
90
92
let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
91
93
ctx_b. store_next_sequence_recv ( & seq_recv_path_on_b, next_seq_recv. increment ( ) ) ?;
92
94
}
93
95
_ => { }
94
96
}
95
- let ack_path_on_b = AckPath :: new (
96
- & msg. packet . port_id_on_b ,
97
- & msg. packet . chan_id_on_b ,
98
- msg. packet . seq_on_a ,
99
- ) ;
97
+ let ack_path_on_b = AckPath :: new ( port_id_on_b, channel_id_on_b, * seq_on_a) ;
100
98
// `writeAcknowledgement` handler state changes
101
99
ctx_b. store_packet_acknowledgement (
102
100
& ack_path_on_b,
@@ -143,16 +141,22 @@ where
143
141
{
144
142
ctx_b. validate_message_signer ( & msg. signer ) ?;
145
143
146
- let chan_end_path_on_b =
147
- ChannelEndPath :: new ( & msg. packet . port_id_on_b , & msg. packet . chan_id_on_b ) ;
144
+ let packet = & msg. packet ;
145
+ let payload = & packet. payloads [ 0 ] ;
146
+
147
+ let port_id_on_a = & payload. header . source_port . 1 ;
148
+ let channel_id_on_a = & packet. header . source_client ;
149
+ let port_id_on_b = & payload. header . target_port . 1 ;
150
+ let channel_id_on_b = & packet. header . target_client ;
151
+ let seq_on_a = & packet. header . seq_on_a ;
152
+ let data = & payload. data ;
153
+
154
+ let chan_end_path_on_b = ChannelEndPath :: new ( port_id_on_b, channel_id_on_b) ;
148
155
let chan_end_on_b = ctx_b. channel_end ( & chan_end_path_on_b) ?;
149
156
150
157
chan_end_on_b. verify_state_matches ( & ChannelState :: Open ) ?;
151
158
152
- let counterparty = Counterparty :: new (
153
- msg. packet . port_id_on_a . clone ( ) ,
154
- Some ( msg. packet . chan_id_on_a . clone ( ) ) ,
155
- ) ;
159
+ let counterparty = Counterparty :: new ( port_id_on_a. clone ( ) , Some ( channel_id_on_a. clone ( ) ) ) ;
156
160
157
161
chan_end_on_b. verify_counterparty_matches ( & counterparty) ?;
158
162
@@ -162,16 +166,16 @@ where
162
166
conn_end_on_b. verify_state_matches ( & ConnectionState :: Open ) ?;
163
167
164
168
let latest_height = ctx_b. host_height ( ) ?;
165
- if msg . packet . timeout_height_on_b . has_expired ( latest_height) {
169
+ if packet. header . timeout_height_on_b . has_expired ( latest_height) {
166
170
return Err ( ChannelError :: InsufficientPacketHeight {
167
171
chain_height : latest_height,
168
- timeout_height : msg . packet . timeout_height_on_b ,
172
+ timeout_height : packet. header . timeout_height_on_b ,
169
173
} ) ;
170
174
}
171
175
172
176
let latest_timestamp = ctx_b. host_timestamp ( ) ?;
173
- if msg
174
- . packet
177
+ if packet
178
+ . header
175
179
. timeout_timestamp_on_b
176
180
. has_expired ( & latest_timestamp)
177
181
{
@@ -200,15 +204,11 @@ where
200
204
client_val_ctx_b. consensus_state ( & client_cons_state_path_on_b) ?;
201
205
202
206
let expected_commitment_on_a = compute_packet_commitment (
203
- & msg. packet . data ,
204
- & msg. packet . timeout_height_on_b ,
205
- & msg. packet . timeout_timestamp_on_b ,
206
- ) ;
207
- let commitment_path_on_a = CommitmentPath :: new (
208
- & msg. packet . port_id_on_a ,
209
- & msg. packet . chan_id_on_a ,
210
- msg. packet . seq_on_a ,
207
+ data,
208
+ & packet. header . timeout_height_on_b ,
209
+ & packet. header . timeout_timestamp_on_b ,
211
210
) ;
211
+ let commitment_path_on_a = CommitmentPath :: new ( port_id_on_a, channel_id_on_a, * seq_on_a) ;
212
212
213
213
verify_conn_delay_passed ( ctx_b, msg. proof_height_on_a , & conn_end_on_b) ?;
214
214
@@ -224,17 +224,16 @@ where
224
224
225
225
match chan_end_on_b. ordering {
226
226
Order :: Ordered => {
227
- let seq_recv_path_on_b =
228
- SeqRecvPath :: new ( & msg. packet . port_id_on_b , & msg. packet . chan_id_on_b ) ;
227
+ let seq_recv_path_on_b = SeqRecvPath :: new ( port_id_on_b, channel_id_on_b) ;
229
228
let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
230
- if msg . packet . seq_on_a > next_seq_recv {
229
+ if seq_on_a > & next_seq_recv {
231
230
return Err ( ChannelError :: MismatchedPacketSequence {
232
- actual : msg . packet . seq_on_a ,
231
+ actual : * seq_on_a,
233
232
expected : next_seq_recv,
234
233
} ) ;
235
234
}
236
235
237
- if msg . packet . seq_on_a == next_seq_recv {
236
+ if seq_on_a == & next_seq_recv {
238
237
// Case where the recvPacket is successful and an
239
238
// acknowledgement will be written (not a no-op)
240
239
validate_write_acknowledgement ( ctx_b, msg) ?;
@@ -265,10 +264,16 @@ fn validate_write_acknowledgement<Ctx>(ctx_b: &Ctx, msg: &MsgRecvPacket) -> Resu
265
264
where
266
265
Ctx : ValidationContext ,
267
266
{
268
- let packet = msg. packet . clone ( ) ;
269
- let ack_path_on_b = AckPath :: new ( & packet. port_id_on_b , & packet. chan_id_on_b , packet. seq_on_a ) ;
267
+ let packet = & msg. packet ;
268
+ let payload = & packet. payloads [ 0 ] ;
269
+
270
+ let port_id_on_b = & payload. header . target_port . 1 ;
271
+ let channel_id_on_b = & packet. header . target_client ;
272
+ let seq_on_a = & packet. header . seq_on_a ;
273
+
274
+ let ack_path_on_b = AckPath :: new ( port_id_on_b, channel_id_on_b, * seq_on_a) ;
270
275
if ctx_b. get_packet_acknowledgement ( & ack_path_on_b) . is_ok ( ) {
271
- return Err ( ChannelError :: DuplicateAcknowledgment ( msg . packet . seq_on_a ) ) ;
276
+ return Err ( ChannelError :: DuplicateAcknowledgment ( * seq_on_a) ) ;
272
277
}
273
278
274
279
Ok ( ( ) )
0 commit comments