Skip to content

Commit c80a583

Browse files
committed
chore(sui): properly impl timeouts as well
Signed-off-by: aeryz <[email protected]>
1 parent c8449d5 commit c80a583

File tree

4 files changed

+127
-153
lines changed

4 files changed

+127
-153
lines changed

sui/ibc/Move.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[move]
44
version = 3
5-
manifest_digest = "3C33850FDD99F7DCB573743C746822C37C58B89B08DE0B01568A064B61FED55E"
5+
manifest_digest = "41B5AD688AF0B89940CBA45F5EF3EBB4005A184F20436E62FEE468996187406D"
66
deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C"
77
dependencies = [
88
{ id = "Bridge", name = "Bridge" },
@@ -13,7 +13,7 @@ dependencies = [
1313

1414
[[move.package]]
1515
id = "Bridge"
16-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/bridge" }
16+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/bridge" }
1717

1818
dependencies = [
1919
{ id = "MoveStdlib", name = "MoveStdlib" },
@@ -23,27 +23,27 @@ dependencies = [
2323

2424
[[move.package]]
2525
id = "MoveStdlib"
26-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/move-stdlib" }
26+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/move-stdlib" }
2727

2828
[[move.package]]
2929
id = "Sui"
30-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/sui-framework" }
30+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/sui-framework" }
3131

3232
dependencies = [
3333
{ id = "MoveStdlib", name = "MoveStdlib" },
3434
]
3535

3636
[[move.package]]
3737
id = "SuiSystem"
38-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/sui-system" }
38+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/sui-system" }
3939

4040
dependencies = [
4141
{ id = "MoveStdlib", name = "MoveStdlib" },
4242
{ id = "Sui", name = "Sui" },
4343
]
4444

4545
[move.toolchain-version]
46-
compiler-version = "1.55.0"
46+
compiler-version = "1.53.2"
4747
edition = "2024.beta"
4848
flavor = "sui"
4949

sui/ibc/sources/ibc.move

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ module ibc::ibc {
260260
}
261261

262262
public struct TimeoutPacket has drop, store, copy {
263-
packet: Packet
263+
packet_hash: vector<u8>
264264
}
265265

266266
public struct WriteAck has drop, store, copy {
@@ -1423,7 +1423,7 @@ module ibc::ibc {
14231423
commitment::batch_packets_commitment_key(
14241424
packet_hash
14251425
);
1426-
set_packet_acknowledged(ibc_store, commitment_key);
1426+
ibc_store.set_packet_acknowledged(commitment_key);
14271427

14281428
event::emit(
14291429
PacketAck {
@@ -1491,32 +1491,37 @@ module ibc::ibc {
14911491
*commitment = commitment::commit_ack(acknowledgement);
14921492
}
14931493

1494-
public fun timeout_packet(
1494+
public fun timeout_packet<T: drop>(
14951495
ibc_store: &mut IBCStore,
14961496
packet: Packet,
14971497
proof: vector<u8>,
14981498
proof_height: u64,
1499+
witness: T,
14991500
) {
1500-
let source_channel = packet::source_channel_id(&packet);
1501-
let destination_channel = packet::destination_channel_id(&packet);
1501+
let source_channel = packet.source_channel_id();
1502+
1503+
let port_id = *ibc_store.channel_to_port.borrow(source_channel);
1504+
validate_port(port_id, witness);
1505+
1506+
let destination_channel = packet.destination_channel_id();
15021507

15031508
if(!ibc_store.channels.contains(source_channel)) {
15041509
abort E_CHANNEL_NOT_FOUND
15051510
};
15061511
let channel = ibc_store.channels.borrow(source_channel);
1507-
assert!(channel::state(channel) == CHAN_STATE_OPEN, E_INVALID_CHANNEL_STATE);
1512+
assert!(channel.state() == CHAN_STATE_OPEN, E_INVALID_CHANNEL_STATE);
15081513

1509-
let connection_id = channel::connection_id(channel);
1514+
let connection_id = channel.connection_id();
15101515

15111516
if(!ibc_store.connections.contains(connection_id)) {
15121517
abort E_CONNECTION_NOT_FOUND
15131518
};
15141519
let connection = ibc_store.connections.borrow(connection_id);
15151520
assert!(
1516-
connection_end::state(connection) == CONN_STATE_OPEN,
1521+
connection.state() == CONN_STATE_OPEN,
15171522
E_INVALID_CONNECTION_STATE
15181523
);
1519-
let client_id = connection_end::client_id(connection);
1524+
let client_id = connection.client_id();
15201525

15211526
if(!ibc_store.client_mgr.exists(client_id)) {
15221527
abort E_CLIENT_NOT_FOUND
@@ -1525,36 +1530,30 @@ module ibc::ibc {
15251530
ibc_store.client_mgr.get_timestamp_at_height(client_id, proof_height);
15261531
assert!(proof_timestamp != 0, E_LATEST_TIMESTAMP_NOT_FOUND);
15271532

1533+
let packet_hash = commitment::commit_packet(&packet);
1534+
let commitment_key = commitment::batch_receipts_commitment_key(packet_hash);
1535+
1536+
let err = ibc_store.client_mgr.verify_non_membership(
1537+
client_id, proof_height, proof, commitment_key);
15281538

1529-
let commitment_key =
1530-
commitment::batch_receipts_commitment_key(
1531-
commitment::commit_packet(&packet)
1532-
);
1533-
let err = ibc_store.client_mgr.verify_non_membership(client_id, proof_height, proof, commitment_key);
15341539
assert!(err == 0, err);
15351540

1536-
if (packet::timeout_timestamp(&packet) != 0) {
1541+
if (packet.timeout_timestamp() == 0) {
1542+
abort E_TIMEOUT_MUST_BE_SET
1543+
} else {
15371544
assert!(
1538-
packet::timeout_timestamp(&packet) < proof_timestamp,
1545+
packet.timeout_timestamp() < proof_timestamp,
15391546
E_TIMESTAMP_TIMEOUT_NOT_REACHED
15401547
);
15411548
};
1542-
let height = packet::timeout_height(&packet);
1543-
if (height != 0) {
1544-
assert!(
1545-
height < proof_height,
1546-
E_TIMEOUT_HEIGHT_NOT_REACHED
1547-
);
1548-
};
15491549

1550-
let commitment_key =
1550+
ibc_store.set_packet_acknowledged(
15511551
commitment::batch_packets_commitment_key(
1552-
commitment::commit_packet(&packet)
1553-
);
1554-
1555-
ibc_store.commitments.remove(commitment_key);
1552+
packet_hash
1553+
)
1554+
);
15561555

1557-
event::emit(TimeoutPacket { packet });
1556+
event::emit(TimeoutPacket { packet_hash });
15581557
}
15591558

15601559
// #[test]

sui/ucs03_zkgm/Move.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[move]
44
version = 3
5-
manifest_digest = "D91557E3BF8BD9C23644361D0AF28C85E04D2FBC5604371FB87600ABFBD56637"
5+
manifest_digest = "94A211358C977F2132CA7348EC7AF04E84D6A38A6A56CEF0560F570786FDBCBF"
66
deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697"
77
dependencies = [
88
{ id = "Bridge", name = "Bridge" },
@@ -14,7 +14,7 @@ dependencies = [
1414

1515
[[move.package]]
1616
id = "Bridge"
17-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/bridge" }
17+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/bridge" }
1818

1919
dependencies = [
2020
{ id = "MoveStdlib", name = "MoveStdlib" },
@@ -24,19 +24,19 @@ dependencies = [
2424

2525
[[move.package]]
2626
id = "MoveStdlib"
27-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/move-stdlib" }
27+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/move-stdlib" }
2828

2929
[[move.package]]
3030
id = "Sui"
31-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/sui-framework" }
31+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/sui-framework" }
3232

3333
dependencies = [
3434
{ id = "MoveStdlib", name = "MoveStdlib" },
3535
]
3636

3737
[[move.package]]
3838
id = "SuiSystem"
39-
source = { git = "https://github.com/MystenLabs/sui.git", rev = "db951a5ea6b125f6253a6b7f436ddba46eb0feb3", subdir = "crates/sui-framework/packages/sui-system" }
39+
source = { git = "https://github.com/MystenLabs/sui.git", rev = "b448b1d971bd6c1aac8ef4eee4305943806d5d5b", subdir = "crates/sui-framework/packages/sui-system" }
4040

4141
dependencies = [
4242
{ id = "MoveStdlib", name = "MoveStdlib" },
@@ -55,7 +55,7 @@ dependencies = [
5555
]
5656

5757
[move.toolchain-version]
58-
compiler-version = "1.55.0"
58+
compiler-version = "1.53.2"
5959
edition = "2024.beta"
6060
flavor = "sui"
6161

0 commit comments

Comments
 (0)