Skip to content

Commit af414ef

Browse files
committed
chore(movement-hubble): fixed wrong event names & params
Signed-off-by: Kaan Caglan <[email protected]>
1 parent 0a03a21 commit af414ef

File tree

16 files changed

+329
-341
lines changed

16 files changed

+329
-341
lines changed

aptos/ibc/sources/acknowledge_packet.move

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ module ibc::acknowledge_packet {
7878
packet_timeout_heights: vector<u64>,
7979
packet_timeout_timestamps: vector<u64>,
8080
acknowledgements: vector<vector<u8>>,
81+
maker: address,
8182
proof: vector<u8>,
8283
proof_height: u64
8384
) {
@@ -157,7 +158,7 @@ module ibc::acknowledge_packet {
157158

158159
dispatcher::delete_storage<T>();
159160

160-
ibc::emit_acknowledge_packet(packet, acknowledgement);
161+
ibc::emit_acknowledge_packet(packet, acknowledgement, maker);
161162

162163
i = i + 1;
163164
}

aptos/ibc/sources/cometbls_lc.move

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ module ibc::cometbls_lc {
7070
use ibc::bcs_utils;
7171
use ibc::groth16_verifier::{Self, ZKP};
7272
use ibc::height::{Self, Height};
73-
use ibc::consensus_state_update::{Self, ConsensusStateUpdate};
7473

7574
const E_INVALID_CLIENT_STATE: u64 = 35100;
7675
const E_CONSENSUS_STATE_TIMESTAMP_ZERO: u64 = 35101;
@@ -138,7 +137,7 @@ module ibc::cometbls_lc {
138137
client_id: u32,
139138
client_state_bytes: vector<u8>,
140139
consensus_state_bytes: vector<u8>
141-
): (ConsensusStateUpdate, String) {
140+
): (vector<u8>, vector<u8>, String) {
142141
let client_state = decode_client_state(client_state_bytes);
143142
let consensus_state = decode_consensus_state(consensus_state_bytes);
144143

@@ -164,12 +163,8 @@ module ibc::cometbls_lc {
164163
let client_signer = object::generate_signer(&store_constructor);
165164

166165
move_to(&client_signer, state);
167-
let state_update = ConsensusStateUpdate {
168-
client_state_commitment: encode_client_state(&client_state),
169-
consensus_state_commitment: encode_consensus_state(&consensus_state),
170-
height: client_state.latest_height
171-
};
172-
(state_update, client_state.chain_id)
166+
167+
(client_state_bytes, consensus_state_bytes, client_state.chain_id)
173168
}
174169

175170
public fun latest_height(client_id: u32): u64 acquires State {
@@ -708,7 +703,7 @@ module ibc::cometbls_lc {
708703
next_validators_hash: x"0000000000000000000000000000000000000000000000000000000000000000"
709704
};
710705

711-
let (cs, cons) =
706+
let (cs, cons, _counterparty_channel_id) =
712707
create_client(
713708
ibc_signer,
714709
0,
@@ -735,7 +730,7 @@ module ibc::cometbls_lc {
735730
client_state.trusting_period = 2;
736731
consensus_state.timestamp = 20000;
737732

738-
let (cs, cons) =
733+
let (cs, cons, _counterparty_channel_id) =
739734
create_client(
740735
ibc_signer,
741736
2,

aptos/ibc/sources/ibc.move

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module ibc::ibc {
149149
struct CreateClient has copy, drop, store {
150150
client_id: u32,
151151
client_type: String,
152-
counterpaty_chain_id: String
152+
counterparty_chain_id: String
153153
}
154154

155155
#[event]
@@ -229,18 +229,22 @@ module ibc::ibc {
229229

230230
#[event]
231231
struct RecvIntentPacket has drop, store {
232-
packet: Packet
232+
packet: Packet,
233+
maker: address,
234+
maker_msg: vector<u8>
233235
}
234236

235237
#[event]
236238
struct PacketRecv has drop, store {
237-
packet: Packet
239+
packet: Packet,
240+
maker: address,
241+
maker_msg: vector<u8>
238242
}
239243

240244
#[event]
241245
struct PacketSend has drop, store {
242-
source_channel_id: u32,
243-
destination_channel_id: u32,
246+
source_channel: u32,
247+
destination_channel: u32,
244248
data: vector<u8>,
245249
timeout_height: u64,
246250
timeout_timestamp: u64
@@ -254,7 +258,8 @@ module ibc::ibc {
254258
#[event]
255259
struct PacketAck has drop, store {
256260
packet: Packet,
257-
acknowledgement: vector<u8>
261+
acknowledgement: vector<u8>,
262+
maker: address,
258263
}
259264

260265
#[event]
@@ -330,7 +335,7 @@ module ibc::ibc {
330335
let client_id = generate_client_identifier();
331336
let store = borrow_global_mut<IBCStore>(get_vault_addr());
332337

333-
let (update, counterparty_chain_id) =
338+
let (client_state, consensus_state, counterparty_chain_id) =
334339
light_client::create_client(
335340
client_type,
336341
&get_ibc_signer(),
@@ -348,19 +353,19 @@ module ibc::ibc {
348353
table::upsert(
349354
&mut store.commitments,
350355
commitment::client_state_commitment_key(client_id),
351-
update.client_state_commitment
356+
client_state
352357
);
353358

354359
let latest_height = light_client::latest_height(client_type, client_id);
355360

356361
table::upsert(
357362
&mut store.commitments,
358363
commitment::consensus_state_commitment_key(client_id, latest_height),
359-
update.consensus_state_commitment
364+
consensus_state
360365
);
361366

362367
event::emit(
363-
CreateClient { client_id, client_type, counterpaty_chain_id: latest_height }
368+
CreateClient { client_id, client_type, counterparty_chain_id: counterparty_chain_id }
364369
);
365370
}
366371

@@ -1036,7 +1041,7 @@ module ibc::ibc {
10361041
///
10371042
/// * `ibc_app`: The signer of the calling contract.
10381043
/// * `source_port`: The address of the calling contract.
1039-
/// * `source_channel_id`: The source channel that will be used for sending this packet.
1044+
/// * `source_channel`: The source channel that will be used for sending this packet.
10401045
/// * `timeout_height`: The height in the COUNTERPARTY chain when this packet will time out. `0` means none, but note that both
10411046
/// `timeout_height` and `timeout_timestamp` cannot be `0`.
10421047
/// * `timeout_timestamp`: The timestamp when this packet will time out. `0` means none, but note that both `timeout_height`
@@ -1045,7 +1050,7 @@ module ibc::ibc {
10451050
public fun send_packet(
10461051
ibc_app: &signer,
10471052
source_port: address,
1048-
source_channel_id: u32,
1053+
source_channel: u32,
10491054
timeout_height: u64,
10501055
timeout_timestamp: u64,
10511056
data: vector<u8>
@@ -1056,21 +1061,21 @@ module ibc::ibc {
10561061
abort E_TIMEOUT_MUST_BE_SET
10571062
};
10581063

1059-
let channel = ensure_channel_state(source_channel_id);
1064+
let channel = ensure_channel_state(source_channel);
10601065

10611066
let store = borrow_global_mut<IBCStore>(get_vault_addr());
10621067

10631068
let packet =
10641069
packet::new(
1065-
source_channel_id,
1070+
source_channel,
10661071
channel::counterparty_channel_id(&channel),
10671072
data,
10681073
timeout_height,
10691074
timeout_timestamp
10701075
);
10711076
let commitment_key =
10721077
commitment::batch_packets_commitment_key(
1073-
source_channel_id, commitment::commit_packet(&packet)
1078+
source_channel, commitment::commit_packet(&packet)
10741079
);
10751080
table::upsert(
10761081
&mut store.commitments,
@@ -1080,8 +1085,8 @@ module ibc::ibc {
10801085

10811086
event::emit(
10821087
PacketSend {
1083-
source_channel_id: source_channel_id,
1084-
destination_channel_id: channel::counterparty_channel_id(&channel),
1088+
source_channel: source_channel,
1089+
destination_channel: channel::counterparty_channel_id(&channel),
10851090
data: data,
10861091
timeout_height: timeout_height,
10871092
timeout_timestamp: timeout_timestamp
@@ -1155,9 +1160,9 @@ module ibc::ibc {
11551160
packet_timeout_timestamp
11561161
);
11571162

1158-
let source_channel_id = packet::source_channel_id(&packet);
1159-
let destination_channel_id = packet::destination_channel_id(&packet);
1160-
let channel = ensure_channel_state(source_channel_id);
1163+
let source_channel = packet::source_channel_id(&packet);
1164+
let destination_channel = packet::destination_channel_id(&packet);
1165+
let channel = ensure_channel_state(source_channel);
11611166
let client_id = ensure_connection_state(channel::connection_id(&channel));
11621167
let client_type = client_id_to_type(client_id);
11631168

@@ -1167,7 +1172,7 @@ module ibc::ibc {
11671172

11681173
let commitment_key =
11691174
commitment::batch_receipts_commitment_key(
1170-
destination_channel_id, commitment::commit_packet(&packet)
1175+
destination_channel, commitment::commit_packet(&packet)
11711176
);
11721177
let err =
11731178
verify_absent_commitment(
@@ -1195,7 +1200,7 @@ module ibc::ibc {
11951200

11961201
let commitment_key =
11971202
commitment::batch_packets_commitment_key(
1198-
source_channel_id, commitment::commit_packet(&packet)
1203+
source_channel, commitment::commit_packet(&packet)
11991204
);
12001205
table::remove(
12011206
&mut borrow_global_mut<IBCStore>(get_vault_addr()).commitments,
@@ -1345,12 +1350,12 @@ module ibc::ibc {
13451350
}
13461351

13471352
fun set_next_sequence_recv(
1348-
destination_channel_id: u32, received_sequence: u64
1353+
destination_channel: u32, received_sequence: u64
13491354
) acquires IBCStore {
13501355
let store = borrow_global_mut<IBCStore>(get_vault_addr());
13511356

13521357
let next_sequence_recv_key =
1353-
commitment::next_sequence_recv_commitment_key(destination_channel_id);
1358+
commitment::next_sequence_recv_commitment_key(destination_channel);
13541359

13551360
let expected_recv_sequence =
13561361
from_bcs::to_u64(
@@ -1368,10 +1373,10 @@ module ibc::ibc {
13681373
);
13691374
}
13701375

1371-
fun set_next_sequence_ack(source_channel_id: u32, ack_sequence: u64) acquires IBCStore {
1376+
fun set_next_sequence_ack(source_channel: u32, ack_sequence: u64) acquires IBCStore {
13721377
let store = borrow_global_mut<IBCStore>(get_vault_addr());
13731378

1374-
let commitment_key = commitment::next_sequence_ack_commitment_key(source_channel_id);
1379+
let commitment_key = commitment::next_sequence_ack_commitment_key(source_channel);
13751380

13761381
let expected_ack_sequence =
13771382
from_bcs::to_u64(*table::borrow(&store.commitments, commitment_key));
@@ -1583,18 +1588,18 @@ module ibc::ibc {
15831588
string_utils::to_string(&bcs::to_bytes(&addr))
15841589
}
15851590

1586-
public(friend) fun emit_recv_packet(packet: Packet) {
1587-
event::emit(PacketRecv { packet })
1591+
public(friend) fun emit_recv_packet(packet: Packet, maker: address, maker_msg: vector<u8>) {
1592+
event::emit(PacketRecv { packet, maker, maker_msg })
15881593
}
15891594

1590-
public(friend) fun emit_recv_intent_packet(packet: Packet) {
1591-
event::emit(RecvIntentPacket { packet })
1595+
public(friend) fun emit_recv_intent_packet(packet: Packet, maker: address, maker_msg: vector<u8>) {
1596+
event::emit(RecvIntentPacket { packet, maker, maker_msg })
15921597
}
15931598

15941599
public(friend) fun emit_acknowledge_packet(
1595-
packet: Packet, acknowledgement: vector<u8>
1600+
packet: Packet, acknowledgement: vector<u8>, maker: address
15961601
) {
1597-
event::emit(PacketAck { packet, acknowledgement });
1602+
event::emit(PacketAck { packet, acknowledgement, maker });
15981603
}
15991604

16001605
// #[test(ibc_signer = @ibc)]

aptos/ibc/sources/light_client.move

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ module ibc::light_client {
6262
use ibc::cometbls_lc;
6363
use ibc::state_lens_ics23_mpt_lc;
6464
use ibc::state_lens_ics23_ics23_lc;
65-
use ibc::consensus_state_update::{ConsensusStateUpdate, Self};
6665
use std::string::{Self, String};
6766

6867
const E_UNKNOWN_CLIENT_TYPE: u64 = 1;
@@ -76,34 +75,34 @@ module ibc::light_client {
7675
client_id: u32,
7776
client_state_bytes: vector<u8>,
7877
consensus_state_bytes: vector<u8>
79-
): (ConsensusStateUpdate, String) {
78+
): (vector<u8>, vector<u8>, String) {
8079
if (string::bytes(&client_type) == &CLIENT_TYPE_COMETBLS) {
81-
let (client_state, counterpaty_chain_id) =
80+
let (client_state, consensus_state, counterparty_chain_id) =
8281
cometbls_lc::create_client(
8382
ibc_signer,
8483
client_id,
8584
client_state_bytes,
8685
consensus_state_bytes
8786
);
88-
return (client_state, counterpaty_chain_id)
87+
return (client_state, consensus_state, counterparty_chain_id)
8988
} else if (string::bytes(&client_type) == &CLIENT_TYPE_STATE_LENS_ICS23_MPT) {
90-
let (client_state, counterpaty_chain_id) =
89+
let (client_state, consensus_state, counterparty_chain_id) =
9190
state_lens_ics23_mpt_lc::create_client(
9291
ibc_signer,
9392
client_id,
9493
client_state_bytes,
9594
consensus_state_bytes
9695
);
97-
return (client_state, counterpaty_chain_id)
96+
return (client_state, consensus_state, counterparty_chain_id)
9897
} else if (string::bytes(&client_type) == &CLIENT_TYPE_STATE_LENS_ICS23_ICS23) {
99-
let (client_state, counterpaty_chain_id) =
98+
let (client_state, consensus_state, counterparty_chain_id) =
10099
state_lens_ics23_ics23_lc::create_client(
101100
ibc_signer,
102101
client_id,
103102
client_state_bytes,
104103
consensus_state_bytes
105104
);
106-
return (client_state, counterpaty_chain_id)
105+
return (client_state, consensus_state, counterparty_chain_id)
107106
};
108107
abort E_UNKNOWN_CLIENT_TYPE
109108

aptos/ibc/sources/recv_packet.move

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ module ibc::recv_packet {
8484
packet_data: vector<vector<u8>>,
8585
packet_timeout_heights: vector<u64>,
8686
packet_timeout_timestamps: vector<u64>,
87+
relayer_msgs: vector<vector<u8>>,
88+
relayer: address,
8789
proof: vector<u8>,
8890
proof_height: u64
8991
) {
@@ -106,11 +108,13 @@ module ibc::recv_packet {
106108
i = i + 1;
107109
};
108110

109-
process_receive<T>(packets, proof_height, proof, false);
111+
process_receive<T>(packets, relayer, relayer_msgs, proof_height, proof, false);
110112
}
111113

112114
public fun process_receive<T: key + store + drop>(
113115
packets: vector<Packet>,
116+
maker: address,
117+
maker_msgs: vector<vector<u8>>,
114118
proof_height: u64,
115119
proof: vector<u8>,
116120
intent: bool
@@ -183,6 +187,7 @@ module ibc::recv_packet {
183187
);
184188

185189
if (!set_packet_receive(commitment_key)) {
190+
let maker_msg = *vector::borrow(&maker_msgs, i);
186191
let acknowledgement =
187192
if (intent) {
188193
let param = helpers::pack_recv_intent_packet_params(packet, @ibc, b"");
@@ -191,7 +196,7 @@ module ibc::recv_packet {
191196
let ack = dispatcher::get_return_value<T>();
192197

193198
dispatcher::delete_storage<T>();
194-
ibc::emit_recv_intent_packet(packet);
199+
ibc::emit_recv_intent_packet(packet, maker, maker_msg);
195200
ack
196201
} else {
197202
let param = helpers::pack_recv_packet_params(packet, @ibc, b"");
@@ -200,7 +205,7 @@ module ibc::recv_packet {
200205
let ack = dispatcher::get_return_value<T>();
201206

202207
dispatcher::delete_storage<T>();
203-
ibc::emit_recv_packet(packet);
208+
ibc::emit_recv_packet(packet, maker, maker_msg);
204209
ack
205210
};
206211
if (vector::length(&acknowledgement) > 0) {

0 commit comments

Comments
 (0)