@@ -37,8 +37,14 @@ pub fn recv_packet_execute<ExecCtx>(
3737where
3838 ExecCtx : ExecutionContext ,
3939{
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) ;
4248 let chan_end_on_b = ctx_b. channel_end ( & chan_end_path_on_b) ?;
4349
4450 // Check if another relayer already relayed the packet.
@@ -48,19 +54,16 @@ where
4854 // Note: ibc-go doesn't make the check for `Order::None` channels
4955 Order :: None => false ,
5056 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) ;
5458 ctx_b. get_packet_receipt ( & receipt_path_on_b) ?. is_ok ( )
5559 }
5660 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) ;
5962 let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
6063
6164 // the sequence number has already been incremented, so
6265 // another relayer already relayed the packet
63- msg . packet . seq_on_a < next_seq_recv
66+ seq_on_a < & next_seq_recv
6467 }
6568 } ;
6669
@@ -77,26 +80,21 @@ where
7780 match chan_end_on_b. ordering {
7881 Order :: Unordered => {
7982 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,
8386 } ;
8487
8588 ctx_b. store_packet_receipt ( & receipt_path_on_b, Receipt :: Ok ) ?;
8689 }
8790 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) ;
9092 let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
9193 ctx_b. store_next_sequence_recv ( & seq_recv_path_on_b, next_seq_recv. increment ( ) ) ?;
9294 }
9395 _ => { }
9496 }
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) ;
10098 // `writeAcknowledgement` handler state changes
10199 ctx_b. store_packet_acknowledgement (
102100 & ack_path_on_b,
@@ -143,16 +141,22 @@ where
143141{
144142 ctx_b. validate_message_signer ( & msg. signer ) ?;
145143
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) ;
148155 let chan_end_on_b = ctx_b. channel_end ( & chan_end_path_on_b) ?;
149156
150157 chan_end_on_b. verify_state_matches ( & ChannelState :: Open ) ?;
151158
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 ( ) ) ) ;
156160
157161 chan_end_on_b. verify_counterparty_matches ( & counterparty) ?;
158162
@@ -162,16 +166,16 @@ where
162166 conn_end_on_b. verify_state_matches ( & ConnectionState :: Open ) ?;
163167
164168 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) {
166170 return Err ( ChannelError :: InsufficientPacketHeight {
167171 chain_height : latest_height,
168- timeout_height : msg . packet . timeout_height_on_b ,
172+ timeout_height : packet. header . timeout_height_on_b ,
169173 } ) ;
170174 }
171175
172176 let latest_timestamp = ctx_b. host_timestamp ( ) ?;
173- if msg
174- . packet
177+ if packet
178+ . header
175179 . timeout_timestamp_on_b
176180 . has_expired ( & latest_timestamp)
177181 {
@@ -200,15 +204,11 @@ where
200204 client_val_ctx_b. consensus_state ( & client_cons_state_path_on_b) ?;
201205
202206 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 ,
211210 ) ;
211+ let commitment_path_on_a = CommitmentPath :: new ( port_id_on_a, channel_id_on_a, * seq_on_a) ;
212212
213213 verify_conn_delay_passed ( ctx_b, msg. proof_height_on_a , & conn_end_on_b) ?;
214214
@@ -224,17 +224,16 @@ where
224224
225225 match chan_end_on_b. ordering {
226226 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) ;
229228 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 {
231230 return Err ( ChannelError :: MismatchedPacketSequence {
232- actual : msg . packet . seq_on_a ,
231+ actual : * seq_on_a,
233232 expected : next_seq_recv,
234233 } ) ;
235234 }
236235
237- if msg . packet . seq_on_a == next_seq_recv {
236+ if seq_on_a == & next_seq_recv {
238237 // Case where the recvPacket is successful and an
239238 // acknowledgement will be written (not a no-op)
240239 validate_write_acknowledgement ( ctx_b, msg) ?;
@@ -265,10 +264,16 @@ fn validate_write_acknowledgement<Ctx>(ctx_b: &Ctx, msg: &MsgRecvPacket) -> Resu
265264where
266265 Ctx : ValidationContext ,
267266{
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) ;
270275 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) ) ;
272277 }
273278
274279 Ok ( ( ) )
0 commit comments