diff --git a/crates/relayer/src/chain/cosmos.rs b/crates/relayer/src/chain/cosmos.rs index 936615b44c..e8d41f6975 100644 --- a/crates/relayer/src/chain/cosmos.rs +++ b/crates/relayer/src/chain/cosmos.rs @@ -106,6 +106,7 @@ use crate::util::pretty::{ use crate::{chain::client::ClientSettings, config::Error as ConfigError}; use self::types::app_state::GenesisAppState; +use self::version::Specs; pub mod batch; pub mod client; @@ -1078,9 +1079,9 @@ impl ChainEndpoint for CosmosSdkChain { ChainConfig::CosmosSdk(self.config.clone()) } - fn version_specs(&self) -> Result<(Option, semver::Version), Error> { + fn version_specs(&self) -> Result { let version_specs = self.block_on(fetch_version_specs(self.id(), &self.grpc_addr))?; - Ok((version_specs.ibc_go, version_specs.cosmos_sdk)) + Ok(version_specs) } fn query_balance(&self, key_name: Option<&str>, denom: Option<&str>) -> Result { diff --git a/crates/relayer/src/chain/endpoint.rs b/crates/relayer/src/chain/endpoint.rs index 38bbdca840..02b1d342cb 100644 --- a/crates/relayer/src/chain/endpoint.rs +++ b/crates/relayer/src/chain/endpoint.rs @@ -33,6 +33,7 @@ use tendermint_rpc::endpoint::broadcast::tx_sync::Response as TxResponse; use crate::account::Balance; use crate::chain::client::ClientSettings; +use crate::chain::cosmos::version::Specs; use crate::chain::handle::Subscription; use crate::chain::requests::*; use crate::chain::tracking::TrackedMsgs; @@ -124,7 +125,7 @@ pub trait ChainEndpoint: Sized { // Versioning /// Return the version of the IBC protocol that this chain is running, if known. - fn version_specs(&self) -> Result<(Option, semver::Version), Error>; + fn version_specs(&self) -> Result; // Send transactions diff --git a/crates/relayer/src/chain/handle.rs b/crates/relayer/src/chain/handle.rs index 5a1271e97b..1ff6aae63f 100644 --- a/crates/relayer/src/chain/handle.rs +++ b/crates/relayer/src/chain/handle.rs @@ -45,6 +45,7 @@ use crate::{ use super::{ client::ClientSettings, + cosmos::version::Specs, endpoint::{ChainStatus, HealthCheck}, requests::*, tracking::TrackedMsgs, @@ -141,7 +142,7 @@ pub enum ChainRequest { }, VersionSpecs { - reply_to: ReplyTo<(Option, semver::Version)>, + reply_to: ReplyTo, }, QueryBalance { @@ -412,7 +413,7 @@ pub trait ChainHandle: Clone + Display + Send + Sync + Debug + 'static { fn add_key(&self, key_name: String, key: AnySigningKeyPair) -> Result<(), Error>; /// Return the version of the IBC protocol that this chain is running, if known. - fn version_specs(&self) -> Result<(Option, semver::Version), Error>; + fn version_specs(&self) -> Result; /// Query the balance of the given account for the given denom. /// If no account is given, behavior must be specified, e.g. retrieve it from configuration file. diff --git a/crates/relayer/src/chain/handle/base.rs b/crates/relayer/src/chain/handle/base.rs index c949050e61..220c9ce7a3 100644 --- a/crates/relayer/src/chain/handle/base.rs +++ b/crates/relayer/src/chain/handle/base.rs @@ -26,7 +26,10 @@ use ibc_relayer_types::{ use crate::{ account::Balance, - chain::{client::ClientSettings, endpoint::ChainStatus, requests::*, tracking::TrackedMsgs}, + chain::{ + client::ClientSettings, cosmos::version::Specs, endpoint::ChainStatus, requests::*, + tracking::TrackedMsgs, + }, client_state::{AnyClientState, IdentifiedAnyClientState}, config::ChainConfig, connection::ConnectionMsgType, @@ -144,7 +147,7 @@ impl ChainHandle for BaseChainHandle { }) } - fn version_specs(&self) -> Result<(Option, semver::Version), Error> { + fn version_specs(&self) -> Result { self.send(|reply_to| ChainRequest::VersionSpecs { reply_to }) } diff --git a/crates/relayer/src/chain/handle/cache.rs b/crates/relayer/src/chain/handle/cache.rs index 59bd0548fb..3c4762b3ae 100644 --- a/crates/relayer/src/chain/handle/cache.rs +++ b/crates/relayer/src/chain/handle/cache.rs @@ -25,6 +25,7 @@ use ibc_relayer_types::Height; use crate::account::Balance; use crate::cache::{Cache, CacheStatus}; use crate::chain::client::ClientSettings; +use crate::chain::cosmos::version::Specs; use crate::chain::endpoint::{ChainStatus, HealthCheck}; use crate::chain::handle::{ChainHandle, ChainRequest, Subscription}; use crate::chain::requests::*; @@ -122,7 +123,7 @@ impl ChainHandle for CachingChainHandle { self.inner().add_key(key_name, key) } - fn version_specs(&self) -> Result<(Option, semver::Version), Error> { + fn version_specs(&self) -> Result { self.inner().version_specs() } diff --git a/crates/relayer/src/chain/handle/counting.rs b/crates/relayer/src/chain/handle/counting.rs index e5998372a7..2211cc3551 100644 --- a/crates/relayer/src/chain/handle/counting.rs +++ b/crates/relayer/src/chain/handle/counting.rs @@ -28,6 +28,7 @@ use ibc_relayer_types::Height; use crate::account::Balance; use crate::chain::client::ClientSettings; +use crate::chain::cosmos::version::Specs; use crate::chain::endpoint::{ChainStatus, HealthCheck}; use crate::chain::handle::{ChainHandle, ChainRequest, Subscription}; use crate::chain::requests::*; @@ -150,7 +151,7 @@ impl ChainHandle for CountingChainHandle { self.inner().add_key(key_name, key) } - fn version_specs(&self) -> Result<(Option, semver::Version), Error> { + fn version_specs(&self) -> Result { self.inc_metric("ibc_version"); self.inner().version_specs() } diff --git a/crates/relayer/src/chain/runtime.rs b/crates/relayer/src/chain/runtime.rs index 42cc9be8dd..d19fbd9cfe 100644 --- a/crates/relayer/src/chain/runtime.rs +++ b/crates/relayer/src/chain/runtime.rs @@ -45,6 +45,7 @@ use crate::{ use super::{ client::ClientSettings, + cosmos::version::Specs, endpoint::{ChainEndpoint, ChainStatus, HealthCheck}, handle::{ChainHandle, ChainRequest, ReplyTo, Subscription}, requests::*, @@ -449,10 +450,7 @@ where reply_to.send(result).map_err(Error::send) } - fn version_specs( - &mut self, - reply_to: ReplyTo<(Option, semver::Version)>, - ) -> Result<(), Error> { + fn version_specs(&mut self, reply_to: ReplyTo) -> Result<(), Error> { let result = self.chain.version_specs(); reply_to.send(result).map_err(Error::send) } diff --git a/crates/relayer/src/upgrade_chain.rs b/crates/relayer/src/upgrade_chain.rs index c9a7130f7d..3c6b407f5c 100644 --- a/crates/relayer/src/upgrade_chain.rs +++ b/crates/relayer/src/upgrade_chain.rs @@ -98,20 +98,20 @@ pub fn build_and_send_ibc_upgrade_proposal( /// If the ibc-go version returned isn't reliable, a deprecated version, then the version /// of Cosmos SDK is used. pub fn requires_legacy_upgrade_proposal(dst_chain: impl ChainHandle) -> bool { - let (maybe_ibc_version, sdk_version) = dst_chain.version_specs().unwrap(); - match maybe_ibc_version { + let version_specs = dst_chain.version_specs().unwrap(); + match version_specs.ibc_go { Some(ibc_version) => { // Some ibc-go simapps return unreliable ibc-go versions, such as simapp v8.0.0 // returns version v1.0.0. So if the ibc-go version matches which is not maintained // anymore, use the Cosmos SDK version to determine if the legacy upgrade proposal // has to be used if ibc_version.major < 4 { - sdk_version.minor < 50 + version_specs.cosmos_sdk.minor < 50 } else { ibc_version.major < 8 } } - None => sdk_version.minor < 50, + None => version_specs.cosmos_sdk.minor < 50, } } diff --git a/tools/test-framework/src/relayer/chain.rs b/tools/test-framework/src/relayer/chain.rs index a00cf87f4d..c4d70fe466 100644 --- a/tools/test-framework/src/relayer/chain.rs +++ b/tools/test-framework/src/relayer/chain.rs @@ -21,6 +21,7 @@ */ use crossbeam_channel as channel; +use ibc_relayer::chain::cosmos::version::Specs; use tracing::Span; use ibc_proto::ibc::apps::fee::v1::{ @@ -121,7 +122,7 @@ where self.value().add_key(key_name, key) } - fn version_specs(&self) -> Result<(Option, semver::Version), Error> { + fn version_specs(&self) -> Result { self.value().version_specs() }