Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ancazamfir committed Apr 7, 2021
1 parent 48b86a0 commit ea1a083
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 221 deletions.
118 changes: 0 additions & 118 deletions modules/src/ics02_client/client_header.rs

This file was deleted.

1 change: 0 additions & 1 deletion modules/src/ics02_client/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::mock::client_state::MockClientState;
use crate::Height;

pub const TENDERMINT_CLIENT_STATE_TYPE_URL: &str = "/ibc.lightclients.tendermint.v1.ClientState";

pub const MOCK_CLIENT_STATE_TYPE_URL: &str = "/ibc.mock.ClientState";

#[dyn_clonable::clonable]
Expand Down
4 changes: 2 additions & 2 deletions modules/src/ics02_client/handler/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod tests {
use crate::ics02_client::msgs::ClientMsg;
use crate::ics07_tendermint::client_state::ClientState;
use crate::ics07_tendermint::header::test_util::get_dummy_tendermint_header;
use crate::ics24_host::identifier::{ChainId, ClientId};
use crate::ics24_host::identifier::ClientId;
use crate::mock::client_state::{MockClientState, MockConsensusState};
use crate::mock::context::MockContext;
use crate::mock::header::MockHeader;
Expand Down Expand Up @@ -222,7 +222,7 @@ mod tests {
let tm_header = get_dummy_tendermint_header();

let tm_client_state = AnyClientState::Tendermint(ClientState {
chain_id: ChainId::from(tm_header.chain_id.clone()),
chain_id: tm_header.chain_id.clone().into(),
trust_level: TrustThreshold {
numerator: 1,
denominator: 3,
Expand Down
5 changes: 3 additions & 2 deletions modules/src/ics03_connection/msgs/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,14 @@ impl From<MsgConnectionOpenTry> for RawMsgConnectionOpenTry {

#[cfg(test)]
pub mod test_util {
use ibc_proto::ibc::core::client::v1::Height;
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry;

use crate::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry;
use crate::ics03_connection::msgs::test_util::get_dummy_raw_counterparty;
use crate::ics03_connection::version::get_compatible_versions;
use crate::ics24_host::identifier::{ClientId, ConnectionId};
use crate::test_utils::{get_dummy_bech32_account, get_dummy_proof};
use ibc_proto::ibc::core::client::v1::Height;
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry;

/// Testing-specific helper methods.
impl MsgConnectionOpenTry {
Expand Down
1 change: 1 addition & 0 deletions modules/src/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ pub fn validate_version(version: String) -> Result<String, Error> {

#[cfg(test)]
pub mod test_util {

use crate::ics24_host::identifier::{ChannelId, ConnectionId, PortId};
use ibc_proto::ibc::core::channel::v1::Channel as RawChannel;
use ibc_proto::ibc::core::channel::v1::Counterparty as RawCounterparty;
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl TryFrom<RawClientState> for ClientState {
impl From<ClientState> for RawClientState {
fn from(value: ClientState) -> Self {
RawClientState {
chain_id: value.chain_id.as_str().parse().unwrap(),
chain_id: value.chain_id.to_string(),
trust_level: Some(Fraction {
numerator: value.trust_level.numerator,
denominator: value.trust_level.denominator,
Expand Down
87 changes: 0 additions & 87 deletions relayer-cli/src/commands/discover.rs

This file was deleted.

2 changes: 1 addition & 1 deletion relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn listen(rt: Arc<TokioRuntime>, config: ChainConfig) -> Result<(), BoxError
Ok(())
}

pub(crate) fn subscribe(
fn subscribe(
chain_config: ChainConfig,
rt: Arc<TokioRuntime>,
) -> Result<(EventMonitor, channel::Receiver<EventBatch>), BoxError> {
Expand Down
26 changes: 18 additions & 8 deletions relayer-cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub struct QueryClientConsensusCmd {
}

/// Implementation of the query for a client's consensus state at a certain height.
/// hermes query client consensus ibc-0 07-tendermint-0 22
/// hermes query client consensus ibc-0 07-tendermint-0 -c 22
impl Runnable for QueryClientConsensusCmd {
fn run(&self) {
let config = app_config();
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Runnable for QueryClientConsensusCmd {
}
}

/// Query client consensus command
/// Query client header command
#[derive(Clone, Command, Debug, Options)]
pub struct QueryClientHeaderCmd {
#[options(free, required, help = "identifier of the chain to query")]
Expand All @@ -159,18 +159,15 @@ pub struct QueryClientHeaderCmd {
#[options(free, required, help = "identifier of the client to query")]
client_id: ClientId,

#[options(free, required, help = "epoch of the header to query")]
consensus_version: u64,

#[options(free, required, help = "height of header to query")]
consensus_height: u64,

#[options(help = "the chain height context for the query", short = "h")]
height: Option<u64>,
}

/// Implementation of the query for a client's consensus state at a certain height.
/// hermes query client consensus ibc-0 07-tendermint-0 22
/// Implementation of the query for the header used in a client update at a certain height.
/// hermes query client header ibc-0 07-tendermint-0 22
impl Runnable for QueryClientHeaderCmd {
fn run(&self) {
let config = app_config();
Expand All @@ -190,7 +187,20 @@ impl Runnable for QueryClientHeaderCmd {

let rt = Arc::new(TokioRuntime::new().unwrap());
let chain = CosmosSdkChain::bootstrap(chain_config.clone(), rt).unwrap();
let consensus_height = ibc::Height::new(self.consensus_version, self.consensus_height);

let counterparty_chain = match chain.query_client_state(&self.client_id, Height::zero()) {
Ok(cs) => cs.chain_id(),
Err(e) => {
return Output::error(format!(
"Failed while querying client '{}' on chain '{}' with error: {}",
self.client_id, self.chain_id, e
))
.exit()
}
};

let consensus_height =
ibc::Height::new(counterparty_chain.version(), self.consensus_height);
let height = ibc::Height::new(chain.id().version(), self.height.unwrap_or(0_u64));

let res = chain.query_txs(QueryTxRequest::Client(QueryClientEventRequest {
Expand Down
1 change: 0 additions & 1 deletion relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ impl Chain for CosmosSdkChain {
Ok(result)
}

// TODO - to be replaced with query for update client event
QueryTxRequest::Client(request) => {
let response = self
.block_on(self.rpc_client.tx_search(
Expand Down

0 comments on commit ea1a083

Please sign in to comment.