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

Spike for parallel relaying between multiple channels #692

Merged
merged 16 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion modules/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl IbcEvent {
serde_json::to_string(self).unwrap()
}

pub fn height(&self) -> &Height {
pub fn height(&self) -> Height {
match self {
IbcEvent::NewBlock(bl) => bl.height(),
IbcEvent::CreateClient(ev) => ev.height(),
Expand Down
16 changes: 8 additions & 8 deletions modules/src/ics02_client/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ impl NewBlock {
pub fn set_height(&mut self, height: Height) {
self.height = height;
}
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
}

Expand Down Expand Up @@ -104,8 +104,8 @@ impl CreateClient {
pub fn client_id(&self) -> &ClientId {
&self.0.client_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -146,8 +146,8 @@ impl UpdateClient {
&self.0.client_id
}

pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -188,8 +188,8 @@ impl ClientMisbehavior {
pub fn client_id(&self) -> &ClientId {
&self.0.client_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down
16 changes: 8 additions & 8 deletions modules/src/ics03_connection/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ impl OpenInit {
pub fn connection_id(&self) -> &Option<ConnectionId> {
&self.0.connection_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -131,8 +131,8 @@ impl OpenTry {
pub fn connection_id(&self) -> &Option<ConnectionId> {
&self.0.connection_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -174,8 +174,8 @@ impl OpenAck {
pub fn connection_id(&self) -> &Option<ConnectionId> {
&self.0.connection_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -217,8 +217,8 @@ impl OpenConfirm {
pub fn connection_id(&self) -> &Option<ConnectionId> {
&self.0.connection_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down
62 changes: 36 additions & 26 deletions modules/src/ics04_channel/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ impl OpenInit {
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -225,8 +225,8 @@ impl OpenTry {
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -269,8 +269,8 @@ impl OpenAck {
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -313,8 +313,8 @@ impl OpenConfirm {
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -357,11 +357,21 @@ impl CloseInit {
pub fn port_id(&self) -> &PortId {
&self.0.port_id
}
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
pub fn channel_id(&self) -> &ChannelId {
// FIXME(romac): Rework encoding of IbcEvents which use `Attributes`
romac marked this conversation as resolved.
Show resolved Hide resolved
self.0
.channel_id
.as_ref()
.expect("CloseInit should always have a channel_id")
}
pub fn counterparty_port_id(&self) -> &PortId {
&self.0.counterparty_port_id
}
pub fn counterparty_channel_id(&self) -> Option<&ChannelId> {
self.0.counterparty_channel_id.as_ref()
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -416,8 +426,8 @@ impl CloseConfirm {
pub fn channel_id(&self) -> &Option<ChannelId> {
&self.0.channel_id
}
pub fn height(&self) -> &Height {
&self.0.height
pub fn height(&self) -> Height {
self.0.height
}
pub fn set_height(&mut self, height: Height) {
self.0.height = height;
Expand Down Expand Up @@ -486,8 +496,8 @@ pub struct SendPacket {
}

impl SendPacket {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height;
Expand Down Expand Up @@ -524,8 +534,8 @@ pub struct ReceivePacket {
}

impl ReceivePacket {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height;
Expand Down Expand Up @@ -564,8 +574,8 @@ pub struct WriteAcknowledgement {
}

impl WriteAcknowledgement {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height;
Expand Down Expand Up @@ -607,8 +617,8 @@ pub struct AcknowledgePacket {
}

impl AcknowledgePacket {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height;
Expand Down Expand Up @@ -643,8 +653,8 @@ pub struct TimeoutPacket {
}

impl TimeoutPacket {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height
Expand Down Expand Up @@ -686,8 +696,8 @@ pub struct TimeoutOnClosePacket {
}

impl TimeoutOnClosePacket {
pub fn height(&self) -> &Height {
&self.height
pub fn height(&self) -> Height {
self.height
}
pub fn set_height(&mut self, height: Height) {
self.height = height;
Expand Down
1 change: 1 addition & 0 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ hex = "0.4"
crossbeam-channel = "0.5.0"
subtle-encoding = "0.5"
dirs-next = "2.0.0"
itertools = "0.10.0"

[dependencies.tendermint-proto]
version = "=0.18.1"
Expand Down
9 changes: 7 additions & 2 deletions relayer-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::commands::channel::ChannelCmds;
use crate::config::Config;

use self::{
keys::KeysCmd, light::LightCmd, listen::ListenCmd, query::QueryCmd, start::StartCmd, tx::TxCmd,
version::VersionCmd,
keys::KeysCmd, light::LightCmd, listen::ListenCmd, query::QueryCmd, start::StartCmd,
start_multi::StartMultiCmd, tx::TxCmd, version::VersionCmd,
};

mod channel;
Expand All @@ -25,6 +25,7 @@ mod light;
mod listen;
mod query;
mod start;
mod start_multi;
mod tx;
mod version;

Expand Down Expand Up @@ -57,6 +58,10 @@ pub enum CliCmd {
#[options(help = "Start the relayer")]
Start(StartCmd),

/// The `start-multi` subcommand
#[options(help = "Start the relayer in multi-channel mode")]
StartMulti(StartMultiCmd),

/// The `channel` subcommand
#[options(help = "Channel functionality for managing channels")]
Channel(ChannelCmds),
Expand Down
20 changes: 13 additions & 7 deletions relayer-cli/src/commands/cli_utils.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use abscissa_core::config;

use ibc::ics24_host::identifier::ChainId;
use ibc_relayer::chain::CosmosSdkChain;
use ibc_relayer::{chain::handle::ChainHandle, config::StoreConfig};
use ibc_relayer::{chain::runtime::ChainRuntime, config::ChainConfig};
use ibc_relayer::{chain::CosmosSdkChain, config::Config};

use crate::application::CliApp;
use crate::error::{Error, Kind};

/// Pair of chain handlers that are used by most CLIs.
#[derive(Clone, Debug)]
pub struct ChainHandlePair {
/// Source chain handle
pub src: Box<dyn ChainHandle>,
Expand All @@ -20,7 +18,7 @@ impl ChainHandlePair {
/// Spawn the source and destination chain runtime from the configuration and chain identifiers,
/// and return the pair of associated handles.
pub fn spawn(
config: &config::Reader<CliApp>,
config: &Config,
src_chain_id: &ChainId,
dst_chain_id: &ChainId,
) -> Result<Self, Error> {
Expand All @@ -32,19 +30,27 @@ impl ChainHandlePair {
/// is used to override each chain configuration before spawning its runtime.
pub fn spawn_with(
options: SpawnOptions,
config: &config::Reader<CliApp>,
config: &Config,
src_chain_id: &ChainId,
dst_chain_id: &ChainId,
) -> Result<Self, Error> {
spawn_chain_runtimes(options, config, src_chain_id, dst_chain_id)
}

/// Swap the two handles to that `dst` becomes `src` and `src` becomes `dst`
pub fn swap(self) -> Self {
Self {
src: self.dst,
dst: self.src,
}
}
}

/// Spawn the source and destination chain runtime from the configuration and chain identifiers,
/// and return the pair of associated handles.
fn spawn_chain_runtimes(
spawn_options: SpawnOptions,
config: &config::Reader<CliApp>,
config: &Config,
src_chain_id: &ChainId,
dst_chain_id: &ChainId,
) -> Result<ChainHandlePair, Error> {
Expand Down
2 changes: 1 addition & 1 deletion relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Runnable for StartCmd {
match channel_relay(
chains.src,
chains.dst,
&LinkParameters {
LinkParameters {
src_port_id: src_port_id.clone(),
src_channel_id: src_channel_id.clone(),
},
Expand Down
Loading