From 4b47f70d2dcc765f16015dc34c72c2b949d62a6c Mon Sep 17 00:00:00 2001 From: liyukun Date: Fri, 8 Dec 2023 15:39:07 +0800 Subject: [PATCH] fix: distinguish two different types of packet --- Cargo.lock | 34 ++++++++++++++--------------- crates/relayer-types/Cargo.toml | 2 +- crates/relayer/Cargo.toml | 4 ++-- crates/relayer/src/chain/ckb4ibc.rs | 23 +++++++++++++++---- tools/ibc-test/Cargo.toml | 2 +- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 185be3ec4..756d9ff3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,39 +362,39 @@ dependencies = [ [[package]] name = "axon-tools" version = "0.1.1" -source = "git+https://github.com/axonweb3/axon.git?rev=f889d38#f889d38949d6201c448ac72ebaec4d4fb0e5ba51" +source = "git+https://github.com/axonweb3/axon.git?rev=dd35f500#dd35f500fce0ec3adf28b59fea8c431a4a4087c8" dependencies = [ "bit-vec", "blst", "bytes", + "cita_trie", "ckb-blst", + "ckb-types", + "derive_more", "ethereum-types", + "ethers-contract", + "ethers-core", + "faster-hex 0.8.1", + "log", "rlp", "rlp-derive", + "serde", + "serde_json", "tiny-keccak", ] [[package]] name = "axon-tools" version = "0.1.1" -source = "git+https://github.com/axonweb3/axon.git?rev=fc7ce22c#fc7ce22c60eeea61399c133dbfd3b0e90e9a78b2" +source = "git+https://github.com/axonweb3/axon.git?rev=f889d38#f889d38949d6201c448ac72ebaec4d4fb0e5ba51" dependencies = [ "bit-vec", "blst", "bytes", - "cita_trie", "ckb-blst", - "ckb-types", - "derive_more", "ethereum-types", - "ethers-contract", - "ethers-core", - "faster-hex 0.8.1", - "log", "rlp", "rlp-derive", - "serde", - "serde_json", "tiny-keccak", ] @@ -1098,9 +1098,9 @@ dependencies = [ [[package]] name = "ckb-ics-axon" version = "0.1.0" -source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=bddb6b9b#bddb6b9bdede6bfadf7fcb5cf52ef35d2b6ac0b7" +source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=a3c3c3a2#a3c3c3a2385bb8df70e0acda35aa31f190d27896" dependencies = [ - "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=fc7ce22c)", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=dd35f500)", "axon-types", "bytes", "ethereum-types", @@ -3735,13 +3735,13 @@ dependencies = [ "anyhow", "async-stream", "async-trait", - "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=fc7ce22c)", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=dd35f500)", "bech32 0.9.1", "bitcoin", "bs58 0.4.0", "bytes", "ckb-hash 0.111.0", - "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=bddb6b9b)", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=a3c3c3a2)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", @@ -3885,7 +3885,7 @@ dependencies = [ name = "ibc-relayer-types" version = "0.23.0" dependencies = [ - "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=fc7ce22c)", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=dd35f500)", "bls", "bytes", "derive_more", @@ -3949,7 +3949,7 @@ dependencies = [ "bytes", "ckb-chain-spec", "ckb-hash 0.106.0", - "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=bddb6b9b)", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=a3c3c3a2)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", diff --git a/crates/relayer-types/Cargo.toml b/crates/relayer-types/Cargo.toml index 3d2e0fcad..a5a103296 100644 --- a/crates/relayer-types/Cargo.toml +++ b/crates/relayer-types/Cargo.toml @@ -64,7 +64,7 @@ tree_hash_derive = { git = "https://github.com/synapseweb3/lighthouse", rev = "2 thiserror = "1.0" ethereum-types = "0.14.1" hex = "0.4" -axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "fc7ce22c", version = "0.1.1", features = [ +axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "dd35f500", version = "0.1.1", features = [ "impl-serde", "proof", "std", diff --git a/crates/relayer/Cargo.toml b/crates/relayer/Cargo.toml index ddaa26bc8..e2aca0a5d 100644 --- a/crates/relayer/Cargo.toml +++ b/crates/relayer/Cargo.toml @@ -34,7 +34,7 @@ tree_hash = { git = "https://github.com/synapseweb3/lighthouse", rev = "2c246d6" eth_light_client_in_ckb-verification = { version = "0.2.3", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.3" } eth_light_client_in_ckb-prover = { version = "0.2.3", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.3" } -axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "fc7ce22c", version = "0.1.1", features = [ +axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "dd35f500", version = "0.1.1", features = [ "impl-serde", "proof", "std", @@ -105,7 +105,7 @@ jsonrpc-core = "18.0" strum = { version = "0.24.1", features = ["derive"] } lazy_static = "1.4.0" -ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "bddb6b9b" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "a3c3c3a2" } cstr_core = "0.2.6" rlp = "0.5.2" diff --git a/crates/relayer/src/chain/ckb4ibc.rs b/crates/relayer/src/chain/ckb4ibc.rs index 874270181..7b69a62a7 100644 --- a/crates/relayer/src/chain/ckb4ibc.rs +++ b/crates/relayer/src/chain/ckb4ibc.rs @@ -21,7 +21,9 @@ use crate::event::IbcEventWithHeight; use crate::keyring::{KeyRing, Secp256k1KeyPair}; use crate::misbehaviour::MisbehaviourEvidence; -use ckb_ics_axon::commitment::{channel_path, connection_path, packet_commitment_path}; +use ckb_ics_axon::commitment::{ + channel_path, connection_path, packet_acknowledgement_commitment_path, packet_commitment_path, +}; use ckb_ics_axon::handler::{IbcChannel, IbcConnections, IbcPacket, PacketStatus}; use ckb_ics_axon::message::{Envelope, MsgType}; use ckb_ics_axon::object::Ordering; @@ -1625,7 +1627,7 @@ impl ChainEndpoint for Ckb4IbcChain { fn build_packet_proofs( &self, - _packet_type: PacketMsgType, + packet_type: PacketMsgType, port_id: PortId, channel_id: ChannelId, sequence: Sequence, @@ -1636,8 +1638,21 @@ impl ChainEndpoint for Ckb4IbcChain { return get_ibc_merkle_proof(height, vec![0u8]); } - let commitment_path = - packet_commitment_path(port_id.as_str(), channel_id.as_str(), sequence.into()); + let commitment_path = match packet_type { + PacketMsgType::Recv => { + packet_commitment_path(port_id.as_str(), channel_id.as_str(), sequence.into()) + } + PacketMsgType::Ack => packet_acknowledgement_commitment_path( + port_id.as_str(), + channel_id.as_str(), + sequence.into(), + ), + _ => { + return Err(Error::other_error(format!( + "unsupported packet type: {packet_type}" + ))) + } + }; let mut tx_hash = self .ibc_transactions_cache .lock() diff --git a/tools/ibc-test/Cargo.toml b/tools/ibc-test/Cargo.toml index 1fbf7e63f..a04b1ad14 100644 --- a/tools/ibc-test/Cargo.toml +++ b/tools/ibc-test/Cargo.toml @@ -28,7 +28,7 @@ jsonrpc-core = "18.0" futures = "0.3.27" serde_json = { version = "1", default-features = false } serde = { version = "1.0", default-features = false } -ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "bddb6b9b" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "a3c3c3a2" } rlp = "0.5.2" secp256k1 = "0.24" ckb-hash = "0.106"