@@ -7,7 +7,8 @@ use ibc_eureka_core_channel_types::msgs::MsgRecvPacket;
7
7
use ibc_eureka_core_client:: context:: prelude:: * ;
8
8
use ibc_eureka_core_handler_types:: events:: { IbcEvent , MessageEvent } ;
9
9
use ibc_eureka_core_host:: types:: path:: {
10
- AckPath , ClientConsensusStatePath , CommitmentPath , Path , ReceiptPath , SeqRecvPath ,
10
+ AckPathV2 as AckPath , ClientConsensusStatePath , CommitmentPathV2 as CommitmentPath , Path ,
11
+ ReceiptPathV2 as ReceiptPath , SeqRecvPathV2 as SeqRecvPath ,
11
12
} ;
12
13
use ibc_eureka_core_host:: { ExecutionContext , ValidationContext } ;
13
14
use ibc_eureka_core_router:: module:: Module ;
@@ -35,16 +36,23 @@ where
35
36
let packet = & msg. packet ;
36
37
let payload = & packet. payloads [ 0 ] ;
37
38
38
- let ( _ , target_port ) = & payload. header . target_port ;
39
+ let ( source_prefix , _source_port ) = & payload. header . source_port ;
39
40
let channel_source_client_on_target = & packet. header . source_client_on_target ;
41
+ let ( target_prefix, _target_port) = & payload. header . target_port ;
42
+ let channel_target_client_on_source = & packet. header . target_client_on_source ;
40
43
let seq_on_a = & packet. header . seq_on_a ;
41
44
42
45
// Check if another relayer already relayed the packet.
43
46
// We don't want to fail the transaction in this case.
44
47
{
45
48
let packet_already_received = {
46
- let receipt_path_on_b =
47
- ReceiptPath :: new ( target_port, channel_source_client_on_target, * seq_on_a) ;
49
+ let receipt_path_on_b = ReceiptPath :: new (
50
+ channel_source_client_on_target. as_ref ( ) ,
51
+ & format ! ( "{source_prefix:?}" ) ,
52
+ channel_target_client_on_source. as_ref ( ) ,
53
+ & format ! ( "{target_prefix:?}" ) ,
54
+ seq_on_a,
55
+ ) ;
48
56
ctx_b. get_packet_receipt ( & receipt_path_on_b) ?. is_ok ( )
49
57
} ;
50
58
@@ -59,11 +67,22 @@ where
59
67
{
60
68
// `recvPacket` core handler state changes
61
69
{
62
- let seq_recv_path_on_b = SeqRecvPath :: new ( target_port, channel_source_client_on_target) ;
70
+ let seq_recv_path_on_b = SeqRecvPath :: new (
71
+ channel_source_client_on_target. as_ref ( ) ,
72
+ & format ! ( "{source_prefix:?}" ) ,
73
+ channel_target_client_on_source. as_ref ( ) ,
74
+ & format ! ( "{target_prefix:?}" ) ,
75
+ ) ;
63
76
let next_seq_recv = ctx_b. get_next_sequence_recv ( & seq_recv_path_on_b) ?;
64
77
ctx_b. store_next_sequence_recv ( & seq_recv_path_on_b, next_seq_recv. increment ( ) ) ?;
65
78
}
66
- let ack_path_on_b = AckPath :: new ( target_port, channel_source_client_on_target, * seq_on_a) ;
79
+ let ack_path_on_b = AckPath :: new (
80
+ channel_source_client_on_target. as_ref ( ) ,
81
+ & format ! ( "{source_prefix:?}" ) ,
82
+ channel_target_client_on_source. as_ref ( ) ,
83
+ & format ! ( "{target_prefix:?}" ) ,
84
+ seq_on_a,
85
+ ) ;
67
86
// `writeAcknowledgement` handler state changes
68
87
ctx_b. store_packet_acknowledgement (
69
88
& ack_path_on_b,
@@ -105,8 +124,9 @@ where
105
124
let packet = & msg. packet ;
106
125
let payload = & packet. payloads [ 0 ] ;
107
126
108
- let ( prefix_source , source_port ) = & payload. header . source_port ;
127
+ let ( source_prefix , _source_port ) = & payload. header . source_port ;
109
128
let channel_target_client_on_source = & packet. header . target_client_on_source ;
129
+ let ( target_prefix, _target_port) = & payload. header . target_port ;
110
130
let channel_source_client_on_target = & packet. header . source_client_on_target ;
111
131
let seq_on_a = & packet. header . seq_on_a ;
112
132
let data = & payload. data ;
@@ -157,15 +177,20 @@ where
157
177
& packet. header . timeout_height_on_b ,
158
178
& packet. header . timeout_timestamp_on_b ,
159
179
) ;
160
- let commitment_path_on_a =
161
- CommitmentPath :: new ( source_port, channel_target_client_on_source, * seq_on_a) ;
180
+ let commitment_path_on_a = CommitmentPath :: new (
181
+ channel_source_client_on_target. as_ref ( ) ,
182
+ & format ! ( "{source_prefix:?}" ) ,
183
+ channel_target_client_on_source. as_ref ( ) ,
184
+ & format ! ( "{target_prefix:?}" ) ,
185
+ seq_on_a,
186
+ ) ;
162
187
163
188
// Verify the proof for the packet against the chain store.
164
189
source_client_on_target. verify_membership (
165
- prefix_source ,
190
+ source_prefix ,
166
191
& msg. proof_commitment_on_a ,
167
192
consensus_state_of_a_on_b. root ( ) ,
168
- Path :: Commitment ( commitment_path_on_a) ,
193
+ Path :: CommitmentV2 ( commitment_path_on_a) ,
169
194
expected_commitment_on_a. into_vec ( ) ,
170
195
) ?;
171
196
}
@@ -191,11 +216,19 @@ where
191
216
let packet = & msg. packet ;
192
217
let payload = & packet. payloads [ 0 ] ;
193
218
194
- let ( _, target_port) = & payload. header . target_port ;
195
219
let channel_source_client_on_target = & packet. header . source_client_on_target ;
220
+ let ( target_prefix, _target_port) = & payload. header . target_port ;
221
+ let channel_target_client_on_source = & packet. header . target_client_on_source ;
222
+ let ( source_prefix, _source_port) = & payload. header . source_port ;
196
223
let seq_on_a = & packet. header . seq_on_a ;
197
224
198
- let ack_path_on_b = AckPath :: new ( target_port, channel_source_client_on_target, * seq_on_a) ;
225
+ let ack_path_on_b = AckPath :: new (
226
+ channel_source_client_on_target. as_ref ( ) ,
227
+ & format ! ( "{source_prefix:?}" ) ,
228
+ channel_target_client_on_source. as_ref ( ) ,
229
+ & format ! ( "{target_prefix:?}" ) ,
230
+ seq_on_a,
231
+ ) ;
199
232
if ctx_b. get_packet_acknowledgement ( & ack_path_on_b) . is_ok ( ) {
200
233
return Err ( ChannelError :: DuplicateAcknowledgment ( * seq_on_a) ) ;
201
234
}
0 commit comments