Skip to content

Commit

Permalink
Rename TendermintChain to CosmosSDKChain (#179)
Browse files Browse the repository at this point in the history
* Rename TendermintChain to CosmosSDKChain

* Clarify TendermintPath (-> TendermintABCIPath)

* Fix sad typo
  • Loading branch information
greg-szabo committed Jul 29, 2020
1 parent 6548786 commit 021cdc4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions relayer/cli/src/commands/light/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -93,7 +93,7 @@ impl Runnable for InitCmd {
)
.unwrap();

let mut store: SledStore<TendermintChain> =
let mut store: SledStore<CosmosSDKChain> =
relayer::store::persistent(format!("store_{}.db", chain_config.id)).unwrap(); // FIXME: unwrap

store.set_trust_options(trust_options).unwrap(); // FIXME: unwrap
Expand Down
5 changes: 2 additions & 3 deletions relayer/cli/src/commands/query/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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::<ChannelEnd>(
ChannelEnds(opts.port_id, opts.channel_id),
opts.height,
Expand Down
6 changes: 3 additions & 3 deletions relayer/cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use relayer::config::{ChainConfig, Config};
use relayer_modules::ics24_host::identifier::ClientId;

//use crate::commands::utils::block_on;
use relayer::chain::tendermint::TendermintChain;
use relayer::chain::CosmosSDKChain;
use relayer_modules::ics24_host::error::ValidationError;
use tendermint::chain::Id as ChainId;

Expand Down Expand Up @@ -79,7 +79,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,
Expand Down Expand Up @@ -171,7 +171,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,
Expand Down
5 changes: 2 additions & 3 deletions relayer/cli/src/commands/query/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down
9 changes: 4 additions & 5 deletions relayer/cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<TendermintChain, impl Store<TendermintChain>>) {
async fn client_task(client: Client<CosmosSDKChain, impl Store<CosmosSDKChain>>) {
let trusted_state = client.last_trusted_state().unwrap();

status_ok!(
Expand Down Expand Up @@ -108,9 +107,9 @@ async fn update_client<C: Chain, S: Store<C>>(mut client: Client<C, S>) {
async fn create_client(
chain_config: ChainConfig,
reset: bool,
) -> Client<TendermintChain, impl Store<TendermintChain>> {
) -> Client<CosmosSDKChain, impl Store<CosmosSDKChain>> {
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
Expand Down
3 changes: 2 additions & 1 deletion relayer/relay/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chain> = <<Chain as self::Chain>::Commit as tmlite::Commit>::ValidatorSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Self, Error> {
// TODO: Derive Clone on RpcClient in tendermint-rs
let requester = RpcRequester::new(RpcClient::new(config.rpc_addr.clone()));
Expand All @@ -42,7 +42,7 @@ impl TendermintChain {
}
}

impl Chain for TendermintChain {
impl Chain for CosmosSDKChain {
type Header = TMHeader;
type Commit = TMCommit;
type ConsensusState = ConsensusState;
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 021cdc4

Please sign in to comment.