diff --git a/.github/workflows/ibc-test.yaml b/.github/workflows/ibc-test.yaml index d8526e6be..bdfa2bdc0 100644 --- a/.github/workflows/ibc-test.yaml +++ b/.github/workflows/ibc-test.yaml @@ -28,8 +28,8 @@ jobs: timeout-minutes: 60 env: SRC_DIR: ${{ github.workspace }}/ibc-test-src - AXON_COMMIT: d03d2bb7cb3dcdc03319c3a74beeee6715e7f448 - IBC_CONTRACT_COMMIT: 35290d79c9fa45583b00f228dd3ed7e8468ccc67 + AXON_COMMIT: a088cf83d29b8658a7d2ae96a74a53bffb743f03 + IBC_CONTRACT_COMMIT: c5417573ec15c8aaab048caa1ec5f3bd50c2170e strategy: fail-fast: false matrix: diff --git a/Cargo.lock b/Cargo.lock index bdc72a74b..442a2c54e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,18 +353,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axon-tools" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945cf176886c0eefa5e85565124fb3e23c5078adfb3eab6baeb6263d78ef0d3f" +source = "git+https://github.com/axonweb3/axon-tools.git?branch=main#ac3faddd9da7c73e41946e15a5a9b5bcd751351b" dependencies = [ "bit-vec", "blst", "bytes", "cita_trie", + "derive_more", "ethereum-types", - "faster-hex 0.6.1", + "faster-hex 0.8.1", "rlp", "rlp-derive", "serde", + "serde_json", "tiny-keccak", ] diff --git a/README.md b/README.md index a902d1001..144327a66 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ $ yarn migrate > migrate.log | tail -f migrate.log After running `yarn migrate`, the `OwnableIBCHandler` address is listing in console, we record it and mark as **`YOUR_IBC_AXON_ADDRESS`** to use later. ### Contract Deployment on CKB -Detailed deployment steps can be found in [ibc-ckb-contracts](https://github.com/synapseweb3/ibc-ckb-contracts). Alternatively, you can find pre-deployed contracts TYPE_ARGS on both testnet and mainnet: +Detailed deployment steps can be found in [forcerelay-ckb-contracts](https://github.com/synapseweb3/forcerelay-ckb-contracts). Alternatively, you can find pre-deployed contracts TYPE_ARGS on both testnet and mainnet: ||Mainnet|Testnet| |-|-|-| |connection|WIP|WIP| @@ -58,7 +58,7 @@ Unlike Axon, business modules cannot be registered directly with a contract on C It's important to note that the IBC port on CKB corresponds to the `LOCK_HASH` of your wallet cell on CKB, which we will refer to as `WALLET_LOCK_HASH` for future use. ### Installation and Setting -We recommand you to download the pre-compiled binary, or you can compile mannully from the source code, which requires `Rust ^v1.72.0` installed: +We recommend you to download the pre-compiled binary, or you can compile mannully from the source code, which requires `Rust ^v1.72.0` installed: ``` $ git clone https://github.com/synapseweb3/forcerelay diff --git a/crates/relayer-types/Cargo.toml b/crates/relayer-types/Cargo.toml index 4ec2c8b5b..8841ada89 100644 --- a/crates/relayer-types/Cargo.toml +++ b/crates/relayer-types/Cargo.toml @@ -52,7 +52,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 = { version = "0.1.1", features = ["impl-serde", "proof"] } +axon-tools = { git = "https://github.com/axonweb3/axon-tools.git", branch = "main", version = "0.1.1", features = ["impl-serde", "proof"] } strum = { version = "0.24.1", features = ["derive"] } [dependencies.tendermint] diff --git a/crates/relayer/Cargo.toml b/crates/relayer/Cargo.toml index 67811e89f..ef1bf5e84 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.1", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.1" } eth_light_client_in_ckb-prover = { version = "0.2.1", git = "https://github.com/synapseweb3/eth-light-client-in-ckb", tag = "v0.2.1" } -axon-tools = { version = "0.1.1", features = ["proof", "impl-serde"] } +axon-tools = { git = "https://github.com/axonweb3/axon-tools.git", branch = "main", version = "0.1.1", features = ["impl-serde", "proof"] } subtle-encoding = "0.5" humantime-serde = "1.1.1" diff --git a/crates/relayer/src/chain/axon.rs b/crates/relayer/src/chain/axon.rs index 57aeb4a2b..fb3e44f3e 100644 --- a/crates/relayer/src/chain/axon.rs +++ b/crates/relayer/src/chain/axon.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, str::FromStr, sync::Arc, thread, time::Duration}; -use axon_tools::types::{AxonBlock, Proof as AxonProof, Validator}; +use axon_tools::types::{AxonBlock, Proof as AxonProof, ValidatorExtend}; use eth2_types::Hash256; use k256::ecdsa::SigningKey; use rlp::Encodable; @@ -1176,12 +1176,17 @@ impl AxonChain { .rt .block_on(self.get_proofs_ingredients(block_number))?; - // FIXME: keep it commentted until Axon team fixed this verify issue - // // check the validation of receipts mpt proof - // let key = rlp::encode(&receipt.transaction_index.as_u64()); - // axon_tools::verify_trie_proof(block.header.receipts_root, &key, receipt_proof.clone()) - // .map_err(|e| Error::rpc_response(format!("unverified receipts mpt: {e:?}")))?; + let key = rlp::encode(&receipt.transaction_index.as_u64()); + let result = + axon_tools::verify_trie_proof(block.header.receipts_root, &key, receipt_proof.clone()) + .map_err(|e| Error::rpc_response(format!("unverified receipts mpt: {e:?}")))?; + if result.is_none() { + return Err(Error::rpc_response(format!( + "trie key: {} doesn't exist", + receipt.transaction_index + ))); + } let object_proof = to_ckb_like_object_proof(&receipt, &receipt_proof, &block, &state_root, &block_proof) @@ -1201,8 +1206,12 @@ impl AxonChain { .unwrap(); // check the validation of Axon block - axon_tools::verify_proof(block, state_root, &mut validators, block_proof) - .map_err(|_| Error::rpc_response("unverified axon block".to_owned()))?; + axon_tools::verify_proof(block, state_root, &mut validators, block_proof).map_err( + |err| { + let err_msg = format!("unverified axon block, err: {:?}", err); + Error::rpc_response(err_msg) + }, + )?; Ok(proofs) } @@ -1210,7 +1219,7 @@ impl AxonChain { async fn get_proofs_ingredients( &self, block_number: U64, - ) -> Result<(AxonBlock, Hash256, AxonProof, Vec), Error> { + ) -> Result<(AxonBlock, Hash256, AxonProof, Vec), Error> { let previous_number = block_number .checked_sub(1u64.into()) .expect("bad block_number"); @@ -1246,8 +1255,9 @@ impl AxonChain { .await? .verifier_list .into_iter() - .map(|v| Validator { - bls_pub_key: v.bls_pub_key, + .map(|v| ValidatorExtend { + bls_pub_key: v.bls_pub_key.clone(), + pub_key: v.pub_key.clone(), address: v.address, propose_weight: v.propose_weight, vote_weight: v.vote_weight, diff --git a/tools/ibc-test/README.md b/tools/ibc-test/README.md index ccf23c64c..f40293586 100644 --- a/tools/ibc-test/README.md +++ b/tools/ibc-test/README.md @@ -27,7 +27,7 @@ Environment variables: ``` bash # IBC contracts -export IBC_CONTRACTS_SRC_PATH = +export IBC_CONTRACTS_SRC_PATH= cd $IBC_CONTRACTS_SRC_PATH && yarn install && yarn compile # Axon diff --git a/tools/ibc-test/src/framework/utils/axon.rs b/tools/ibc-test/src/framework/utils/axon.rs index 77b33c8c0..f2849f87b 100644 --- a/tools/ibc-test/src/framework/utils/axon.rs +++ b/tools/ibc-test/src/framework/utils/axon.rs @@ -48,23 +48,30 @@ pub(crate) fn prepare_axon_chain( working_dir.push(dir_path); let _ = std::fs::remove_dir_all(dir_path); std::fs::create_dir_all(dir_path).with_context(|| format!("create_dir {:?}", dir_path))?; + let binding = working_dir.join("devtools/chain/specs/single_node"); + let chain_spec_dir_path = binding.to_str().unwrap(); + std::fs::create_dir_all(chain_spec_dir_path) + .with_context(|| format!("create_chain_spec_dir {:?}", chain_spec_dir_path))?; // copy configs to working dir for file in [ "config.toml", - "genesis_single_node.json", + "specs/single_node/chain-spec.toml", "default.db-options", + "bls.key", + "net.key", ] { let src_path = axon_src_path.join("devtools/chain").join(file); - std::fs::copy(&src_path, working_dir.join(file)) + std::fs::copy(&src_path, working_dir.join("devtools/chain").join(file)) .with_context(|| format!("cp {:?} -> {:?}", &src_path, working_dir.join(file)))?; } - let chain_config_path = working_dir.join("config.toml"); - let genesis_config_path = working_dir.join("genesis_single_node.json"); + let chain_config_path = working_dir.join("devtools/chain").join("config.toml"); + let chain_spec_path = working_dir + .join("devtools/chain") + .join("specs/single_node/chain-spec.toml"); // Modify configs - let mut config_doc = fs::read_to_string(&chain_config_path) .with_context(|| format!("read chain config from {:?}", &chain_config_path))? .parse::() @@ -80,14 +87,22 @@ pub(crate) fn prepare_axon_chain( fs::write(&chain_config_path, config_doc.to_string()) .with_context(|| format!("write config to {:?}", &chain_config_path))?; + // init axon + let _init_command = Command::new("axon") + .arg("init") + .arg("--config") + .arg(&chain_config_path) + .arg("--chain-spec") + .arg(&chain_spec_path) + .current_dir(&working_dir) + .output()?; + // start process let chain_process = ChildProcess::new( Command::new("axon") .arg("run") - .arg("-c") + .arg("--config") .arg(&chain_config_path) - .arg("-g") - .arg(&genesis_config_path) .current_dir(&working_dir) .stdout(Stdio::null()) .stderr(Stdio::null())