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

Replace positional arguments with flags in CLI #2275

Merged
merged 39 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
51852ae
Updated CLI commands to take flags everywhere and updated e2e tests a…
ljoss17 Jun 7, 2022
21580d3
Updated gm to use flags when calling Hermes
ljoss17 Jun 7, 2022
09c157f
Added missing flags to e2e test for 'query client state' command
ljoss17 Jun 7, 2022
612a707
Fixed flag errors in e2e tests and removed conflicting short flag.
ljoss17 Jun 7, 2022
88474db
Removed all short flags and updated CLI commands comments
ljoss17 Jun 8, 2022
a76599f
Removed forgotten short flags.
ljoss17 Jun 8, 2022
bf60ca1
Updated Hermes guide with flags instead of positional arguments
ljoss17 Jun 8, 2022
b9983ef
Updated script and comment with new long flags for Hermes
ljoss17 Jun 8, 2022
eb13cd0
Completed 'tx raw upgrade-' commands guide page. Updated Testing clie…
ljoss17 Jun 10, 2022
7a25573
Added changelog entry
ljoss17 Jun 10, 2022
2e3fff3
Added example unit-tests to the 'keys add' command
ljoss17 Jun 15, 2022
ff84119
Added value names to parameters and removed cli parsing unit-tests
ljoss17 Jun 17, 2022
4d35800
Cargo fmt changes
ljoss17 Jun 17, 2022
c7e1b9a
Updated flags in order to reflect ADR 010
ljoss17 Jun 17, 2022
c363e04
Updated guide to reflect flag changes from ADR 010
ljoss17 Jun 17, 2022
9e6d309
Updated gm script and e2e tests to match flag changes from ADR 010
ljoss17 Jun 17, 2022
52f5542
Merge branch 'master' into luca_joss/replace_positional_args_with_flags
ljoss17 Jun 20, 2022
89bfbf6
Fixed ADR 010 typo
ljoss17 Jun 20, 2022
01aeaac
Remove short flags from `key` error messages
seanchen1991 Jun 21, 2022
f5ee6dd
Fix inconsistent error messaging in channel.rs
seanchen1991 Jun 21, 2022
3f923de
Fix more inconsistent error messaging
seanchen1991 Jun 21, 2022
7b28a03
Run cargo fmt
seanchen1991 Jun 21, 2022
ca4a26d
Fix commands that use deprecated `-c` flag
seanchen1991 Jun 22, 2022
d4218da
Added the query transfer subcommand in docs.
adizere Jun 24, 2022
a28dc78
Scrub query clients
adizere Jun 24, 2022
52a83c9
Scrub query client state
adizere Jun 24, 2022
2624c7a
Removed excessive debug line
adizere Jun 24, 2022
7612d8b
Disabled filtering for query channels CLI
adizere Jun 24, 2022
49b4a41
Merge branch 'master' into luca_joss/replace_positional_args_with_flags
ljoss17 Jun 28, 2022
840a51c
Added aliases for 'connection', 'channel' and 'sequence' flags
ljoss17 Jun 28, 2022
d389f3d
Fixed error in CLI replacing HeightQuery with QueryHeight
ljoss17 Jun 28, 2022
e06b55a
Fix cargo fmt
ljoss17 Jun 28, 2022
fd71131
Changed 'version' to 'channel-version' for 'hermes create channel' co…
ljoss17 Jun 28, 2022
64e54e2
Separated 'hermes create channel' help into short and long message
ljoss17 Jun 28, 2022
d2ef49c
Updated 'hermes listen' so that '--events' flag can take multiple values
ljoss17 Jun 28, 2022
7d8a58e
Updated guide with new '--events' flag for 'hermes listen'
ljoss17 Jun 28, 2022
92cd463
Start all arguments help text with an uppercase letter, to match Clap…
romac Jun 28, 2022
eff375c
Update guide to account for argument help text starting with an upper…
romac Jun 28, 2022
6b2947e
Add shortened aliases for `tx raw` commands
romac Jun 28, 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 @@
- Updated all CLI commands to take flags instead of positional arguments.
([#2239](https://github.com/informalsystems/ibc-rs/issues/2239))
10 changes: 5 additions & 5 deletions ci/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ echo "--------------------------------------------------------------------------
echo "Show relayer version"
echo "-----------------------------------------------------------------------------------------------------------------"
echo Config: "$CONFIG_PATH"
$RELAYER_CMD -c "$CONFIG_PATH" version
$RELAYER_CMD --config "$CONFIG_PATH" version
echo "-----------------------------------------------------------------------------------------------------------------"
echo "Setting up chains"
echo "-----------------------------------------------------------------------------------------------------------------"
Expand All @@ -34,10 +34,10 @@ echo "==========================================================================
echo "-----------------------------------------------------------------------------------------------------------------"
echo "Add keys for chains"
echo "-----------------------------------------------------------------------------------------------------------------"
hermes -c "$CONFIG_PATH" keys add "$CHAIN_A" -f user_seed_"$CHAIN_A".json
hermes -c "$CONFIG_PATH" keys add "$CHAIN_B" -f user_seed_"$CHAIN_B".json
hermes -c "$CONFIG_PATH" keys add "$CHAIN_A" -f user2_seed_"$CHAIN_A".json -k user2
hermes -c "$CONFIG_PATH" keys add "$CHAIN_B" -f user2_seed_"$CHAIN_B".json -k user2
hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_A" --key-file user_seed_"$CHAIN_A".json
hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_B" --key-file user_seed_"$CHAIN_B".json
hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_A" --key-file user2_seed_"$CHAIN_A".json --key-name user2
hermes --config "$CONFIG_PATH" keys add --chain "$CHAIN_B" --key-file user2_seed_"$CHAIN_B".json --key-name user2

echo "================================================================================================================="
echo " END-TO-END TESTS "
Expand Down
6 changes: 5 additions & 1 deletion docs/architecture/adr-010-unified-cli-arguments-hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ __Connection__
* Optional: `[--height <HEIGHT>]`

* `query connections --chain <CHAIN_ID>`
* Optional: `[--chain-counterparty <CHAIN_COUNTERPARTY_ID>] [--verbose]`
* Optional: `[--counterparty-chain <COUNTERPARTY_CHAIN_ID>] [--verbose]`

__Channel__

Expand Down Expand Up @@ -148,6 +148,10 @@ __Packet__

* `query packet unreceived-packets --chain <CHAIN_ID> --port <PORT_ID> --chan <CHANNEL_ID>`

__Transfer__

* `query transfer denom-trace --chain <CHAIN_ID> --hash <HASH>`

__Tx__

* `query tx events --chain <CHAIN_ID> --hash <HASH>`
Expand Down
58 changes: 29 additions & 29 deletions e2e/e2e/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class TxChanOpenInit(Cmd[TxChanOpenInitRes]):
ordering: Optional[Ordering] = None

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.connection_id,
self.dst_port_id, self.src_port_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.connection_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id]

if self.ordering is not None:
args.extend(['--ordering', str(self.ordering)])
Expand Down Expand Up @@ -65,10 +65,10 @@ class TxChanOpenTry(Cmd[TxChanOpenTryRes]):
ordering: Optional[Ordering] = None

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.connection_id,
self.dst_port_id, self.src_port_id,
"-s", self.src_channel_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.connection_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id,
"--src-chan", self.src_channel_id]

