Skip to content

Commit

Permalink
New optional flag --host-chain for upgrade clients command (infor…
Browse files Browse the repository at this point in the history
  • Loading branch information
ljoss17 authored Jul 13, 2022
1 parent b0d1169 commit cf1eab3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Added new optional flag `--host-chain` to filter which clients are upgraded when
running `upgrade clients` command
([#2311](https://github.com/informalsystems/ibc-rs/issues/2311))
5 changes: 5 additions & 0 deletions docs/architecture/adr-010-unified-cli-arguments-hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Changelog
* 15.06.2022: Proposed.
* 28.06.2022: Accepted.

## Context

Expand Down Expand Up @@ -185,6 +186,10 @@ The following are not yet implemented:

The PR which updates the flags for all the commands as described in this ADR: [#2275](https://github.com/informalsystems/ibc-rs/pull/2275)

__08.07.22__

* Created a new PR, [#2384](https://github.com/informalsystems/ibc-rs/pull/2384), to add the optional flag for the `upgrade clients` command, issue [#2311](https://github.com/informalsystems/ibc-rs/issues/2311)

## Consequences

### Positive
Expand Down
33 changes: 32 additions & 1 deletion relayer-cli/src/commands/tx/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ pub struct TxUpgradeClientsCmd {
help = "The height at which the reference chain halts for the client upgrade"
)]
reference_upgrade_height: u64,

#[clap(
long = "host-chain",
value_name = "HOST_CHAIN_ID",
help = "Identifier of the chain hosting the clients to be upgraded"
)]
host_chain_id: Option<ChainId>,
}

impl Runnable for TxUpgradeClientsCmd {
Expand Down Expand Up @@ -386,7 +393,10 @@ impl Runnable for TxUpgradeClientsCmd {
.chains
.iter()
.filter_map(|chain| {
(self.reference_chain_id != chain.id).then(|| {
(self.reference_chain_id != chain.id
&& (self.host_chain_id.is_none()
|| self.host_chain_id == Some(chain.id.clone())))
.then(|| {
self.upgrade_clients_for_chain(
&config,
reference_chain.clone(),
Expand Down Expand Up @@ -938,6 +948,7 @@ mod tests {
TxUpgradeClientsCmd {
reference_chain_id: ChainId::from_string("chain_id"),
reference_upgrade_height: 42,
host_chain_id: None,
},
TxUpgradeClientsCmd::parse_from(&[
"test",
Expand All @@ -949,6 +960,26 @@ mod tests {
)
}

#[test]
fn test_upgrade_clients_host_chain() {
assert_eq!(
TxUpgradeClientsCmd {
reference_chain_id: ChainId::from_string("chain_id"),
reference_upgrade_height: 42,
host_chain_id: Some(ChainId::from_string("chain_host_id")),
},
TxUpgradeClientsCmd::parse_from(&[
"test",
"--reference-chain",
"chain_id",
"--upgrade-height",
"42",
"--host-chain",
"chain_host_id",
])
)
}

#[test]
fn test_upgrade_clients_no_upgrade_height() {
assert!(
Expand Down

0 comments on commit cf1eab3

Please sign in to comment.