From 02c35b6fa371e5b20475617439ae1e7066ecbb05 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 10:15:58 -0500 Subject: [PATCH 01/28] Document CreateChannelCommand --- relayer-cli/src/commands/create/channel.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index fc6e4dfe10..60ba4e1d9e 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -16,6 +16,23 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; +/// The data structure that represents all the possible options when invoking +/// the `create channel` CLI command. +/// +/// There are two possible ways to invoke this command: +/// +/// `create channel --port-a --port-b --new-client-connection` to indicate +/// that a new connection/client pair is being created as part of this new channel. +/// This will bring up an interactive yes/no prompt so that the operator at least has to +/// consider the fact that they're initializing a new connection with the channel. +/// +/// `create channel --port-a --port-b ` is the default +/// way in which this command should be used, specifying a `connection-id` for this new channel +/// to re-use. The command expects that `connection-ID` is associated with Chain-A. +/// +/// `connection-ID`s have to be considered based off of the chain's perspective. Although chain A +/// and chain B might refer to the connection with different names, they are referring to the same +/// connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { From 6193d1ddd831e557bea0dde8179643a2019c35af Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 10:31:48 -0500 Subject: [PATCH 02/28] Add `new-client-connection` flag to `create channel` command --- relayer-cli/src/commands/create/channel.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 60ba4e1d9e..b82d7866d9 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -81,6 +81,12 @@ pub struct CreateChannelCommand { help = "the version for the new channel" )] version: Option, + + #[clap( + long, + help = "indicates that a new client and connection will be created alongside the new channel" + )] + new_client_connection: bool, } impl Runnable for CreateChannelCommand { From 5a9be156491ed0509d6de6275506cd3934c1e990 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 11:14:35 -0500 Subject: [PATCH 03/28] Add new `run` logic for `CreateChannelCommand` --- relayer-cli/src/commands/create/channel.rs | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index b82d7866d9..85c139efe1 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -91,26 +91,33 @@ pub struct CreateChannelCommand { impl Runnable for CreateChannelCommand { fn run(&self) { - match &self.chain_b_id { - None => self.run_reusing_connection(), - Some(chain_b) => self.run_using_new_connection(chain_b), + match &self.connection_a { + Some(conn) => self.run_reusing_connection(conn), + None => match &self.chain_b_id { + Some(chain_b) => { + if self.new_client_connection { + self.run_using_new_connection(chain_b) + } else { + Output::error( + "The `--new-client-connection` flag is required if invoking with ``".to_string() + ) + .exit(); + } + } + None => { + Output::error("Missing one of `` or ``".to_string()) + .exit() + } + }, } } } impl CreateChannelCommand { - // Creates a new channel, as well as a new underlying connection and clients. + /// Creates a new channel, as well as a new underlying connection and clients. fn run_using_new_connection(&self, chain_b_id: &ChainId) { let config = app_config(); - // Bail with an explicit error. The user might be expecting to use this connection. - if self.connection_a.is_some() { - Output::error( - "Option `` is incompatible with ``".to_string(), - ) - .exit(); - } - let chains = ChainHandlePair::spawn(&config, &self.chain_a_id, chain_b_id) .unwrap_or_else(exit_with_unrecoverable_error); @@ -141,24 +148,14 @@ impl CreateChannelCommand { Output::success(channel).exit(); } - // Creates a new channel, reusing an already existing connection and its clients. - fn run_reusing_connection(&self) { + /// Creates a new channel, reusing an already existing connection and its clients. + fn run_reusing_connection(&self, connection_a_id: &ConnectionId) { let config = app_config(); // Validate & spawn runtime for side a. let chain_a = spawn_chain_runtime(&config, &self.chain_a_id) .unwrap_or_else(exit_with_unrecoverable_error); - // Unwrap the identifier of the connection on side a. - let connection_a_id = match &self.connection_a { - Some(c) => c, - None => Output::error( - "Option `--connection-a` is necessary when argument is missing" - .to_string(), - ) - .exit(), - }; - // Query the connection end. let height = Height::new(chain_a.id().version(), 0); let conn_end = chain_a From 79040116c71a41b01b5810c8fccd083a9b1cf076 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 12:04:56 -0500 Subject: [PATCH 04/28] Add dialoguer dependency in order to enable interactive CLI prompts --- relayer-cli/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 82761dd908..37c9ee1a2f 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -56,6 +56,7 @@ itertools = "0.10.3" atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" +dialoguer = 0.10.0 [dependencies.tendermint-proto] version = "=0.23.5" From 9ac2bb17f2b2a07a568f469897e05cac3252b191 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 12:37:23 -0500 Subject: [PATCH 05/28] Add interactive prompt functionality --- relayer-cli/Cargo.toml | 2 +- relayer-cli/src/commands/create/channel.rs | 28 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 37c9ee1a2f..71017ed7e0 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -56,7 +56,7 @@ itertools = "0.10.3" atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" -dialoguer = 0.10.0 +dialoguer = "0.10.0" [dependencies.tendermint-proto] version = "=0.23.5" diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 85c139efe1..6150fe3fbe 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -1,5 +1,6 @@ use abscissa_core::clap::Parser; use abscissa_core::{Command, Runnable}; +use dialoguer::Confirm; use ibc::core::ics02_client::client_state::ClientState; use ibc::core::ics03_connection::connection::IdentifiedConnectionEnd; @@ -16,6 +17,8 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; +static PROMPT: &str = "WARN: Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation `hermes create channel --port-a --port-b ` to re-use a pre-existing connection."; + /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. /// @@ -30,9 +33,9 @@ use ibc_relayer::config::default::connection_delay; /// way in which this command should be used, specifying a `connection-id` for this new channel /// to re-use. The command expects that `connection-ID` is associated with Chain-A. /// -/// `connection-ID`s have to be considered based off of the chain's perspective. Although chain A -/// and chain B might refer to the connection with different names, they are referring to the same -/// connection. +/// Note that `connection-ID`s have to be considered based off of the chain's perspective. Although +/// chain A and chain B might refer to the connection with different names, they are referring +/// to the same connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { @@ -96,7 +99,24 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - self.run_using_new_connection(chain_b) + match Confirm::new() + .with_prompt(PROMPT) + .interact_on(&Term::stdout()) + { + Ok(confirm) => { + if confirm { + self.run_using_new_connection(chain_b); + } else { + Output::error("You elected not to create new clients and connections. Please re-invoke `create channel` with a pre-existing connection ID".to_string()).exit(); + } + } + Err(e) => { + Output::error(format!( + "An error occurred while waiting for user input: {}", + e + )); + } + } } else { Output::error( "The `--new-client-connection` flag is required if invoking with ``".to_string() From 1b4428a4d1a9099e7c05ce5d6d54fa5d0551c617 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 13:05:37 -0500 Subject: [PATCH 06/28] Remove unnecessary Term::stdout parameter --- relayer-cli/src/commands/create/channel.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 6150fe3fbe..05068e6462 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -17,7 +17,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -static PROMPT: &str = "WARN: Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation `hermes create channel --port-a --port-b ` to re-use a pre-existing connection."; +static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation\n`hermes create channel --port-a --port-b `\nto re-use a pre-existing connection."; /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. @@ -99,10 +99,7 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - match Confirm::new() - .with_prompt(PROMPT) - .interact_on(&Term::stdout()) - { + match Confirm::new().with_prompt(PROMPT).interact() { Ok(confirm) => { if confirm { self.run_using_new_connection(chain_b); From b96c735505c333044e7416e3dfff16e2cb7cb78c Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:05:50 -0500 Subject: [PATCH 07/28] Add style to prompts --- relayer-cli/Cargo.toml | 1 + relayer-cli/src/commands/create/channel.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 71017ed7e0..0ca5fa7b6f 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -57,6 +57,7 @@ atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" dialoguer = "0.10.0" +console = "0.15.0" [dependencies.tendermint-proto] version = "=0.23.5" diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 05068e6462..0639b89b00 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -1,5 +1,7 @@ use abscissa_core::clap::Parser; use abscissa_core::{Command, Runnable}; + +use console::style; use dialoguer::Confirm; use ibc::core::ics02_client::client_state::ClientState; @@ -17,7 +19,8 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation\n`hermes create channel --port-a --port-b `\nto re-use a pre-existing connection."; +static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters."; +static HINT: &str = "Consider using the default invocation\n\nhermes create channel --port-a --port-b \n\nto re-use a pre-existing connection."; /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. @@ -99,7 +102,16 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - match Confirm::new().with_prompt(PROMPT).interact() { + match Confirm::new() + .with_prompt(format!( + "{}: {}\n{}: {}", + style("WARN").yellow(), + PROMPT, + style("Hint").cyan(), + HINT + )) + .interact() + { Ok(confirm) => { if confirm { self.run_using_new_connection(chain_b); From 4668dc76d576e07b50c472a89f92cbb9727741fb Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:15:03 -0500 Subject: [PATCH 08/28] Clean up CreateChannelCommand documentation --- relayer-cli/src/commands/create/channel.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 0639b89b00..2dbdb159fd 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -27,17 +27,17 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --port-a --port-b --new-client-connection` to indicate +/// `create channel --port-a --port-b --new-client-connection` to indicate /// that a new connection/client pair is being created as part of this new channel. -/// This will bring up an interactive yes/no prompt so that the operator at least has to -/// consider the fact that they're initializing a new connection with the channel. +/// This brings up an interactive yes/no prompt to ensure that the operator at least +/// considers the fact that they're initializing a new connection with the channel. /// -/// `create channel --port-a --port-b ` is the default -/// way in which this command should be used, specifying a `connection-id` for this new channel -/// to re-use. The command expects that `connection-ID` is associated with Chain-A. +/// `create channel --port-a --port-b ` is the default +/// way in which this command should be used, specifying a `Connection-ID` for this new channel +/// to re-use. The command expects that `Connection-ID` is associated with chain A. /// -/// Note that `connection-ID`s have to be considered based off of the chain's perspective. Although -/// chain A and chain B might refer to the connection with different names, they are referring +/// Note that `Connection-ID`s have to be considered based off of the chain's perspective. Although +/// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] From 3a19b770f1c34abd1264e7c36aa51d4c7689089f Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:18:24 -0500 Subject: [PATCH 09/28] Fix documentation formatting --- relayer-cli/src/commands/create/channel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 2dbdb159fd..dcfc697634 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -27,8 +27,8 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --port-a --port-b --new-client-connection` to indicate -/// that a new connection/client pair is being created as part of this new channel. +/// `create channel --port-a --port-b --new-client-connection` +/// to indicate that a new connection/client pair is being created as part of this new channel. /// This brings up an interactive yes/no prompt to ensure that the operator at least /// considers the fact that they're initializing a new connection with the channel. /// From 0ebb59fc9f221c5ab6c9cb385e920dc88b874f14 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:42:14 -0500 Subject: [PATCH 10/28] Add changelog entry --- .../improvements/relayer-cli/1421-create-channel-cli.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md diff --git a/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md b/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md new file mode 100644 index 0000000000..a64398d712 --- /dev/null +++ b/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md @@ -0,0 +1,2 @@ +- Change `create channel` CLI command such that it is more difficult to create + clients / connections using it ([#1421](https://github.com/informalsystems/ibc-rs/issues/1421)) From 27d93694456a256fbe7130e907d11847d92a76d9 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 10:15:58 -0500 Subject: [PATCH 11/28] Document CreateChannelCommand --- relayer-cli/src/commands/create/channel.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index c8fd42f9bb..7de54541d4 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -17,6 +17,23 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; +/// The data structure that represents all the possible options when invoking +/// the `create channel` CLI command. +/// +/// There are two possible ways to invoke this command: +/// +/// `create channel --port-a --port-b --new-client-connection` to indicate +/// that a new connection/client pair is being created as part of this new channel. +/// This will bring up an interactive yes/no prompt so that the operator at least has to +/// consider the fact that they're initializing a new connection with the channel. +/// +/// `create channel --port-a --port-b ` is the default +/// way in which this command should be used, specifying a `connection-id` for this new channel +/// to re-use. The command expects that `connection-ID` is associated with Chain-A. +/// +/// `connection-ID`s have to be considered based off of the chain's perspective. Although chain A +/// and chain B might refer to the connection with different names, they are referring to the same +/// connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { From 2642dd8dbecf0c3c1aee571af74c4c632cac6232 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:56:04 -0500 Subject: [PATCH 12/28] Add `new-client-connection` flag to `create channel` command --- relayer-cli/src/commands/create/channel.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 7de54541d4..5ee8f4b443 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -82,6 +82,12 @@ pub struct CreateChannelCommand { help = "the version for the new channel" )] version: Option, + + #[clap( + long, + help = "indicates that a new client and connection will be created alongside the new channel" + )] + new_client_connection: bool, } impl Runnable for CreateChannelCommand { From 514d5127464fe68f03925cdfde17a3d40dd7f97a Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 11:14:35 -0500 Subject: [PATCH 13/28] Add new `run` logic for `CreateChannelCommand` --- relayer-cli/src/commands/create/channel.rs | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 5ee8f4b443..47f1680a41 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -92,26 +92,33 @@ pub struct CreateChannelCommand { impl Runnable for CreateChannelCommand { fn run(&self) { - match &self.chain_b_id { - None => self.run_reusing_connection(), - Some(chain_b) => self.run_using_new_connection(chain_b), + match &self.connection_a { + Some(conn) => self.run_reusing_connection(conn), + None => match &self.chain_b_id { + Some(chain_b) => { + if self.new_client_connection { + self.run_using_new_connection(chain_b) + } else { + Output::error( + "The `--new-client-connection` flag is required if invoking with ``".to_string() + ) + .exit(); + } + } + None => { + Output::error("Missing one of `` or ``".to_string()) + .exit() + } + }, } } } impl CreateChannelCommand { - // Creates a new channel, as well as a new underlying connection and clients. + /// Creates a new channel, as well as a new underlying connection and clients. fn run_using_new_connection(&self, chain_b_id: &ChainId) { let config = app_config(); - // Bail with an explicit error. The user might be expecting to use this connection. - if self.connection_a.is_some() { - Output::error( - "Option `` is incompatible with ``".to_string(), - ) - .exit(); - } - let chains = ChainHandlePair::spawn(&config, &self.chain_a_id, chain_b_id) .unwrap_or_else(exit_with_unrecoverable_error); @@ -142,24 +149,14 @@ impl CreateChannelCommand { Output::success(channel).exit(); } - // Creates a new channel, reusing an already existing connection and its clients. - fn run_reusing_connection(&self) { + /// Creates a new channel, reusing an already existing connection and its clients. + fn run_reusing_connection(&self, connection_a_id: &ConnectionId) { let config = app_config(); // Validate & spawn runtime for side a. let chain_a = spawn_chain_runtime(&config, &self.chain_a_id) .unwrap_or_else(exit_with_unrecoverable_error); - // Unwrap the identifier of the connection on side a. - let connection_a_id = match &self.connection_a { - Some(c) => c, - None => Output::error( - "Option `--connection-a` is necessary when argument is missing" - .to_string(), - ) - .exit(), - }; - // Query the connection end. let height = Height::new(chain_a.id().version(), 0); let conn_end = chain_a From cc30c4dd3fa521af08fe2746253056301776b529 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 12:04:56 -0500 Subject: [PATCH 14/28] Add dialoguer dependency in order to enable interactive CLI prompts --- relayer-cli/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 7317f1c8cf..30a549f246 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -56,6 +56,7 @@ itertools = "0.10.3" atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" +dialoguer = 0.10.0 [dependencies.tendermint-proto] version = "=0.23.5" From b8faca084230fbf2cc042c6ca9ea6c21e555395e Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 12:37:23 -0500 Subject: [PATCH 15/28] Add interactive prompt functionality --- relayer-cli/Cargo.toml | 2 +- relayer-cli/src/commands/create/channel.rs | 28 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 30a549f246..023487f401 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -56,7 +56,7 @@ itertools = "0.10.3" atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" -dialoguer = 0.10.0 +dialoguer = "0.10.0" [dependencies.tendermint-proto] version = "=0.23.5" diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 47f1680a41..b4b46de2f8 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -1,5 +1,6 @@ use abscissa_core::clap::Parser; use abscissa_core::{Command, Runnable}; +use dialoguer::Confirm; use ibc::core::ics02_client::client_state::ClientState; use ibc::core::ics03_connection::connection::IdentifiedConnectionEnd; @@ -17,6 +18,8 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; +static PROMPT: &str = "WARN: Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation `hermes create channel --port-a --port-b ` to re-use a pre-existing connection."; + /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. /// @@ -31,9 +34,9 @@ use ibc_relayer::config::default::connection_delay; /// way in which this command should be used, specifying a `connection-id` for this new channel /// to re-use. The command expects that `connection-ID` is associated with Chain-A. /// -/// `connection-ID`s have to be considered based off of the chain's perspective. Although chain A -/// and chain B might refer to the connection with different names, they are referring to the same -/// connection. +/// Note that `connection-ID`s have to be considered based off of the chain's perspective. Although +/// chain A and chain B might refer to the connection with different names, they are referring +/// to the same connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] pub struct CreateChannelCommand { @@ -97,7 +100,24 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - self.run_using_new_connection(chain_b) + match Confirm::new() + .with_prompt(PROMPT) + .interact_on(&Term::stdout()) + { + Ok(confirm) => { + if confirm { + self.run_using_new_connection(chain_b); + } else { + Output::error("You elected not to create new clients and connections. Please re-invoke `create channel` with a pre-existing connection ID".to_string()).exit(); + } + } + Err(e) => { + Output::error(format!( + "An error occurred while waiting for user input: {}", + e + )); + } + } } else { Output::error( "The `--new-client-connection` flag is required if invoking with ``".to_string() From d2d20cf001c389e4228b5ddf9a572edfe2196798 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 24 Mar 2022 13:05:37 -0500 Subject: [PATCH 16/28] Remove unnecessary Term::stdout parameter --- relayer-cli/src/commands/create/channel.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index b4b46de2f8..7d799b75a5 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -18,7 +18,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -static PROMPT: &str = "WARN: Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation `hermes create channel --port-a --port-b ` to re-use a pre-existing connection."; +static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation\n`hermes create channel --port-a --port-b `\nto re-use a pre-existing connection."; /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. @@ -100,10 +100,7 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - match Confirm::new() - .with_prompt(PROMPT) - .interact_on(&Term::stdout()) - { + match Confirm::new().with_prompt(PROMPT).interact() { Ok(confirm) => { if confirm { self.run_using_new_connection(chain_b); From 6ffb41c54d133f22aa81fafc682a667b0f90bc72 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:05:50 -0500 Subject: [PATCH 17/28] Add style to prompts --- relayer-cli/Cargo.toml | 1 + relayer-cli/src/commands/create/channel.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 023487f401..16c2aabd3d 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -57,6 +57,7 @@ atty = "0.2.14" flex-error = { version = "0.4.4", default-features = false, features = ["std", "eyre_tracer"] } signal-hook = "0.3.13" dialoguer = "0.10.0" +console = "0.15.0" [dependencies.tendermint-proto] version = "=0.23.5" diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 7d799b75a5..d148bc60e5 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -1,5 +1,7 @@ use abscissa_core::clap::Parser; use abscissa_core::{Command, Runnable}; + +use console::style; use dialoguer::Confirm; use ibc::core::ics02_client::client_state::ClientState; @@ -18,7 +20,8 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters.\nHint: consider using the default invocation\n`hermes create channel --port-a --port-b `\nto re-use a pre-existing connection."; +static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters."; +static HINT: &str = "Consider using the default invocation\n\nhermes create channel --port-a --port-b \n\nto re-use a pre-existing connection."; /// The data structure that represents all the possible options when invoking /// the `create channel` CLI command. @@ -100,7 +103,16 @@ impl Runnable for CreateChannelCommand { None => match &self.chain_b_id { Some(chain_b) => { if self.new_client_connection { - match Confirm::new().with_prompt(PROMPT).interact() { + match Confirm::new() + .with_prompt(format!( + "{}: {}\n{}: {}", + style("WARN").yellow(), + PROMPT, + style("Hint").cyan(), + HINT + )) + .interact() + { Ok(confirm) => { if confirm { self.run_using_new_connection(chain_b); From b3e3259326e8cdf3877396cc641b90224f7b1f9c Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:15:03 -0500 Subject: [PATCH 18/28] Clean up CreateChannelCommand documentation --- relayer-cli/src/commands/create/channel.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index d148bc60e5..5e77fcb6e8 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -28,17 +28,17 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --port-a --port-b --new-client-connection` to indicate +/// `create channel --port-a --port-b --new-client-connection` to indicate /// that a new connection/client pair is being created as part of this new channel. -/// This will bring up an interactive yes/no prompt so that the operator at least has to -/// consider the fact that they're initializing a new connection with the channel. +/// This brings up an interactive yes/no prompt to ensure that the operator at least +/// considers the fact that they're initializing a new connection with the channel. /// -/// `create channel --port-a --port-b ` is the default -/// way in which this command should be used, specifying a `connection-id` for this new channel -/// to re-use. The command expects that `connection-ID` is associated with Chain-A. +/// `create channel --port-a --port-b ` is the default +/// way in which this command should be used, specifying a `Connection-ID` for this new channel +/// to re-use. The command expects that `Connection-ID` is associated with chain A. /// -/// Note that `connection-ID`s have to be considered based off of the chain's perspective. Although -/// chain A and chain B might refer to the connection with different names, they are referring +/// Note that `Connection-ID`s have to be considered based off of the chain's perspective. Although +/// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. #[derive(Clone, Command, Debug, Parser)] #[clap(disable_version_flag = true)] From 419d5e5fbe8f8284d7103190f419c6859adabd29 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:18:24 -0500 Subject: [PATCH 19/28] Fix documentation formatting --- relayer-cli/src/commands/create/channel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 5e77fcb6e8..5ea7b28e29 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -28,8 +28,8 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// -/// `create channel --port-a --port-b --new-client-connection` to indicate -/// that a new connection/client pair is being created as part of this new channel. +/// `create channel --port-a --port-b --new-client-connection` +/// to indicate that a new connection/client pair is being created as part of this new channel. /// This brings up an interactive yes/no prompt to ensure that the operator at least /// considers the fact that they're initializing a new connection with the channel. /// From b2747e573f4febe801ea1515c6d359ca261cd668 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Fri, 25 Mar 2022 10:42:14 -0500 Subject: [PATCH 20/28] Add changelog entry --- .../improvements/relayer-cli/1421-create-channel-cli.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md diff --git a/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md b/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md new file mode 100644 index 0000000000..a64398d712 --- /dev/null +++ b/.changelog/unreleased/improvements/relayer-cli/1421-create-channel-cli.md @@ -0,0 +1,2 @@ +- Change `create channel` CLI command such that it is more difficult to create + clients / connections using it ([#1421](https://github.com/informalsystems/ibc-rs/issues/1421)) From e095270da9fb06d63d8662507a60276c05416022 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 29 Mar 2022 10:49:53 -0500 Subject: [PATCH 21/28] Incorporate PR feedback --- relayer-cli/src/commands/create.rs | 4 +++- relayer-cli/src/commands/create/channel.rs | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/relayer-cli/src/commands/create.rs b/relayer-cli/src/commands/create.rs index 46b04e4c51..2f5dfb42d8 100644 --- a/relayer-cli/src/commands/create.rs +++ b/relayer-cli/src/commands/create.rs @@ -18,6 +18,8 @@ pub enum CreateCmds { /// Create a new connection between two chains Connection(CreateConnectionCommand), - /// Create a new channel between two chains + /// Create a new channel using a pre-existing connection. + /// Alternatively, create a new client and a new connection underlying + /// the new channel if a pre-existing connection is not provided. Channel(CreateChannelCommand), } diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 5ea7b28e29..f26f3a267f 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -20,7 +20,7 @@ use crate::conclude::{exit_with_unrecoverable_error, Output}; use crate::prelude::*; use ibc_relayer::config::default::connection_delay; -static PROMPT: &str = "Are you sure you want new clients & connections to be created? Hermes will use default security parameters."; +static PROMPT: &str = "Are you sure you want a new connection & clients to be created? Hermes will use default security parameters."; static HINT: &str = "Consider using the default invocation\n\nhermes create channel --port-a --port-b \n\nto re-use a pre-existing connection."; /// The data structure that represents all the possible options when invoking @@ -28,15 +28,15 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan /// /// There are two possible ways to invoke this command: /// +/// `create channel --port-a --port-b ` is the default +/// way in which this command should be used, specifying a `Connection-ID` for this new channel +/// to re-use. The command expects that `Connection-ID` is associated with chain A. +/// /// `create channel --port-a --port-b --new-client-connection` /// to indicate that a new connection/client pair is being created as part of this new channel. /// This brings up an interactive yes/no prompt to ensure that the operator at least /// considers the fact that they're initializing a new connection with the channel. /// -/// `create channel --port-a --port-b ` is the default -/// way in which this command should be used, specifying a `Connection-ID` for this new channel -/// to re-use. The command expects that `Connection-ID` is associated with chain A. -/// /// Note that `Connection-ID`s have to be considered based off of the chain's perspective. Although /// chain A and chain B might refer to the connection with different names, they are actually referring /// to the same connection. @@ -49,14 +49,14 @@ pub struct CreateChannelCommand { )] chain_a_id: ChainId, - #[clap(help = "identifier of the side `b` chain for the new channel (optional)")] - chain_b_id: Option, - #[clap( short, long, - help = "identifier of the connection on chain `a` to use in creating the new channel" + help = "identifier of the side `b` chain for the new channel (optional)" )] + chain_b_id: Option, + + #[clap(help = "identifier of the connection on chain `a` to use in creating the new channel")] connection_a: Option, #[clap( @@ -91,7 +91,7 @@ pub struct CreateChannelCommand { #[clap( long, - help = "indicates that a new client and connection will be created alongside the new channel" + help = "indicates that a new client and connection will be created underlying the new channel" )] new_client_connection: bool, } From 771ad3d3c18253741c710091eb9a5d70e9a1bdb2 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 31 Mar 2022 08:49:24 -0500 Subject: [PATCH 22/28] Remove unnecessary attribute cruft and make help messages consistent --- relayer-cli/src/commands/create/channel.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index f26f3a267f..aef70dbc83 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -45,38 +45,38 @@ static HINT: &str = "Consider using the default invocation\n\nhermes create chan pub struct CreateChannelCommand { #[clap( required = true, - help = "identifier of the side `a` chain for the new channel" + help = "Identifier of the side `a` chain for the new channel" )] chain_a_id: ChainId, #[clap( short, long, - help = "identifier of the side `b` chain for the new channel (optional)" + help = "Identifier of the side `b` chain for the new channel" )] chain_b_id: Option, - #[clap(help = "identifier of the connection on chain `a` to use in creating the new channel")] + /// Identifier of the connection on chain `a` to use in creating the new channel. connection_a: Option, #[clap( long, required = true, - help = "identifier of the side `a` port for the new channel" + help = "Identifier of the side `a` port for the new channel" )] port_a: PortId, #[clap( long, required = true, - help = "identifier of the side `b` port for the new channel" + help = "Identifier of the side `b` port for the new channel" )] port_b: PortId, #[clap( short, long, - help = "the channel ordering, valid options 'unordered' (default) and 'ordered'", + help = "The channel ordering, valid options 'unordered' (default) and 'ordered'", default_value_t )] order: Order, @@ -85,13 +85,13 @@ pub struct CreateChannelCommand { short, long = "channel-version", alias = "version", - help = "the version for the new channel" + help = "The version for the new channel" )] version: Option, #[clap( long, - help = "indicates that a new client and connection will be created underlying the new channel" + help = "Indicates that a new client and connection will be created underlying the new channel" )] new_client_connection: bool, } From 473b12113b11bb7bd801f54568a830ae9021ff22 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 31 Mar 2022 15:09:49 -0500 Subject: [PATCH 23/28] Update Hermes guide with the new `create channel` flow --- guide/src/commands/path-setup/channels.md | 360 +++++++++--------- guide/src/commands/path-setup/index.md | 6 +- .../relay-paths/multiple-paths.md | 17 +- relayer-cli/src/commands/create.rs | 2 +- 4 files changed, 206 insertions(+), 179 deletions(-) diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index 4b44dd9e8f..50fffcd74f 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -10,32 +10,210 @@ Use the `create channel` command to establish a new channel. ```shell USAGE: - hermes create channel + hermes create channel [OPTIONS] --port-a --port-b + [CONNECTION_A] DESCRIPTION: - Create a new channel between two chains + Create a new channel between two chains using a pre-existing connection. + Alternatively, create a new client and a new connection underlying the new + channel if a pre-existing connection is not provided POSITIONAL ARGUMENTS: - chain_a_id identifier of the side `a` chain for the new channel - chain_b_id identifier of the side `b` chain for the new channel (optional) + Identifier of the side `a` chain for the new channel + Identifier of the connection on chain `a` to use in creating the new channel FLAGS: - -c, --connection-a CONNECTION-A - --port-a PORT-A identifier of the side `a` port for the new channel - --port-b PORT-B identifier of the side `b` port for the new channel - -o, --order ORDER the channel ordering, valid options 'unordered' (default) and 'ordered' - -v, --channel-version VERSION the version for the new channel + -c, --chain-b-id Identifier of the side `b` chain for the new channel + -h, --help Print help information + --new-client-connection Indicates that a new client and connection will be created + underlying the new channel + -o, --order The channel ordering, valid options 'unordered' (default) and + 'ordered' [default: ORDER_UNORDERED] + --port-a Identifier of the side `a` port for the new channel + --port-b Identifier of the side `b` port for the new channel + -v, --channel-version The version for the new channel ``` ## Examples +### New channel over an existing connection + +This is the preferred way to create a new channel, by leveraging an existing +connection. + +Create a new unordered channel between `ibc-0` and `ibc-1` over an existing connection, +specifically the one we just created in the example above, with port name `transfer` on both sides: + +```shell +hermes create channel ibc-0 --connection-a connection-0 --port-a transfer --port-b transfer -o unordered +``` + +Notice that one can omit the destination chain parameter, as Hermes will automatically +figure it out by looking up the given connection on `ibc-0`. + +```json +🥳 ibc-0 => OpenInitChannel( + OpenInit( + Attributes { + height: Height { revision: 0, height: 129 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: None + } + ) +) + +🥳 ibc-1 => OpenTryChannel( + OpenTry( + Attributes { + height: Height { revision: 1, height: 126 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 ibc-0 => OpenAckChannel( + OpenAck( + Attributes { + height: Height { revision: 0, height: 137 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 ibc-1 => OpenConfirmChannel( + OpenConfirm( + Attributes { + height: Height { revision: 1, height: 129 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 🥳 🥳 Channel handshake finished for Channel { + ordering: Unordered, + a_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-0", + version: 0, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + b_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-1", + version: 1, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + connection_delay: 0s, +} + +Success: Channel { + ordering: Unordered, + a_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-0", + version: 0, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + b_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-1", + version: 1, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + connection_delay: 0s, +} +``` + ### New channel over a new connection +Should you specifically want to create a new client and a new connection as part +of the `create channel` flow, that option exists, though this is the +less-preferred option over the previous flow, as creating new clients and +connections should only be done in certain specific circumstances so as not to +create redundant resources. + Create a new unordered channel between `ibc-0` and `ibc-1` over a new connection, using -port name `transfer` on both sides: +port name `transfer` on both sides and accepting the interactive prompt that +pops up notifying you that a new client and a new connection will be initialized +as part of the process: ```shell -hermes create channel ibc-0 ibc-1 --port-a transfer --port-b transfer -o unordered +hermes create channel ibc-0 --chain-b-id ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection ``` ```json @@ -314,163 +492,3 @@ Success: Channel { A new channel with identifier `channel-0` on both sides has been established on a new connection with identifier `connection-0` on both sides. - -### New channel over an existing connection - -Create a new unordered channel between `ibc-0` and `ibc-1` over an existing connection, -specifically the one we just created in the example above, with port name `transfer` on both sides: - -```shell -hermes create channel ibc-0 --connection-a connection-0 --port-a transfer --port-b transfer -o unordered -``` - -Notice that one can omit the destination chain parameter, as Hermes will automatically -figure it out by looking up the given connection on `ibc-0`. - -```json -🥳 ibc-0 => OpenInitChannel( - OpenInit( - Attributes { - height: Height { revision: 0, height: 129 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: None - } - ) -) - -🥳 ibc-1 => OpenTryChannel( - OpenTry( - Attributes { - height: Height { revision: 1, height: 126 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 ibc-0 => OpenAckChannel( - OpenAck( - Attributes { - height: Height { revision: 0, height: 137 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 ibc-1 => OpenConfirmChannel( - OpenConfirm( - Attributes { - height: Height { revision: 1, height: 129 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 🥳 🥳 Channel handshake finished for Channel { - ordering: Unordered, - a_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-0", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - b_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-1", - version: 1, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - connection_delay: 0s, -} - -Success: Channel { - ordering: Unordered, - a_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-0", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - b_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-1", - version: 1, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - connection_delay: 0s, -} -``` diff --git a/guide/src/commands/path-setup/index.md b/guide/src/commands/path-setup/index.md index 60c5243407..ae654ca77a 100644 --- a/guide/src/commands/path-setup/index.md +++ b/guide/src/commands/path-setup/index.md @@ -7,11 +7,11 @@ This section describes a number of commands that can be used to manage clients, | `create client` | [Create a client for source chain on destination chain](./clients.md#create-client) | | `update client` | [Update the specified client on destination chain](./clients.md#md-client) | | `create connection` | [Establish a connection using existing or new clients](./connections.md#establish-connection) | -| `create channel` | [Establish a channel using existing or new connection](./channels.md#establish-channel) | +| `create channel` | [Establish a channel using a pre-existing connection, or alternatively create a new client and a new connection underlying the new channel](./channels.md#establish-channel) | ## Create -Use the `create` commands to create new clients, connections and channels. +Use the `create` commands to create new clients, connections, and channels. ```shell USAGE: @@ -40,4 +40,4 @@ DESCRIPTION: SUBCOMMANDS: help Get usage information client Update an IBC client -``` \ No newline at end of file +``` diff --git a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md index c24d738ab0..1abf92c34f 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -92,12 +92,20 @@ Follow the steps below to connect three chains together and relay packets betwee The script configures and starts three __`gaiad`__ instances, named __`ibc-0`__, and __`ibc-1`__, and __`ibc-2`__. -3. Create a channel between `ibc-0` and `ibc-1`: +3. Create a channel between `ibc-0` and `ibc-1`. Since this is the first time + we're connecting these two chains, we'll need to spin up a client and a + connection between them as well. The `create channel` command gives us the + convenient option to create a client and a connection. Keep in mind that this + is not the default behavior of `create channel`, but in this case we're + making an exception. Execute the following command: ```shell - hermes create channel ibc-0 ibc-1 --port-a transfer --port-b transfer -o unordered + hermes create channel ibc-0 --chain-b-id ibc-1 --port-a transfer --port-b transfer --new-client-connection ``` + Then respond 'yes' to the prompt that pops up. Once the command has run to + completion, you should see the following among the output logs: + ```json (...) @@ -154,10 +162,11 @@ Follow the steps below to connect three chains together and relay packets betwee Note that the channel identifier on both `ibc-0` and `ibc-1` is `channel-0`. -5. Create a channel between `ibc-1` and `ibc-2`: +5. Create a channel between `ibc-1` and `ibc-2` using the structure of the + previous invocation we used to create a channel between `ibc-0` and `ibc-1`: ```shell - hermes create channel ibc-1 ibc-2 --port-a transfer --port-b transfer -o unordered + hermes create channel ibc-1 --chain-b-id ibc-2 --port-a transfer --port-b transfer --new-client-connection ``` ```json diff --git a/relayer-cli/src/commands/create.rs b/relayer-cli/src/commands/create.rs index 2f5dfb42d8..f2e9ea3a95 100644 --- a/relayer-cli/src/commands/create.rs +++ b/relayer-cli/src/commands/create.rs @@ -18,7 +18,7 @@ pub enum CreateCmds { /// Create a new connection between two chains Connection(CreateConnectionCommand), - /// Create a new channel using a pre-existing connection. + /// Create a new channel between two chains using a pre-existing connection. /// Alternatively, create a new client and a new connection underlying /// the new channel if a pre-existing connection is not provided. Channel(CreateChannelCommand), From 610baa59684a3c2facdd40cf65c9c36aa8dbb6c3 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Mon, 4 Apr 2022 14:10:34 -0500 Subject: [PATCH 24/28] Remove `_id` suffixes from create channel options --- relayer-cli/src/commands/create/channel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index aef70dbc83..633c5105aa 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -47,14 +47,14 @@ pub struct CreateChannelCommand { required = true, help = "Identifier of the side `a` chain for the new channel" )] - chain_a_id: ChainId, + chain_a: ChainId, #[clap( short, long, help = "Identifier of the side `b` chain for the new channel" )] - chain_b_id: Option, + chain_b: Option, /// Identifier of the connection on chain `a` to use in creating the new channel. connection_a: Option, From 01a1f3179b081e974c1f16f816906bcf3e975b69 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 5 Apr 2022 11:42:14 -0500 Subject: [PATCH 25/28] Fix inconsistent naming in code and guide --- guide/src/commands/path-setup/channels.md | 4 ++-- relayer-cli/src/commands/create/channel.rs | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index 50fffcd74f..4eae1775f9 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -23,7 +23,7 @@ POSITIONAL ARGUMENTS: Identifier of the connection on chain `a` to use in creating the new channel FLAGS: - -c, --chain-b-id Identifier of the side `b` chain for the new channel + -c, --chain-b Identifier of the side `b` chain for the new channel -h, --help Print help information --new-client-connection Indicates that a new client and connection will be created underlying the new channel @@ -213,7 +213,7 @@ pops up notifying you that a new client and a new connection will be initialized as part of the process: ```shell -hermes create channel ibc-0 --chain-b-id ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection +hermes create channel ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection ``` ```json diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 633c5105aa..e8d75879d1 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -100,7 +100,7 @@ impl Runnable for CreateChannelCommand { fn run(&self) { match &self.connection_a { Some(conn) => self.run_reusing_connection(conn), - None => match &self.chain_b_id { + None => match &self.chain_b { Some(chain_b) => { if self.new_client_connection { match Confirm::new() @@ -145,10 +145,10 @@ impl Runnable for CreateChannelCommand { impl CreateChannelCommand { /// Creates a new channel, as well as a new underlying connection and clients. - fn run_using_new_connection(&self, chain_b_id: &ChainId) { + fn run_using_new_connection(&self, chain_b: &ChainId) { let config = app_config(); - let chains = ChainHandlePair::spawn(&config, &self.chain_a_id, chain_b_id) + let chains = ChainHandlePair::spawn(&config, &self.chain_a, chain_b) .unwrap_or_else(exit_with_unrecoverable_error); info!( @@ -179,28 +179,28 @@ impl CreateChannelCommand { } /// Creates a new channel, reusing an already existing connection and its clients. - fn run_reusing_connection(&self, connection_a_id: &ConnectionId) { + fn run_reusing_connection(&self, connection_a: &ConnectionId) { let config = app_config(); // Validate & spawn runtime for side a. - let chain_a = spawn_chain_runtime(&config, &self.chain_a_id) + let chain_a = spawn_chain_runtime(&config, &self.chain_a) .unwrap_or_else(exit_with_unrecoverable_error); // Query the connection end. let height = Height::new(chain_a.id().version(), 0); let conn_end = chain_a - .query_connection(connection_a_id, height) + .query_connection(connection_a, height) .unwrap_or_else(exit_with_unrecoverable_error); // Query the client state, obtain the identifier of chain b. - let chain_b_id = chain_a + let chain_b = chain_a .query_client_state(conn_end.client_id(), height) .map(|cs| cs.chain_id()) .unwrap_or_else(exit_with_unrecoverable_error); // Spawn the runtime for side b. let chain_b = - spawn_chain_runtime(&config, &chain_b_id).unwrap_or_else(exit_with_unrecoverable_error); + spawn_chain_runtime(&config, &chain_b).unwrap_or_else(exit_with_unrecoverable_error); // Create the foreign client handles. let client_a = ForeignClient::find(chain_b.clone(), chain_a.clone(), conn_end.client_id()) @@ -208,7 +208,7 @@ impl CreateChannelCommand { let client_b = ForeignClient::find(chain_a, chain_b, conn_end.counterparty().client_id()) .unwrap_or_else(exit_with_unrecoverable_error); - let identified_end = IdentifiedConnectionEnd::new(connection_a_id.clone(), conn_end); + let identified_end = IdentifiedConnectionEnd::new(connection_a.clone(), conn_end); let connection = Connection::find(client_a, client_b, &identified_end) .unwrap_or_else(exit_with_unrecoverable_error); From 381e17c83a3351235d387c88aa77880fbe763862 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Tue, 5 Apr 2022 13:07:46 -0500 Subject: [PATCH 26/28] Remove `-id`s in output messages --- relayer-cli/src/commands/create/channel.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index e8d75879d1..73a6b3342c 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -129,15 +129,13 @@ impl Runnable for CreateChannelCommand { } } else { Output::error( - "The `--new-client-connection` flag is required if invoking with ``".to_string() + "The `--new-client-connection` flag is required if invoking with ``".to_string() ) .exit(); } } - None => { - Output::error("Missing one of `` or ``".to_string()) - .exit() - } + None => Output::error("Missing one of `` or ``".to_string()) + .exit(), }, } } From dd35d59c9c8cd7e7ed318b6fecf4106fabe208a7 Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Wed, 6 Apr 2022 12:18:21 -0500 Subject: [PATCH 27/28] Make error message a bit clearer --- relayer-cli/src/commands/create/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relayer-cli/src/commands/create/channel.rs b/relayer-cli/src/commands/create/channel.rs index 73a6b3342c..5118ae1a79 100644 --- a/relayer-cli/src/commands/create/channel.rs +++ b/relayer-cli/src/commands/create/channel.rs @@ -129,7 +129,7 @@ impl Runnable for CreateChannelCommand { } } else { Output::error( - "The `--new-client-connection` flag is required if invoking with ``".to_string() + "The `--new-client-connection` flag is required if invoking with `--chain-b`".to_string() ) .exit(); } From 536feec43262d0abb8251bfb3c916fa3b128fc5a Mon Sep 17 00:00:00 2001 From: Sean Chen Date: Thu, 7 Apr 2022 15:13:12 -0500 Subject: [PATCH 28/28] Revert guide changes --- guide/src/commands/path-setup/channels.md | 360 +++++++++--------- guide/src/commands/path-setup/index.md | 4 +- .../relay-paths/multiple-paths.md | 17 +- 3 files changed, 177 insertions(+), 204 deletions(-) diff --git a/guide/src/commands/path-setup/channels.md b/guide/src/commands/path-setup/channels.md index 4eae1775f9..4b44dd9e8f 100644 --- a/guide/src/commands/path-setup/channels.md +++ b/guide/src/commands/path-setup/channels.md @@ -10,210 +10,32 @@ Use the `create channel` command to establish a new channel. ```shell USAGE: - hermes create channel [OPTIONS] --port-a --port-b - [CONNECTION_A] + hermes create channel DESCRIPTION: - Create a new channel between two chains using a pre-existing connection. - Alternatively, create a new client and a new connection underlying the new - channel if a pre-existing connection is not provided + Create a new channel between two chains POSITIONAL ARGUMENTS: - Identifier of the side `a` chain for the new channel - Identifier of the connection on chain `a` to use in creating the new channel + chain_a_id identifier of the side `a` chain for the new channel + chain_b_id identifier of the side `b` chain for the new channel (optional) FLAGS: - -c, --chain-b Identifier of the side `b` chain for the new channel - -h, --help Print help information - --new-client-connection Indicates that a new client and connection will be created - underlying the new channel - -o, --order The channel ordering, valid options 'unordered' (default) and - 'ordered' [default: ORDER_UNORDERED] - --port-a Identifier of the side `a` port for the new channel - --port-b Identifier of the side `b` port for the new channel - -v, --channel-version The version for the new channel + -c, --connection-a CONNECTION-A + --port-a PORT-A identifier of the side `a` port for the new channel + --port-b PORT-B identifier of the side `b` port for the new channel + -o, --order ORDER the channel ordering, valid options 'unordered' (default) and 'ordered' + -v, --channel-version VERSION the version for the new channel ``` ## Examples -### New channel over an existing connection - -This is the preferred way to create a new channel, by leveraging an existing -connection. - -Create a new unordered channel between `ibc-0` and `ibc-1` over an existing connection, -specifically the one we just created in the example above, with port name `transfer` on both sides: - -```shell -hermes create channel ibc-0 --connection-a connection-0 --port-a transfer --port-b transfer -o unordered -``` - -Notice that one can omit the destination chain parameter, as Hermes will automatically -figure it out by looking up the given connection on `ibc-0`. - -```json -🥳 ibc-0 => OpenInitChannel( - OpenInit( - Attributes { - height: Height { revision: 0, height: 129 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: None - } - ) -) - -🥳 ibc-1 => OpenTryChannel( - OpenTry( - Attributes { - height: Height { revision: 1, height: 126 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 ibc-0 => OpenAckChannel( - OpenAck( - Attributes { - height: Height { revision: 0, height: 137 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 ibc-1 => OpenConfirmChannel( - OpenConfirm( - Attributes { - height: Height { revision: 1, height: 129 }, - port_id: PortId("transfer"), - channel_id: Some(ChannelId("channel-1")), - connection_id: ConnectionId("connection-0"), - counterparty_port_id: PortId("transfer"), - counterparty_channel_id: Some(ChannelId("channel-1")) - } - ) -) - -🥳 🥳 🥳 Channel handshake finished for Channel { - ordering: Unordered, - a_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-0", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - b_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-1", - version: 1, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - connection_delay: 0s, -} - -Success: Channel { - ordering: Unordered, - a_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-0", - version: 0, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - b_side: ChannelSide { - chain: ProdChainHandle { - chain_id: ChainId { - id: "ibc-1", - version: 1, - }, - runtime_sender: Sender { .. }, - }, - client_id: ClientId( - "07-tendermint-0", - ), - connection_id: ConnectionId( - "connection-0", - ), - port_id: PortId( - "transfer", - ), - channel_id: ChannelId( - "channel-1", - ), - }, - connection_delay: 0s, -} -``` - ### New channel over a new connection -Should you specifically want to create a new client and a new connection as part -of the `create channel` flow, that option exists, though this is the -less-preferred option over the previous flow, as creating new clients and -connections should only be done in certain specific circumstances so as not to -create redundant resources. - Create a new unordered channel between `ibc-0` and `ibc-1` over a new connection, using -port name `transfer` on both sides and accepting the interactive prompt that -pops up notifying you that a new client and a new connection will be initialized -as part of the process: +port name `transfer` on both sides: ```shell -hermes create channel ibc-0 --chain-b ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection +hermes create channel ibc-0 ibc-1 --port-a transfer --port-b transfer -o unordered ``` ```json @@ -492,3 +314,163 @@ Success: Channel { A new channel with identifier `channel-0` on both sides has been established on a new connection with identifier `connection-0` on both sides. + +### New channel over an existing connection + +Create a new unordered channel between `ibc-0` and `ibc-1` over an existing connection, +specifically the one we just created in the example above, with port name `transfer` on both sides: + +```shell +hermes create channel ibc-0 --connection-a connection-0 --port-a transfer --port-b transfer -o unordered +``` + +Notice that one can omit the destination chain parameter, as Hermes will automatically +figure it out by looking up the given connection on `ibc-0`. + +```json +🥳 ibc-0 => OpenInitChannel( + OpenInit( + Attributes { + height: Height { revision: 0, height: 129 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: None + } + ) +) + +🥳 ibc-1 => OpenTryChannel( + OpenTry( + Attributes { + height: Height { revision: 1, height: 126 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 ibc-0 => OpenAckChannel( + OpenAck( + Attributes { + height: Height { revision: 0, height: 137 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 ibc-1 => OpenConfirmChannel( + OpenConfirm( + Attributes { + height: Height { revision: 1, height: 129 }, + port_id: PortId("transfer"), + channel_id: Some(ChannelId("channel-1")), + connection_id: ConnectionId("connection-0"), + counterparty_port_id: PortId("transfer"), + counterparty_channel_id: Some(ChannelId("channel-1")) + } + ) +) + +🥳 🥳 🥳 Channel handshake finished for Channel { + ordering: Unordered, + a_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-0", + version: 0, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + b_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-1", + version: 1, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + connection_delay: 0s, +} + +Success: Channel { + ordering: Unordered, + a_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-0", + version: 0, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + b_side: ChannelSide { + chain: ProdChainHandle { + chain_id: ChainId { + id: "ibc-1", + version: 1, + }, + runtime_sender: Sender { .. }, + }, + client_id: ClientId( + "07-tendermint-0", + ), + connection_id: ConnectionId( + "connection-0", + ), + port_id: PortId( + "transfer", + ), + channel_id: ChannelId( + "channel-1", + ), + }, + connection_delay: 0s, +} +``` diff --git a/guide/src/commands/path-setup/index.md b/guide/src/commands/path-setup/index.md index ae654ca77a..620a356860 100644 --- a/guide/src/commands/path-setup/index.md +++ b/guide/src/commands/path-setup/index.md @@ -7,11 +7,11 @@ This section describes a number of commands that can be used to manage clients, | `create client` | [Create a client for source chain on destination chain](./clients.md#create-client) | | `update client` | [Update the specified client on destination chain](./clients.md#md-client) | | `create connection` | [Establish a connection using existing or new clients](./connections.md#establish-connection) | -| `create channel` | [Establish a channel using a pre-existing connection, or alternatively create a new client and a new connection underlying the new channel](./channels.md#establish-channel) | +| `create channel` | [Establish a channel using existing or new connection](./channels.md#establish-channel) | ## Create -Use the `create` commands to create new clients, connections, and channels. +Use the `create` commands to create new clients, connections and channels. ```shell USAGE: diff --git a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md index 1abf92c34f..c24d738ab0 100644 --- a/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md +++ b/guide/src/tutorials/local-chains/relay-paths/multiple-paths.md @@ -92,20 +92,12 @@ Follow the steps below to connect three chains together and relay packets betwee The script configures and starts three __`gaiad`__ instances, named __`ibc-0`__, and __`ibc-1`__, and __`ibc-2`__. -3. Create a channel between `ibc-0` and `ibc-1`. Since this is the first time - we're connecting these two chains, we'll need to spin up a client and a - connection between them as well. The `create channel` command gives us the - convenient option to create a client and a connection. Keep in mind that this - is not the default behavior of `create channel`, but in this case we're - making an exception. Execute the following command: +3. Create a channel between `ibc-0` and `ibc-1`: ```shell - hermes create channel ibc-0 --chain-b-id ibc-1 --port-a transfer --port-b transfer --new-client-connection + hermes create channel ibc-0 ibc-1 --port-a transfer --port-b transfer -o unordered ``` - Then respond 'yes' to the prompt that pops up. Once the command has run to - completion, you should see the following among the output logs: - ```json (...) @@ -162,11 +154,10 @@ Follow the steps below to connect three chains together and relay packets betwee Note that the channel identifier on both `ibc-0` and `ibc-1` is `channel-0`. -5. Create a channel between `ibc-1` and `ibc-2` using the structure of the - previous invocation we used to create a channel between `ibc-0` and `ibc-1`: +5. Create a channel between `ibc-1` and `ibc-2`: ```shell - hermes create channel ibc-1 --chain-b-id ibc-2 --port-a transfer --port-b transfer --new-client-connection + hermes create channel ibc-1 ibc-2 --port-a transfer --port-b transfer -o unordered ``` ```json