if self.ordering is not None:
args.extend(['--ordering', str(self.ordering)])
Expand Down Expand Up @@ -104,11 +104,11 @@ class TxChanOpenAck(Cmd[TxChanOpenAckRes]):
src_channel_id: ChannelId

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.connection_id,
self.dst_port_id, self.src_port_id,
"-d", self.dst_channel_id,
"-s", self.src_channel_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.connection_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id,
"--dst-chan", self.dst_channel_id,
"--src-chan", self.src_channel_id]

return args

Expand Down Expand Up @@ -141,11 +141,11 @@ class TxChanOpenConfirm(Cmd[TxChanOpenConfirmRes]):
src_channel_id: ChannelId

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.connection_id,
self.dst_port_id, self.src_port_id,
"-d", self.dst_channel_id,
"-s", self.src_channel_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.connection_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id,
"--dst-chan", self.dst_channel_id,
"--src-chan", self.src_channel_id]

return args

Expand Down Expand Up @@ -177,11 +177,11 @@ class TxChanCloseInit(Cmd[TxChanCloseInitRes]):
src_chan_id: ChannelId

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.dst_conn_id,
self.dst_port_id, self.src_port_id,
"-d", self.dst_chan_id,
"-s", self.src_chan_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.dst_conn_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id,
"--dst-chan", self.dst_chan_id,
"--src-chan", self.src_chan_id]

return args

Expand Down Expand Up @@ -214,11 +214,11 @@ class TxChanCloseConfirm(Cmd[TxChanCloseConfirmRes]):
src_chan_id: ChannelId

def args(self) -> List[str]:
args = [self.dst_chain_id, self.src_chain_id,
self.dst_conn_id,
self.dst_port_id, self.src_port_id,
"-d", self.dst_chan_id,
"-s", self.src_chan_id]
args = ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-conn", self.dst_conn_id,
"--dst-port", self.dst_port_id, "--src-port", self.src_port_id,
"--dst-chan", self.dst_chan_id,
"--src-chan", self.src_chan_id]

