From 3491f2836d88185b55b397bcee68e8fe92cb7172 Mon Sep 17 00:00:00 2001 From: liyukun Date: Fri, 8 Dec 2023 10:51:01 +0800 Subject: [PATCH 1/2] chore: erase useless config fields in Axon --- crates/relayer/src/chain/axon.rs | 22 +------------------ crates/relayer/src/config/axon.rs | 3 --- .../config/fixtures/relayer_conf_example.toml | 2 -- tools/ibc-test/src/framework/utils/axon.rs | 2 -- tools/test-framework/src/types/axon/mod.rs | 2 -- tools/test-framework/src/types/single/node.rs | 4 ---- 6 files changed, 1 insertion(+), 34 deletions(-) diff --git a/crates/relayer/src/chain/axon.rs b/crates/relayer/src/chain/axon.rs index e5f79ab6c..97666671b 100644 --- a/crates/relayer/src/chain/axon.rs +++ b/crates/relayer/src/chain/axon.rs @@ -39,9 +39,7 @@ use ibc_proto::{ use ibc_relayer_types::{ applications::ics31_icq::response::CrossChainQueryResponse, clients::ics07_axon::{ - client_state::AxonClientState, - consensus_state::AxonConsensusState, - header::{AxonHeader, AXON_HEADER_TYPE_URL}, + client_state::AxonClientState, consensus_state::AxonConsensusState, header::AxonHeader, light_block::AxonLightBlock, }, core::{ @@ -1392,24 +1390,6 @@ impl AxonChain { create_client::TYPE_URL => { convert!(self, msg, MsgCreateClient, create_client) } - // TODO: this update_client uses Hermes internal message to handle the Axon-specific function, - // so maybe there is possibility to create a new one to do so - update_client::TYPE_URL => { - let msg = update_client::MsgUpdateClient::from_any(msg) - .map_err(|e| Error::protobuf_decode(update_client::TYPE_URL.to_string(), e))?; - let bytes = msg.header.value.as_slice(); - let type_url = msg.header.type_url; - let to = match type_url.as_str() { - AXON_HEADER_TYPE_URL => self.config.ckb_light_client_contract_address, - "CELL_TYPE_URL" => self.config.image_cell_contract_address, - type_url => { - return Err(Error::other_error(format!("unknown type_url {type_url}"))) - } - }; - let tx = TransactionRequest::new().to(to).data(bytes.to_vec()); - self.rt - .block_on(async { Ok(self.client.send_transaction(tx, None).await?.await?) }) - } // connection conn_open_init::TYPE_URL => { convert!(self, msg, MsgConnectionOpenInit, connection_open_init) diff --git a/crates/relayer/src/config/axon.rs b/crates/relayer/src/config/axon.rs index 0bf61d09d..413b55906 100644 --- a/crates/relayer/src/config/axon.rs +++ b/crates/relayer/src/config/axon.rs @@ -1,4 +1,3 @@ -use ethers::types::H160; use ibc_relayer_types::core::ics24_host::identifier::ChainId; use serde_derive::{Deserialize, Serialize}; use tendermint_rpc::Url; @@ -16,8 +15,6 @@ pub struct AxonChainConfig { pub restore_block_count: u64, pub key_name: String, pub store_prefix: String, - pub ckb_light_client_contract_address: H160, - pub image_cell_contract_address: H160, #[serde(default)] pub packet_filter: PacketFilter, diff --git a/crates/relayer/tests/config/fixtures/relayer_conf_example.toml b/crates/relayer/tests/config/fixtures/relayer_conf_example.toml index 58c8e1aae..de46b89da 100644 --- a/crates/relayer/tests/config/fixtures/relayer_conf_example.toml +++ b/crates/relayer/tests/config/fixtures/relayer_conf_example.toml @@ -94,8 +94,6 @@ transfer_contract_address = "0x0000000000000000000000000000000000000000" restore_block_count = 10000 key_name = "relayer_axon_wallet" store_prefix = "forcerelay" -ckb_light_client_contract_address = "0x71C7656EC7ab88b098defB751B7401B5f6d8976F" -image_cell_contract_address = "0x71C7656EC7ab88b098defB751B7401B5f6d8976F" [[chains]] id = "ckb4ibc-0" diff --git a/tools/ibc-test/src/framework/utils/axon.rs b/tools/ibc-test/src/framework/utils/axon.rs index f2849f87b..092865feb 100644 --- a/tools/ibc-test/src/framework/utils/axon.rs +++ b/tools/ibc-test/src/framework/utils/axon.rs @@ -159,8 +159,6 @@ pub(crate) fn prepare_axon_chain( let deployment = DeployedContracts { contract_address, transfer_contract_address, - image_cell_contract_address: ethers::types::H160::default(), - ckb_light_client_contract_address: ethers::types::H160::default(), }; let path = working_dir.join(AXON_CONTRACTS_CONFIG_PATH); std::fs::write(path, toml::to_string(&deployment)?).with_context(|| "write deployment info")?; diff --git a/tools/test-framework/src/types/axon/mod.rs b/tools/test-framework/src/types/axon/mod.rs index adfab4d3f..772109e8c 100644 --- a/tools/test-framework/src/types/axon/mod.rs +++ b/tools/test-framework/src/types/axon/mod.rs @@ -5,6 +5,4 @@ use serde_derive::{Deserialize, Serialize}; pub struct DeployedContracts { pub contract_address: H160, pub transfer_contract_address: H160, - pub image_cell_contract_address: H160, - pub ckb_light_client_contract_address: H160, } diff --git a/tools/test-framework/src/types/single/node.rs b/tools/test-framework/src/types/single/node.rs index fe8a46a54..70c001446 100644 --- a/tools/test-framework/src/types/single/node.rs +++ b/tools/test-framework/src/types/single/node.rs @@ -228,8 +228,6 @@ impl FullNode { let DeployedContracts { contract_address, transfer_contract_address, - image_cell_contract_address, - ckb_light_client_contract_address, .. } = deployed_contracts; @@ -243,8 +241,6 @@ impl FullNode { contract_address, transfer_contract_address, restore_block_count, - ckb_light_client_contract_address, - image_cell_contract_address, }; Ok(config::ChainConfig::Axon(axon_config)) } From a5ea365704331bd87009e82a446508a495a4e4bb Mon Sep 17 00:00:00 2001 From: liyukun Date: Fri, 8 Dec 2023 13:53:42 +0800 Subject: [PATCH 2/2] chore: add metadata deployment infomation --- .../deployment/metadata.deployment.toml | 12 ++++ tools/ibc-test/contracts/metadata | Bin 0 -> 1581 bytes .../src/generator/deploy_packet_metadata.rs | 54 ++++++++++++------ 3 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 tools/ibc-test/contracts/deployment/metadata.deployment.toml create mode 100644 tools/ibc-test/contracts/metadata diff --git a/tools/ibc-test/contracts/deployment/metadata.deployment.toml b/tools/ibc-test/contracts/deployment/metadata.deployment.toml new file mode 100644 index 000000000..32cf5ff04 --- /dev/null +++ b/tools/ibc-test/contracts/deployment/metadata.deployment.toml @@ -0,0 +1,12 @@ +# this is a deployment file for ckb testnet + +[[cells]] +name = "metadata" +enable_type_id = true +location = { file = "../metadata" } + +# The lock script set to output cells +[lock] +code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" +args = "0x470dcdc5e44064909650113a274b3b36aecb6dc7" +hash_type = "type" diff --git a/tools/ibc-test/contracts/metadata b/tools/ibc-test/contracts/metadata new file mode 100644 index 0000000000000000000000000000000000000000..33b36cdd24192bccbc638c152df4f2d3030f23d4 GIT binary patch literal 1581 zcmdO8V_?u=U|`S$VnZNy1Y%Dh_5xyWAkGHj%S=Fma*zQu#sg?f1`u}u@d_Y50mLtW zn1d1M3?TLZ;tU|}0OA!ud;*AH05JzpuLejzb({jUaTE;K5Qt(1rWc^+f`GIQkahrK z7a(>6Vm}}b1L7zkHUi3<0kIVj+X1l?5W4}f7ZBqIH-M>71gPXF5SIZ{r#g_o5y+MS zVjm#x1>%K3ycCF60`b&^c^AJNu_`H;SYEiliQVz`1&5=O=|Z~Ca*ytrpZ7m9cyac# z1Al)UVp^1&ug%}l3e-Y-fX~4zE*?K3s`F%R-~YOoENt7(eyV#n{lim*9h_Yq|1FA7 zSgqLZJ8QL-jHsD(to2DHzge_*Ezkyh4(^>fD@HTH-)JiLzxx{Vv-|4wr6hl3EA*N( zs66NVUMs}$^#Q{jC!=KsDZy;QtGv|)+`;SLpSt`_V-EL$m46vTzZ&29bMX4Ez{LN7 i?M(lkuRCm9vY^+0N%Xq+t<5=d34Z-bvUG7UAxi*zcYt63 literal 0 HcmV?d00001 diff --git a/tools/ibc-test/src/generator/deploy_packet_metadata.rs b/tools/ibc-test/src/generator/deploy_packet_metadata.rs index 4d2bf7869..4a4cd1558 100644 --- a/tools/ibc-test/src/generator/deploy_packet_metadata.rs +++ b/tools/ibc-test/src/generator/deploy_packet_metadata.rs @@ -88,23 +88,9 @@ pub fn generate_deploy_packet_metadata(attribute: &ChannelAttribute) -> PacketMe .build(); // Same as axon example single node spec which is used in ibc-tests. - let bls_pub_key = hex::decode("a26e3fe1cf51bd4822072c61bdc315ac32e3d3c2e2484bb92942666399e863b4bf56cf2926383cc706ffc15dfebc85c6").unwrap(); - let metadata = Metadata::new_builder() - .validators( - ValidatorList::new_builder() - .push( - Validator::new_builder() - // Only bls_pub_key matters for now. - .bls_pub_key(Entity::from_slice(&bls_pub_key).unwrap()) - .build(), - ) - .build(), - ) - .build(); - - let metadata_cell_data = MetadataCellData::new_builder() - .metadata(MetadataList::new_builder().push(metadata).build()) - .build(); + let metadata_cell_data = generate_metadata_cell_data( + vec!["a26e3fe1cf51bd4822072c61bdc315ac32e3d3c2e2484bb92942666399e863b4bf56cf2926383cc706ffc15dfebc85c6"] + ); let metadata_output = CellOutput::new_builder() .lock(lock_script.clone()) @@ -162,3 +148,37 @@ pub fn generate_deploy_packet_metadata(attribute: &ChannelAttribute) -> PacketMe balance_index: 2, } } + +fn generate_metadata_cell_data(bls_pubkeys: Vec<&str>) -> MetadataCellData { + let mut validator_list = ValidatorList::new_builder(); + for key in bls_pubkeys { + let bls_pub_key = hex::decode(key).unwrap(); + validator_list = validator_list.push( + Validator::new_builder() + // Only bls_pub_key matters for now. + .bls_pub_key(Entity::from_slice(&bls_pub_key).unwrap()) + .build(), + ); + } + + let metadata = Metadata::new_builder() + .validators(validator_list.build()) + .build(); + + MetadataCellData::new_builder() + .metadata(MetadataList::new_builder().push(metadata).build()) + .build() +} + +#[test] +fn test_generate_metadata_cell_data() { + let metadata = generate_metadata_cell_data( + vec![ + "95a16ed1f4c43a7470917771bf820741dbd040c51967122de66dc5bc9f6eff5953a36be6c0fdf8c202a26d6f2b0f8885", + "a8d1c7c4152ce4ad8eff7ee90406b6cdf27eee97f0e520b8098a88ff3873c83aa8b74d9aab3a1c15361b5d3bc9224e9a", + "8d999a5c29604f32950bfedf289f6b8e7e2f1a19f86b208d370024e709f77d1208f5e000dc4232a63064530613aa4b26", + "afefcad3f6289c0bc0a9fd0015f533dcfcc1d7ba5161ff518702fee7aec33374a08d4fa45baeef85836c1e604e8f221d" + ] + ); + std::fs::write("contracts/metadata", metadata.as_slice()).unwrap(); +}