Skip to content

Commit

Permalink
Remove Height::zero() from relayer (informalsystems#2329)
Browse files Browse the repository at this point in the history
* Cargo lock

* HeightQuery -> QueryHeight

* move query types to relayer's requests file

* QueryClientEventRequest uses QueryHeight

* QueryPacketEventDataRequest uses QueryHeight

* Make trusted_height an Option<Height>

* target_height: use QueryHeight

* MsgTransfer uses Option<Height> for timeout_height field

* Import nit

Co-authored-by: Adi Seredinschi <adi@informal.systems>
  • Loading branch information
plafer and adizere authored Jun 24, 2022
1 parent b601c32 commit f13126c
Show file tree
Hide file tree
Showing 46 changed files with 351 additions and 395 deletions.
97 changes: 10 additions & 87 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions relayer-cli/src/commands/create/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ibc::core::ics04_channel::Version;
use ibc::core::ics24_host::identifier::{ChainId, ConnectionId, PortId};
use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{
HeightQuery, IncludeProof, QueryClientStateRequest, QueryConnectionRequest,
IncludeProof, QueryClientStateRequest, QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::channel::Channel;
use ibc_relayer::connection::Connection;
Expand Down Expand Up @@ -191,7 +191,7 @@ impl CreateChannelCommand {
.query_connection(
QueryConnectionRequest {
connection_id: connection_a.clone(),
height: HeightQuery::Latest,
height: QueryHeight::Latest,
},
IncludeProof::No,
)
Expand All @@ -202,7 +202,7 @@ impl CreateChannelCommand {
.query_client_state(
QueryClientStateRequest {
client_id: conn_end.client_id().clone(),
height: HeightQuery::Latest,
height: QueryHeight::Latest,
},
IncludeProof::No,
)
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/commands/create/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use abscissa_core::{Command, Runnable};
use ibc::core::ics02_client::client_state::ClientState;
use ibc::core::ics24_host::identifier::{ChainId, ClientId};
use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{HeightQuery, IncludeProof, QueryClientStateRequest};
use ibc_relayer::chain::requests::{IncludeProof, QueryClientStateRequest, QueryHeight};
use ibc_relayer::connection::Connection;
use ibc_relayer::foreign_client::ForeignClient;

Expand Down Expand Up @@ -116,7 +116,7 @@ impl CreateConnectionCommand {
let chain_b_id = match chain_a.query_client_state(
QueryClientStateRequest {
client_id: client_a_id.clone(),
height: HeightQuery::Latest,
height: QueryHeight::Latest,
},
IncludeProof::No,
) {
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/commands/misbehaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ibc::core::ics02_client::events::UpdateClient;
use ibc::core::ics24_host::identifier::{ChainId, ClientId};
use ibc::events::IbcEvent;
use ibc_relayer::chain::handle::ChainHandle;
use ibc_relayer::chain::requests::{HeightQuery, IncludeProof, QueryClientStateRequest};
use ibc_relayer::chain::requests::{IncludeProof, QueryClientStateRequest, QueryHeight};
use ibc_relayer::config::Config;
use ibc_relayer::foreign_client::{ForeignClient, MisbehaviourResults};
use std::ops::Deref;
Expand Down Expand Up @@ -102,7 +102,7 @@ fn misbehaviour_handling<Chain: ChainHandle>(
.query_client_state(
QueryClientStateRequest {
client_id: client_id.clone(),
height: HeightQuery::Latest,
height: QueryHeight::Latest,
},
IncludeProof::No,
)
Expand Down
6 changes: 3 additions & 3 deletions relayer-cli/src/commands/query/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ibc_relayer::chain::handle::ChainHandle;

use ibc::core::ics24_host::identifier::ChainId;
use ibc::core::ics24_host::identifier::{ChannelId, PortId};
use ibc_relayer::chain::requests::{HeightQuery, IncludeProof, QueryChannelRequest};
use ibc_relayer::chain::requests::{IncludeProof, QueryChannelRequest, QueryHeight};

use crate::cli_utils::spawn_chain_runtime;
use crate::conclude::{exit_with_unrecoverable_error, Output};
Expand Down Expand Up @@ -39,8 +39,8 @@ impl Runnable for QueryChannelEndCmd {
QueryChannelRequest {
port_id: self.port_id.clone(),
channel_id: self.channel_id,
height: self.height.map_or(HeightQuery::Latest, |revision_height| {
HeightQuery::Specific(ibc::Height::new(chain.id().version(), revision_height))
height: self.height.map_or(QueryHeight::Latest, |revision_height| {
QueryHeight::Specific(ibc::Height::new(chain.id().version(), revision_height))
}),
},
IncludeProof::No,
Expand Down
10 changes: 5 additions & 5 deletions relayer-cli/src/commands/query/channel_ends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ibc::core::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortI
use ibc::Height;
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{
HeightQuery, IncludeProof, QueryChannelRequest, QueryClientStateRequest, QueryConnectionRequest,
IncludeProof, QueryChannelRequest, QueryClientStateRequest, QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::registry::Registry;

Expand Down Expand Up @@ -85,7 +85,7 @@ fn do_run<Chain: ChainHandle>(cmd: &QueryChannelEndsCmd) -> Result<(), Box<dyn s
QueryChannelRequest {
port_id: port_id.clone(),
channel_id,
height: HeightQuery::Specific(chain_height),
height: QueryHeight::Specific(chain_height),
},
IncludeProof::No,
)?;
Expand All @@ -111,7 +111,7 @@ fn do_run<Chain: ChainHandle>(cmd: &QueryChannelEndsCmd) -> Result<(), Box<dyn s
let (connection_end, _) = chain.query_connection(
QueryConnectionRequest {
connection_id: connection_id.clone(),
height: HeightQuery::Specific(chain_height),
height: QueryHeight::Specific(chain_height),
},
IncludeProof::No,
)?;
Expand All @@ -121,7 +121,7 @@ fn do_run<Chain: ChainHandle>(cmd: &QueryChannelEndsCmd) -> Result<(), Box<dyn s
let (client_state, _) = chain.query_client_state(
QueryClientStateRequest {
client_id: client_id.clone(),
height: HeightQuery::Specific(chain_height),
height: QueryHeight::Specific(chain_height),
},
IncludeProof::No,
)?;
Expand Down Expand Up @@ -153,7 +153,7 @@ fn do_run<Chain: ChainHandle>(cmd: &QueryChannelEndsCmd) -> Result<(), Box<dyn s
let counterparty_chain_id = client_state.chain_id();
let counterparty_chain = registry.get_or_spawn(&counterparty_chain_id)?;
let counterparty_chain_height_query =
HeightQuery::Specific(counterparty_chain.query_latest_height()?);
QueryHeight::Specific(counterparty_chain.query_latest_height()?);

let (counterparty_connection_end, _) = counterparty_chain.query_connection(
QueryConnectionRequest {
Expand Down
10 changes: 5 additions & 5 deletions relayer-cli/src/commands/query/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use ibc::core::ics04_channel::channel::{ChannelEnd, State};
use ibc::core::ics24_host::identifier::{ChainId, ChannelId, ConnectionId, PortChannelId, PortId};
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::chain::requests::{
HeightQuery, IncludeProof, PageRequest, QueryChannelRequest, QueryChannelsRequest,
QueryClientStateRequest, QueryConnectionRequest,
IncludeProof, PageRequest, QueryChannelRequest, QueryChannelsRequest, QueryClientStateRequest,
QueryConnectionRequest, QueryHeight,
};
use ibc_relayer::registry::Registry;

Expand Down Expand Up @@ -95,7 +95,7 @@ fn run_query_channels<Chain: ChainHandle>(
chain_id,
port_id,
channel_id,
HeightQuery::Specific(chain_height),
QueryHeight::Specific(chain_height),
);

match channel_ends {
Expand Down Expand Up @@ -123,7 +123,7 @@ fn query_channel_ends<Chain: ChainHandle>(
chain_id: ChainId,
port_id: PortId,
channel_id: ChannelId,
chain_height_query: HeightQuery,
chain_height_query: QueryHeight,
) -> Result<ChannelEnds, Box<dyn std::error::Error>> {
let (connection_end, _) = chain.query_connection(
QueryConnectionRequest {
Expand Down Expand Up @@ -177,7 +177,7 @@ fn query_channel_ends<Chain: ChainHandle>(

let counterparty_chain = registry.get_or_spawn(&counterparty_chain_id)?;
let counterparty_chain_height_query =
HeightQuery::Specific(counterparty_chain.query_latest_height()?);
QueryHeight::Specific(counterparty_chain.query_latest_height()?);

let (counterparty_connection_end, _) = counterparty_chain.query_connection(
QueryConnectionRequest {
Expand Down
Loading

0 comments on commit f13126c

Please sign in to comment.