return args

Expand Down Expand Up @@ -267,7 +267,7 @@ class QueryChannelEnd(Cmd[ChannelEnd]):
channel_id: ChannelId

def args(self) -> List[str]:
return [self.chain_id, self.port_id, self.channel_id]
return ["--chain", self.chain_id, "--port", self.port_id, "--chan", self.channel_id]

def process(self, result: Any) -> ChannelEnd:
return from_dict(ChannelEnd, result)
Expand All @@ -280,7 +280,7 @@ class QueryChannelEnds(Cmd[ChannelEnds]):
channel_id: ChannelId

def args(self) -> List[str]:
return [self.chain_id, self.port_id, self.channel_id]
return ["--chain", self.chain_id, "--port", self.port_id, "--chan", self.channel_id]

def process(self, result: Any) -> ChannelEnds:
return from_dict(ChannelEnds, result)
Expand Down
6 changes: 3 additions & 3 deletions e2e/e2e/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TxCreateClient(Cmd[ClientCreated]):
src_chain_id: ChainId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id]
return ["--host-chain", self.dst_chain_id, "--reference-chain", self.src_chain_id]

def process(self, result: Any) -> ClientCreated:
return from_dict(ClientCreated, result['CreateClient'])
Expand All @@ -43,7 +43,7 @@ class TxUpdateClient(Cmd[ClientUpdated]):
dst_client_id: ClientId

def args(self) -> List[str]:
return [self.dst_chain_id, self.dst_client_id]
return ["--host-chain", self.dst_chain_id, "--client", self.dst_client_id]

def process(self, result: Any) -> ClientUpdated:
return from_dict(ClientUpdated, result[-1]['UpdateClient']['common'])
Expand Down Expand Up @@ -86,7 +86,7 @@ def args(self) -> List[str]:
if self.proof:
args.append('--proof')

args.extend([self.chain_id, self.client_id])
args.extend(["--chain", self.chain_id, "--client", self.client_id])

return args

Expand Down
2 changes: 1 addition & 1 deletion e2e/e2e/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def to_cmd(self) -> str:
return f"{self.name} {' '.join(self.args())}"

def run(self, config: Config, retries: int = 0) -> CmdResult[T]:
full_cmd = f'{config.relayer_cmd} -c {config.config_file} --json'.split(' ')
full_cmd = f'{config.relayer_cmd} --config {config.config_file} --json'.split(' ')
full_cmd.extend(self.name.split(' '))
full_cmd.extend(self.args())
l.debug(' '.join(full_cmd))
Expand Down
28 changes: 14 additions & 14 deletions e2e/e2e/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class TxConnInit(Cmd[TxConnInitRes]):
src_client_id: ClientId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id,
self.dst_client_id, self.src_client_id]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-client", self.dst_client_id, "--src-client", self.src_client_id]

def process(self, result: Any) -> TxConnInitRes:
return from_dict(TxConnInitRes, result['OpenInitConnection'])
Expand All @@ -46,9 +46,9 @@ class TxConnTry(Cmd[TxConnTryRes]):
src_conn_id: ConnectionId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id,
self.dst_client_id, self.src_client_id,
"-s", self.src_conn_id]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-client", self.dst_client_id, "--src-client", self.src_client_id,
"--src-conn", self.src_conn_id]

def process(self, result: Any) -> TxConnTryRes:
return from_dict(TxConnTryRes, result['OpenTryConnection'])
Expand All @@ -72,10 +72,10 @@ class TxConnAck(Cmd[TxConnAckRes]):
src_conn_id: ConnectionId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id,
self.dst_client_id, self.src_client_id,
"-d", self.dst_conn_id,
"-s", self.src_conn_id]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-client", self.dst_client_id, "--src-client", self.src_client_id,
"--dst-conn", self.dst_conn_id,
"--src-conn", self.src_conn_id]

def process(self, result: Any) -> TxConnAckRes:
return from_dict(TxConnAckRes, result['OpenAckConnection'])
Expand All @@ -99,10 +99,10 @@ class TxConnConfirm(Cmd[TxConnConfirmRes]):
src_conn_id: ConnectionId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id,
self.dst_client_id, self.src_client_id,
"-d", self.dst_conn_id,
"-s", self.src_conn_id]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id,
"--dst-client", self.dst_client_id, "--src-client", self.src_client_id,
"--dst-conn", self.dst_conn_id,
"--src-conn", self.src_conn_id]

