Skip to content

Commit

Permalink
WIP: ckb <-> axon transfer test
Browse files Browse the repository at this point in the history
  • Loading branch information
blckngm committed Sep 25, 2023
1 parent 59d9dcd commit 1496f9e
Show file tree
Hide file tree
Showing 19 changed files with 591 additions and 136 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ibc-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
env:
SRC_DIR: ${{ github.workspace }}/ibc-test-src
AXON_COMMIT: d03d2bb7cb3dcdc03319c3a74beeee6715e7f448
IBC_CONTRACT_COMMIT: 5746d048304ca4d73dc4800459ddd79d57fa124c
# commit fe226b288ccb7ddb9226ab674232bfddbe4f6e82 (HEAD -> ics20-erc20, origin/ics20-erc20)
# Add script for transfer test
IBC_CONTRACT_COMMIT: fe226b288ccb7ddb9226ab674232bfddbe4f6e82
strategy:
fail-fast: false
matrix:
Expand Down
67 changes: 40 additions & 27 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/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,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 = "aa075a5" }
ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "bfd8ab46a1f1fc" }
cstr_core = "0.2.6"
rlp = "0.5.2"

Expand Down
3 changes: 2 additions & 1 deletion crates/relayer/src/chain/ckb4ibc/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ impl Ckb4IbcEventMonitor {
}
let client_id = self
.config
.lc_client_id(ClientType::Ckb4Ibc)
// FIXME: what type?
.lc_client_id(ClientType::Axon)
.expect("ckb4ibc client_id");
self.cache_set.write().unwrap().insert(tx_hash.clone());
let events = ibc_connection_cell
Expand Down
6 changes: 5 additions & 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 = "aa075a5" }
ckb-ics-axon = { git = "https://github.com/synapseweb3/ckb-ics.git", rev = "bfd8ab46a1f1fc" }
rlp = "0.5.2"
secp256k1 = "0.24"
ckb-hash = "0.106"
Expand All @@ -47,3 +47,7 @@ lazy_static = "1.4.0"
ethers = { version = "2.0.2", features = ["rustls", "ws"] }

forcerelay-ckb-sdk = { git = "https://github.com/synapseweb3/forcerelay-ckb-sdk", rev = "86e797b60311" }

[dependencies]
bytes = "1.5.0"
prost = { version = "0.12.1", features = ["prost-derive"] }
8 changes: 4 additions & 4 deletions tools/ibc-test/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ pub const SUDT_CODE_HASH: H256 =
pub const CONNECTION_CODE_HASH: H256 =
h256!("0xe802fa98adeed078eb39225f6d7759ceeeecc32fa28942f2d2c6a158ec40cebb");
pub const CHANNEL_CODE_HASH: H256 =
h256!("0x6aa27dceb63c33ac6301bacdd6896753928996b5006ecc872b95e51ae68c8d40");
h256!("0x0994bee0f1e606c7461c80b9b768c3163679203ed342f3d55890cb9c025251a0");

pub const SUDT_TYPE_ARGS: H256 =
h256!("0xf49ce32397c6741998b04d7548c5ed372007424daf67ee5bfadaefec3c865781");
pub const CONNECTION_TYPE_ARGS: H256 =
h256!("0x9d46ad77b8f5107d5898d7e7ad82be206c4fd95f562004efe32488605e8846c7");
pub const CHANNEL_TYPE_ARGS: H256 =
h256!("0x585800429f94f87e8bd37f248a4a76c24302ac8be3c0807a5540259ee6909d1c");
h256!("0xfa8b909ec087b37c60ed78b5406f0980a5de0ebf3cee1d0e6c03699ae81fc09d");
pub const PACKET_TYPE_ARGS: H256 =
h256!("0xdfaee46d7b8c354d5ecd502381c8701f0c25dd9b1c5ccf3eab55f0ba89217cfe");
h256!("0x4048ccfa831feae246c6652c0414c65e7696d4981362f5b94f94d40af86b403d");
pub const CLIENT_TYPE_ARGS: H256 =
h256!("0xbfa52ecd8f17b73524cfae3b0a2e65395491fcf7da703a63ce514bf3f5582fc6");
h256!("0x99c77b7a7e35e400bc78e6dc88191c0ab49dfd945134d99952155d08a2f6d96b");
17 changes: 17 additions & 0 deletions tools/ibc-test/src/framework/binary/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ where
)))
}

pub fn run_arbitrary_binary_connection_test<Test, Overrides>(test: &Test) -> Result<(), Error>
where
Test: BinaryConnectionTest,
Test: HasOverrides<Overrides = Overrides>,
Overrides: TestConfigOverride
+ NodeConfigOverride
+ NodeGenesisOverride
+ RelayerConfigOverride
+ ClientOptionsOverride
+ SupervisorOverride
+ ConnectionDelayOverride,
{
run_arbitrary_binary_node_test(&RunBinaryChainTest::new(&RunBinaryConnectionTest::new(
&RunWithSupervisor::new(test),
)))
}

/// This test override the default port for ckb and axon chain
pub struct RunExtendedChannelTest<'a, Test> {
overrides: ExtendedChannelOverrides,
Expand Down
2 changes: 2 additions & 0 deletions tools/ibc-test/src/framework/utils/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ pub(crate) fn prepare_axon_chain(
let contract_address = parsing_contract_address_from_output(&output, "OwnableIBCHandler")?;
let mock_transfer_contract_address =
parsing_contract_address_from_output(&output, "MockTransfer")?;
let transfer_contract_address = parsing_contract_address_from_output(&output, "ICS20TransferERC20")?;

println!("ibc handler deployed at {:#x}", contract_address);

// write deployment info
let deployment = DeployedContracts {
contract_address,
mock_transfer_contract_address,
transfer_contract_address,
image_cell_contract_address: ethers::types::H160::default(),
ckb_light_client_contract_address: ethers::types::H160::default(),
};
Expand Down
2 changes: 1 addition & 1 deletion tools/ibc-test/src/tests/ckb/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use ibc_test_framework::prelude::*;
use log::info;
use tokio::runtime::Runtime;

mod utils;
pub mod utils;
use utils::*;

pub struct CKB4IbcPacketTest;
Expand Down
2 changes: 1 addition & 1 deletion tools/ibc-test/src/tests/ckb/packet/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn complete_partial_transaction(
Ok(signed_tx)
}

fn search_sudt_cells(
pub fn search_sudt_cells(
rt: &Runtime,
ckb_url: &str,
) -> EyreResult<(CellDep, CellInput, CellOutput, u128)> {
Expand Down
1 change: 1 addition & 0 deletions tools/ibc-test/src/tests/ibc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Contains all IBC tests
pub mod channel;
pub mod transfer;
pub mod sudt_erc20_transfer;
Loading

0 comments on commit 1496f9e

Please sign in to comment.