From 1ef57953d0adcda4d3dbcb9114563735f96f2069 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 09:58:55 -0600 Subject: [PATCH 01/23] Clean up start command --- crates/cli/cli/src/commands/mod.rs | 4 ++-- crates/cli/cli/src/commands/start.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/cli/cli/src/commands/mod.rs b/crates/cli/cli/src/commands/mod.rs index 3b00c567e..692f7350e 100644 --- a/crates/cli/cli/src/commands/mod.rs +++ b/crates/cli/cli/src/commands/mod.rs @@ -8,10 +8,10 @@ pub mod channel; pub mod clear; pub mod client; pub mod connection; -pub mod query; - pub mod keys; +pub mod query; pub mod start; + #[derive(Debug, clap::Parser)] pub enum HermesCommand { /// Start the Hermes relayer diff --git a/crates/cli/cli/src/commands/start.rs b/crates/cli/cli/src/commands/start.rs index d8de4be5c..e1c7b0dc6 100644 --- a/crates/cli/cli/src/commands/start.rs +++ b/crates/cli/cli/src/commands/start.rs @@ -1,10 +1,13 @@ use cgp_core::CanRun; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_relayer_components::build::traits::components::birelay_builder::CanBuildBiRelay; + use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; -use oneline_eyre::eyre::eyre; + +use oneline_eyre::eyre::Context; use tracing::info; use crate::Result; @@ -60,7 +63,7 @@ impl CommandRunner for Start { &self.client_id_b, ) .await - .map_err(|e| eyre!("Relayer failed to start: {e}"))?; + .wrap_err("Relayer failed to start")?; info!( "Relaying between {} and {}...", @@ -70,7 +73,7 @@ impl CommandRunner for Start { birelay .run() .await - .map_err(|e| eyre!("Relayed exited because of error: {e}"))?; + .wrap_err("Relayed exited because of error")?; Ok(Output::success_msg("Relayer exited successfully.")) } From ead66a2b10e780e42c9a10b27bb92c71a4063044 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:06:15 -0600 Subject: [PATCH 02/23] Clean up keys add command --- crates/cli/cli/src/commands/keys/add.rs | 8 ++++---- crates/cli/cli/src/commands/start.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/cli/cli/src/commands/keys/add.rs b/crates/cli/cli/src/commands/keys/add.rs index 14c9f2759..755e7938f 100644 --- a/crates/cli/cli/src/commands/keys/add.rs +++ b/crates/cli/cli/src/commands/keys/add.rs @@ -178,9 +178,9 @@ pub fn restore_key( fn check_key_exists(keyring: &KeyRing, key_name: &str, overwrite: bool) { if keyring.get_key(key_name).is_ok() { if overwrite { - warn!("key '{key_name}' will be overwritten"); + warn!("key `{key_name}` will be overwritten"); } else { - Output::error(format!("key with name '{key_name}' already exists")).exit(); + Output::error(format!("key with name `{key_name}` already exists")).exit(); } } } @@ -209,7 +209,7 @@ impl CommandRunner for crate::commands::keys::add::KeysAddCmd { ); match key { Ok(key) => Output::success_msg(format!( - "added key '{}' ({}) on chain `{}`", + "added key `{}` ({}) on chain `{}`", opts.name, key.account(), opts.config.id, @@ -233,7 +233,7 @@ impl CommandRunner for crate::commands::keys::add::KeysAddCmd { match key { Ok(key) => Output::success_msg(format!( - "restored key '{}' ({}) on chain `{}`", + "restored key `{}` ({}) on chain `{}`", opts.name, key.account(), opts.config.id diff --git a/crates/cli/cli/src/commands/start.rs b/crates/cli/cli/src/commands/start.rs index e1c7b0dc6..ccff6b038 100644 --- a/crates/cli/cli/src/commands/start.rs +++ b/crates/cli/cli/src/commands/start.rs @@ -63,7 +63,7 @@ impl CommandRunner for Start { &self.client_id_b, ) .await - .wrap_err("Relayer failed to start")?; + .wrap_err("relayer failed to start")?; info!( "Relaying between {} and {}...", @@ -73,8 +73,8 @@ impl CommandRunner for Start { birelay .run() .await - .wrap_err("Relayed exited because of error")?; + .wrap_err("relayer exited because of error")?; - Ok(Output::success_msg("Relayer exited successfully.")) + Ok(Output::success_msg("relayer exited successfully")) } } From c6d5247a6eb14a0281b99c76354641671a24ab9a Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:33:53 -0600 Subject: [PATCH 03/23] Clean up create channel command --- crates/cli/cli/src/commands/channel/create.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/cli/cli/src/commands/channel/create.rs b/crates/cli/cli/src/commands/channel/create.rs index 802469bcf..3c138a731 100644 --- a/crates/cli/cli/src/commands/channel/create.rs +++ b/crates/cli/cli/src/commands/channel/create.rs @@ -1,3 +1,6 @@ +use oneline_eyre::eyre::{eyre, Context}; +use tracing::info; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_client_components::types::channel::CosmosInitChannelOptions; @@ -5,11 +8,10 @@ use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_relayer_components::build::traits::components::relay_builder::CanBuildRelay; use hermes_relayer_components::build::traits::target::relay::RelayAToBTarget; use hermes_relayer_components::relay::impls::channel::bootstrap::CanBootstrapChannel; + use ibc_relayer::channel::version::Version; use ibc_relayer_types::core::ics04_channel::channel::Ordering; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId, ConnectionId, PortId}; -use oneline_eyre::eyre::eyre; -use tracing::info; use crate::Result; @@ -104,7 +106,7 @@ impl CommandRunner for ChannelCreate { &self.client_id_b, ) .await - .map_err(|e| eyre!("Failed to build relay: {e}"))?; + .wrap_err("relayer failed to start")?; let options = CosmosInitChannelOptions { ordering: self.ordering, @@ -114,7 +116,7 @@ impl CommandRunner for ChannelCreate { info!( ?options, - "Creating channel between {}:{} and {}:{} on connection {}...", + "Creating channel between `{}`:`{}` and `{}`:`{}` on connection `{}`...", self.chain_id_a, self.client_id_a, self.chain_id_b, @@ -125,11 +127,11 @@ impl CommandRunner for ChannelCreate { let (channel_id_a, channel_id_b) = relay .bootstrap_channel(&self.port_id_a, &self.port_id_b, &options) .await - .map_err(|e| eyre!("Failed to create channel: channel handshake failed: {e}"))?; + .wrap_err("failed to create channel; channel handshake failed")?; info!( %channel_id_a, %channel_id_b, - "Channel successfully created between {} and {}", + "Channel successfully created between `{}` and `{}`", self.chain_id_a, self.chain_id_b, ); From 56fe7bff22bc9c46db1aaee5e5da4d3ebd14ff2c Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:37:21 -0600 Subject: [PATCH 04/23] Clean up packet clear command --- crates/cli/cli/src/commands/clear/packets.rs | 9 ++++++--- crates/cli/cli/src/commands/start.rs | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/cli/cli/src/commands/clear/packets.rs b/crates/cli/cli/src/commands/clear/packets.rs index 0c190d6b8..4aa859f68 100644 --- a/crates/cli/cli/src/commands/clear/packets.rs +++ b/crates/cli/cli/src/commands/clear/packets.rs @@ -1,10 +1,12 @@ +use futures::stream::{self, StreamExt}; +use oneline_eyre::eyre::Context; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; - -use futures::stream::{self, StreamExt}; use hermes_relayer_components::build::traits::components::birelay_builder::CanBuildBiRelay; use hermes_relayer_components::relay::traits::packet_clearer::CanClearPackets; + use ibc_relayer_types::core::ics24_host::identifier::ChainId; use ibc_relayer_types::core::ics24_host::identifier::ChannelId; use ibc_relayer_types::core::ics24_host::identifier::ClientId; @@ -97,7 +99,8 @@ impl CommandRunner for PacketsClear { &self.client_id, &self.counterparty_client_id, // nothing to pass here ) - .await?; + .await + .wrap_err("relayer failed to start")?; stream::iter(vec![ relayer.relay_a_to_b.clear_packets( diff --git a/crates/cli/cli/src/commands/start.rs b/crates/cli/cli/src/commands/start.rs index ccff6b038..4928a4a30 100644 --- a/crates/cli/cli/src/commands/start.rs +++ b/crates/cli/cli/src/commands/start.rs @@ -1,3 +1,6 @@ +use oneline_eyre::eyre::Context; +use tracing::info; + use cgp_core::CanRun; use hermes_cli_framework::command::CommandRunner; @@ -7,9 +10,6 @@ use hermes_relayer_components::build::traits::components::birelay_builder::CanBu use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; -use oneline_eyre::eyre::Context; -use tracing::info; - use crate::Result; #[derive(Debug, clap::Parser)] @@ -75,6 +75,6 @@ impl CommandRunner for Start { .await .wrap_err("relayer exited because of error")?; - Ok(Output::success_msg("relayer exited successfully")) + Ok(Output::success_msg("Relayer exited successfully")) } } From 311a79b63c24a86bda988def82f0f8fab061f020 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:44:31 -0600 Subject: [PATCH 05/23] Clean up client create command --- crates/cli/cli/src/commands/channel/create.rs | 2 +- crates/cli/cli/src/commands/client/create.rs | 18 ++++++++++-------- crates/cli/cli/src/commands/keys/add.rs | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/cli/cli/src/commands/channel/create.rs b/crates/cli/cli/src/commands/channel/create.rs index 3c138a731..05f3d69fc 100644 --- a/crates/cli/cli/src/commands/channel/create.rs +++ b/crates/cli/cli/src/commands/channel/create.rs @@ -1,4 +1,4 @@ -use oneline_eyre::eyre::{eyre, Context}; +use oneline_eyre::eyre::Context; use tracing::info; use hermes_cli_framework::command::CommandRunner; diff --git a/crates/cli/cli/src/commands/client/create.rs b/crates/cli/cli/src/commands/client/create.rs index 237a9d1fb..9f669334b 100644 --- a/crates/cli/cli/src/commands/client/create.rs +++ b/crates/cli/cli/src/commands/client/create.rs @@ -1,15 +1,17 @@ +use oneline_eyre::eyre::{eyre, Context}; +use tracing::info; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::relay::CosmosRelay; use hermes_relayer_components::relay::traits::client_creator::CanCreateClient; use hermes_relayer_components::relay::traits::target::DestinationTarget; + use ibc_relayer::chain::client::ClientSettings; use ibc_relayer::foreign_client::CreateOptions; use ibc_relayer_types::core::ics02_client::trust_threshold::TrustThreshold; use ibc_relayer_types::core::ics24_host::identifier::ChainId; -use oneline_eyre::eyre::eyre; -use tracing::info; use crate::Result; @@ -72,7 +74,7 @@ impl CommandRunner for ClientCreate { .find_chain(&self.host_chain_id) .ok_or_else(|| { eyre!( - "No chain configuration found for chain `{}`", + "no chain configuration found for chain `{}`", self.host_chain_id ) })?; @@ -82,7 +84,7 @@ impl CommandRunner for ClientCreate { .find_chain(&self.reference_chain_id) .ok_or_else(|| { eyre!( - "No chain configuration found for chain `{}`", + "no chain configuration found for chain `{}`", self.reference_chain_id ) })?; @@ -109,7 +111,7 @@ impl CommandRunner for ClientCreate { let client_id_on_host = CosmosRelay::create_client(DestinationTarget, &host_chain, &reference_chain, &settings) .await - .map_err(|e| eyre!("Failed to create client on host chain: {e}"))?; + .wrap_err("failed to create client on host chain")?; info!( %client_id_on_host, @@ -129,12 +131,12 @@ fn parse_trust_threshold(input: &str) -> Result { let numerator = num_part .trim() .parse() - .map_err(|_| eyre!("invalid trust threshold numerator"))?; + .wrap_err("invalid trust threshold numerator")?; let denominator = denom_part .trim() .parse() - .map_err(|_| eyre!("invalid trust threshold denominator"))?; + .wrap_err("invalid trust threshold denominator")?; - TrustThreshold::new(numerator, denominator).map_err(|e| eyre!("invalid trust threshold: {e}")) + TrustThreshold::new(numerator, denominator).wrap_err("invalid trust threshold") } diff --git a/crates/cli/cli/src/commands/keys/add.rs b/crates/cli/cli/src/commands/keys/add.rs index 755e7938f..9ea1cc2ca 100644 --- a/crates/cli/cli/src/commands/keys/add.rs +++ b/crates/cli/cli/src/commands/keys/add.rs @@ -3,18 +3,18 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use hdpath::StandardHDPath; +use oneline_eyre::eyre::{self, eyre, Context}; +use tracing::warn; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; + use ibc_relayer::config::ChainConfig; use ibc_relayer::keyring::{ AnySigningKeyPair, KeyRing, Secp256k1KeyPair, SigningKeyPair, SigningKeyPairSized, Store, }; use ibc_relayer_types::core::ics24_host::identifier::ChainId; -use oneline_eyre::eyre; -use oneline_eyre::eyre::eyre; -use oneline_eyre::eyre::WrapErr; -use tracing::warn; /// The data structure that represents the arguments when invoking the `keys add` CLI command. /// From 6ada78ea80cceafaed9b459c11ef25fc5a638c10 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:51:51 -0600 Subject: [PATCH 06/23] Clean up client update command --- crates/cli/cli/src/commands/client/update.rs | 28 +++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/crates/cli/cli/src/commands/client/update.rs b/crates/cli/cli/src/commands/client/update.rs index ed4038ad6..e3054c9f9 100644 --- a/crates/cli/cli/src/commands/client/update.rs +++ b/crates/cli/cli/src/commands/client/update.rs @@ -1,3 +1,6 @@ +use oneline_eyre::eyre::Context; +use tracing::info; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; @@ -8,10 +11,9 @@ use hermes_relayer_components::chain::traits::queries::chain_status::CanQueryCha use hermes_relayer_components::chain::traits::queries::client_state::CanQueryClientStateWithLatestHeight; use hermes_relayer_components::relay::traits::target::SourceTarget; use hermes_relayer_components::relay::traits::update_client_message_builder::CanSendUpdateClientMessage; + use ibc_relayer_types::core::ics02_client::height::Height; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; -use oneline_eyre::eyre::Context; -use tracing::info; use crate::Result; @@ -45,15 +47,22 @@ pub struct ClientUpdate { impl CommandRunner for ClientUpdate { async fn run(&self, builder: &CosmosBuilder) -> Result { - let host_chain = builder.build_chain(&self.host_chain_id).await?; + let host_chain = builder + .build_chain(&self.host_chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.host_chain_id))?; let client_state = >:: query_client_state_with_latest_height(&host_chain, &self.client_id) - .await?; + .await + .wrap_err_with(|| format!("failed to query client `{}`", self.client_id))?; let reference_chain_id = client_state.chain_id; - let reference_chain = builder.build_chain(&reference_chain_id).await?; + let reference_chain = builder + .build_chain(&reference_chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", reference_chain_id))?; let relayer = builder .build_relay( @@ -63,12 +72,13 @@ impl CommandRunner for ClientUpdate { &self.client_id, &self.client_id, // nothing to pass here ) - .await?; + .await + .wrap_err("relayer failed to start")?; let target_height = match self.target_height { Some(height) => { let height = Height::new(reference_chain_id.version(), height) - .wrap_err("Invalid value for --target-height")?; + .wrap_err_with(|| format!("invalid value for --target-height `{height}`"))?; info!("Updating client using specified target height: {height}"); height @@ -76,7 +86,7 @@ impl CommandRunner for ClientUpdate { None => { let height = reference_chain.query_chain_height().await?; - info!("Updating client using specified target height: {height}"); + info!("Updating client using specified target height: `{height}`"); height } }; @@ -84,7 +94,7 @@ impl CommandRunner for ClientUpdate { relayer .send_update_client_messages(SourceTarget, &target_height) .await - .wrap_err("Failed to send update client message")?; + .wrap_err("failed to send update client message")?; Ok(Output::success_msg("Client successfully updated!")) } From 96faff41c645fdcdcb9309f82bf5127413208131 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 10:54:20 -0600 Subject: [PATCH 07/23] Clean up create connection command --- crates/cli/cli/src/commands/connection/create.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/cli/cli/src/commands/connection/create.rs b/crates/cli/cli/src/commands/connection/create.rs index 6da0a7d34..588a67858 100644 --- a/crates/cli/cli/src/commands/connection/create.rs +++ b/crates/cli/cli/src/commands/connection/create.rs @@ -1,5 +1,8 @@ use std::time::Duration; +use oneline_eyre::eyre::{eyre, Context}; +use tracing::info; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_client_components::types::connection::CosmosInitConnectionOptions; @@ -7,10 +10,9 @@ use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_relayer_components::build::traits::components::relay_builder::CanBuildRelay; use hermes_relayer_components::build::traits::target::relay::RelayAToBTarget; use hermes_relayer_components::relay::impls::connection::bootstrap::CanBootstrapConnection; + use ibc_relayer_types::core::ics03_connection::version::Version; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; -use oneline_eyre::eyre::eyre; -use tracing::info; use crate::Result; @@ -64,7 +66,7 @@ impl CommandRunner for ConnectionCreate { &self.client_id_b, ) .await - .map_err(|e| eyre!("Failed to build relay: {e}"))?; + .wrap_err("relayer failed to start")?; let options = CosmosInitConnectionOptions { delay_period: Duration::from_secs(0), @@ -73,7 +75,7 @@ impl CommandRunner for ConnectionCreate { info!( ?options, - "Creating connection between {}:{} and {}:{}...", + "Creating connection between `{}`:`{}` and `{}`:`{}`...", self.chain_id_a, self.client_id_a, self.chain_id_b, @@ -83,7 +85,7 @@ impl CommandRunner for ConnectionCreate { let (connection_id_a, connection_id_b) = relay .bootstrap_connection(&options) .await - .map_err(|e| eyre!("Failed to create connection: connection handshake failed: {e}"))?; + .wrap_err("failed to create connection; connection handshake failed")?; info!( %connection_id_a, %connection_id_b, From db60058ca221d737c15cc773011ff20287757e71 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 14:56:47 -0600 Subject: [PATCH 08/23] Clean up query client state command --- .../cli/src/commands/query/client/state.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/cli/cli/src/commands/query/client/state.rs b/crates/cli/cli/src/commands/query/client/state.rs index 452a61a48..033d1a6f7 100644 --- a/crates/cli/cli/src/commands/query/client/state.rs +++ b/crates/cli/cli/src/commands/query/client/state.rs @@ -1,6 +1,7 @@ use std::error::Error as StdError; use std::fmt::Debug; +use oneline_eyre::eyre::Context; use serde::Serialize; use tracing::info; @@ -15,6 +16,7 @@ use hermes_relayer_components::chain::traits::queries::client_state::{ }; use hermes_relayer_components::chain::traits::types::client_state::HasClientStateType; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; + use ibc_relayer_types::core::ics02_client::height::Height; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; @@ -64,18 +66,23 @@ where let chain_id = &self.chain_id; let client_id = &self.client_id; - let chain = builder.build_chain(ChainATarget, &self.chain_id).await?; + let chain = builder + .build_chain(ChainATarget, &self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let client_state = match self.height { Some(height) => { let height = Height::new(self.chain_id.version(), height).unwrap(); - chain.query_client_state(&self.client_id, &height).await? - } - None => { chain - .query_client_state_with_latest_height(&self.client_id) - .await? + .query_client_state(&self.client_id, &height) + .await + .wrap_err_with(|| format!("failed to query client `{}`", self.client_id))? } + None => chain + .query_client_state_with_latest_height(&self.client_id) + .await + .wrap_err_with(|| format!("failed to query client `{}`", self.client_id))?, }; info!("Found client state for client `{client_id}` on chain `{chain_id}`!"); From 2ffa85d15f2ae80b4b907d8f4038a83e0b17032f Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 14:59:41 -0600 Subject: [PATCH 09/23] Clean up query client status command --- crates/cli/cli/src/commands/query/client/status.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/cli/cli/src/commands/query/client/status.rs b/crates/cli/cli/src/commands/query/client/status.rs index f77806fad..8b533a54d 100644 --- a/crates/cli/cli/src/commands/query/client/status.rs +++ b/crates/cli/cli/src/commands/query/client/status.rs @@ -1,6 +1,7 @@ use std::error::Error as StdError; use std::fmt::Debug; +use oneline_eyre::eyre::Context; use serde::Serialize; use tracing::info; @@ -20,6 +21,7 @@ use hermes_relayer_components::chain::traits::types::consensus_state::{ HasConsensusStateFields, HasConsensusStateType, }; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; + use ibc_relayer_types::core::ics02_client::height::Height; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; @@ -61,8 +63,15 @@ where Build::Error: From + StdError, { async fn run(&self, builder: &Build) -> Result { - let chain = builder.build_chain(ChainATarget, &self.chain_id).await?; - let client_status = chain.query_client_status(&self.client_id).await?; + let chain = builder + .build_chain(ChainATarget, &self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; + + let client_status = chain + .query_client_status(&self.client_id) + .await + .wrap_err_with(|| format!("failed to query client `{}`", self.client_id))?; match client_status { ClientStatus::Frozen => { From 42f53d22ee7c6e871747777beec6b6b2a7998937 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 15:02:41 -0600 Subject: [PATCH 10/23] Clean up query client consensus command --- crates/cli/cli/src/commands/query/client/consensus.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/cli/cli/src/commands/query/client/consensus.rs b/crates/cli/cli/src/commands/query/client/consensus.rs index cc5817d04..58724df87 100644 --- a/crates/cli/cli/src/commands/query/client/consensus.rs +++ b/crates/cli/cli/src/commands/query/client/consensus.rs @@ -51,7 +51,10 @@ pub struct QueryClientConsensus { impl CommandRunner for QueryClientConsensus { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let counterparty_chain_id = for QueryClientConsensus { let query_height = self.height.map(|height| { Height::new(self.chain_id.version(), height) .wrap_err_with(|| format!( - "Failed to create Height with revision number `{}` and revision height `{height}`", + "failed to create Height with revision number `{}` and revision height `{height}`", self.chain_id.version() )) }).transpose()?; From b73fe0c0d6dd6924cf2f797930c63688f8d6ba19 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 15:06:05 -0600 Subject: [PATCH 11/23] Clean up query connection end command --- .../cli/src/commands/query/connection/end.rs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/cli/cli/src/commands/query/connection/end.rs b/crates/cli/cli/src/commands/query/connection/end.rs index fa1bf64b1..8ab56b395 100644 --- a/crates/cli/cli/src/commands/query/connection/end.rs +++ b/crates/cli/cli/src/commands/query/connection/end.rs @@ -1,4 +1,4 @@ -use oneline_eyre::eyre::eyre; +use oneline_eyre::eyre::{eyre, Context}; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; @@ -7,6 +7,7 @@ use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_cosmos_relayer::types::error::BaseError as RelayerError; use hermes_relayer_components::chain::traits::queries::connection_end::CanQueryConnectionEnd; use hermes_relayer_components::chain::traits::types::chain_id::HasChainId; + use ibc_relayer_types::core::ics03_connection::connection::State; use ibc_relayer_types::core::ics24_host::identifier::ChainId; use ibc_relayer_types::core::ics24_host::identifier::ConnectionId; @@ -45,11 +46,22 @@ pub struct QueryConnectionEnd { impl CommandRunner for QueryConnectionEnd { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; - let height = self.height.map(|h| - Height::new(chain.chain_id().version(), h) - .map_err(|e| RelayerError::generic(eyre!("Failed to create Height with revision number `{}` and revision height `{h}`. Error: {e}", chain.chain_id().version()))) - ).transpose()?; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; + + let height = self + .height + .map(|h| { + Height::new(chain.chain_id().version(), h).wrap_err_with(|| { + format!( + "failed to create Height with revision number `{}` and revision height `{h}`", + chain.chain_id().version() + ) + }) + }) + .transpose()?; let connection_end = >::query_connection_end( @@ -57,7 +69,8 @@ impl CommandRunner for QueryConnectionEnd { &self.connection_id, height.as_ref(), ) - .await?; + .await + .wrap_err_with(|| format!("failed to query connection `{}`", self.connection_id))?; if connection_end.state_matches(&State::Uninitialized) { return Ok(Output::error(format!( From c2de3c0cb7c283f082e472b3d1a952506df1e26e Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 15:13:33 -0600 Subject: [PATCH 12/23] Clean up query clients command --- crates/cli/cli/src/commands/query/clients.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/cli/cli/src/commands/query/clients.rs b/crates/cli/cli/src/commands/query/clients.rs index b22824c7b..b783da672 100644 --- a/crates/cli/cli/src/commands/query/clients.rs +++ b/crates/cli/cli/src/commands/query/clients.rs @@ -2,11 +2,11 @@ use std::error::Error as StdError; use std::fmt; use cgp_core::HasErrorType; -use hermes_cli_components::any_client::contexts::any_counterparty::AnyCounterparty; -use hermes_cli_components::any_client::types::client_state::AnyClientState; use oneline_eyre::eyre::Context; use tracing::info; +use hermes_cli_components::any_client::contexts::any_counterparty::AnyCounterparty; +use hermes_cli_components::any_client::types::client_state::AnyClientState; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::types::tendermint::TendermintClientState; @@ -18,6 +18,7 @@ use hermes_relayer_components::chain::traits::types::client_state::{ HasClientStateFields, HasClientStateType, }; use hermes_relayer_components::chain::traits::types::ibc::HasIbcChainTypes; + use ibc_relayer_types::core::ics02_client::client_state::ClientState; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId}; @@ -50,13 +51,18 @@ pub struct QueryClients { impl CommandRunner for QueryClients { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.host_chain_id).await?; + let chain = builder + .build_chain(&self.host_chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.host_chain_id))?; + let clients = query_client_states::<_, AnyCounterparty>( &chain, &self.host_chain_id, self.reference_chain_id.as_ref(), ) - .await?; + .await + .wrap_err_with(|| format!("failed to query clients for chain `{}`", self.host_chain_id))?; if !json() { clients.iter().for_each(|client| { @@ -149,7 +155,7 @@ where let mut clients = chain .query_client_states_with_latest_height() .await - .wrap_err("Failed to query clients")? + .wrap_err("failed to query clients")? .into_iter() .map(|(client_id, client_state)| Client:: { client_id, From d26bce56489ee1e1af5c4bd951934c6e4163cc1a Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 20 Feb 2024 15:19:42 -0600 Subject: [PATCH 13/23] Clean up query connections command --- crates/cli/cli/src/commands/query/connections.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/cli/cli/src/commands/query/connections.rs b/crates/cli/cli/src/commands/query/connections.rs index 0dac1332e..4c2751bd9 100644 --- a/crates/cli/cli/src/commands/query/connections.rs +++ b/crates/cli/cli/src/commands/query/connections.rs @@ -9,6 +9,7 @@ use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_cosmos_relayer::types::error::BaseError; use hermes_relayer_components::chain::traits::queries::client_state::CanQueryClientStateWithLatestHeight; + use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::PageRequest; use ibc_relayer::chain::requests::QueryConnectionsRequest; From 3d46d4d6494c52b6959730d62663e006d2b8dfc1 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 09:06:30 -0600 Subject: [PATCH 14/23] Clean up query channel client command --- crates/cli/cli/src/commands/client/create.rs | 10 ++++- .../cli/cli/src/commands/connection/create.rs | 2 +- .../cli/src/commands/query/channel/client.rs | 38 +++++++++++-------- .../cli/cli/src/commands/query/channel/mod.rs | 7 ++-- .../cli/src/commands/query/connection/end.rs | 3 +- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/crates/cli/cli/src/commands/client/create.rs b/crates/cli/cli/src/commands/client/create.rs index 9f669334b..2925ce79d 100644 --- a/crates/cli/cli/src/commands/client/create.rs +++ b/crates/cli/cli/src/commands/client/create.rs @@ -89,8 +89,14 @@ impl CommandRunner for ClientCreate { ) })?; - let host_chain = builder.build_chain(&self.host_chain_id).await?; - let reference_chain = builder.build_chain(&self.reference_chain_id).await?; + let host_chain = builder + .build_chain(&self.host_chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.host_chain_id))?; + let reference_chain = builder + .build_chain(&self.reference_chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.reference_chain_id))?; let options = CreateOptions { max_clock_drift: self.clock_drift.map(|d| d.into()), diff --git a/crates/cli/cli/src/commands/connection/create.rs b/crates/cli/cli/src/commands/connection/create.rs index 588a67858..c84dfe1e7 100644 --- a/crates/cli/cli/src/commands/connection/create.rs +++ b/crates/cli/cli/src/commands/connection/create.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use oneline_eyre::eyre::{eyre, Context}; +use oneline_eyre::eyre::Context; use tracing::info; use hermes_cli_framework::command::CommandRunner; diff --git a/crates/cli/cli/src/commands/query/channel/client.rs b/crates/cli/cli/src/commands/query/channel/client.rs index 3e03c3305..38e16b069 100644 --- a/crates/cli/cli/src/commands/query/channel/client.rs +++ b/crates/cli/cli/src/commands/query/channel/client.rs @@ -1,13 +1,14 @@ +use cgp_core::CanRaiseError; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; - use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; -use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; -use hermes_cosmos_relayer::types::error::BaseError; +use hermes_cosmos_relayer::contexts::{builder::CosmosBuilder, chain::CosmosChain}; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::QueryChannelClientStateRequest; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; +use oneline_eyre::eyre::Context; use crate::Result; @@ -43,24 +44,29 @@ pub struct QueryChannelClient { impl CommandRunner for QueryChannelClient { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; let channel_id = self.channel_id.clone(); let port_id = self.port_id.clone(); + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; - match chain + let client_state = chain .with_blocking_chain_handle(move |chain_handle| { - match chain_handle.query_channel_client_state(QueryChannelClientStateRequest { - port_id, - channel_id, - }) { - Ok(maybe_client_state) => Ok(maybe_client_state), - Err(e) => Err(BaseError::relayer(e).into()), - } + chain_handle + .query_channel_client_state(QueryChannelClientStateRequest { + port_id, + channel_id, + }) + .map_err(|e| { + CosmosChain::raise_error( + e.1.wrap_err("failed to query client state for channel"), + ) + }) }) .await - { - Ok(client_state) => Ok(Output::success(client_state)), - Err(e) => Err(e.into()), - } + .wrap_err("`query channel client` command failed")?; + + Ok(Output::success(client_state)) } } diff --git a/crates/cli/cli/src/commands/query/channel/mod.rs b/crates/cli/cli/src/commands/query/channel/mod.rs index fb02a7aad..1ff4d2e5a 100644 --- a/crates/cli/cli/src/commands/query/channel/mod.rs +++ b/crates/cli/cli/src/commands/query/channel/mod.rs @@ -1,9 +1,10 @@ mod client; -mod end; -mod ends; - pub use client::QueryChannelClient; + +mod end; pub use end::QueryChannelEnd; + +mod ends; pub use ends::QueryChannelEnds; use hermes_cli_framework::command::CommandRunner; diff --git a/crates/cli/cli/src/commands/query/connection/end.rs b/crates/cli/cli/src/commands/query/connection/end.rs index 8ab56b395..048c0a713 100644 --- a/crates/cli/cli/src/commands/query/connection/end.rs +++ b/crates/cli/cli/src/commands/query/connection/end.rs @@ -1,10 +1,9 @@ -use oneline_eyre::eyre::{eyre, Context}; +use oneline_eyre::eyre::Context; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; -use hermes_cosmos_relayer::types::error::BaseError as RelayerError; use hermes_relayer_components::chain::traits::queries::connection_end::CanQueryConnectionEnd; use hermes_relayer_components::chain::traits::types::chain_id::HasChainId; From f034aa4a3e20206a12330a097f2b229b79e9b846 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 09:45:42 -0600 Subject: [PATCH 15/23] Clean up query channel end command --- .../cli/cli/src/commands/query/channel/end.rs | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/crates/cli/cli/src/commands/query/channel/end.rs b/crates/cli/cli/src/commands/query/channel/end.rs index 05d4bc238..2cc766fa1 100644 --- a/crates/cli/cli/src/commands/query/channel/end.rs +++ b/crates/cli/cli/src/commands/query/channel/end.rs @@ -1,10 +1,12 @@ -use oneline_eyre::eyre::eyre; +use oneline_eyre::eyre::{eyre, Context}; + +use cgp_core::CanRaiseError; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; - use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_cosmos_relayer::types::error::BaseError; use ibc_relayer::chain::handle::ChainHandle; @@ -54,14 +56,17 @@ pub struct QueryChannelEnd { impl CommandRunner for QueryChannelEnd { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; let channel_id = self.channel_id.clone(); let port_id = self.port_id.clone(); let height = self.height; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let query_height = if let Some(height) = height { let specified_height = Height::new(chain.chain_id.version(), height) - .map_err(|e| BaseError::generic(eyre!("Failed to create Height with revision number `{}` and revision height `{height}`. Error: {e}", chain.chain_id.version())))?; + .map_err(|e| CosmosChain::raise_error(e.1.wrap_err(format!("failed to create Height with revision number `{}` and revision height `{height}`", chain.chain_id.version()))))?; QueryHeight::Specific(specified_height) } else { @@ -79,25 +84,22 @@ impl CommandRunner for QueryChannelEnd { IncludeProof::No, ) { Ok((channel_end, _)) => Ok(channel_end), - Err(e) => Err(BaseError::relayer(e).into()), + Err(e) => Err(CosmosChain::raise_error( + e.1.wrap_err("failed to query channel"), + )), } }) - .await; + .await + .wrap_err("`query channel end` command failed")?; - match channel_end { - Ok(channel_end) => { - if channel_end.state_matches(&State::Uninitialized) { - Err(BaseError::generic(eyre!( - "port '{}' & channel '{}' do not exist", - self.port_id, - self.channel_id, - )) - .into()) - } else { - Ok(Output::success(channel_end)) - } - } - Err(e) => Err(e.into()), + if channel_end.state_matches(&State::Uninitialized) { + Err(eyre!( + "port `{}` & channel `{}` do not exist", + self.port_id, + self.channel_id, + )) + } else { + Ok(Output::success(channel_end)) } } } From 905981166fa1c2c6d02109119d268a58643a9727 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 10:07:14 -0600 Subject: [PATCH 16/23] Clean up query channel ends command --- .../cli/cli/src/commands/query/channel/end.rs | 1 - .../cli/src/commands/query/channel/ends.rs | 67 +++++++++---------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/crates/cli/cli/src/commands/query/channel/end.rs b/crates/cli/cli/src/commands/query/channel/end.rs index 2cc766fa1..6f5ae118d 100644 --- a/crates/cli/cli/src/commands/query/channel/end.rs +++ b/crates/cli/cli/src/commands/query/channel/end.rs @@ -7,7 +7,6 @@ use hermes_cli_framework::output::Output; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; -use hermes_cosmos_relayer::types::error::BaseError; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight}; diff --git a/crates/cli/cli/src/commands/query/channel/ends.rs b/crates/cli/cli/src/commands/query/channel/ends.rs index 2470c7f9a..c9178d669 100644 --- a/crates/cli/cli/src/commands/query/channel/ends.rs +++ b/crates/cli/cli/src/commands/query/channel/ends.rs @@ -1,12 +1,13 @@ -use oneline_eyre::eyre::eyre; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; +use oneline_eyre::eyre::Context; use serde::{Deserialize, Serialize}; +use cgp_core::CanRaiseError; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::Output; - use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; -use hermes_cosmos_relayer::types::error::BaseError; use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{ @@ -78,11 +79,14 @@ impl CommandRunner for QueryChannelEnds { let port_id = self.port_id.clone(); let height = self.height; - let chain = builder.build_chain(&chain_id).await?; + let chain = builder + .build_chain(&chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", chain_id))?; let query_height = if let Some(height) = height { - let specified_height = Height::new(chain_id.version(), height) - .map_err(|e| BaseError::generic(eyre!("Failed to create Height with revision number `{}` and revision height `{height}`: {e}", chain_id.version())))?; + let specified_height = Height::new(chain.chain_id.version(), height) + .map_err(|e| CosmosChain::raise_error(e.1.wrap_err(format!("failed to create Height with revision number `{}` and revision height `{height}`", chain.chain_id.version()))))?; QueryHeight::Specific(specified_height) } else { @@ -91,7 +95,7 @@ impl CommandRunner for QueryChannelEnds { let channel_ends_summary = chain .with_blocking_chain_handle(move |chain_handle| { - let Ok((channel_end , _)) = chain_handle + let Ok((channel_end, _)) = chain_handle .query_channel( QueryChannelRequest { port_id: port_id.clone(), @@ -100,22 +104,19 @@ impl CommandRunner for QueryChannelEnds { }, IncludeProof::No, ) else { - return Err(BaseError::generic(eyre!( - "failed to query channel end for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?}" - )).into()); + return Err(CosmosChain::raise_error( + "failed to query channel end for `{channel_id}`:`{port_id}` on chain {chain_id} @ {query_height:?}" + )); }; if channel_end.state_matches(&State::Uninitialized) { - return Err(BaseError::generic(eyre!( - "{port_id}/{channel_id} on chain {chain_id} @ {query_height:?} is uninitialized", - )) - .into()); + return Err(CosmosChain::raise_error("`{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` is uninitialized")); } let Some(connection_id) = channel_end.connection_hops.first() else { - return Err(BaseError::generic(eyre!( - "missing connection hops for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?}", - )).into()); + return Err(CosmosChain::raise_error( + "missing connection hops for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`", + )); }; let Ok((connection_end, _)) = chain_handle @@ -126,9 +127,9 @@ impl CommandRunner for QueryChannelEnds { }, IncludeProof::No, ) else { - return Err(BaseError::generic(eyre!( - "failed to query connection end for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?}" - )).into()); + return Err(CosmosChain::raise_error( + "failed to query connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`" + )); }; let client_id = connection_end.client_id().clone(); @@ -141,9 +142,9 @@ impl CommandRunner for QueryChannelEnds { }, IncludeProof::No, ) else { - return Err(BaseError::generic(eyre!( - "failed to query client state for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?}" - )).into()); + return Err(CosmosChain::raise_error( + "failed to query client state for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`" + )); }; let channel_counterparty = channel_end.counterparty().clone(); @@ -151,17 +152,17 @@ impl CommandRunner for QueryChannelEnds { let counterparty_client_id = connection_counterparty.client_id().clone(); let Some(counterparty_connection_id) = connection_counterparty.connection_id else { - return Err(BaseError::generic(eyre!( - "connection end for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?} does not have counterparty connection id {connection_end:?}", - )).into()); + return Err(CosmosChain::raise_error( + "connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty connection id `{connection_end:?}`", + )); }; let counterparty_port_id = channel_counterparty.port_id().clone(); let Some(counterparty_channel_id) = channel_counterparty.channel_id else { - return Err(BaseError::generic(eyre!( - "channel end for {port_id}/{channel_id} on chain {chain_id} @ {query_height:?} does not have counterparty channel id {channel_end:?}", - )).into()); + return Err(CosmosChain::raise_error( + "channel end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty channel id `{channel_end:?}`", + )); }; let counterparty_chain_id = client_state.chain_id(); @@ -179,11 +180,9 @@ impl CommandRunner for QueryChannelEnds { counterparty_port_id, }) }) - .await; + .await + .wrap_err("`query channel ends` command failed")?; - match channel_ends_summary { - Ok(summary) => Ok(Output::success(summary)), - Err(e) => Err(e.into()), - } + Ok(Output::success(channel_ends_summary)) } } From eb254019cfb655eb32cb6b22caf47c34999cc119 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 10:42:32 -0600 Subject: [PATCH 17/23] Clean up query channels command --- crates/cli/cli/src/commands/query/channels.rs | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/crates/cli/cli/src/commands/query/channels.rs b/crates/cli/cli/src/commands/query/channels.rs index f32ef346e..60f7c31d0 100644 --- a/crates/cli/cli/src/commands/query/channels.rs +++ b/crates/cli/cli/src/commands/query/channels.rs @@ -1,12 +1,15 @@ use oneline_eyre::eyre::Context; use tracing::{info, warn}; +use cgp_core::CanRaiseError; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; -use hermes_cosmos_relayer::types::error::BaseError; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_relayer_components::chain::traits::queries::chain_status::CanQueryChainHeight; + use ibc_relayer::chain::handle::ChainHandle; use ibc_relayer::chain::requests::{ IncludeProof, PageRequest, QueryChannelsRequest, QueryClientStateRequest, @@ -42,12 +45,22 @@ pub struct QueryChannels { show_counterparty: bool, } +#[derive(Debug, serde::Serialize)] +struct Counterparty { + chain_id: ChainId, + port_id: PortId, + channel_id: Option, +} + impl CommandRunner for QueryChannels { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; let chain_id = self.chain_id.clone(); let dst_chain_id = self.counterparty_chain_id.clone(); let show_counterparty = self.show_counterparty; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let all_channels = chain .with_blocking_chain_handle(move |chain_handle| { @@ -55,14 +68,16 @@ impl CommandRunner for QueryChannels { .query_channels(QueryChannelsRequest { pagination: Some(PageRequest::all()), }) - .map_err(|e| BaseError::relayer(e).into()) + .map_err(|e| { + CosmosChain::raise_error(e.1.wrap_err("failed to query all channel ends")) + }) }) .await?; let chain_height = chain .query_chain_height() .await - .wrap_err("Failed to query latest chain height")?; + .wrap_err("failed to query latest chain height")?; let mut channels = Vec::new(); @@ -74,7 +89,7 @@ impl CommandRunner for QueryChannels { if channel_end.state_matches(&State::Uninitialized) { warn!( - "channel `{port_id}/{channel_id}` on chain `{chain_id}` at {chain_height} is uninitialized" + "channel `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}` is uninitialized" ); continue; @@ -82,7 +97,7 @@ impl CommandRunner for QueryChannels { let Some(connection_id) = channel.channel_end.connection_hops.first() else { warn!( - "missing connection hops for `{port_id}/{channel_id}` on chain `{chain_id}` at `{chain_height}`" + "missing connection hops for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`" ); continue; @@ -100,13 +115,15 @@ impl CommandRunner for QueryChannels { }, IncludeProof::No, ) - .map_err(|e| BaseError::relayer(e).into()) + .map_err(|e| { + CosmosChain::raise_error(e.1.wrap_err("failed to query connection")) + }) }) .await; let Ok((connection_end, _)) = connection_end else { warn!( - "missing connection end for `{port_id}/{channel_id}` on chain `{chain_id}` at {chain_height}" + "missing connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`" ); continue; @@ -123,12 +140,16 @@ impl CommandRunner for QueryChannels { }, IncludeProof::No, ) - .map_err(|e| BaseError::relayer(e).into()) + .map_err(|e| { + CosmosChain::raise_error( + e.1.wrap_err("failed to query client state"), + ) + }) }) .await; let Ok((client_state, _)) = client_state else { - warn!("missing client state for {port_id}/{channel_id} on chain {chain_id} at {chain_height}"); + warn!("missing client state for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`"); continue; }; @@ -182,11 +203,11 @@ impl CommandRunner for QueryChannels { } channels.iter().for_each(|(channel, counterparty)| { - info!("- {}/{}", channel.port_id, channel.channel_id); + info!("- `{}`/`{}`", channel.port_id, channel.channel_id); if let Some(counterparty) = counterparty { info!( - " - counterparty: {}/{} on chain {}", + " - counterparty: `{}`/`{}` on chain `{}`", counterparty.port_id, counterparty .channel_id @@ -203,10 +224,3 @@ impl CommandRunner for QueryChannels { ))) } } - -#[derive(Debug, serde::Serialize)] -struct Counterparty { - chain_id: ChainId, - port_id: PortId, - channel_id: Option, -} From 020678cb24a48ea3de4374af3933e7b6d894d5a1 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 10:51:40 -0600 Subject: [PATCH 18/23] Clean up query pending packets command --- .../cli/cli/src/commands/query/packet/mod.rs | 12 +++--- .../cli/src/commands/query/packet/pending.rs | 37 +++++++++++++------ 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/crates/cli/cli/src/commands/query/packet/mod.rs b/crates/cli/cli/src/commands/query/packet/mod.rs index dfe6d7e5a..968cee2b9 100644 --- a/crates/cli/cli/src/commands/query/packet/mod.rs +++ b/crates/cli/cli/src/commands/query/packet/mod.rs @@ -1,22 +1,24 @@ mod pending; +pub use pending::QueryPendingPackets; mod commitments; +pub use commitments::QueryPacketCommitments; + mod pending_acks; -mod util; +pub use pending_acks::QueryPendingAcks; -use hermes_cli_framework::output::Output; -pub use pending::QueryPendingPackets; +mod util; use hermes_cli_framework::command::CommandRunner; +use hermes_cli_framework::output::Output; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; -use crate::commands::query::packet::pending_acks::QueryPendingAcks; use crate::Result; #[derive(Debug, clap::Subcommand)] pub enum PacketCommands { /// Query packet commitments - Commitments(commitments::QueryPacketCommitments), + Commitments(QueryPacketCommitments), /// Output a summary of pending packets in both directions of a channel Pending(QueryPendingPackets), diff --git a/crates/cli/cli/src/commands/query/packet/pending.rs b/crates/cli/cli/src/commands/query/packet/pending.rs index 927fea1db..b9dc2eed5 100644 --- a/crates/cli/cli/src/commands/query/packet/pending.rs +++ b/crates/cli/cli/src/commands/query/packet/pending.rs @@ -1,16 +1,20 @@ use core::fmt; +use cgp_core::CanRaiseError; use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_cosmos_relayer::types::error::BaseError; + use ibc_relayer::chain::counterparty::pending_packet_summary; use ibc_relayer::chain::counterparty::{ channel_connection_client, channel_on_destination, PendingPackets, }; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; -use oneline_eyre::eyre::eyre; + +use oneline_eyre::eyre::{eyre, Context}; use serde::Serialize; use crate::Result; @@ -113,39 +117,48 @@ impl QueryPendingPackets { let chain_id = self.chain_id.clone(); let port_id = self.port_id.clone(); let channel_id = self.channel_id.clone(); - let chain = builder.build_chain(&self.chain_id).await?; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let chan_conn_cli = chain .with_blocking_chain_handle(move |handle| { let chan_conn_cli = channel_connection_client(&handle, &port_id, &channel_id) .map_err(|e| { - BaseError::generic(eyre!( - "failed to get channel connection and client: {}", - e - )) + CosmosChain::raise_error( + e.1.wrap_err("failed to get channel connection and client"), + ) })?; Ok(chan_conn_cli) }) .await?; let counterparty_chain_id = chan_conn_cli.client.client_state.chain_id(); - let counterparty_chain = builder.build_chain(&counterparty_chain_id.clone()).await?; + let counterparty_chain = builder + .build_chain(&counterparty_chain_id.clone()) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", counterparty_chain_id))?; let src_summary = pending_packet_summary( &chain.handle, &counterparty_chain.handle, &chan_conn_cli.channel, ) - .map_err(|e| BaseError::generic(eyre!("failed to get pending packet summary: {}", e)))?; + .map_err(|e| { + CosmosChain::raise_error(e.1.wrap_err("failed to get pending packet summary")) + })?; let counterparty_channel = channel_on_destination( &chan_conn_cli.channel, &chan_conn_cli.connection, &counterparty_chain.handle, ) - .map_err(|e| BaseError::generic(eyre!("failed to get channel on destination: {}", e)))? + .map_err(|e| { + CosmosChain::raise_error(e.1.wrap_err("failed to get channel on destination")) + })? .ok_or_else(|| { - BaseError::generic(eyre!( + CosmosChain::raise_error(eyre!( "missing counterparty channel for ({}, {})", chan_conn_cli.channel.channel_id, chan_conn_cli.channel.port_id @@ -157,7 +170,9 @@ impl QueryPendingPackets { &chain.handle, &counterparty_channel, ) - .map_err(|e| BaseError::generic(eyre!("failed to get pending packet summary: {}", e)))?; + .map_err(|e| { + CosmosChain::raise_error(e.1.wrap_err("failed to get pending packet summary")) + })?; Ok(Summary { src_chain: chain_id, From b05800dfb7ab786dc4810acc6555bc6898067c25 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 10:54:16 -0600 Subject: [PATCH 19/23] Clean up query packet commitments command --- .../cli/src/commands/query/packet/commitments.rs | 16 ++++++++++++---- .../cli/cli/src/commands/query/packet/pending.rs | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/cli/cli/src/commands/query/packet/commitments.rs b/crates/cli/cli/src/commands/query/packet/commitments.rs index 041e7d849..17e482f28 100644 --- a/crates/cli/cli/src/commands/query/packet/commitments.rs +++ b/crates/cli/cli/src/commands/query/packet/commitments.rs @@ -1,12 +1,16 @@ -use crate::commands::query::packet::util::PacketSequences; -use crate::Result; +use oneline_eyre::eyre::Context; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_relayer_components::chain::traits::queries::packet_commitments::CanQueryPacketCommitments; + use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; +use crate::commands::query::packet::util::PacketSequences; +use crate::Result; + #[derive(Debug, clap::Parser)] pub struct QueryPacketCommitments { /// Identifier of the host chain @@ -39,7 +43,10 @@ pub struct QueryPacketCommitments { impl CommandRunner for QueryPacketCommitments { async fn run(&self, builder: &CosmosBuilder) -> Result { - let chain = builder.build_chain(&self.chain_id).await?; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to bu;ild chain `{}`", self.chain_id))?; let (sequences, height) = >::query_packet_commitments( @@ -47,7 +54,8 @@ impl CommandRunner for QueryPacketCommitments { &self.channel_id, &self.port_id, ) - .await?; + .await + .wrap_err("failed to query packet commitments")?; let packet_sequences = PacketSequences::new(height, sequences); diff --git a/crates/cli/cli/src/commands/query/packet/pending.rs b/crates/cli/cli/src/commands/query/packet/pending.rs index b9dc2eed5..a41c46d1a 100644 --- a/crates/cli/cli/src/commands/query/packet/pending.rs +++ b/crates/cli/cli/src/commands/query/packet/pending.rs @@ -1,12 +1,12 @@ use core::fmt; use cgp_core::CanRaiseError; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; -use hermes_cosmos_relayer::types::error::BaseError; use ibc_relayer::chain::counterparty::pending_packet_summary; use ibc_relayer::chain::counterparty::{ From c2df2f04f7f33b36a64f3a957436bfa56f5d6bc7 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 11:00:05 -0600 Subject: [PATCH 20/23] Clean up query packet pending acks command --- .../src/commands/query/packet/pending_acks.rs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/crates/cli/cli/src/commands/query/packet/pending_acks.rs b/crates/cli/cli/src/commands/query/packet/pending_acks.rs index 7f83ac24e..6fa210cc8 100644 --- a/crates/cli/cli/src/commands/query/packet/pending_acks.rs +++ b/crates/cli/cli/src/commands/query/packet/pending_acks.rs @@ -1,14 +1,17 @@ +use cgp_core::CanRaiseError; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; +use oneline_eyre::eyre::{eyre, Context}; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; -use hermes_cosmos_relayer::types::error::BaseError; + use ibc_relayer::chain::counterparty::{channel_connection_client, unreceived_acknowledgements}; use ibc_relayer::path::PathIdentifiers; use ibc_relayer_types::core::ics04_channel::packet::Sequence; use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ChannelId, PortId}; use ibc_relayer_types::Height; -use oneline_eyre::eyre::{eyre, Context}; use crate::Result; @@ -48,29 +51,34 @@ impl QueryPendingAcks { async fn execute(&self, builder: &CosmosBuilder) -> Result, Height)>> { let port_id = self.port_id.clone(); let channel_id = self.channel_id.clone(); - let chain = builder.build_chain(&self.chain_id).await?; + let chain = builder + .build_chain(&self.chain_id) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", self.chain_id))?; let chan_conn_cli = chain .with_blocking_chain_handle(move |handle| { let chan_conn_cli = channel_connection_client(&handle, &port_id, &channel_id) .map_err(|e| { - BaseError::generic(eyre!( - "failed to get channel connection and client: {}", - e - )) + CosmosChain::raise_error( + e.1.wrap_err("failed to get channel connection and client"), + ) })?; Ok(chan_conn_cli) }) .await?; let counterparty_chain_id = chan_conn_cli.client.client_state.chain_id(); - let counterparty_chain = builder.build_chain(&counterparty_chain_id.clone()).await?; + let counterparty_chain = builder + .build_chain(&counterparty_chain_id.clone()) + .await + .wrap_err_with(|| format!("failed to build chain `{}`", counterparty_chain_id))?; let channel = chan_conn_cli.channel.clone(); let path_identifiers = PathIdentifiers::from_channel_end(channel.clone()).ok_or_else(|| { - BaseError::generic(eyre!( - "failed to get the path identifiers for channel ({}, {})", + CosmosChain::raise_error(eyre!( + "failed to get the path identifiers for channel (`{}`, `{}`)", channel.channel_id, channel.port_id )) From d242c8030b125942f0b48bc32a4803db9a5a6ab6 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 11:05:28 -0600 Subject: [PATCH 21/23] Fix channel_id:port_id formatting --- crates/cli/cli/src/commands/query/channel/ends.rs | 14 +++++++------- crates/cli/cli/src/commands/query/channels.rs | 8 ++++---- .../cli/cli/src/commands/query/packet/pending.rs | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/cli/cli/src/commands/query/channel/ends.rs b/crates/cli/cli/src/commands/query/channel/ends.rs index c9178d669..88b8fa885 100644 --- a/crates/cli/cli/src/commands/query/channel/ends.rs +++ b/crates/cli/cli/src/commands/query/channel/ends.rs @@ -105,17 +105,17 @@ impl CommandRunner for QueryChannelEnds { IncludeProof::No, ) else { return Err(CosmosChain::raise_error( - "failed to query channel end for `{channel_id}`:`{port_id}` on chain {chain_id} @ {query_height:?}" + "failed to query channel end for `{port_id}`/`{channel_id}` on chain {chain_id} @ {query_height:?}" )); }; if channel_end.state_matches(&State::Uninitialized) { - return Err(CosmosChain::raise_error("`{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` is uninitialized")); + return Err(CosmosChain::raise_error("`{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}` is uninitialized")); } let Some(connection_id) = channel_end.connection_hops.first() else { return Err(CosmosChain::raise_error( - "missing connection hops for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`", + "missing connection hops for `{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}`", )); }; @@ -128,7 +128,7 @@ impl CommandRunner for QueryChannelEnds { IncludeProof::No, ) else { return Err(CosmosChain::raise_error( - "failed to query connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`" + "failed to query connection end for `{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}`" )); }; @@ -143,7 +143,7 @@ impl CommandRunner for QueryChannelEnds { IncludeProof::No, ) else { return Err(CosmosChain::raise_error( - "failed to query client state for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}`" + "failed to query client state for `{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}`" )); }; @@ -153,7 +153,7 @@ impl CommandRunner for QueryChannelEnds { let Some(counterparty_connection_id) = connection_counterparty.connection_id else { return Err(CosmosChain::raise_error( - "connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty connection id `{connection_end:?}`", + "connection end for `{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty connection id `{connection_end:?}`", )); }; @@ -161,7 +161,7 @@ impl CommandRunner for QueryChannelEnds { let Some(counterparty_channel_id) = channel_counterparty.channel_id else { return Err(CosmosChain::raise_error( - "channel end for `{channel_id}`:`{port_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty channel id `{channel_end:?}`", + "channel end for `{port_id}`/`{channel_id}` on chain `{chain_id}` @ `{query_height:?}` does not have counterparty channel id `{channel_end:?}`", )); }; diff --git a/crates/cli/cli/src/commands/query/channels.rs b/crates/cli/cli/src/commands/query/channels.rs index 60f7c31d0..a91218f15 100644 --- a/crates/cli/cli/src/commands/query/channels.rs +++ b/crates/cli/cli/src/commands/query/channels.rs @@ -89,7 +89,7 @@ impl CommandRunner for QueryChannels { if channel_end.state_matches(&State::Uninitialized) { warn!( - "channel `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}` is uninitialized" + "channel `{port_id}`/`{channel_id}` on chain `{chain_id}` at height `{chain_height}` is uninitialized" ); continue; @@ -97,7 +97,7 @@ impl CommandRunner for QueryChannels { let Some(connection_id) = channel.channel_end.connection_hops.first() else { warn!( - "missing connection hops for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`" + "missing connection hops for `{port_id}`/`{channel_id}` on chain `{chain_id}` at height `{chain_height}`" ); continue; @@ -123,7 +123,7 @@ impl CommandRunner for QueryChannels { let Ok((connection_end, _)) = connection_end else { warn!( - "missing connection end for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`" + "missing connection end for `{port_id}`/`{channel_id}` on chain `{chain_id}` at height `{chain_height}`" ); continue; @@ -149,7 +149,7 @@ impl CommandRunner for QueryChannels { .await; let Ok((client_state, _)) = client_state else { - warn!("missing client state for `{channel_id}`:`{port_id}` on chain `{chain_id}` at height `{chain_height}`"); + warn!("missing client state for `{port_id}`/`{channel_id}` on chain `{chain_id}` at height `{chain_height}`"); continue; }; diff --git a/crates/cli/cli/src/commands/query/packet/pending.rs b/crates/cli/cli/src/commands/query/packet/pending.rs index a41c46d1a..a1240de15 100644 --- a/crates/cli/cli/src/commands/query/packet/pending.rs +++ b/crates/cli/cli/src/commands/query/packet/pending.rs @@ -159,7 +159,7 @@ impl QueryPendingPackets { })? .ok_or_else(|| { CosmosChain::raise_error(eyre!( - "missing counterparty channel for ({}, {})", + "missing counterparty channel for (`{}`, `{}`)", chan_conn_cli.channel.channel_id, chan_conn_cli.channel.port_id )) From 6d1f9453d88038cc710e0e14c78a5623a0229893 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 11:13:12 -0600 Subject: [PATCH 22/23] Tweak an error message --- crates/cli/cli/src/commands/query/packet/commitments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli/cli/src/commands/query/packet/commitments.rs b/crates/cli/cli/src/commands/query/packet/commitments.rs index 17e482f28..c45fc8245 100644 --- a/crates/cli/cli/src/commands/query/packet/commitments.rs +++ b/crates/cli/cli/src/commands/query/packet/commitments.rs @@ -55,7 +55,7 @@ impl CommandRunner for QueryPacketCommitments { &self.port_id, ) .await - .wrap_err("failed to query packet commitments")?; + .wrap_err("`query packet commitments` command failed")?; let packet_sequences = PacketSequences::new(height, sequences); From 98ce52d63b622078b51dcc532a31425021cd3a82 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 21 Feb 2024 11:14:20 -0600 Subject: [PATCH 23/23] Better organize some dependencies --- crates/cli/cli/src/commands/query/packet/pending_acks.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/cli/cli/src/commands/query/packet/pending_acks.rs b/crates/cli/cli/src/commands/query/packet/pending_acks.rs index 6fa210cc8..939734afa 100644 --- a/crates/cli/cli/src/commands/query/packet/pending_acks.rs +++ b/crates/cli/cli/src/commands/query/packet/pending_acks.rs @@ -1,11 +1,12 @@ -use cgp_core::CanRaiseError; -use hermes_cosmos_relayer::contexts::chain::CosmosChain; use oneline_eyre::eyre::{eyre, Context}; +use cgp_core::CanRaiseError; + use hermes_cli_framework::command::CommandRunner; use hermes_cli_framework::output::{json, Output}; use hermes_cosmos_client_components::traits::chain_handle::HasBlockingChainHandle; use hermes_cosmos_relayer::contexts::builder::CosmosBuilder; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; use ibc_relayer::chain::counterparty::{channel_connection_client, unreceived_acknowledgements}; use ibc_relayer::path::PathIdentifiers;