From cf1eab343ca680275120e55f18a2a89979495c07 Mon Sep 17 00:00:00 2001 From: Luca Joss <43531661+ljoss17@users.noreply.github.com> Date: Wed, 13 Jul 2022 08:57:50 +0200 Subject: [PATCH] New optional flag `--host-chain` for `upgrade clients` command (#2384) --- .../2311-new-optional-flag-upgrade-clients.md | 3 ++ .../adr-010-unified-cli-arguments-hermes.md | 5 +++ relayer-cli/src/commands/tx/client.rs | 33 ++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .changelog/unreleased/features/ibc-relayer-cli/2311-new-optional-flag-upgrade-clients.md diff --git a/.changelog/unreleased/features/ibc-relayer-cli/2311-new-optional-flag-upgrade-clients.md b/.changelog/unreleased/features/ibc-relayer-cli/2311-new-optional-flag-upgrade-clients.md new file mode 100644 index 0000000000..13ab42175f --- /dev/null +++ b/.changelog/unreleased/features/ibc-relayer-cli/2311-new-optional-flag-upgrade-clients.md @@ -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)) \ No newline at end of file diff --git a/docs/architecture/adr-010-unified-cli-arguments-hermes.md b/docs/architecture/adr-010-unified-cli-arguments-hermes.md index a154e8f7d6..499e2bdc85 100644 --- a/docs/architecture/adr-010-unified-cli-arguments-hermes.md +++ b/docs/architecture/adr-010-unified-cli-arguments-hermes.md @@ -2,6 +2,7 @@ ## Changelog * 15.06.2022: Proposed. +* 28.06.2022: Accepted. ## Context @@ -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 diff --git a/relayer-cli/src/commands/tx/client.rs b/relayer-cli/src/commands/tx/client.rs index 5935f3bbbb..225dbccc49 100644 --- a/relayer-cli/src/commands/tx/client.rs +++ b/relayer-cli/src/commands/tx/client.rs @@ -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, } impl Runnable for TxUpgradeClientsCmd { @@ -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(), @@ -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", @@ -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!(