def process(self, result: Any) -> TxConnConfirmRes:
return from_dict(TxConnConfirmRes, result['OpenConfirmConnection'])
Expand Down Expand Up @@ -139,7 +139,7 @@ class QueryConnectionEnd(Cmd[ConnectionEnd]):
connection_id: ConnectionId

def args(self) -> List[str]:
return [self.chain_id, self.connection_id]
return ["--chain", self.chain_id, "--conn", self.connection_id]

def process(self, result: Any) -> ConnectionEnd:
return from_dict(ConnectionEnd, result)
Expand Down
26 changes: 13 additions & 13 deletions e2e/e2e/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ class TxPacketSend(Cmd[TxPacketSendRes]):

def args(self) -> List[str]:
args = [
self.dst_chain_id,
self.src_chain_id,
self.src_port,
self.src_channel,
str(self.amount),
"-o", str(self.height_offset),
"--dst-chain", self.dst_chain_id,
"--src-chain", self.src_chain_id,
"--src-port", self.src_port,
"--src-chan", self.src_channel,
"--amount", str(self.amount),
"--timeout-height-offset", str(self.height_offset),
]

if self.number_msgs != None:
args.extend(['-n', str(self.number_msgs)])
args.extend(['--number-msgs', str(self.number_msgs)])

if self.key != None:
args.extend(['-k', str(self.key)])
args.extend(['--key-name', str(self.key)])

return args

Expand All @@ -75,7 +75,7 @@ class TxPacketRecv(Cmd[TxPacketRecvRes]):
src_channel: ChannelId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel]

def process(self, result: Any) -> TxPacketRecvRes:
entry = find_entry(result, 'WriteAcknowledgement')
Expand All @@ -99,7 +99,7 @@ class TxPacketTimeout(Cmd[TxPacketTimeoutRes]):
src_channel: ChannelId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel]

def process(self, result: Any) -> TxPacketTimeoutRes:
entry = find_entry(result, 'TimeoutPacket')
Expand All @@ -124,7 +124,7 @@ class TxPacketAck(Cmd[TxPacketAckRes]):
src_channel: ChannelId

def args(self) -> List[str]:
return [self.dst_chain_id, self.src_chain_id, self.src_port, self.src_channel]
return ["--dst-chain", self.dst_chain_id, "--src-chain", self.src_chain_id, "--src-port", self.src_port, "--src-chan", self.src_channel]

def process(self, result: Any) -> TxPacketAckRes:
entry = find_entry(result, 'AcknowledgePacket')
Expand All @@ -141,7 +141,7 @@ class QueryUnreceivedPackets(Cmd[List[int]]):
channel: ChannelId

def args(self) -> List[str]:
return [self.chain, self.port, self.channel]
return ["--chain", self.chain, "--port", self.port, "--chan", self.channel]

def process(self, result: Any) -> List[int]:
return from_dict(List[int], result)
Expand Down Expand Up @@ -169,7 +169,7 @@ class QueryUnreceivedAcks(Cmd[List[int]]):
channel: ChannelId

def args(self) -> List[str]:
return [self.chain, self.port, self.channel]
return ["--chain", self.chain, "--port", self.port, "--chan", self.channel]

def process(self, result: Any) -> List[int]:
return from_dict(List[int], result)
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2e/relayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@


def start(c: Config) -> Popen:
full_cmd = f'{c.relayer_cmd} -c {c.config_file} -j start'.split(' ')
full_cmd = f'{c.relayer_cmd} --config {c.config_file} --json start'.split(' ')
l.debug(' '.join(full_cmd))
return Popen(full_cmd)
1 change: 1 addition & 0 deletions guide/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- [Channel Open](./commands/raw/channel-open.md)
- [Channel Close](./commands/raw/channel-close.md)
- [Packet](./commands/raw/packet.md)
- [Upgrade](./commands/raw/upgrade.md)
- [Help](./help.md)
- [Glossary](./glossary.md)
---
6 changes: 3 additions & 3 deletions guide/src/commands/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ your configuration file.

```shell
USAGE:
hermes config validate <OPTIONS>
hermes config validate

DESCRIPTION:
validate the relayer configuration
Expand All @@ -30,13 +30,13 @@ Success: "validation passed successfully"
Validate a config file at an arbitrary location:

```shell
hermes -c ./config.toml config validate
hermes --config ./config.toml config validate
```

This one fails validation because we mistakenly added two separate sections for
the same chain `ibc-1`:

```text
hermes -c ./config.toml config validate
hermes --config ./config.toml config validate
error: hermes fatal error: config error: config file has duplicate entry for the chain with id ibc-1
```
Loading