diff --git a/relayer/cli/src/commands/light/init.rs b/relayer/cli/src/commands/light/init.rs index 5a73fc9b91..595ffa267a 100644 --- a/relayer/cli/src/commands/light/init.rs +++ b/relayer/cli/src/commands/light/init.rs @@ -9,7 +9,7 @@ use tendermint::chain::Id as ChainId; use tendermint::hash::Hash; use tendermint::lite::Height; -use relayer::chain::tendermint::TendermintChain; +use relayer::chain::CosmosSDKChain; use relayer::client::trust_options::TrustOptions; use relayer::config::{ChainConfig, Config}; use relayer::store::{sled::SledStore, Store}; @@ -93,7 +93,7 @@ impl Runnable for InitCmd { ) .unwrap(); - let mut store: SledStore = + let mut store: SledStore = relayer::store::persistent(format!("store_{}.db", chain_config.id)).unwrap(); // FIXME: unwrap store.set_trust_options(trust_options).unwrap(); // FIXME: unwrap diff --git a/relayer/cli/src/commands/query/channel.rs b/relayer/cli/src/commands/query/channel.rs index 2ed02f2798..e6a25f459f 100644 --- a/relayer/cli/src/commands/query/channel.rs +++ b/relayer/cli/src/commands/query/channel.rs @@ -7,8 +7,7 @@ use relayer_modules::ics04_channel::channel::ChannelEnd; use relayer_modules::ics24_host::identifier::{ChannelId, PortId}; use relayer_modules::ics24_host::Path::ChannelEnds; -use relayer::chain::tendermint::TendermintChain; -use relayer::chain::Chain; +use relayer::chain::{Chain, CosmosSDKChain}; use relayer_modules::ics24_host::error::ValidationError; use tendermint::chain::Id as ChainId; @@ -97,7 +96,7 @@ impl Runnable for QueryChannelEndCmd { // run without proof: // cargo run --bin relayer -- -c relayer/relay/tests/config/fixtures/simple_config.toml query channel end ibc-test firstport firstchannel --height 3 -p false - let chain = TendermintChain::from_config(chain_config).unwrap(); + let chain = CosmosSDKChain::from_config(chain_config).unwrap(); let res = chain.query::( ChannelEnds(opts.port_id, opts.channel_id), opts.height, diff --git a/relayer/cli/src/commands/query/client.rs b/relayer/cli/src/commands/query/client.rs index ba55bb737d..c20ef4783a 100644 --- a/relayer/cli/src/commands/query/client.rs +++ b/relayer/cli/src/commands/query/client.rs @@ -77,7 +77,7 @@ impl Runnable for QueryClientStateCmd { // // Note: currently both fail in amino_unmarshal_binary_length_prefixed(). // To test this start a Gaia node and configure a client using the go relayer. - let _chain = TendermintChain::from_config(chain_config).unwrap(); + let _chain = CosmosSDKChain::from_config(chain_config).unwrap(); /* Todo: Implement client full state query let res = block_on(query_client_full_state( &chain, @@ -170,7 +170,7 @@ impl Runnable for QueryClientConsensusCmd { // // Note: currently both fail in amino_unmarshal_binary_length_prefixed(). // To test this start a Gaia node and configure a client using the go relayer. - let _chain = TendermintChain::from_config(chain_config).unwrap(); + let _chain = CosmosSDKChain::from_config(chain_config).unwrap(); /* Todo: Implement client consensus state query let res = block_on(query_client_consensus_state( &chain, diff --git a/relayer/cli/src/commands/query/connection.rs b/relayer/cli/src/commands/query/connection.rs index e51d6909a9..70c2bdd870 100644 --- a/relayer/cli/src/commands/query/connection.rs +++ b/relayer/cli/src/commands/query/connection.rs @@ -3,8 +3,7 @@ use crate::prelude::*; use abscissa_core::{Command, Options, Runnable}; use relayer::config::{ChainConfig, Config}; -use relayer::chain::tendermint::TendermintChain; -use relayer::chain::Chain; +use relayer::chain::{Chain, CosmosSDKChain}; use relayer_modules::ics24_host::error::ValidationError; use relayer_modules::ics24_host::identifier::ConnectionId; use relayer_modules::ics24_host::Path::Connections; @@ -83,7 +82,7 @@ impl Runnable for QueryConnectionEndCmd { }; status_info!("Options", "{:?}", opts); - let chain = TendermintChain::from_config(chain_config).unwrap(); + let chain = CosmosSDKChain::from_config(chain_config).unwrap(); // run without proof: // cargo run --bin relayer -- -c relayer/relay/tests/config/fixtures/simple_config.toml query connection end ibc-test connectionidone --height 3 -p false let res = diff --git a/relayer/cli/src/commands/start.rs b/relayer/cli/src/commands/start.rs index 9bc7a38b91..5ab561f91a 100644 --- a/relayer/cli/src/commands/start.rs +++ b/relayer/cli/src/commands/start.rs @@ -9,8 +9,7 @@ use abscissa_core::{Command, Options, Runnable}; use tendermint::lite::types::Header; use crate::commands::utils::block_on; -use relayer::chain::tendermint::TendermintChain; -use relayer::chain::Chain; +use relayer::chain::{Chain, CosmosSDKChain}; use relayer::client::Client; use relayer::config::ChainConfig; @@ -62,7 +61,7 @@ async fn spawn_client(chain_config: ChainConfig, reset: bool) { .expect("could not spawn client task") } -async fn client_task(client: Client>) { +async fn client_task(client: Client>) { let trusted_state = client.last_trusted_state().unwrap(); status_ok!( @@ -108,9 +107,9 @@ async fn update_client>(mut client: Client) { async fn create_client( chain_config: ChainConfig, reset: bool, -) -> Client> { +) -> Client> { let id = chain_config.id; - let chain = TendermintChain::from_config(chain_config).unwrap(); + let chain = CosmosSDKChain::from_config(chain_config).unwrap(); let store = relayer::store::persistent(format!("store_{}.db", chain.id())).unwrap(); //FIXME: unwrap let trust_options = store.get_trust_options().unwrap(); // FIXME: unwrap diff --git a/relayer/relay/src/chain.rs b/relayer/relay/src/chain.rs index f4ebc4eb6a..f8cb81b30d 100644 --- a/relayer/relay/src/chain.rs +++ b/relayer/relay/src/chain.rs @@ -16,7 +16,8 @@ use crate::config::ChainConfig; use crate::error; use std::error::Error; -pub mod tendermint; +mod cosmos; +pub use cosmos::CosmosSDKChain; /// Handy type alias for the type of validator set associated with a chain pub type ValidatorSet = <::Commit as tmlite::Commit>::ValidatorSet; diff --git a/relayer/relay/src/chain/tendermint.rs b/relayer/relay/src/chain/cosmos.rs similarity index 93% rename from relayer/relay/src/chain/tendermint.rs rename to relayer/relay/src/chain/cosmos.rs index 10664b759d..59aad7b597 100644 --- a/relayer/relay/src/chain/tendermint.rs +++ b/relayer/relay/src/chain/cosmos.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use tendermint::abci::Path as TendermintPath; +use tendermint::abci::Path as TendermintABCIPath; use tendermint::block::signed_header::SignedHeader as TMCommit; use tendermint::block::Header as TMHeader; use tendermint::block::Height; @@ -22,13 +22,13 @@ use bytes::Bytes; use prost::Message; use std::str::FromStr; -pub struct TendermintChain { +pub struct CosmosSDKChain { config: ChainConfig, rpc_client: RpcClient, requester: RpcRequester, } -impl TendermintChain { +impl CosmosSDKChain { pub fn from_config(config: ChainConfig) -> Result { // TODO: Derive Clone on RpcClient in tendermint-rs let requester = RpcRequester::new(RpcClient::new(config.rpc_addr.clone())); @@ -42,7 +42,7 @@ impl TendermintChain { } } -impl Chain for TendermintChain { +impl Chain for CosmosSDKChain { type Header = TMHeader; type Commit = TMCommit; type ConsensusState = ConsensusState; @@ -54,7 +54,7 @@ impl Chain for TendermintChain { where T: TryFromRaw, { - let path = TendermintPath::from_str(IBC_QUERY_PATH).unwrap(); + let path = TendermintABCIPath::from_str(IBC_QUERY_PATH).unwrap(); if !data.is_provable() & prove { return Err(Kind::Store .context("requested proof for privateStore path") @@ -96,8 +96,8 @@ impl Chain for TendermintChain { /// Perform a generic `abci_query`, and return the corresponding deserialized response data. async fn abci_query( - chain: &TendermintChain, - path: TendermintPath, + chain: &CosmosSDKChain, + path: TendermintABCIPath, data: String, height: u64, prove: bool,