From 0ecf25496d03025c5bc63e53051dda93d28667ce Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Mon, 2 Dec 2024 17:29:05 +0100 Subject: [PATCH 1/3] Use new CosmosChainConfig instead of CosmosSdkConfig --- crates/cli/cli/src/commands/keys/add.rs | 16 +-- crates/cli/cli/src/commands/keys/delete.rs | 14 +-- crates/cli/cli/src/commands/keys/list.rs | 2 +- crates/cli/cli/src/impls/build.rs | 2 +- .../src/impls/types/config.rs | 99 +++++++++++++++++++ .../src/impls/types/mod.rs | 1 + .../src/types/config/gas/gas_config.rs | 59 ++++++++--- .../src/types/config/tx_config.rs | 24 +++-- .../src/contexts/chain_driver.rs | 8 +- .../impls/bootstrap/relayer_chain_config.rs | 5 +- .../traits/bootstrap/relayer_chain_config.rs | 4 +- .../cosmos-relayer/src/contexts/build.rs | 15 +-- .../cosmos-relayer/src/contexts/chain.rs | 22 ++--- tools/integration-test/src/tests/context.rs | 3 +- 14 files changed, 206 insertions(+), 68 deletions(-) create mode 100644 crates/cosmos/cosmos-chain-components/src/impls/types/config.rs diff --git a/crates/cli/cli/src/commands/keys/add.rs b/crates/cli/cli/src/commands/keys/add.rs index b4eed3010..2769a6fd0 100644 --- a/crates/cli/cli/src/commands/keys/add.rs +++ b/crates/cli/cli/src/commands/keys/add.rs @@ -6,7 +6,7 @@ use hdpath::StandardHDPath; use hermes_cli_components::traits::build::CanLoadBuilder; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use ibc_relayer::keyring::{ AnySigningKeyPair, KeyRing, Secp256k1KeyPair, SigningKeyPair, SigningKeyPairSized, Store, }; @@ -94,7 +94,7 @@ pub struct KeysAddCmd { } impl KeysAddCmd { - fn options(&self, chain_config: &CosmosSdkConfig) -> eyre::Result { + fn options(&self, chain_config: &CosmosChainConfig) -> eyre::Result { let name = self .key_name .clone() @@ -114,12 +114,12 @@ impl KeysAddCmd { #[derive(Clone, Debug)] pub struct KeysAddOptions { pub name: String, - pub config: CosmosSdkConfig, + pub config: CosmosChainConfig, pub hd_path: StandardHDPath, } pub fn add_key( - config: &CosmosSdkConfig, + config: &CosmosChainConfig, key_name: &str, file: &Path, hd_path: &StandardHDPath, @@ -128,7 +128,7 @@ pub fn add_key( let mut keyring = KeyRing::new_secp256k1( Store::Test, &config.account_prefix, - &config.id, + &ChainId::from_string(&config.id), &config.key_store_folder, )?; @@ -146,7 +146,7 @@ pub fn restore_key( mnemonic: &Path, key_name: &str, hdpath: &StandardHDPath, - config: &CosmosSdkConfig, + config: &CosmosChainConfig, overwrite: bool, ) -> eyre::Result { let mnemonic_content = @@ -155,7 +155,7 @@ pub fn restore_key( let mut keyring = KeyRing::new_secp256k1( Store::Test, &config.account_prefix, - &config.id, + &ChainId::from_string(&config.id), &config.key_store_folder, )?; @@ -164,7 +164,7 @@ pub fn restore_key( let key_pair = Secp256k1KeyPair::from_mnemonic( &mnemonic_content, hdpath, - &config.address_type, + &ibc_relayer::config::AddressType::Cosmos, keyring.account_prefix(), )?; diff --git a/crates/cli/cli/src/commands/keys/delete.rs b/crates/cli/cli/src/commands/keys/delete.rs index a3d1c7388..45fe8375f 100644 --- a/crates/cli/cli/src/commands/keys/delete.rs +++ b/crates/cli/cli/src/commands/keys/delete.rs @@ -1,7 +1,7 @@ use hermes_cli_components::traits::build::CanLoadBuilder; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use ibc_relayer::keyring::{KeyRing, Store}; use ibc_relayer_types::core::ics24_host::identifier::ChainId; use oneline_eyre::eyre::{eyre, Context}; @@ -46,7 +46,7 @@ pub struct KeysDeleteCmd { } impl KeysDeleteCmd { - fn options(&self, config: &CosmosSdkConfig) -> eyre::Result> { + fn options(&self, config: &CosmosChainConfig) -> eyre::Result> { let id = match (self.all, &self.key_name) { (true, None) => KeysDeleteId::All, (false, Some(ref key_name)) => KeysDeleteId::Named(key_name), @@ -67,7 +67,7 @@ impl KeysDeleteCmd { #[derive(Clone, Debug)] struct KeysDeleteOptions<'a> { id: KeysDeleteId<'a>, - config: CosmosSdkConfig, + config: CosmosChainConfig, } #[derive(Clone, Debug)] @@ -118,11 +118,11 @@ impl CommandRunner for KeysDeleteCmd { } } -fn delete_key(config: &CosmosSdkConfig, key_name: &str) -> eyre::Result<()> { +fn delete_key(config: &CosmosChainConfig, key_name: &str) -> eyre::Result<()> { let mut keyring = KeyRing::new_secp256k1( Store::Test, &config.account_prefix, - &config.id, + &ChainId::from_string(&config.id), &config.key_store_folder, )?; @@ -131,11 +131,11 @@ fn delete_key(config: &CosmosSdkConfig, key_name: &str) -> eyre::Result<()> { Ok(()) } -fn delete_all_keys(config: &CosmosSdkConfig) -> eyre::Result<()> { +fn delete_all_keys(config: &CosmosChainConfig) -> eyre::Result<()> { let mut keyring = KeyRing::new_secp256k1( Store::Test, &config.account_prefix, - &config.id, + &ChainId::from_string(&config.id), &config.key_store_folder, )?; diff --git a/crates/cli/cli/src/commands/keys/list.rs b/crates/cli/cli/src/commands/keys/list.rs index dae45e11d..1de02011f 100644 --- a/crates/cli/cli/src/commands/keys/list.rs +++ b/crates/cli/cli/src/commands/keys/list.rs @@ -34,7 +34,7 @@ impl CommandRunner for KeysListCmd { let keyring = KeyRing::new_secp256k1( Store::Test, &chain_config.account_prefix, - &chain_config.id, + &ChainId::from_string(&chain_config.id), &chain_config.key_store_folder, )?; diff --git a/crates/cli/cli/src/impls/build.rs b/crates/cli/cli/src/impls/build.rs index 99a063bc5..072bf65da 100644 --- a/crates/cli/cli/src/impls/build.rs +++ b/crates/cli/cli/src/impls/build.rs @@ -24,7 +24,7 @@ where .into_iter() .map(|config| { let ChainConfig::CosmosSdk(config) = config; - config + config.into() }) .collect(); diff --git a/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs new file mode 100644 index 000000000..42a649d7b --- /dev/null +++ b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs @@ -0,0 +1,99 @@ +use core::time::Duration; +use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; +use serde::Deserialize; +use serde::Serialize; +use std::path::PathBuf; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CosmosChainConfig { + pub id: String, + pub grpc_addr: String, + pub account_prefix: String, + pub key_store_folder: Option, + pub key_name: String, + pub store_prefix: String, + pub event_source: EventSourceMode, + + pub clock_drift: Duration, + pub max_block_time: Duration, + + pub rpc_addr: String, + pub rpc_timeout: Duration, + pub address_type: String, + pub max_msg_num: usize, + pub max_tx_size: usize, + + pub default_gas: Option, + pub max_gas: Option, + pub gas_multiplier: Option, + pub gas_price_amount: f64, + pub gas_price_denom: String, + pub fee_granter: Option, + pub dynamic_gas_price_enabled: bool, + pub dynamic_gas_price_multiplier: f64, + pub dynamic_gas_price_max: f64, + + pub compat_mode: Option, + pub extension_options: Vec, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(tag = "mode", rename_all = "lowercase")] +pub enum EventSourceMode { + Push { + url: String, + }, + + #[serde(alias = "poll")] + Pull, +} + +impl From for CosmosChainConfig { + fn from(value: CosmosSdkConfig) -> Self { + let event_source = match value.event_source { + ibc_relayer::config::EventSourceMode::Push { + url, + batch_delay: _, + } => EventSourceMode::Push { + url: url.to_string(), + }, + ibc_relayer::config::EventSourceMode::Pull { + interval: _, + max_retries: _, + } => EventSourceMode::Pull, + }; + Self { + id: value.id.to_string(), + grpc_addr: value.grpc_addr.to_string(), + account_prefix: value.account_prefix, + key_store_folder: value.key_store_folder, + key_name: value.key_name, + store_prefix: value.store_prefix, + event_source, + rpc_addr: value.rpc_addr.to_string(), + rpc_timeout: value.rpc_timeout, + address_type: value.address_type.to_string(), + max_msg_num: value.max_msg_num.to_usize(), + max_tx_size: value.max_tx_size.to_usize(), + default_gas: value.default_gas, + max_gas: value.max_gas, + gas_multiplier: value + .gas_multiplier + .map(|gas_multiplier| gas_multiplier.to_f64()), + gas_price_amount: value.gas_price.price, + gas_price_denom: value.gas_price.denom, + fee_granter: value.fee_granter, + dynamic_gas_price_enabled: value.dynamic_gas_price.enabled, + dynamic_gas_price_multiplier: value.dynamic_gas_price.multiplier, + dynamic_gas_price_max: value.dynamic_gas_price.max, + compat_mode: value.compat_mode.map(|compat_mode| compat_mode.to_string()), + extension_options: value + .extension_options + .iter() + .map(|extension_option| extension_option.to_string()) + .collect(), + clock_drift: value.clock_drift, + max_block_time: value.max_block_time, + } + } +} diff --git a/crates/cosmos/cosmos-chain-components/src/impls/types/mod.rs b/crates/cosmos/cosmos-chain-components/src/impls/types/mod.rs index 2ce4bcdeb..4be9389d8 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/types/mod.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/types/mod.rs @@ -1,5 +1,6 @@ pub mod chain; pub mod client_state; +pub mod config; pub mod consensus_state; pub mod create_client_options; pub mod payload; diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs index 786cb7ff2..4978c39bd 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs @@ -1,10 +1,8 @@ use ibc_proto::cosmos::tx::v1beta1::Fee; -use ibc_relayer::chain::cosmos::types::gas::{ - default_gas_from_config, gas_multiplier_from_config, max_gas_from_config, -}; -use ibc_relayer::chain::cosmos::{config::CosmosSdkConfig, gas::calculate_fee}; +use ibc_relayer::chain::cosmos::gas::calculate_fee; use ibc_relayer::config::GasPrice; +use crate::impls::types::config::CosmosChainConfig; use crate::types::config::gas::dynamic_gas_config::DynamicGasConfig; use crate::types::config::gas::eip_type::EipQueryType; @@ -18,28 +16,32 @@ pub struct GasConfig { pub dynamic_gas_config: Option, } -impl<'a> From<&'a CosmosSdkConfig> for GasConfig { - fn from(config: &'a CosmosSdkConfig) -> Self { +impl<'a> From<&'a CosmosChainConfig> for GasConfig { + fn from(config: &'a CosmosChainConfig) -> Self { let eip_query_type = if config.id.as_str().starts_with("osmo") { EipQueryType::Osmosis } else { EipQueryType::FeeMarket }; - let dynamic_gas_config = if config.dynamic_gas_price.enabled { + let dynamic_gas_config = if config.dynamic_gas_price_enabled { Some(DynamicGasConfig { - multiplier: config.dynamic_gas_price.multiplier, - max: config.dynamic_gas_price.max, - denom: config.gas_price.denom.clone(), + multiplier: config.dynamic_gas_price_multiplier, + max: config.dynamic_gas_price_max, + denom: config.gas_price_denom.clone(), eip_query_type, }) } else { None }; + let gas_price = GasPrice { + price: config.gas_price_amount, + denom: config.gas_price_denom.clone(), + }; Self { default_gas: default_gas_from_config(config), max_gas: max_gas_from_config(config), gas_multiplier: gas_multiplier_from_config(config), - gas_price: config.gas_price.clone(), + gas_price, max_fee: max_fee_from_config(config), fee_granter: fee_granter_from_config(config), dynamic_gas_config, @@ -48,15 +50,24 @@ impl<'a> From<&'a CosmosSdkConfig> for GasConfig { } /// Get the fee granter address -fn fee_granter_from_config(config: &CosmosSdkConfig) -> String { - config.fee_granter.as_deref().unwrap_or("").to_string() +fn fee_granter_from_config(config: &CosmosChainConfig) -> String { + config + .fee_granter + .clone() + .unwrap_or("".to_owned()) + .to_string() } -fn max_fee_from_config(config: &CosmosSdkConfig) -> Fee { +fn max_fee_from_config(config: &CosmosChainConfig) -> Fee { let max_gas = max_gas_from_config(config); + let gas_price = GasPrice { + price: config.gas_price_amount, + denom: config.gas_price_denom.clone(), + }; + // The maximum fee the relayer pays for a transaction - let max_fee_in_coins = calculate_fee(max_gas, &config.gas_price); + let max_fee_in_coins = calculate_fee(max_gas, &gas_price); let fee_granter = fee_granter_from_config(config); @@ -67,3 +78,21 @@ fn max_fee_from_config(config: &CosmosSdkConfig) -> Fee { granter: fee_granter, } } + +/// The default amount of gas the relayer is willing to pay for a transaction, +/// when it cannot simulate the tx and therefore estimate the gas amount needed. +fn default_gas_from_config(config: &CosmosChainConfig) -> u64 { + config + .default_gas + .unwrap_or_else(|| max_gas_from_config(config)) +} + +/// The maximum amount of gas the relayer is willing to pay for a transaction +fn max_gas_from_config(config: &CosmosChainConfig) -> u64 { + config.max_gas.unwrap_or(400_000) +} + +/// The gas multiplier +fn gas_multiplier_from_config(config: &CosmosChainConfig) -> f64 { + config.gas_multiplier.unwrap_or_default() +} diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs index 67492960b..e52e36a36 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs @@ -3,13 +3,14 @@ use core::time::Duration; use eyre::Report; use http::Uri; use ibc::primitives::proto::Any; +use ibc_relayer::extension_options::ExtensionOptionDynamicFeeTx; use tendermint_rpc::Url; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize}; use ibc_relayer::config::AddressType; use ibc_relayer_types::core::ics24_host::identifier::ChainId; +use crate::impls::types::config::CosmosChainConfig; use crate::types::config::gas::gas_config::GasConfig; pub struct TxConfig { @@ -24,10 +25,10 @@ pub struct TxConfig { pub extension_options: Vec, } -impl<'a> TryFrom<&'a CosmosSdkConfig> for TxConfig { +impl<'a> TryFrom<&'a CosmosChainConfig> for TxConfig { type Error = Report; - fn try_from(config: &'a CosmosSdkConfig) -> Result { + fn try_from(config: &'a CosmosChainConfig) -> Result { let grpc_address = Uri::from_str(&config.grpc_addr.to_string()).map_err(|e| { Report::msg(format!( "failed to create Uri from gRPC address string `{}`: {e}", @@ -40,18 +41,23 @@ impl<'a> TryFrom<&'a CosmosSdkConfig> for TxConfig { let extension_options = config .extension_options .iter() - .map(|opt| opt.to_any()) + .map(|opt| { + ExtensionOptionDynamicFeeTx { + max_priority_price: opt.into(), + } + .to_any() + }) .collect::>()?; Ok(Self { - chain_id: config.id.clone(), + chain_id: ChainId::from_string(&config.id), gas_config, - rpc_address: config.rpc_addr.clone(), + rpc_address: Url::from_str(&config.rpc_addr).unwrap(), grpc_address, rpc_timeout: config.rpc_timeout, - address_type: config.address_type.clone(), - max_msg_num: config.max_msg_num, - max_tx_size: config.max_tx_size, + address_type: AddressType::Cosmos, + max_msg_num: MaxMsgNum::new(config.max_msg_num).unwrap(), + max_tx_size: MaxTxSize::new(config.max_tx_size).unwrap(), extension_options, }) } diff --git a/crates/cosmos/cosmos-integration-tests/src/contexts/chain_driver.rs b/crates/cosmos/cosmos-integration-tests/src/contexts/chain_driver.rs index b0c110d40..06c091212 100644 --- a/crates/cosmos/cosmos-integration-tests/src/contexts/chain_driver.rs +++ b/crates/cosmos/cosmos-integration-tests/src/contexts/chain_driver.rs @@ -32,7 +32,7 @@ use hermes_test_components::chain_driver::traits::fields::wallet::{ RelayerWallet, UserWallet, ValidatorWallet, WalletGetterAt, WalletsGetter, }; use hermes_test_components::chain_driver::traits::types::chain::{ChainGetter, ProvideChainType}; -use ibc_relayer::config::{ChainConfig, Config}; +use ibc_relayer::config::Config; use tokio::process::Child; use toml::to_string_pretty; @@ -180,13 +180,13 @@ impl ChainProcessTaker for CosmosChainDriverComponents { impl ConfigUpdater for CosmosChainDriverComponents { fn update_config( chain_driver: &CosmosChainDriver, - config: &mut Config, + _config: &mut Config, ) -> Result { let chain_config_str = to_string_pretty(&chain_driver.chain.chain_config)?; - let chain_config = chain_driver.chain.chain_config.clone(); + let _chain_config = chain_driver.chain.chain_config.clone(); - config.chains.push(ChainConfig::CosmosSdk(chain_config)); + //config.chains.push(ChainConfig::CosmosSdk(chain_config)); Ok(chain_config_str) } diff --git a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs index fbe9f3e02..c9c03a62c 100644 --- a/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs +++ b/crates/cosmos/cosmos-integration-tests/src/impls/bootstrap/relayer_chain_config.rs @@ -2,6 +2,7 @@ use core::str::FromStr; use core::time::Duration; use cgp::core::error::CanRaiseError; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use hermes_cosmos_test_components::bootstrap::traits::fields::account_prefix::HasAccountPrefix; use hermes_cosmos_test_components::bootstrap::traits::fields::dynamic_gas_fee::HasDynamicGas; use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType; @@ -39,7 +40,7 @@ where chain_node_config: &CosmosChainNodeConfig, chain_genesis_config: &CosmosGenesisConfig, relayer_wallet: &CosmosTestWallet, - ) -> Result { + ) -> Result { let dynamic_gas_price = if let Some(dynamic_gas_config) = bootstrap.dynamic_gas() { DynamicGasPrice::unsafe_new(true, dynamic_gas_config.multiplier, dynamic_gas_config.max) } else { @@ -97,6 +98,6 @@ where allow_ccq: false, }; - Ok(relayer_chain_config) + Ok(relayer_chain_config.into()) } } diff --git a/crates/cosmos/cosmos-integration-tests/src/traits/bootstrap/relayer_chain_config.rs b/crates/cosmos/cosmos-integration-tests/src/traits/bootstrap/relayer_chain_config.rs index 9096d9da8..131e4ab35 100644 --- a/crates/cosmos/cosmos-integration-tests/src/traits/bootstrap/relayer_chain_config.rs +++ b/crates/cosmos/cosmos-integration-tests/src/traits/bootstrap/relayer_chain_config.rs @@ -1,9 +1,9 @@ use cgp::prelude::*; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use hermes_cosmos_test_components::bootstrap::traits::types::chain_node_config::HasChainNodeConfigType; use hermes_cosmos_test_components::bootstrap::traits::types::genesis_config::HasChainGenesisConfigType; use hermes_test_components::chain::traits::types::wallet::{HasWalletType, WalletOf}; use hermes_test_components::chain_driver::traits::types::chain::HasChainType; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; /** Capability for the bootstrap context to build a Hermes v1 relayer chain config. @@ -19,5 +19,5 @@ where chain_node_config: &Self::ChainNodeConfig, chain_genesis_config: &Self::ChainGenesisConfig, relayer_wallet: &WalletOf, - ) -> Result; + ) -> Result; } diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index 028dfd3da..5c603327b 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -2,8 +2,10 @@ use alloc::collections::BTreeMap; use alloc::sync::Arc; use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent}; use cgp::prelude::*; +use core::str::FromStr; use eyre::eyre; use futures::lock::Mutex; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use std::collections::HashMap; use std::fs::{self, File}; @@ -25,7 +27,6 @@ use hermes_runtime::types::runtime::HermesRuntime; use hermes_runtime_components::traits::runtime::{ ProvideDefaultRuntimeField, RuntimeGetterComponent, RuntimeTypeComponent, }; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; use ibc_relayer::config::filter::PacketFilter; use ibc_relayer::keyring::{ AnySigningKeyPair, Secp256k1KeyPair, KEYSTORE_DEFAULT_FOLDER, KEYSTORE_FILE_EXTENSION, @@ -44,7 +45,7 @@ use crate::types::telemetry::CosmosTelemetry; #[derive(HasField)] pub struct CosmosBuilder { - pub config_map: HashMap, + pub config_map: HashMap, pub packet_filter: PacketFilter, pub telemetry: CosmosTelemetry, pub runtime: HermesRuntime, @@ -126,7 +127,7 @@ impl CosmosBuilder { } pub fn new( - chain_configs: Vec, + chain_configs: Vec, runtime: HermesRuntime, telemetry: CosmosTelemetry, packet_filter: PacketFilter, @@ -136,7 +137,7 @@ impl CosmosBuilder { let config_map = HashMap::from_iter( chain_configs .into_iter() - .map(|config| (config.id.clone(), config)), + .map(|config| (ChainId::from_string(&config.id), config)), ); Self { @@ -165,7 +166,7 @@ impl CosmosBuilder { pub async fn build_chain_with_config( &self, - chain_config: CosmosSdkConfig, + chain_config: CosmosChainConfig, m_keypair: Option<&Secp256k1KeyPair>, ) -> Result { let key = get_keypair(&chain_config, m_keypair)?; @@ -177,7 +178,7 @@ impl CosmosBuilder { let mut rpc_client = HttpClient::new(tx_config.rpc_address.clone())?; let compat_mode = if let Some(compat_mode) = &chain_config.compat_mode { - *compat_mode + CompatMode::from_str(compat_mode.as_str()).unwrap() } else { let status = rpc_client.status().await?; @@ -225,7 +226,7 @@ impl CosmosBuilder { } pub fn get_keypair( - chain_config: &CosmosSdkConfig, + chain_config: &CosmosChainConfig, m_keypair: Option<&Secp256k1KeyPair>, ) -> Result { let ks_folder = &chain_config.key_store_folder; diff --git a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs index 7b44999d2..13a6806cc 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs @@ -1,5 +1,7 @@ use alloc::sync::Arc; use core::ops::Deref; +use core::str::FromStr; +use hermes_cosmos_chain_components::impls::types::config::{CosmosChainConfig, EventSourceMode}; use hermes_cosmos_chain_components::traits::convert_gas_to_fee::CanConvertGasToFee; use hermes_cosmos_chain_components::traits::eip::eip_query::CanQueryEipBaseFee; use hermes_cosmos_chain_components::traits::unbonding_period::CanQueryUnbondingPeriod; @@ -100,9 +102,7 @@ use hermes_wasm_test_components::traits::chain::upload_client_code::{ use http::Uri; use ibc::core::channel::types::channel::ChannelEnd; use ibc_proto::cosmos::tx::v1beta1::Fee; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; use ibc_relayer::chain::cosmos::types::account::Account; -use ibc_relayer::config::EventSourceMode; use ibc_relayer::event::source::queries::all as all_queries; use ibc_relayer::keyring::Secp256k1KeyPair; use ibc_relayer_types::core::ics02_client::height::Height; @@ -110,7 +110,7 @@ use ibc_relayer_types::core::ics24_host::identifier::ChainId; use prost_types::Any; use tendermint::abci::Event as AbciEvent; use tendermint_rpc::client::CompatMode; -use tendermint_rpc::{HttpClient, Url}; +use tendermint_rpc::{HttpClient, Url, WebSocketClientUrl}; use crate::contexts::encoding::ProvideCosmosEncoding; use crate::impls::error::HandleCosmosError; @@ -124,7 +124,7 @@ pub struct CosmosChain { #[derive(HasField)] pub struct BaseCosmosChain { - pub chain_config: CosmosSdkConfig, + pub chain_config: CosmosChainConfig, pub chain_id: ChainId, pub compat_mode: CompatMode, pub runtime: HermesRuntime, @@ -265,7 +265,7 @@ impl IbcCommitmentPrefixGetter for CosmosChainContextComponents { impl CosmosChain { pub fn new( - chain_config: CosmosSdkConfig, + chain_config: CosmosChainConfig, tx_config: TxConfig, rpc_client: HttpClient, compat_mode: CompatMode, @@ -277,12 +277,12 @@ impl CosmosChain { let chain_version = tx_config.chain_id.version(); let subscription = match event_source_mode { - EventSourceMode::Push { - url, - batch_delay: _, - } => { - runtime.new_abci_event_subscription(chain_version, url, compat_mode, all_queries()) - } + EventSourceMode::Push { url } => runtime.new_abci_event_subscription( + chain_version, + WebSocketClientUrl::from_str(&url).unwrap(), + compat_mode, + all_queries(), + ), EventSourceMode::Pull { .. } => { // TODO: implement pull-based event source Arc::new(EmptySubscription::new()) diff --git a/tools/integration-test/src/tests/context.rs b/tools/integration-test/src/tests/context.rs index a8709c97f..0f0c0c83c 100644 --- a/tools/integration-test/src/tests/context.rs +++ b/tools/integration-test/src/tests/context.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use hermes_cosmos_relayer::contexts::birelay::CosmosBiRelay; use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_relayer_components::build::traits::builders::birelay_builder::CanBuildBiRelay; @@ -36,7 +37,7 @@ where .iter() .map(|config| { let ChainConfig::CosmosSdk(config) = config; - config.clone() + CosmosChainConfig::from(config.clone()) }) .collect(); From ae5454cd15f1c3744e97e722016e15e9be3e4ada Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Tue, 3 Dec 2024 14:53:42 +0100 Subject: [PATCH 2/3] Remove TxConfig and move the required fields to CosmosChainConfig --- Cargo.lock | 3 + crates/cli/cli-components/Cargo.toml | 1 + crates/cli/cli/Cargo.toml | 1 + .../cli/src/commands/query/channel/client.rs | 4 +- crates/cli/cli/src/commands/query/channels.rs | 4 +- .../cli/cli/src/commands/query/connections.rs | 4 +- crates/cli/cli/src/impls/error.rs | 2 + .../impls/queries/consensus_state_height.rs | 13 ++- .../impls/queries/packet_acknowledgements.rs | 28 ++++-- .../src/impls/queries/packet_commitments.rs | 25 ++++-- .../src/impls/queries/unreceived_acks.rs | 18 +++- .../src/impls/queries/unreceived_packet.rs | 18 +++- .../src/impls/transaction/estimate_fee.rs | 12 ++- .../src/impls/transaction/query_nonce.rs | 13 ++- .../src/impls/types/config.rs | 88 ++++++++++++------- .../src/traits/grpc_address.rs | 4 +- .../types/config/gas/dynamic_gas_config.rs | 5 +- .../src/types/config/gas/eip_type.rs | 4 +- .../src/types/config/gas/gas_config.rs | 88 +------------------ .../src/types/config/mod.rs | 1 - .../src/types/config/tx_config.rs | 64 -------------- .../cosmos-relayer/src/contexts/build.rs | 6 +- .../cosmos-relayer/src/contexts/chain.rs | 21 ++--- .../cosmos/cosmos-relayer/src/impls/error.rs | 2 + .../cosmos/cosmos-test-components/Cargo.toml | 1 + .../src/chain/impls/proposal/query_status.rs | 20 +++-- .../src/chain/impls/queries/balance.rs | 15 +++- .../cosmos-wasm-relayer/src/context/chain.rs | 13 ++- 28 files changed, 222 insertions(+), 256 deletions(-) delete mode 100644 crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs diff --git a/Cargo.lock b/Cargo.lock index 3cebda4ee..608ca836f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1636,6 +1636,7 @@ dependencies = [ "hermes-relayer-components", "hermes-runtime", "hermes-runtime-components", + "http 1.1.0", "humantime", "ibc", "ibc-relayer", @@ -1660,6 +1661,7 @@ dependencies = [ "hermes-relayer-components", "hermes-runtime-components", "hermes-test-components", + "http 1.1.0", "serde", "toml", ] @@ -1854,6 +1856,7 @@ dependencies = [ "hermes-runtime", "hermes-runtime-components", "hermes-test-components", + "http 1.1.0", "ibc-proto", "ibc-relayer", "ibc-relayer-types", diff --git a/crates/cli/cli-components/Cargo.toml b/crates/cli/cli-components/Cargo.toml index ed3b5b1fc..4d1da2d9c 100644 --- a/crates/cli/cli-components/Cargo.toml +++ b/crates/cli/cli-components/Cargo.toml @@ -20,6 +20,7 @@ hermes-logging-components = { workspace = true } hermes-test-components = { workspace = true } cgp = { workspace = true } +http = { workspace = true } serde = { workspace = true, features = ["derive"] } toml = { workspace = true } clap = { workspace = true, features = ["derive"] } diff --git a/crates/cli/cli/Cargo.toml b/crates/cli/cli/Cargo.toml index 1d9c8f2f4..2360eb19a 100644 --- a/crates/cli/cli/Cargo.toml +++ b/crates/cli/cli/Cargo.toml @@ -42,6 +42,7 @@ eyre = { workspace = true } toml = { workspace = true } oneline-eyre = { workspace = true } hdpath = { workspace = true } +http = { workspace = true } humantime = { workspace = true } tracing = { workspace = true } tonic = { workspace = true } diff --git a/crates/cli/cli/src/commands/query/channel/client.rs b/crates/cli/cli/src/commands/query/channel/client.rs index adda17d6f..a33925a7e 100644 --- a/crates/cli/cli/src/commands/query/channel/client.rs +++ b/crates/cli/cli/src/commands/query/channel/client.rs @@ -3,6 +3,7 @@ use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; +use http::Uri; use ibc::core::channel::types::proto::v1::query_client::QueryClient; use ibc::core::channel::types::proto::v1::QueryChannelClientStateRequest; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; @@ -48,7 +49,8 @@ impl CommandRunner for QueryChannelClient { let channel_id = self.channel_id.clone(); let port_id = self.port_id.clone(); - let mut client = QueryClient::connect(chain.grpc_address().clone()).await?; + let mut client = + QueryClient::connect(Uri::try_from(&chain.grpc_address().to_string())?).await?; let request = tonic::Request::new(QueryChannelClientStateRequest { port_id: port_id.to_string(), diff --git a/crates/cli/cli/src/commands/query/channels.rs b/crates/cli/cli/src/commands/query/channels.rs index 56a21b0e7..899f6a373 100644 --- a/crates/cli/cli/src/commands/query/channels.rs +++ b/crates/cli/cli/src/commands/query/channels.rs @@ -1,3 +1,4 @@ +use http::Uri; use std::marker::PhantomData; use std::str::FromStr; use tracing::{info, warn}; @@ -53,7 +54,8 @@ impl CommandRunner for QueryChannels { let dst_chain_id = self.counterparty_chain_id.clone(); let show_counterparty = self.show_counterparty; - let mut client = QueryClient::connect(chain.grpc_address().clone()).await?; + let mut client = + QueryClient::connect(Uri::try_from(&chain.grpc_address().to_string())?).await?; let request = tonic::Request::new(QueryChannelsRequest { pagination: None }); diff --git a/crates/cli/cli/src/commands/query/connections.rs b/crates/cli/cli/src/commands/query/connections.rs index bc81b1f73..2913a4b0c 100644 --- a/crates/cli/cli/src/commands/query/connections.rs +++ b/crates/cli/cli/src/commands/query/connections.rs @@ -1,4 +1,5 @@ use core::marker::PhantomData; +use http::Uri; use tracing::{info, warn}; use hermes_cli_components::traits::build::CanLoadBuilder; @@ -51,7 +52,8 @@ impl CommandRunner for QueryConnections { let counterparty_chain_id = self.counterparty_chain_id.clone(); let verbose = self.verbose; - let mut client = QueryClient::connect(chain.grpc_address().clone()).await?; + let mut client = + QueryClient::connect(Uri::try_from(&chain.grpc_address().to_string())?).await?; let request = tonic::Request::new(QueryConnectionsRequest { pagination: None }); diff --git a/crates/cli/cli/src/impls/error.rs b/crates/cli/cli/src/impls/error.rs index 39f8fed7d..38fefd4ed 100644 --- a/crates/cli/cli/src/impls/error.rs +++ b/crates/cli/cli/src/impls/error.rs @@ -19,6 +19,7 @@ use ibc_relayer_types::core::ics02_client::height::HeightError; use ibc_relayer_types::core::ics03_connection::error::Error as Ics03Error; use ibc_relayer_types::core::ics23_commitment::error::Error as Ics23Error; use ibc_relayer_types::core::ics24_host::error::ValidationError as Ics24ValidationError; +use tonic::transport::Error as TransportError; pub struct ProvideCliError; @@ -59,6 +60,7 @@ delegate_components! { Ics03Error, Ics23Error, Ics24ValidationError, + TransportError, ]: ReportError, [ <'a> &'a str, diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/consensus_state_height.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/consensus_state_height.rs index 635b199f8..983820757 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/consensus_state_height.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/consensus_state_height.rs @@ -2,6 +2,8 @@ use cgp::core::error::CanRaiseError; use hermes_relayer_components::chain::traits::queries::consensus_state_height::ConsensusStateHeightsQuerier; use hermes_relayer_components::chain::traits::types::height::HasHeightType; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; +use http::uri::InvalidUri; +use http::Uri; use ibc_proto::ibc::core::client::v1::query_client::QueryClient; use ibc_relayer::chain::requests::QueryConsensusStateHeightsRequest; use ibc_relayer_types::core::ics24_host::identifier::ClientId; @@ -19,6 +21,7 @@ where Chain: HasIbcChainTypes + HasGrpcAddress + CanRaiseError + + CanRaiseError + CanRaiseError, Counterparty: HasHeightType, { @@ -26,10 +29,12 @@ where chain: &Chain, client_id: &ClientId, ) -> Result, Chain::Error> { - let mut client = QueryClient::connect(chain.grpc_address().clone()) - .await - .map_err(Chain::raise_error)? - .max_decoding_message_size(33554432); + let mut client = QueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)? + .max_decoding_message_size(33554432); let request = QueryConsensusStateHeightsRequest { client_id: client_id.clone(), diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs index f4ebb46ed..586dfbefd 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs @@ -1,15 +1,21 @@ -use std::collections::HashSet; - use cgp::core::error::CanRaiseError; use eyre::eyre; +use http::uri::InvalidUri; +use http::Uri; +use std::collections::HashSet; +use tonic::transport::Error as TransportError; +use tonic::Request; +use tonic::Status; + use hermes_relayer_components::chain::traits::queries::packet_acknowledgements::PacketAcknowledgementsQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; + use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::{Paginate, QueryPacketAcknowledgementsRequest}; +use ibc_relayer_types::core::ics02_client::error::Error as Ics02Error; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; use ibc_relayer_types::Height; -use tonic::Request; use crate::traits::grpc_address::HasGrpcAddress; @@ -25,6 +31,10 @@ where ChannelId = ChannelId, Sequence = Sequence, > + HasGrpcAddress + + CanRaiseError + + CanRaiseError + + CanRaiseError + + CanRaiseError + CanRaiseError, Counterparty: HasIbcChainTypes, { @@ -34,9 +44,11 @@ where port_id: &Chain::PortId, sequences: &[Counterparty::Sequence], ) -> Result, Chain::Height)>, Chain::Error> { - let mut client = ChannelQueryClient::connect(chain.grpc_address().clone()) - .await - .map_err(|e| Chain::raise_error(e.into()))?; + let mut client = ChannelQueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)?; let raw_request = QueryPacketAcknowledgementsRequest { port_id: port_id.clone(), @@ -50,7 +62,7 @@ where let response = client .packet_acknowledgements(request) .await - .map_err(|e| Chain::raise_error(e.into()))? + .map_err(Chain::raise_error)? .into_inner(); let commit_set = sequences.iter().cloned().collect::>(); @@ -68,7 +80,7 @@ where .height .ok_or_else(|| Chain::raise_error(eyre!("missing height in response")))?; - let height = Height::try_from(raw_height).map_err(|e| Chain::raise_error(e.into()))?; + let height = Height::try_from(raw_height).map_err(Chain::raise_error)?; Ok(Some((response_acks, height))) } diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs index b281d6058..1e3e9c796 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs @@ -1,13 +1,20 @@ use cgp::core::error::CanRaiseError; use eyre::eyre; +use http::uri::InvalidUri; +use http::Uri; +use tonic::transport::Error as TransportError; +use tonic::Request; +use tonic::Status; + use hermes_relayer_components::chain::traits::queries::packet_commitments::PacketCommitmentsQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; + use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::{Paginate, QueryPacketCommitmentsRequest}; +use ibc_relayer_types::core::ics02_client::error::Error as Ics02Error; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; use ibc_relayer_types::Height; -use tonic::Request; use crate::traits::grpc_address::HasGrpcAddress; @@ -23,6 +30,10 @@ where ChannelId = ChannelId, Sequence = Sequence, > + HasGrpcAddress + + CanRaiseError + + CanRaiseError + + CanRaiseError + + CanRaiseError + CanRaiseError, { async fn query_packet_commitments( @@ -30,9 +41,11 @@ where channel_id: &Chain::ChannelId, port_id: &Chain::PortId, ) -> Result<(Vec, Chain::Height), Chain::Error> { - let mut client = ChannelQueryClient::connect(chain.grpc_address().clone()) - .await - .map_err(|e| Chain::raise_error(e.into()))?; + let mut client = ChannelQueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)?; let raw_request = QueryPacketCommitmentsRequest { port_id: port_id.clone(), @@ -46,7 +59,7 @@ where let response = client .packet_commitments(request) .await - .map_err(|e| Chain::raise_error(e.into()))? + .map_err(Chain::raise_error)? .into_inner(); let commitment_sequences: Vec = response @@ -59,7 +72,7 @@ where .height .ok_or_else(|| Chain::raise_error(eyre!("missing height in response")))?; - let height = Height::try_from(raw_height).map_err(|e| Chain::raise_error(e.into()))?; + let height = Height::try_from(raw_height).map_err(Chain::raise_error)?; Ok((commitment_sequences, height)) } diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs index 629f27fb6..682968264 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs @@ -1,6 +1,11 @@ use cgp::core::error::{CanRaiseError, HasErrorType}; use hermes_relayer_components::chain::traits::queries::unreceived_acks_sequences::UnreceivedAcksSequencesQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; +use http::uri::InvalidUri; +use http::Uri; +use tonic::transport::Error as TransportError; +use tonic::Status; + use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::QueryUnreceivedAcksRequest; use ibc_relayer_types::core::ics04_channel::packet::Sequence; @@ -17,6 +22,9 @@ where Chain: HasIbcChainTypes + HasErrorType + HasGrpcAddress + + CanRaiseError + + CanRaiseError + + CanRaiseError + CanRaiseError, Counterparty: HasIbcChainTypes, { @@ -26,9 +34,11 @@ where port_id: &Chain::PortId, sequences: &[Chain::Sequence], ) -> Result, Chain::Error> { - let mut client = ChannelQueryClient::connect(chain.grpc_address().clone()) - .await - .map_err(|e| Chain::raise_error(e.into()))?; + let mut client = ChannelQueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)?; let raw_request = QueryUnreceivedAcksRequest { port_id: port_id.clone(), @@ -41,7 +51,7 @@ where let response = client .unreceived_acks(request) .await - .map_err(|e| Chain::raise_error(e.into()))? + .map_err(Chain::raise_error)? .into_inner(); let response_sequences = response.sequences.into_iter().map(|s| s.into()).collect(); diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs index 58cf1ed5e..6c5c97826 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs @@ -1,6 +1,11 @@ use cgp::core::error::{CanRaiseError, HasErrorType}; use hermes_relayer_components::chain::traits::queries::unreceived_packet_sequences::UnreceivedPacketSequencesQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; +use http::uri::InvalidUri; +use http::Uri; +use tonic::transport::Error as TransportError; +use tonic::Status; + use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::QueryUnreceivedPacketsRequest; use ibc_relayer_types::core::ics04_channel::packet::Sequence; @@ -17,6 +22,9 @@ where Chain: HasIbcChainTypes + HasErrorType + HasGrpcAddress + + CanRaiseError + + CanRaiseError + + CanRaiseError + CanRaiseError, Counterparty: HasIbcChainTypes, { @@ -26,9 +34,11 @@ where port_id: &Chain::PortId, sequences: &[Counterparty::Sequence], ) -> Result, Chain::Error> { - let mut client = ChannelQueryClient::connect(chain.grpc_address().clone()) - .await - .map_err(|e| Chain::raise_error(e.into()))?; + let mut client = ChannelQueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)?; let raw_request = QueryUnreceivedPacketsRequest { port_id: port_id.clone(), @@ -41,7 +51,7 @@ where let response = client .unreceived_packets(request) .await - .map_err(|e| Chain::raise_error(e.into()))? + .map_err(Chain::raise_error)? .into_inner(); let response_sequences = response.sequences.into_iter().map(|s| s.into()).collect(); diff --git a/crates/cosmos/cosmos-chain-components/src/impls/transaction/estimate_fee.rs b/crates/cosmos/cosmos-chain-components/src/impls/transaction/estimate_fee.rs index cf7edaad5..37a7d31a2 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/transaction/estimate_fee.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/transaction/estimate_fee.rs @@ -3,6 +3,7 @@ use hermes_relayer_components::chain::traits::types::chain_id::HasChainId; use hermes_relayer_components::transaction::traits::estimate_tx_fee::TxFeeEstimator; use hermes_relayer_components::transaction::traits::types::fee::HasFeeType; use hermes_relayer_components::transaction::traits::types::transaction::HasTransactionType; +use http::uri::InvalidUri; use ibc_proto::cosmos::tx::v1beta1::service_client::ServiceClient; use ibc_proto::cosmos::tx::v1beta1::{Fee, SimulateRequest, SimulateResponse, Tx}; use ibc_relayer::chain::cosmos::types::tx::SignedTx; @@ -31,6 +32,7 @@ where + HasChainId + CanRaiseError + CanRaiseError + + CanRaiseError + CanConvertGasToFee + CanRaiseError<&'static str>, { @@ -48,10 +50,12 @@ where ..Default::default() }; - let mut client = ServiceClient::connect(chain.grpc_address().clone()) - .await - .map_err(Chain::raise_error)? - .max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize); + let mut client = ServiceClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)? + .max_decoding_message_size(max_grpc_decoding_size().get_bytes() as usize); let response = client .simulate(request) diff --git a/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs b/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs index 3d5429eef..d0d5db451 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs @@ -2,6 +2,9 @@ use cgp::core::error::CanRaiseError; use hermes_relayer_components::transaction::traits::nonce::query_nonce::NonceQuerier; use hermes_relayer_components::transaction::traits::types::nonce::HasNonceType; use hermes_relayer_components::transaction::traits::types::signer::HasSignerType; +use http::uri::InvalidUri; +use http::Uri; + use ibc_relayer::chain::cosmos::query::account::query_account; use ibc_relayer::chain::cosmos::types::account::Account; use ibc_relayer::error::Error as RelayerError; @@ -16,6 +19,7 @@ where Chain: HasSignerType + HasNonceType + HasGrpcAddress + + CanRaiseError + CanRaiseError, { async fn query_nonce( @@ -24,9 +28,12 @@ where ) -> Result { let address = key_pair.account(); - let account = query_account(chain.grpc_address(), &address) - .await - .map_err(Chain::raise_error)?; + let account = query_account( + &Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + &address, + ) + .await + .map_err(Chain::raise_error)?; Ok(account.into()) } diff --git a/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs index 42a649d7b..44e45c8e9 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs @@ -1,13 +1,22 @@ use core::time::Duration; -use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; +use ibc_proto::cosmos::base::v1beta1::Coin; use serde::Deserialize; use serde::Serialize; use std::path::PathBuf; +use tendermint_rpc::Url; + +use ibc_proto::cosmos::tx::v1beta1::Fee; +use ibc_proto::google::protobuf::Any; +use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; + +use crate::types::config::gas::dynamic_gas_config::DynamicGasConfig; +use crate::types::config::gas::gas_config::GasConfig; + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CosmosChainConfig { pub id: String, - pub grpc_addr: String, + pub grpc_addr: Url, pub account_prefix: String, pub key_store_folder: Option, pub key_name: String, @@ -17,24 +26,16 @@ pub struct CosmosChainConfig { pub clock_drift: Duration, pub max_block_time: Duration, - pub rpc_addr: String, + pub rpc_addr: Url, pub rpc_timeout: Duration, pub address_type: String, pub max_msg_num: usize, pub max_tx_size: usize, - pub default_gas: Option, - pub max_gas: Option, - pub gas_multiplier: Option, - pub gas_price_amount: f64, - pub gas_price_denom: String, - pub fee_granter: Option, - pub dynamic_gas_price_enabled: bool, - pub dynamic_gas_price_multiplier: f64, - pub dynamic_gas_price_max: f64, + pub gas_config: GasConfig, pub compat_mode: Option, - pub extension_options: Vec, + pub extension_options: Vec, } #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] @@ -62,36 +63,61 @@ impl From for CosmosChainConfig { max_retries: _, } => EventSourceMode::Pull, }; + let gas_multiplier = value.gas_multiplier.unwrap_or_default().to_f64(); + let fee_granter = value.fee_granter.unwrap_or("".to_owned()); + let max_gas = value.max_gas.unwrap_or(400_000); + let max_amount = (max_gas as f64 * gas_multiplier) * value.gas_price.price; + let max_gas_fee_in_coin = Coin { + denom: value.gas_price.denom.clone(), + amount: max_amount.to_string(), + }; + + let max_fee = Fee { + amount: vec![max_gas_fee_in_coin], + gas_limit: max_gas, + payer: "".to_string(), + granter: fee_granter.clone(), + }; + + let dynamic_gas = if value.dynamic_gas_price.enabled { + Some(DynamicGasConfig { + multiplier: value.dynamic_gas_price.multiplier, + max: value.dynamic_gas_price.max, + eip_query_type: Default::default(), + denom: value.gas_price.denom.clone(), + }) + } else { + None + }; + let gas_config = GasConfig { + default_gas: value.default_gas.unwrap_or(400_000), + max_gas, + gas_multiplier: value.gas_multiplier.unwrap_or_default().to_f64(), + gas_price: value.gas_price, + max_fee, + fee_granter, + dynamic_gas_config: dynamic_gas, + }; + let mut extension_options = vec![]; + for extension_option in value.extension_options.into_iter() { + extension_options.push(extension_option.to_any().unwrap()); + } Self { id: value.id.to_string(), - grpc_addr: value.grpc_addr.to_string(), + grpc_addr: value.grpc_addr, account_prefix: value.account_prefix, key_store_folder: value.key_store_folder, key_name: value.key_name, store_prefix: value.store_prefix, event_source, - rpc_addr: value.rpc_addr.to_string(), + rpc_addr: value.rpc_addr, rpc_timeout: value.rpc_timeout, address_type: value.address_type.to_string(), max_msg_num: value.max_msg_num.to_usize(), max_tx_size: value.max_tx_size.to_usize(), - default_gas: value.default_gas, - max_gas: value.max_gas, - gas_multiplier: value - .gas_multiplier - .map(|gas_multiplier| gas_multiplier.to_f64()), - gas_price_amount: value.gas_price.price, - gas_price_denom: value.gas_price.denom, - fee_granter: value.fee_granter, - dynamic_gas_price_enabled: value.dynamic_gas_price.enabled, - dynamic_gas_price_multiplier: value.dynamic_gas_price.multiplier, - dynamic_gas_price_max: value.dynamic_gas_price.max, + gas_config, compat_mode: value.compat_mode.map(|compat_mode| compat_mode.to_string()), - extension_options: value - .extension_options - .iter() - .map(|extension_option| extension_option.to_string()) - .collect(), + extension_options, clock_drift: value.clock_drift, max_block_time: value.max_block_time, } diff --git a/crates/cosmos/cosmos-chain-components/src/traits/grpc_address.rs b/crates/cosmos/cosmos-chain-components/src/traits/grpc_address.rs index 1ea26bb99..af3d05fcf 100644 --- a/crates/cosmos/cosmos-chain-components/src/traits/grpc_address.rs +++ b/crates/cosmos/cosmos-chain-components/src/traits/grpc_address.rs @@ -1,7 +1,7 @@ use cgp::prelude::*; -use http::Uri; +use tendermint_rpc::Url; #[derive_component(GrpcAddressGetterComponent, GrpcAddressGetter)] pub trait HasGrpcAddress: Async { - fn grpc_address(&self) -> &Uri; + fn grpc_address(&self) -> &Url; } diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs index f46b8d319..031408fa0 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs @@ -1,6 +1,9 @@ +use serde::Deserialize; +use serde::Serialize; + use crate::types::config::gas::eip_type::EipQueryType; -#[derive(Debug, Clone, PartialEq, PartialOrd)] +#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct DynamicGasConfig { pub multiplier: f64, pub max: f64, diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs index 0b75ce5ca..89ebbfa09 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs @@ -1,7 +1,9 @@ use core::str::FromStr; use eyre::Report; +use serde::Deserialize; +use serde::Serialize; -#[derive(Clone, Debug, Default, PartialEq, PartialOrd)] +#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Serialize, Deserialize)] pub enum EipQueryType { #[default] FeeMarket, diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs index 4978c39bd..f29cf0e36 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs @@ -1,11 +1,12 @@ +use serde::Deserialize; +use serde::Serialize; + use ibc_proto::cosmos::tx::v1beta1::Fee; -use ibc_relayer::chain::cosmos::gas::calculate_fee; use ibc_relayer::config::GasPrice; -use crate::impls::types::config::CosmosChainConfig; use crate::types::config::gas::dynamic_gas_config::DynamicGasConfig; -use crate::types::config::gas::eip_type::EipQueryType; +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct GasConfig { pub default_gas: u64, pub max_gas: u64, @@ -15,84 +16,3 @@ pub struct GasConfig { pub fee_granter: String, pub dynamic_gas_config: Option, } - -impl<'a> From<&'a CosmosChainConfig> for GasConfig { - fn from(config: &'a CosmosChainConfig) -> Self { - let eip_query_type = if config.id.as_str().starts_with("osmo") { - EipQueryType::Osmosis - } else { - EipQueryType::FeeMarket - }; - let dynamic_gas_config = if config.dynamic_gas_price_enabled { - Some(DynamicGasConfig { - multiplier: config.dynamic_gas_price_multiplier, - max: config.dynamic_gas_price_max, - denom: config.gas_price_denom.clone(), - eip_query_type, - }) - } else { - None - }; - let gas_price = GasPrice { - price: config.gas_price_amount, - denom: config.gas_price_denom.clone(), - }; - Self { - default_gas: default_gas_from_config(config), - max_gas: max_gas_from_config(config), - gas_multiplier: gas_multiplier_from_config(config), - gas_price, - max_fee: max_fee_from_config(config), - fee_granter: fee_granter_from_config(config), - dynamic_gas_config, - } - } -} - -/// Get the fee granter address -fn fee_granter_from_config(config: &CosmosChainConfig) -> String { - config - .fee_granter - .clone() - .unwrap_or("".to_owned()) - .to_string() -} - -fn max_fee_from_config(config: &CosmosChainConfig) -> Fee { - let max_gas = max_gas_from_config(config); - - let gas_price = GasPrice { - price: config.gas_price_amount, - denom: config.gas_price_denom.clone(), - }; - - // The maximum fee the relayer pays for a transaction - let max_fee_in_coins = calculate_fee(max_gas, &gas_price); - - let fee_granter = fee_granter_from_config(config); - - Fee { - amount: vec![max_fee_in_coins], - gas_limit: max_gas, - payer: "".to_string(), - granter: fee_granter, - } -} - -/// The default amount of gas the relayer is willing to pay for a transaction, -/// when it cannot simulate the tx and therefore estimate the gas amount needed. -fn default_gas_from_config(config: &CosmosChainConfig) -> u64 { - config - .default_gas - .unwrap_or_else(|| max_gas_from_config(config)) -} - -/// The maximum amount of gas the relayer is willing to pay for a transaction -fn max_gas_from_config(config: &CosmosChainConfig) -> u64 { - config.max_gas.unwrap_or(400_000) -} - -/// The gas multiplier -fn gas_multiplier_from_config(config: &CosmosChainConfig) -> f64 { - config.gas_multiplier.unwrap_or_default() -} diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/mod.rs b/crates/cosmos/cosmos-chain-components/src/types/config/mod.rs index 06b2635f4..8826db296 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/mod.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/mod.rs @@ -1,2 +1 @@ pub mod gas; -pub mod tx_config; diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs deleted file mode 100644 index e52e36a36..000000000 --- a/crates/cosmos/cosmos-chain-components/src/types/config/tx_config.rs +++ /dev/null @@ -1,64 +0,0 @@ -use core::str::FromStr; -use core::time::Duration; -use eyre::Report; -use http::Uri; -use ibc::primitives::proto::Any; -use ibc_relayer::extension_options::ExtensionOptionDynamicFeeTx; -use tendermint_rpc::Url; - -use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize}; -use ibc_relayer::config::AddressType; -use ibc_relayer_types::core::ics24_host::identifier::ChainId; - -use crate::impls::types::config::CosmosChainConfig; -use crate::types::config::gas::gas_config::GasConfig; - -pub struct TxConfig { - pub chain_id: ChainId, - pub gas_config: GasConfig, - pub rpc_address: Url, - pub grpc_address: Uri, - pub rpc_timeout: Duration, - pub address_type: AddressType, - pub max_msg_num: MaxMsgNum, - pub max_tx_size: MaxTxSize, - pub extension_options: Vec, -} - -impl<'a> TryFrom<&'a CosmosChainConfig> for TxConfig { - type Error = Report; - - fn try_from(config: &'a CosmosChainConfig) -> Result { - let grpc_address = Uri::from_str(&config.grpc_addr.to_string()).map_err(|e| { - Report::msg(format!( - "failed to create Uri from gRPC address string `{}`: {e}", - config.grpc_addr - )) - })?; - - let gas_config = GasConfig::from(config); - - let extension_options = config - .extension_options - .iter() - .map(|opt| { - ExtensionOptionDynamicFeeTx { - max_priority_price: opt.into(), - } - .to_any() - }) - .collect::>()?; - - Ok(Self { - chain_id: ChainId::from_string(&config.id), - gas_config, - rpc_address: Url::from_str(&config.rpc_addr).unwrap(), - grpc_address, - rpc_timeout: config.rpc_timeout, - address_type: AddressType::Cosmos, - max_msg_num: MaxMsgNum::new(config.max_msg_num).unwrap(), - max_tx_size: MaxTxSize::new(config.max_tx_size).unwrap(), - extension_options, - }) - } -} diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index 5c603327b..7a7e0063d 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -9,7 +9,6 @@ use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use std::collections::HashMap; use std::fs::{self, File}; -use hermes_cosmos_chain_components::types::config::tx_config::TxConfig; use hermes_error::types::Error; use hermes_relayer_components::build::traits::builders::birelay_from_relay_builder::BiRelayFromRelayBuilder; use hermes_relayer_components::build::traits::builders::chain_builder::ChainBuilder; @@ -173,9 +172,9 @@ impl CosmosBuilder { let event_source_mode = chain_config.event_source.clone(); - let tx_config = TxConfig::try_from(&chain_config)?; + //let tx_config = TxConfig::try_from(&chain_config)?; - let mut rpc_client = HttpClient::new(tx_config.rpc_address.clone())?; + let mut rpc_client = HttpClient::new(chain_config.rpc_addr.clone())?; let compat_mode = if let Some(compat_mode) = &chain_config.compat_mode { CompatMode::from_str(compat_mode.as_str()).unwrap() @@ -189,7 +188,6 @@ impl CosmosBuilder { let context = CosmosChain::new( chain_config, - tx_config, rpc_client, compat_mode, key, diff --git a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs index 13a6806cc..f7c48aba1 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs @@ -6,7 +6,6 @@ use hermes_cosmos_chain_components::traits::convert_gas_to_fee::CanConvertGasToF use hermes_cosmos_chain_components::traits::eip::eip_query::CanQueryEipBaseFee; use hermes_cosmos_chain_components::traits::unbonding_period::CanQueryUnbondingPeriod; use hermes_cosmos_chain_components::types::config::gas::gas_config::GasConfig; -use hermes_cosmos_chain_components::types::config::tx_config::TxConfig; use hermes_cosmos_chain_components::types::payloads::client::{ CosmosCreateClientOptions, CosmosCreateClientPayload, CosmosUpdateClientPayload, }; @@ -99,7 +98,6 @@ use hermes_wasm_test_components::traits::chain::messages::store_code::StoreCodeM use hermes_wasm_test_components::traits::chain::upload_client_code::{ CanUploadWasmClientCode, WasmClientCodeUploaderComponent, }; -use http::Uri; use ibc::core::channel::types::channel::ChannelEnd; use ibc_proto::cosmos::tx::v1beta1::Fee; use ibc_relayer::chain::cosmos::types::account::Account; @@ -130,7 +128,6 @@ pub struct BaseCosmosChain { pub runtime: HermesRuntime, pub telemetry: CosmosTelemetry, pub subscription: Arc)>>, - pub tx_config: TxConfig, pub ibc_commitment_prefix: Vec, pub rpc_client: HttpClient, pub key_entry: Secp256k1KeyPair, @@ -216,13 +213,13 @@ delegate_components! { impl TxExtensionOptionsGetter for CosmosChainContextComponents { fn tx_extension_options(chain: &CosmosChain) -> &Vec { - &chain.tx_config.extension_options + &chain.chain_config.extension_options } } impl GasConfigGetter for CosmosChainContextComponents { fn gas_config(chain: &CosmosChain) -> &GasConfig { - &chain.tx_config.gas_config + &chain.chain_config.gas_config } } @@ -234,7 +231,7 @@ impl DefaultSignerGetter for CosmosChainContextComponents { impl FeeForSimulationGetter for CosmosChainContextComponents { fn fee_for_simulation(chain: &CosmosChain) -> &Fee { - &chain.tx_config.gas_config.max_fee + &chain.chain_config.gas_config.max_fee } } @@ -266,7 +263,6 @@ impl IbcCommitmentPrefixGetter for CosmosChainContextComponents { impl CosmosChain { pub fn new( chain_config: CosmosChainConfig, - tx_config: TxConfig, rpc_client: HttpClient, compat_mode: CompatMode, key_entry: Secp256k1KeyPair, @@ -274,7 +270,8 @@ impl CosmosChain { runtime: HermesRuntime, telemetry: CosmosTelemetry, ) -> Self { - let chain_version = tx_config.chain_id.version(); + let chain_id = ChainId::from_string(&chain_config.id); + let chain_version = chain_id.version(); let subscription = match event_source_mode { EventSourceMode::Push { url } => runtime.new_abci_event_subscription( @@ -289,7 +286,6 @@ impl CosmosChain { } }; - let chain_id = tx_config.chain_id.clone(); let ibc_commitment_prefix = chain_config.store_prefix.clone().into(); let chain = Self { @@ -300,7 +296,6 @@ impl CosmosChain { runtime, telemetry, subscription, - tx_config, ibc_commitment_prefix, rpc_client, key_entry, @@ -321,8 +316,8 @@ impl HasTelemetry for CosmosChain { } impl GrpcAddressGetter for CosmosChainContextComponents { - fn grpc_address(chain: &CosmosChain) -> &Uri { - &chain.tx_config.grpc_address + fn grpc_address(chain: &CosmosChain) -> &Url { + &chain.chain_config.grpc_addr } } @@ -332,7 +327,7 @@ impl RpcClientGetter for CosmosChainContextComponents { } fn rpc_address(chain: &CosmosChain) -> &Url { - &chain.tx_config.rpc_address + &chain.chain_config.rpc_addr } } diff --git a/crates/cosmos/cosmos-relayer/src/impls/error.rs b/crates/cosmos/cosmos-relayer/src/impls/error.rs index 71b8342dc..03686f89d 100644 --- a/crates/cosmos/cosmos-relayer/src/impls/error.rs +++ b/crates/cosmos/cosmos-relayer/src/impls/error.rs @@ -3,6 +3,7 @@ use core::array::TryFromSliceError; use core::convert::Infallible; use core::num::{ParseFloatError, ParseIntError, TryFromIntError}; use core::str::Utf8Error; +use http::uri::InvalidUri; use cgp::core::component::UseDelegate; use cgp::core::error::{ErrorRaiser, ErrorRaiserComponent, ErrorTypeComponent}; @@ -145,6 +146,7 @@ delegate_components! { TryFromSliceError, subtle_encoding::Error, reqwest::Error, + InvalidUri, // TODO: make it retryable? TransportError, diff --git a/crates/cosmos/cosmos-test-components/Cargo.toml b/crates/cosmos/cosmos-test-components/Cargo.toml index feee46ff8..697d5490d 100644 --- a/crates/cosmos/cosmos-test-components/Cargo.toml +++ b/crates/cosmos/cosmos-test-components/Cargo.toml @@ -23,6 +23,7 @@ ibc-relayer = { workspace = true } ibc-relayer-types = { workspace = true } ibc-proto = { workspace = true } +http = { workspace = true } itertools = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs b/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs index 5a0785f2c..f4785581f 100644 --- a/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs +++ b/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs @@ -1,14 +1,17 @@ +use cgp::core::error::CanRaiseError; use core::fmt::Debug; +use http::uri::InvalidUri; +use http::Uri; +use tonic::transport::Error as TransportError; +use tonic::Status; -use cgp::core::error::CanRaiseError; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; use hermes_test_components::chain::traits::proposal::query_status::ProposalStatusQuerier; use hermes_test_components::chain::traits::proposal::types::proposal_id::HasProposalIdType; use hermes_test_components::chain::traits::proposal::types::proposal_status::HasProposalStatusType; + use ibc_proto::cosmos::gov::v1::query_client::QueryClient; use ibc_proto::cosmos::gov::v1::{Proposal, QueryProposalRequest}; -use tonic::transport::Error as TransportError; -use tonic::Status; use crate::chain::types::proposal_status::ProposalStatus; @@ -24,6 +27,7 @@ where Chain: HasProposalIdType + HasProposalStatusType + HasGrpcAddress + + CanRaiseError + CanRaiseError + CanRaiseError + CanRaiseError @@ -33,11 +37,11 @@ where chain: &Chain, proposal_id: &u64, ) -> Result { - let grpc_address = chain.grpc_address(); - - let mut client = QueryClient::connect(grpc_address.clone()) - .await - .map_err(Chain::raise_error)?; + let mut client = QueryClient::connect( + Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + ) + .await + .map_err(Chain::raise_error)?; let request = tonic::Request::new(QueryProposalRequest { proposal_id: *proposal_id, diff --git a/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs b/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs index 9569b01db..fbae95495 100644 --- a/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs +++ b/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs @@ -5,6 +5,9 @@ use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; use hermes_test_components::chain::traits::queries::balance::BalanceQuerier; use hermes_test_components::chain::traits::types::address::HasAddressType; use hermes_test_components::chain::traits::types::amount::HasAmountType; +use http::uri::InvalidUri; +use http::Uri; + use ibc_relayer::chain::cosmos::query::balance::query_balance; use ibc_relayer::error::Error as RelayerError; @@ -19,6 +22,7 @@ where + HasAmountType + HasGrpcAddress + CanRaiseError + + CanRaiseError + CanRaiseError, { async fn query_balance( @@ -26,12 +30,15 @@ where address: &Chain::Address, denom: &Denom, ) -> Result { - let grpc_address = chain.grpc_address(); let denom_str = denom.to_string(); - let balance = query_balance(grpc_address, &address.to_string(), &denom_str) - .await - .map_err(Chain::raise_error)?; + let balance = query_balance( + &Uri::try_from(&chain.grpc_address().to_string()).map_err(Chain::raise_error)?, + &address.to_string(), + &denom_str, + ) + .await + .map_err(Chain::raise_error)?; let quantity = balance.amount.parse().map_err(Chain::raise_error)?; diff --git a/crates/cosmos/cosmos-wasm-relayer/src/context/chain.rs b/crates/cosmos/cosmos-wasm-relayer/src/context/chain.rs index 49930a0e5..8d159b6a6 100644 --- a/crates/cosmos/cosmos-wasm-relayer/src/context/chain.rs +++ b/crates/cosmos/cosmos-wasm-relayer/src/context/chain.rs @@ -227,7 +227,6 @@ use hermes_wasm_test_components::traits::chain::messages::store_code::StoreCodeM use hermes_wasm_test_components::traits::chain::upload_client_code::{ CanUploadWasmClientCode, WasmClientCodeUploaderComponent, }; -use http::Uri; use ibc::core::channel::types::channel::ChannelEnd; use ibc_proto::cosmos::tx::v1beta1::Fee; use ibc_relayer::chain::cosmos::types::account::Account; @@ -475,13 +474,13 @@ delegate_components! { impl TxExtensionOptionsGetter for WasmCosmosChainComponents { fn tx_extension_options(chain: &WasmCosmosChain) -> &Vec { - &chain.tx_config.extension_options + &chain.chain_config.extension_options } } impl GasConfigGetter for WasmCosmosChainComponents { fn gas_config(chain: &WasmCosmosChain) -> &GasConfig { - &chain.tx_config.gas_config + &chain.chain_config.gas_config } } @@ -493,7 +492,7 @@ impl DefaultSignerGetter for WasmCosmosChainComponents { impl FeeForSimulationGetter for WasmCosmosChainComponents { fn fee_for_simulation(chain: &WasmCosmosChain) -> &Fee { - &chain.tx_config.gas_config.max_fee + &chain.chain_config.gas_config.max_fee } } @@ -523,8 +522,8 @@ impl IbcCommitmentPrefixGetter for WasmCosmosChainComponents { } impl GrpcAddressGetter for WasmCosmosChainComponents { - fn grpc_address(chain: &WasmCosmosChain) -> &Uri { - &chain.tx_config.grpc_address + fn grpc_address(chain: &WasmCosmosChain) -> &Url { + &chain.chain_config.grpc_addr } } @@ -534,7 +533,7 @@ impl RpcClientGetter for WasmCosmosChainComponents { } fn rpc_address(chain: &WasmCosmosChain) -> &Url { - &chain.tx_config.rpc_address + &chain.chain_config.rpc_addr } } From 10dbf439eb0564ad5a16b32278d7e9726a3f0078 Mon Sep 17 00:00:00 2001 From: Luca Joss Date: Wed, 4 Dec 2024 10:01:13 +0100 Subject: [PATCH 3/3] cargo fmt --- .../cli/cli/src/commands/query/channel/client.rs | 4 +--- crates/cli/cli/src/commands/query/channels.rs | 2 +- crates/cli/cli/src/commands/query/connections.rs | 5 ++--- .../src/impls/queries/packet_acknowledgements.rs | 14 ++++++-------- .../src/impls/queries/packet_commitments.rs | 11 ++++------- .../src/impls/queries/unreceived_acks.rs | 6 ++---- .../src/impls/queries/unreceived_packet.rs | 6 ++---- .../src/impls/transaction/query_nonce.rs | 1 - .../src/impls/types/config.rs | 8 +++----- .../src/types/config/gas/dynamic_gas_config.rs | 3 +-- .../src/types/config/gas/eip_type.rs | 3 +-- .../src/types/config/gas/gas_config.rs | 4 +--- crates/cosmos/cosmos-relayer/src/contexts/build.rs | 2 +- crates/cosmos/cosmos-relayer/src/contexts/chain.rs | 2 +- crates/cosmos/cosmos-relayer/src/impls/error.rs | 2 +- .../src/chain/impls/proposal/query_status.rs | 11 +++++------ .../src/chain/impls/queries/balance.rs | 1 - 17 files changed, 32 insertions(+), 53 deletions(-) diff --git a/crates/cli/cli/src/commands/query/channel/client.rs b/crates/cli/cli/src/commands/query/channel/client.rs index f4f5a944d..32e02aa7c 100644 --- a/crates/cli/cli/src/commands/query/channel/client.rs +++ b/crates/cli/cli/src/commands/query/channel/client.rs @@ -1,10 +1,8 @@ -use http::Uri; - use hermes_cli_components::traits::build::CanLoadBuilder; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; - +use http::Uri; use ibc::core::channel::types::proto::v1::query_client::QueryClient; use ibc::core::channel::types::proto::v1::QueryChannelClientStateRequest; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; diff --git a/crates/cli/cli/src/commands/query/channels.rs b/crates/cli/cli/src/commands/query/channels.rs index b502d00f9..fce350ebf 100644 --- a/crates/cli/cli/src/commands/query/channels.rs +++ b/crates/cli/cli/src/commands/query/channels.rs @@ -1,4 +1,3 @@ -use http::Uri; use std::marker::PhantomData; use std::str::FromStr; @@ -9,6 +8,7 @@ use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_relayer_components::chain::traits::queries::chain_status::CanQueryChainHeight; +use http::Uri; use ibc::core::channel::types::proto::v1::query_client::QueryClient; use ibc::core::channel::types::proto::v1::QueryChannelsRequest; use ibc_relayer_types::core::ics04_channel::channel::{IdentifiedChannelEnd, State}; diff --git a/crates/cli/cli/src/commands/query/connections.rs b/crates/cli/cli/src/commands/query/connections.rs index 2913a4b0c..935382e68 100644 --- a/crates/cli/cli/src/commands/query/connections.rs +++ b/crates/cli/cli/src/commands/query/connections.rs @@ -1,6 +1,4 @@ use core::marker::PhantomData; -use http::Uri; -use tracing::{info, warn}; use hermes_cli_components::traits::build::CanLoadBuilder; use hermes_cli_framework::command::CommandRunner; @@ -8,12 +6,13 @@ use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_relayer_components::chain::traits::queries::client_state::CanQueryClientStateWithLatestHeight; - +use http::Uri; use ibc::core::connection::types::proto::v1::query_client::QueryClient; use ibc::core::connection::types::proto::v1::QueryConnectionsRequest; use ibc_relayer_types::core::ics02_client::client_state::ClientState; use ibc_relayer_types::core::ics03_connection::connection::IdentifiedConnectionEnd; use ibc_relayer_types::core::ics24_host::identifier::ChainId; +use tracing::{info, warn}; use crate::contexts::app::HermesApp; use crate::Result; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs index 586dfbefd..89835e52a 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_acknowledgements.rs @@ -1,21 +1,19 @@ -use cgp::core::error::CanRaiseError; -use eyre::eyre; -use http::uri::InvalidUri; -use http::Uri; use std::collections::HashSet; -use tonic::transport::Error as TransportError; -use tonic::Request; -use tonic::Status; +use cgp::core::error::CanRaiseError; +use eyre::eyre; use hermes_relayer_components::chain::traits::queries::packet_acknowledgements::PacketAcknowledgementsQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; - +use http::uri::InvalidUri; +use http::Uri; use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::{Paginate, QueryPacketAcknowledgementsRequest}; use ibc_relayer_types::core::ics02_client::error::Error as Ics02Error; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; use ibc_relayer_types::Height; +use tonic::transport::Error as TransportError; +use tonic::{Request, Status}; use crate::traits::grpc_address::HasGrpcAddress; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs index 1e3e9c796..e9c60b563 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/packet_commitments.rs @@ -1,20 +1,17 @@ use cgp::core::error::CanRaiseError; use eyre::eyre; -use http::uri::InvalidUri; -use http::Uri; -use tonic::transport::Error as TransportError; -use tonic::Request; -use tonic::Status; - use hermes_relayer_components::chain::traits::queries::packet_commitments::PacketCommitmentsQuerier; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; - +use http::uri::InvalidUri; +use http::Uri; use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::{Paginate, QueryPacketCommitmentsRequest}; use ibc_relayer_types::core::ics02_client::error::Error as Ics02Error; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; use ibc_relayer_types::Height; +use tonic::transport::Error as TransportError; +use tonic::{Request, Status}; use crate::traits::grpc_address::HasGrpcAddress; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs index 682968264..c8b46703b 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_acks.rs @@ -3,14 +3,12 @@ use hermes_relayer_components::chain::traits::queries::unreceived_acks_sequences use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; use http::uri::InvalidUri; use http::Uri; -use tonic::transport::Error as TransportError; -use tonic::Status; - use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::QueryUnreceivedAcksRequest; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; -use tonic::Request; +use tonic::transport::Error as TransportError; +use tonic::{Request, Status}; use crate::traits::grpc_address::HasGrpcAddress; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs index 6c5c97826..9df0ad851 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/queries/unreceived_packet.rs @@ -3,14 +3,12 @@ use hermes_relayer_components::chain::traits::queries::unreceived_packet_sequenc use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; use http::uri::InvalidUri; use http::Uri; -use tonic::transport::Error as TransportError; -use tonic::Status; - use ibc_proto::ibc::core::channel::v1::query_client::QueryClient as ChannelQueryClient; use ibc_relayer::chain::requests::QueryUnreceivedPacketsRequest; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChannelId, PortId}; -use tonic::Request; +use tonic::transport::Error as TransportError; +use tonic::{Request, Status}; use crate::traits::grpc_address::HasGrpcAddress; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs b/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs index d0d5db451..8f0c2ccef 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/transaction/query_nonce.rs @@ -4,7 +4,6 @@ use hermes_relayer_components::transaction::traits::types::nonce::HasNonceType; use hermes_relayer_components::transaction::traits::types::signer::HasSignerType; use http::uri::InvalidUri; use http::Uri; - use ibc_relayer::chain::cosmos::query::account::query_account; use ibc_relayer::chain::cosmos::types::account::Account; use ibc_relayer::error::Error as RelayerError; diff --git a/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs index 44e45c8e9..54686638c 100644 --- a/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs +++ b/crates/cosmos/cosmos-chain-components/src/impls/types/config.rs @@ -1,14 +1,12 @@ use core::time::Duration; -use ibc_proto::cosmos::base::v1beta1::Coin; -use serde::Deserialize; -use serde::Serialize; use std::path::PathBuf; -use tendermint_rpc::Url; - +use ibc_proto::cosmos::base::v1beta1::Coin; use ibc_proto::cosmos::tx::v1beta1::Fee; use ibc_proto::google::protobuf::Any; use ibc_relayer::chain::cosmos::config::CosmosSdkConfig; +use serde::{Deserialize, Serialize}; +use tendermint_rpc::Url; use crate::types::config::gas::dynamic_gas_config::DynamicGasConfig; use crate::types::config::gas::gas_config::GasConfig; diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs index 031408fa0..858971764 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/dynamic_gas_config.rs @@ -1,5 +1,4 @@ -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use crate::types::config::gas::eip_type::EipQueryType; diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs index c29c31652..24eccf155 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/eip_type.rs @@ -1,8 +1,7 @@ use core::str::FromStr; use eyre::Report; -use serde::Deserialize; -use serde::Serialize; +use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Default, PartialEq, PartialOrd, Serialize, Deserialize)] pub enum EipQueryType { diff --git a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs index f29cf0e36..d543658c3 100644 --- a/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs +++ b/crates/cosmos/cosmos-chain-components/src/types/config/gas/gas_config.rs @@ -1,8 +1,6 @@ -use serde::Deserialize; -use serde::Serialize; - use ibc_proto::cosmos::tx::v1beta1::Fee; use ibc_relayer::config::GasPrice; +use serde::{Deserialize, Serialize}; use crate::types::config::gas::dynamic_gas_config::DynamicGasConfig; diff --git a/crates/cosmos/cosmos-relayer/src/contexts/build.rs b/crates/cosmos/cosmos-relayer/src/contexts/build.rs index 8a66d958c..eb10aabbf 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/build.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/build.rs @@ -2,7 +2,6 @@ use alloc::collections::BTreeMap; use alloc::sync::Arc; use core::marker::PhantomData; use core::ops::Deref; -use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use std::collections::HashMap; use std::fs::{self, File}; use std::str::FromStr; @@ -11,6 +10,7 @@ use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent}; use cgp::prelude::*; use eyre::eyre; use futures::lock::Mutex; +use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig; use hermes_error::types::Error; use hermes_relayer_components::build::traits::builders::birelay_from_relay_builder::BiRelayFromRelayBuilder; use hermes_relayer_components::build::traits::builders::chain_builder::ChainBuilder; diff --git a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs index 6bbee15e2..468082e1f 100644 --- a/crates/cosmos/cosmos-relayer/src/contexts/chain.rs +++ b/crates/cosmos/cosmos-relayer/src/contexts/chain.rs @@ -1,6 +1,5 @@ use alloc::sync::Arc; use core::ops::Deref; -use hermes_cosmos_chain_components::impls::types::config::{CosmosChainConfig, EventSourceMode}; use std::str::FromStr; use cgp::core::error::{ErrorRaiserComponent, ErrorTypeComponent}; @@ -16,6 +15,7 @@ use hermes_cosmos_chain_components::components::client::*; use hermes_cosmos_chain_components::components::cosmos_to_cosmos::CosmosToCosmosComponents; use hermes_cosmos_chain_components::components::delegate::DelegateCosmosChainComponents; use hermes_cosmos_chain_components::components::transaction::*; +use hermes_cosmos_chain_components::impls::types::config::{CosmosChainConfig, EventSourceMode}; use hermes_cosmos_chain_components::traits::convert_gas_to_fee::CanConvertGasToFee; use hermes_cosmos_chain_components::traits::eip::eip_query::CanQueryEipBaseFee; use hermes_cosmos_chain_components::traits::gas_config::GasConfigGetter; diff --git a/crates/cosmos/cosmos-relayer/src/impls/error.rs b/crates/cosmos/cosmos-relayer/src/impls/error.rs index 03686f89d..e9162aafb 100644 --- a/crates/cosmos/cosmos-relayer/src/impls/error.rs +++ b/crates/cosmos/cosmos-relayer/src/impls/error.rs @@ -3,7 +3,6 @@ use core::array::TryFromSliceError; use core::convert::Infallible; use core::num::{ParseFloatError, ParseIntError, TryFromIntError}; use core::str::Utf8Error; -use http::uri::InvalidUri; use cgp::core::component::UseDelegate; use cgp::core::error::{ErrorRaiser, ErrorRaiserComponent, ErrorTypeComponent}; @@ -53,6 +52,7 @@ use hermes_test_components::chain::impls::ibc_transfer::MissingSendPacketEventEr use hermes_test_components::chain::traits::types::address::HasAddressType; use hermes_test_components::chain::traits::types::amount::HasAmountType; use hermes_wasm_test_components::impls::chain::upload_client_code::ProposalIdNotFound; +use http::uri::InvalidUri; use ibc::core::client::types::error::ClientError; use ibc::core::commitment_types::error::CommitmentError; use ibc::core::host::types::error::DecodingError; diff --git a/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs b/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs index f4785581f..771943398 100644 --- a/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs +++ b/crates/cosmos/cosmos-test-components/src/chain/impls/proposal/query_status.rs @@ -1,17 +1,16 @@ -use cgp::core::error::CanRaiseError; use core::fmt::Debug; -use http::uri::InvalidUri; -use http::Uri; -use tonic::transport::Error as TransportError; -use tonic::Status; +use cgp::core::error::CanRaiseError; use hermes_cosmos_chain_components::traits::grpc_address::HasGrpcAddress; use hermes_test_components::chain::traits::proposal::query_status::ProposalStatusQuerier; use hermes_test_components::chain::traits::proposal::types::proposal_id::HasProposalIdType; use hermes_test_components::chain::traits::proposal::types::proposal_status::HasProposalStatusType; - +use http::uri::InvalidUri; +use http::Uri; use ibc_proto::cosmos::gov::v1::query_client::QueryClient; use ibc_proto::cosmos::gov::v1::{Proposal, QueryProposalRequest}; +use tonic::transport::Error as TransportError; +use tonic::Status; use crate::chain::types::proposal_status::ProposalStatus; diff --git a/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs b/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs index fbae95495..59085a1d2 100644 --- a/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs +++ b/crates/cosmos/cosmos-test-components/src/chain/impls/queries/balance.rs @@ -7,7 +7,6 @@ use hermes_test_components::chain::traits::types::address::HasAddressType; use hermes_test_components::chain::traits::types::amount::HasAmountType; use http::uri::InvalidUri; use http::Uri; - use ibc_relayer::chain::cosmos::query::balance::query_balance; use ibc_relayer::error::Error as RelayerError;