Skip to content

Commit

Permalink
chore: erase useless config fields in Axon (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuralyk authored Dec 10, 2023
2 parents a6ff159 + a5ea365 commit 74445f7
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 51 deletions.
22 changes: 1 addition & 21 deletions crates/relayer/src/chain/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions crates/relayer/src/config/axon.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions tools/ibc-test/contracts/deployment/metadata.deployment.toml
Original file line number Diff line number Diff line change
@@ -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"
Binary file added tools/ibc-test/contracts/metadata
Binary file not shown.
2 changes: 0 additions & 2 deletions tools/ibc-test/src/framework/utils/axon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down
54 changes: 37 additions & 17 deletions tools/ibc-test/src/generator/deploy_packet_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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();
}
2 changes: 0 additions & 2 deletions tools/test-framework/src/types/axon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
4 changes: 0 additions & 4 deletions tools/test-framework/src/types/single/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ impl FullNode {
let DeployedContracts {
contract_address,
transfer_contract_address,
image_cell_contract_address,
ckb_light_client_contract_address,
..
} = deployed_contracts;

Expand All @@ -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))
}
Expand Down

0 comments on commit 74445f7

Please sign in to comment.