From 2886cf4060772c55b91db4fd3bbeb8eb51bdf03d Mon Sep 17 00:00:00 2001 From: liyukun Date: Tue, 19 Dec 2023 14:24:55 +0800 Subject: [PATCH] chore: start cell-emitter in CI --- .github/workflows/ibc-test.yaml | 15 ++++++++++++- Cargo.lock | 12 +++++----- tools/ibc-test/src/framework/binary/node.rs | 23 ++++++++++++++++++-- tools/ibc-test/src/framework/utils/common.rs | 21 ++++++++++++++++++ 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ibc-test.yaml b/.github/workflows/ibc-test.yaml index 73d8067a8..76aaa467f 100644 --- a/.github/workflows/ibc-test.yaml +++ b/.github/workflows/ibc-test.yaml @@ -29,8 +29,9 @@ jobs: env: SRC_DIR: ${{ github.workspace }}/ibc-test-src # https://github.com/axonweb3/axon/commits/forcerelay-dev - AXON_COMMIT: 922fc3858b4c470a39b3ae98a479980e774896b5 + AXON_COMMIT: 343f329b78b8187e28fdac9e9af6c28222656b92 IBC_CONTRACT_COMMIT: c5417573ec15c8aaab048caa1ec5f3bd50c2170e + CELL_EMITTER_COMMIT: 0a897111b389472a078512815d293703910c25d5 strategy: fail-fast: false matrix: @@ -73,6 +74,9 @@ jobs: - name: Prepare Axon source run: git clone --recursive https://github.com/axonweb3/axon.git $SRC_DIR/axon && cd $SRC_DIR/axon && git checkout $AXON_COMMIT + - name: Prepare Cell Emitter + run: git clone --recursive https://github.com/axonweb3/emitter.git $SRC_DIR/emitter && cd $SRC_DIR/emitter && git checkout $CELL_EMITTER_COMMIT + - name: Rust cache uses: Swatinem/rust-cache@v2 with: @@ -110,6 +114,15 @@ jobs: command: build args: -p ibc-test --tests --jobs=4 + - name: Build Cell Emitter + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --manifest-path ${{env.SRC_DIR}}/emitter/Cargo.toml + + - name: Add cell-emitter bin to path + run: echo "${{env.SRC_DIR}}/emitter/target/release/" >> $GITHUB_PATH + - name: Run IBC tests uses: actions-rs/cargo@v1 env: diff --git a/Cargo.lock b/Cargo.lock index 5e3d44ef6..5e690c5de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1087,9 +1087,9 @@ dependencies = [ [[package]] name = "ckb-ics-axon" version = "0.1.0" -source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=adb8bcfb033d111174f06b88609aded5b9f2a181#adb8bcfb033d111174f06b88609aded5b9f2a181" +source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=942389081039cca0361b7fb9bfb25e646a9cdfb3#942389081039cca0361b7fb9bfb25e646a9cdfb3" dependencies = [ - "axon-tools 0.1.1 (git+https://github.com/axonweb3/axon.git?rev=dd35f500)", + "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", @@ -1107,9 +1107,9 @@ dependencies = [ [[package]] name = "ckb-ics-axon" version = "0.1.0" -source = "git+https://github.com/synapseweb3/ckb-ics.git?rev=d1c45bbc#d1c45bbcb9bc1ef1f463ce86a14a46174ff85d8f" +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=01704ec0)", + "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", @@ -3750,7 +3750,7 @@ dependencies = [ "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=d1c45bbc)", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=942389081039cca0361b7fb9bfb25e646a9cdfb3)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", @@ -3958,7 +3958,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=d1c45bbc)", + "ckb-ics-axon 0.1.0 (git+https://github.com/synapseweb3/ckb-ics.git?rev=942389081039cca0361b7fb9bfb25e646a9cdfb3)", "ckb-jsonrpc-types", "ckb-sdk", "ckb-types", diff --git a/tools/ibc-test/src/framework/binary/node.rs b/tools/ibc-test/src/framework/binary/node.rs index d06d9c342..7fa5fe9f0 100644 --- a/tools/ibc-test/src/framework/binary/node.rs +++ b/tools/ibc-test/src/framework/binary/node.rs @@ -1,5 +1,5 @@ use ibc_test_framework::{ - chain::builder::ChainBuilder, + chain::{builder::ChainBuilder, chain_type::ChainType}, framework::{ base::BasicTest, binary::node::{NodeConfigOverride, NodeGenesisOverride}, @@ -7,7 +7,9 @@ use ibc_test_framework::{ prelude::*, }; -use crate::framework::bootstrap::node::bootstrap_single_node; +use crate::framework::{ + bootstrap::node::bootstrap_single_node, utils::common::prepare_cell_emitter, +}; /** A wrapper type that lifts a test case that implements [`BinaryNodeTest`] @@ -46,6 +48,23 @@ where let _node_process_a = node_a.process.clone(); let _node_process_b = node_b.process.clone(); + // start cell-emitter if only one part of connected chains is Axon + let chain_types = ( + &node_a.chain_driver.chain_type, + &node_b.chain_driver.chain_type, + ); + if matches!(chain_types, (&ChainType::Axon, &ChainType::Ckb)) { + let axon_port = node_a.chain_driver.rpc_port; + let ckb_port = node_b.chain_driver.rpc_port; + println!("start cell-emiter for Axon:{axon_port} and CKB:{ckb_port}"); + prepare_cell_emitter(axon_port, ckb_port); + } else if matches!(chain_types, (&ChainType::Ckb, &ChainType::Axon)) { + let axon_port = node_b.chain_driver.rpc_port; + let ckb_port = node_a.chain_driver.rpc_port; + println!("start cell-emiter for Axon:{axon_port} and CKB:{ckb_port}"); + prepare_cell_emitter(axon_port, ckb_port); + } + eprintln!("Node is initialized, Starting running inner test.........."); self.test.run(config, node_a, node_b) diff --git a/tools/ibc-test/src/framework/utils/common.rs b/tools/ibc-test/src/framework/utils/common.rs index 0906ee791..1e76891ec 100644 --- a/tools/ibc-test/src/framework/utils/common.rs +++ b/tools/ibc-test/src/framework/utils/common.rs @@ -4,12 +4,14 @@ use ckb_types::prelude::Entity; use futures::Future; use ibc_test_framework::prelude::*; use relayer::chain::ChainType; +use secp256k1::rand::rngs; use secp256k1::Secp256k1; use secp256k1::{ rand::{self, Rng}, SecretKey, }; use std::path::PathBuf; +use std::process::{Command, Stdio}; use std::str::FromStr; use tokio::runtime::Runtime; @@ -62,3 +64,22 @@ pub fn transfer_port_id(chain_type: ChainType) -> PortId { } } } + +pub fn prepare_cell_emitter(axon_port: u16, ckb_port: u16) { + let listen_port = rngs::OsRng.gen_range(9000..10000); + let store_path = std::env::current_dir() + .unwrap() + .join(format!("emitter/store-{listen_port}")); + Command::new("emitter") + .arg("-c") + .arg(format!("http://localhost:{ckb_port}")) + .arg("--i") + .arg(format!("http://localhost:{axon_port}")) + .arg("-l") + .arg(format!("127.0.0.1:{listen_port}")) + .arg("-s") + .arg(store_path) + .stdout(Stdio::null()) + .spawn() + .expect("cell emitter"); +}