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

Implement ability to select specific wallet for packet clearing CLI #2252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
042480e
Pull in upstream changes
seanchen1991 Apr 22, 2022
69a1f8f
Merge branch 'informalsystems:master' into master
seanchen1991 Apr 22, 2022
d0be1f8
Pull in upstream changes
seanchen1991 May 3, 2022
45e082f
Pull in upstream changes
seanchen1991 May 4, 2022
f0fc83d
Merge branch 'master' of https://github.com/informalsystems/ibc-rs
seanchen1991 May 4, 2022
8bc79b7
Merge branch 'master' of https://github.com/informalsystems/ibc-rs
seanchen1991 May 10, 2022
9bee642
Merge branch 'master' of https://github.com/informalsystems/ibc-rs
seanchen1991 May 16, 2022
82cdf25
Merge branch 'master' of https://github.com/informalsystems/ibc-rs
seanchen1991 May 25, 2022
0e2c0c1
Add `-k` key flag to clear packets command
seanchen1991 May 26, 2022
b6596f4
Implement Override<Config> for ClearPacketsCmd
seanchen1991 May 26, 2022
c6a3ada
Add changelog entry
seanchen1991 May 31, 2022
4609268
Update guide
seanchen1991 May 31, 2022
c4c8093
Merge branch 'master' into select-specific-wallet-packet-clearing
seanchen1991 Jun 16, 2022
faaa85d
Remove unnecessary import
seanchen1991 Jun 16, 2022
75b2ebf
Merge branch 'master' of https://github.com/informalsystems/ibc-rs in…
seanchen1991 Jun 17, 2022
a0dbc8b
Remove short flag option
seanchen1991 Jun 17, 2022
f67d6c6
Merge branch 'master' into select-specific-wallet-packet-clearing
seanchen1991 Jun 17, 2022
59a14b6
Add clap option for `counterparty_key_name` flag
seanchen1991 Jun 20, 2022
15a4b4f
Merge branch 'master' into select-specific-wallet-packet-clearing
seanchen1991 Jun 24, 2022
e90736e
Merge branch 'select-specific-wallet-packet-clearing' of github.com:s…
seanchen1991 Jun 24, 2022
92b2f96
Attempting to fetch counterparty chain config
seanchen1991 Jun 24, 2022
53a376b
Overwrite dst chain's `key_name` in clear packet flow
seanchen1991 Jun 28, 2022
17dcfd0
Change a word in a comment
seanchen1991 Jun 28, 2022
304def4
Merge branch 'master' into select-specific-wallet-packet-clearing
seanchen1991 Jun 28, 2022
a75192b
Make language in guide consistent with CLI output
seanchen1991 Jun 28, 2022
b2bc588
Update ADR 010 to reflect changes to `clear packet` command
seanchen1991 Jun 28, 2022
a19cfb0
Merge branch 'master' into select-specific-wallet-packet-clearing
romac Jun 29, 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 @@
- Add support for selecting a specific wallet in the `clear packets` CLI flow ([#2111](https://github.com/informalsystems/ibc-rs/issues/2111))
5 changes: 3 additions & 2 deletions docs/architecture/adr-010-unified-cli-arguments-hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ The following commands are implemented, with the binary name `hermes` often omit

### Clear packets

* `clear packets --chain <CHAIN_ID> --port <PORT_ID> --channel <CHANNEL_ID>`
* `clear packets --chain <CHAIN_ID> --port <PORT_ID> --channel <CHANNEL_ID>
--key-name <KEY> --counterparty-key-name <KEY>`

### Queries

Expand Down Expand Up @@ -195,4 +196,4 @@ The PR which updates the flags for all the commands as described in this ADR: [#

## References

* Proposal in issue: [#2239](https://github.com/informalsystems/ibc-rs/issues/2239)
* Proposal in issue: [#2239](https://github.com/informalsystems/ibc-rs/issues/2239)
12 changes: 8 additions & 4 deletions guide/src/commands/relaying/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ DESCRIPTION:

The channel is identified by the chain, port, and channel IDs at one of its ends

OPTIONS:
-h, --help Print help information

FLAGS:
--chain <CHAIN_ID> Identifier of the chain
--channel <CHANNEL_ID> Identifier of the channel
--port <PORT_ID> Identifier of the port
--chain <CHAIN_ID> Identifier of the chain
--channel <CHANNEL_ID> Identifier of the channel
--port <PORT_ID> Identifier of the port
--key-name <KEY> Use the given signing key for the specified chain (default: `key_name` config)
--counterparty-key-name <KEY> Use the given signing key for the counterparty chain (default: `key_name` config)
```

### Example
Expand Down Expand Up @@ -437,4 +442,3 @@ Success: [
2022-02-24T14:21:28.874190Z INFO ThreadId(01) using default configuration from '/Users/coromac/.hermes/config.toml'
Success: []
```

48 changes: 45 additions & 3 deletions relayer-cli/src/commands/clear.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use abscissa_core::clap::Parser;
use abscissa_core::{Command, Runnable};
use abscissa_core::config::Override;
use abscissa_core::{Command, FrameworkErrorKind, Runnable};

use ibc::core::ics24_host::identifier::{ChainId, ChannelId, PortId};
use ibc::events::IbcEvent;
use ibc_relayer::chain::handle::BaseChainHandle;
use ibc_relayer::chain::handle::{BaseChainHandle, ChainHandle};
use ibc_relayer::config::Config;
use ibc_relayer::link::error::LinkError;
use ibc_relayer::link::{Link, LinkParameters};

Expand All @@ -21,7 +23,7 @@ pub enum ClearCmds {
Packets(ClearPacketsCmd),
}

#[derive(Debug, Parser)]
#[derive(Debug, Parser, Command)]
pub struct ClearPacketsCmd {
#[clap(
long = "chain",
Expand All @@ -47,6 +49,35 @@ pub struct ClearPacketsCmd {
help = "Identifier of the channel"
)]
channel_id: ChannelId,

#[clap(
long,
help = "use the given signing key for the specified chain (default: `key_name` config)"
)]
key_name: Option<String>,

#[clap(
long,
help = "use the given signing key for the counterparty chain (default: `counterparty_key_name` config)"
)]
counterparty_key_name: Option<String>,
}

impl Override<Config> for ClearPacketsCmd {
fn override_config(&self, mut config: Config) -> Result<Config, abscissa_core::FrameworkError> {
let chain_config = config.find_chain_mut(&self.chain_id).ok_or_else(|| {
FrameworkErrorKind::ComponentError.context(format!(
"missing configuration for chain '{}'",
self.chain_id
))
})?;

if let Some(ref key_name) = self.key_name {
chain_config.key_name = key_name.to_string();
}

Ok(config)
}
}

impl Runnable for ClearPacketsCmd {
Expand All @@ -63,6 +94,17 @@ impl Runnable for ClearPacketsCmd {
Err(e) => Output::error(format!("{}", e)).exit(),
};

// If `counterparty_key_name` is provided, fetch the counterparty chain's
// config and overwrite its `key_name` parameter
if let Some(ref counterparty_key_name) = self.counterparty_key_name {
seanchen1991 marked this conversation as resolved.
Show resolved Hide resolved
match chains.dst.config() {
Ok(mut dst_chain_cfg) => {
dst_chain_cfg.key_name = counterparty_key_name.to_string();
}
Err(e) => Output::error(format!("{}", e)).exit(),
}
}

let mut ev_list = vec![];

// Construct links in both directions.
Expand Down