From c9ba3a3d013cfa8ba0e6adf186deb709d8e655ad Mon Sep 17 00:00:00 2001 From: liyukun Date: Fri, 15 Dec 2023 10:03:44 +0800 Subject: [PATCH 1/3] chore: enable rlp encode for axon proof --- Cargo.lock | 53 +++++++++++++++++++---- crates/relayer-types/Cargo.toml | 2 +- crates/relayer/Cargo.toml | 4 +- crates/relayer/src/chain/ckb4ibc/utils.rs | 17 +++++--- tools/ibc-test/Cargo.toml | 2 +- 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0867852b2..5e3d44ef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,7 +362,7 @@ dependencies = [ [[package]] name = "axon-tools" version = "0.1.1" -source = "git+https://github.com/axonweb3/axon.git?rev=dd35f500#dd35f500fce0ec3adf28b59fea8c431a4a4087c8" +source = "git+https://github.com/axonweb3/axon.git?rev=01704ec0#01704ec0c6db7845d18b4fdf82da46ad3d0f966c" dependencies = [ "bit-vec", "blst", @@ -383,6 +383,21 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "axon-tools" +version = "0.1.1" +source = "git+https://github.com/axonweb3/axon.git?rev=dd35f500#dd35f500fce0ec3adf28b59fea8c431a4a4087c8" +dependencies = [ + "bit-vec", + "blst", + "bytes", + "ckb-blst", + "ethereum-types", + "rlp", + "rlp-derive", + "tiny-keccak", +] + [[package]] name = "axon-types" version = "0.1.0" @@ -1072,9 +1087,29 @@ dependencies = [ [[package]] name = "ckb-ics-axon" version = "0.1.0" -source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=ac9850ff#ac9850ff6d747626997f5bc975b2463162347a61" +source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=adb8bcfb033d111174f06b88609aded5b9f2a181#adb8bcfb033d111174f06b88609aded5b9f2a181" +dependencies = [ + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=dd35f500)", + "axon-types 0.1.0 (git+https://github.com/axonweb3/axon-contract?rev=b82a843)", + "bytes", + "ethereum-types", + "hex", + "molecule", + "prost 0.12.1", + "prost-build", + "protobuf-src", + "rlp", + "rlp-derive", + "sha2 0.10.8", + "tiny-keccak", +] + +[[package]] +name = "ckb-ics-axon" +version = "0.1.0" +source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=d1c45bbc#d1c45bbcb9bc1ef1f463ce86a14a46174ff85d8f" dependencies = [ - "axon-tools", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=01704ec0)", "axon-types 0.1.0 (git+https://github.com/axonweb3/axon-contract?rev=b82a843)", "bytes", "ethereum-types", @@ -2921,13 +2956,13 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "forcerelay-ckb-sdk" version = "0.1.0" -source = "git+https://github.com/synapseweb3/forcerelay-ckb-sdk?rev=9971868#997186841ada6876cfd0502beaca4018f461fd4b" +source = "git+https://github.com/synapseweb3/forcerelay-ckb-sdk?rev=59d5e92ee3efe2e260bbbbcba2b926e79b063dd2#59d5e92ee3efe2e260bbbbcba2b926e79b063dd2" dependencies = [ "anyhow", "async-stream", "bytes", "ckb-fixed-hash", - "ckb-ics-axon", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=adb8bcfb033d111174f06b88609aded5b9f2a181)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", @@ -3709,13 +3744,13 @@ dependencies = [ "anyhow", "async-stream", "async-trait", - "axon-tools", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=01704ec0)", "bech32 0.9.1", "bitcoin", "bs58 0.4.0", "bytes", "ckb-hash 0.111.0", - "ckb-ics-axon", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=d1c45bbc)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", @@ -3859,7 +3894,7 @@ dependencies = [ name = "ibc-relayer-types" version = "0.23.0" dependencies = [ - "axon-tools", + "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=01704ec0)", "bls", "bytes", "derive_more", @@ -3923,7 +3958,7 @@ dependencies = [ "bytes", "ckb-chain-spec", "ckb-hash 0.106.0", - "ckb-ics-axon", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=d1c45bbc)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", diff --git a/crates/relayer-types/Cargo.toml b/crates/relayer-types/Cargo.toml index a5a103296..48be7edea 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 = "dd35f500", version = "0.1.1", features = [ +axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "01704ec0", version = "0.1.1", features = [ "impl-serde", "proof", "std", diff --git a/crates/relayer/Cargo.toml b/crates/relayer/Cargo.toml index 1a362744b..4d7e1e13f 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 = "dd35f500", version = "0.1.1", features = [ +axon-tools = { git = "https://github.com/axonweb3/axon.git", package = "axon-tools", rev = "01704ec0", 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 = "adb8bcfb033d111174f06b88609aded5b9f2a181" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "d1c45bbc" } cstr_core = "0.2.6" rlp = "0.5.2" diff --git a/crates/relayer/src/chain/ckb4ibc/utils.rs b/crates/relayer/src/chain/ckb4ibc/utils.rs index 76b19462d..affcb272c 100644 --- a/crates/relayer/src/chain/ckb4ibc/utils.rs +++ b/crates/relayer/src/chain/ckb4ibc/utils.rs @@ -24,8 +24,6 @@ use ckb_types::packed::{Byte32, Bytes, BytesOpt, OutPoint, Script, Transaction}; use ckb_types::prelude::{Builder, Entity, Pack, Unpack}; use ckb_types::utilities::{merkle_root, MerkleProof}; use ckb_types::{h256, H256}; -use ethers::abi::AbiEncode; -use ethers::contract::{EthAbiCodec, EthAbiType}; use ibc_relayer_types::core::ics02_client::client_type::ClientType; use ibc_relayer_types::core::ics03_connection::events::Attributes as ConnectionAttributes; use ibc_relayer_types::core::ics04_channel::events::{ @@ -41,6 +39,7 @@ use ibc_relayer_types::proofs::{ConsensusProof, Proofs}; use ibc_relayer_types::timestamp::Timestamp; use ibc_relayer_types::Height; use itertools::Itertools; +use rlp::Encodable; use tiny_keccak::{Hasher, Keccak}; use super::extractor::{ @@ -66,7 +65,7 @@ pub struct EncodedObject { pub data: Bytes, } -pub fn get_encoded_object(obj: &T) -> EncodedObject { +pub fn get_encoded_object(obj: &T) -> EncodedObject { let content = rlp::encode(obj); let slice = content.as_ref(); let hash = keccak256(slice); @@ -540,13 +539,21 @@ pub fn parse_transaction(tx: ResponseFormat) -> TransactionView } } -#[derive(EthAbiCodec, EthAbiType)] struct AxonObjectProof { pub ckb_transaction: Vec, pub block_hash: [u8; 32], pub proof_payload: VerifyProofPayload, } +impl Encodable for AxonObjectProof { + fn rlp_append(&self, s: &mut rlp::RlpStream) { + s.begin_list(3) + .append(&self.ckb_transaction) + .append(&self.block_hash.as_slice()) + .append(&self.proof_payload); + } +} + pub async fn generate_tx_proof_from_block( rpc_client: &impl CkbReader, tx_hash: &H256, @@ -617,7 +624,7 @@ pub async fn generate_tx_proof_from_block( // assemble ibc-compatible proof let block_number = Height::from_noncosmos_height(header.inner.number.into()); - let proofs = get_ibc_merkle_proof(block_number, object_proof.encode())?; + let proofs = get_ibc_merkle_proof(block_number, object_proof.rlp_bytes().to_vec())?; Ok(Some(proofs)) } diff --git a/tools/ibc-test/Cargo.toml b/tools/ibc-test/Cargo.toml index c4f4f8d08..42d81570a 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 = "adb8bcfb033d111174f06b88609aded5b9f2a181" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "d1c45bbc" } rlp = "0.5.2" secp256k1 = "0.24" ckb-hash = "0.106" From 881b7b565ef0c031bc68b2f6f7a1ac78c72af180 Mon Sep 17 00:00:00 2001 From: Flouse <1297478+Flouse@users.noreply.github.com> Date: Fri, 15 Dec 2023 14:25:14 +0800 Subject: [PATCH 2/3] Update synapseweb3/ckb-ics commit in crates/relayer/Cargo.toml --- crates/relayer/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/relayer/Cargo.toml b/crates/relayer/Cargo.toml index 4d7e1e13f..3545c827a 100644 --- a/crates/relayer/Cargo.toml +++ b/crates/relayer/Cargo.toml @@ -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 = "d1c45bbc" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "942389081039cca0361b7fb9bfb25e646a9cdfb3" } cstr_core = "0.2.6" rlp = "0.5.2" From fbf52888b018932dc4274b9aa34794120faf673a Mon Sep 17 00:00:00 2001 From: Flouse <1297478+Flouse@users.noreply.github.com> Date: Fri, 15 Dec 2023 14:25:28 +0800 Subject: [PATCH 3/3] Update synapseweb3/ckb-ics commit in tools/ibc-test/Cargo.toml --- tools/ibc-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ibc-test/Cargo.toml b/tools/ibc-test/Cargo.toml index 42d81570a..95852eae8 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 = "d1c45bbc" } +ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "942389081039cca0361b7fb9bfb25e646a9cdfb3" } rlp = "0.5.2" secp256k1 = "0.24" ckb-hash = "0.106"