Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Height::zero() from relayer #2329

Merged
merged 9 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

21 changes: 11 additions & 10 deletions modules/src/applications/transfer/msgs/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub struct MsgTransfer<C = Coin> {
/// the recipient address on the destination chain
pub receiver: Signer,
/// Timeout height relative to the current block height.
/// The timeout is disabled when set to 0.
pub timeout_height: Height,
/// The timeout is disabled when set to None.
pub timeout_height: Option<Height>,
/// Timeout timestamp relative to the current block timestamp.
/// The timeout is disabled when set to 0.
pub timeout_timestamp: Timestamp,
Expand All @@ -63,12 +63,13 @@ impl TryFrom<RawMsgTransfer> for MsgTransfer {
let timeout_timestamp = Timestamp::from_nanoseconds(raw_msg.timeout_timestamp)
.map_err(|_| Error::invalid_packet_timeout_timestamp(raw_msg.timeout_timestamp))?;

let timeout_height = match raw_msg.timeout_height.clone() {
None => Height::zero(),
Some(raw_height) => raw_height.try_into().map_err(|e| {
let timeout_height: Option<Height> = raw_msg
.timeout_height
.map(|raw_height| raw_height.try_into())
.transpose()
.map_err(|e| {
Error::invalid_packet_timeout_height(format!("invalid timeout height {}", e))
})?,
};
})?;

Ok(MsgTransfer {
source_port: raw_msg
Expand Down Expand Up @@ -96,7 +97,7 @@ impl From<MsgTransfer> for RawMsgTransfer {
token: Some(domain_msg.token),
sender: domain_msg.sender.to_string(),
receiver: domain_msg.receiver.to_string(),
timeout_height: Some(domain_msg.timeout_height.into()),
timeout_height: domain_msg.timeout_height.map(|height| height.into()),
timeout_timestamp: domain_msg.timeout_timestamp.nanoseconds(),
}
}
Expand Down Expand Up @@ -156,10 +157,10 @@ pub mod test_util {
sender: address.clone(),
receiver: address,
timeout_timestamp: Timestamp::now().add(Duration::from_secs(10)).unwrap(),
timeout_height: Height {
timeout_height: Some(Height {
revision_number: 0,
revision_height: height,
},
}),
}
}
}
3 changes: 2 additions & 1 deletion modules/src/applications/transfer/relay/send_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::applications::transfer::events::TransferEvent;
use crate::applications::transfer::msgs::transfer::MsgTransfer;
use crate::applications::transfer::packet::PacketData;
use crate::applications::transfer::{is_sender_chain_source, Coin, PrefixedCoin};
use crate::core::ics02_client::height::Height;
use crate::core::ics04_channel::handler::send_packet::send_packet;
use crate::core::ics04_channel::packet::Packet;
use crate::events::ModuleEvent;
Expand Down Expand Up @@ -80,7 +81,7 @@ where
destination_port,
destination_channel,
data,
timeout_height: msg.timeout_height,
timeout_height: msg.timeout_height.unwrap_or_else(Height::zero),
timeout_timestamp: msg.timeout_timestamp,
};

Expand Down
11 changes: 0 additions & 11 deletions modules/src/core/ics02_client/client_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use crate::core::ics02_client::client_type::ClientType;
use crate::core::ics02_client::error::Error;
use crate::core::ics02_client::height::Height;
use crate::core::ics23_commitment::commitment::CommitmentRoot;
use crate::core::ics24_host::identifier::ClientId;
use crate::events::WithBlockDataType;
use crate::timestamp::Timestamp;

#[cfg(any(test, feature = "mocks"))]
Expand Down Expand Up @@ -166,12 +164,3 @@ impl ConsensusState for AnyConsensusState {
self
}
}

/// Query request for a single client event, identified by `event_id`, for `client_id`.
#[derive(Clone, Debug)]
pub struct QueryClientEventRequest {
pub height: crate::Height,
pub event_id: WithBlockDataType,
pub client_id: ClientId,
pub consensus_height: crate::Height,
}
17 changes: 1 addition & 16 deletions modules/src/core/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ use ibc_proto::ibc::core::channel::v1::{
IdentifiedChannel as RawIdentifiedChannel,
};

use crate::core::ics02_client::height::Height;
use crate::core::ics04_channel::{error::Error, packet::Sequence, Version};
use crate::core::ics04_channel::{error::Error, Version};
use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId};
use crate::events::WithBlockDataType;

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct IdentifiedChannelEnd {
Expand Down Expand Up @@ -409,19 +407,6 @@ impl core::fmt::Display for State {
}
}

/// Used to query a packet event, identified by `event_id`, for specific channel and sequences.
/// The query is preformed for the chain context at `height`.
#[derive(Clone, Debug)]
pub struct QueryPacketEventDataRequest {
pub event_id: WithBlockDataType,
pub source_channel_id: ChannelId,
pub source_port_id: PortId,
pub destination_channel_id: ChannelId,
pub destination_port_id: PortId,
pub sequences: Vec<Sequence>,
pub height: Height,
}

#[cfg(test)]
pub mod test_util {
use crate::core::ics24_host::identifier::{ChannelId, ConnectionId, PortId};
Expand Down
3 changes: 2 additions & 1 deletion modules/src/core/ics26_routing/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ mod tests {
let mut msg_to_on_close =
MsgTimeoutOnClose::try_from(get_dummy_raw_msg_timeout_on_close(36, 5)).unwrap();
msg_to_on_close.packet.sequence = 2.into();
msg_to_on_close.packet.timeout_height = msg_transfer_two.timeout_height;
msg_to_on_close.packet.timeout_height =
msg_transfer_two.timeout_height.unwrap_or_else(Height::zero);
msg_to_on_close.packet.timeout_timestamp = msg_transfer_two.timeout_timestamp;

let denom = msg_transfer_two.token.denom.clone();
Expand Down
1 change: 0 additions & 1 deletion modules/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub mod handler;
pub mod keys;
pub mod macros;
pub mod proofs;
pub mod query;
pub mod relayer;
pub mod signer;
pub mod timestamp;
Expand Down
20 changes: 0 additions & 20 deletions modules/src/query.rs

This file was deleted.

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
Loading