Skip to content

Commit

Permalink
fix: distinguish two different types of packet
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Dec 10, 2023
1 parent 4f0da66 commit 4b47f70
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 25 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/relayer-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"

Expand Down
23 changes: 19 additions & 4 deletions crates/relayer/src/chain/ckb4ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tools/ibc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4b47f70

Please sign in to comment.