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

Add flag to enable interactive prompt in create channel CLI #2014

Merged
merged 29 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
02c35b6
Document CreateChannelCommand
seanchen1991 Mar 24, 2022
6193d1d
Add `new-client-connection` flag to `create channel` command
seanchen1991 Mar 24, 2022
5a9be15
Add new `run` logic for `CreateChannelCommand`
seanchen1991 Mar 24, 2022
7904011
Add dialoguer dependency in order to enable interactive CLI prompts
seanchen1991 Mar 24, 2022
9ac2bb1
Add interactive prompt functionality
seanchen1991 Mar 24, 2022
1b4428a
Remove unnecessary Term::stdout parameter
seanchen1991 Mar 24, 2022
b96c735
Add style to prompts
seanchen1991 Mar 25, 2022
4668dc7
Clean up CreateChannelCommand documentation
seanchen1991 Mar 25, 2022
3a19b77
Fix documentation formatting
seanchen1991 Mar 25, 2022
0ebb59f
Add changelog entry
seanchen1991 Mar 25, 2022
27d9369
Document CreateChannelCommand
seanchen1991 Mar 24, 2022
2642dd8
Add `new-client-connection` flag to `create channel` command
seanchen1991 Mar 25, 2022
514d512
Add new `run` logic for `CreateChannelCommand`
seanchen1991 Mar 24, 2022
cc30c4d
Add dialoguer dependency in order to enable interactive CLI prompts
seanchen1991 Mar 24, 2022
b8faca0
Add interactive prompt functionality
seanchen1991 Mar 24, 2022
d2d20cf
Remove unnecessary Term::stdout parameter
seanchen1991 Mar 24, 2022
6ffb41c
Add style to prompts
seanchen1991 Mar 25, 2022
b3e3259
Clean up CreateChannelCommand documentation
seanchen1991 Mar 25, 2022
419d5e5
Fix documentation formatting
seanchen1991 Mar 25, 2022
b2747e5
Add changelog entry
seanchen1991 Mar 25, 2022
3e0e6d6
Merge branch 'create-channel-cli' of github.com:seanchen1991/ibc-rs i…
seanchen1991 Mar 25, 2022
e095270
Incorporate PR feedback
seanchen1991 Mar 29, 2022
771ad3d
Remove unnecessary attribute cruft and make help messages consistent
seanchen1991 Mar 31, 2022
473b121
Update Hermes guide with the new `create channel` flow
seanchen1991 Mar 31, 2022
610baa5
Remove `_id` suffixes from create channel options
seanchen1991 Apr 4, 2022
01a1f31
Fix inconsistent naming in code and guide
seanchen1991 Apr 5, 2022
381e17c
Remove `-id`s in output messages
seanchen1991 Apr 5, 2022
dd35d59
Make error message a bit clearer
seanchen1991 Apr 6, 2022
536feec
Revert guide changes
seanchen1991 Apr 7, 2022
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
Original file line number Diff line number Diff line change
@@ -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))
360 changes: 189 additions & 171 deletions guide/src/commands/path-setup/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,210 @@ Use the `create channel` command to establish a new channel.

```shell
USAGE:
hermes create channel <OPTIONS>
hermes create channel [OPTIONS] --port-a <PORT_A> --port-b <PORT_B>
<CHAIN_A_ID> [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)
<CHAIN_A_ID> Identifier of the side `a` chain for the new channel
<CONNECTION_A> 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 <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 <ORDER> The channel ordering, valid options 'unordered' (default) and
'ordered' [default: ORDER_UNORDERED]
--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
-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:
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 ibc-1 --port-a transfer --port-b transfer -o unordered --new-client-connection
```

```json
Expand Down Expand Up @@ -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,
}
```
Loading