From 23db26fbdd74459b9c75f883beae4aae1cc22838 Mon Sep 17 00:00:00 2001 From: Nikola Milosavljevic <73236646+NikolaMilosa@users.noreply.github.com> Date: Thu, 27 Feb 2025 17:02:02 +0100 Subject: [PATCH] fix: not merging lists if a custom height is used (#1314) --- rs/cli/src/commands/registry.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/rs/cli/src/commands/registry.rs b/rs/cli/src/commands/registry.rs index c3384ce5a..53ab12030 100644 --- a/rs/cli/src/commands/registry.rs +++ b/rs/cli/src/commands/registry.rs @@ -167,7 +167,7 @@ impl Registry { node_operators: node_operators.values().cloned().collect_vec(), node_rewards_table, api_bns, - node_providers: get_node_providers(&local_registry, ctx.network(), ctx.is_offline()).await?, + node_providers: get_node_providers(&local_registry, ctx.network(), ctx.is_offline(), self.height.is_none()).await?, }) } } @@ -423,7 +423,12 @@ fn get_api_boundary_nodes(local_registry: &Arc) -> anyhow::Res Ok(api_bns) } -async fn get_node_providers(local_registry: &Arc, network: &Network, offline: bool) -> anyhow::Result> { +async fn get_node_providers( + local_registry: &Arc, + network: &Network, + offline: bool, + latest_height: bool, +) -> anyhow::Result> { let all_nodes = local_registry.nodes().await?; // Get the node providers from the node operator records, and from the governance canister, and merge them @@ -455,13 +460,18 @@ async fn get_node_providers(local_registry: &Arc, network: &Ne .map(|operator| operator.provider.clone()) .collect_vec(); let reg_provider_ids = reg_node_providers.iter().map(|provider| provider.principal).collect::>(); - for principal in gov_node_providers.keys() { - if !reg_provider_ids.contains(principal) { - reg_node_providers.push(ic_management_types::Provider { - principal: *principal, - name: None, - website: None, - }); + + // Governance canister doesn't have the mechanism to retrieve node providers on a certain height + // meaning that merging the lists on arbitrary heights wouldn't make sense. + if latest_height { + for principal in gov_node_providers.keys() { + if !reg_provider_ids.contains(principal) { + reg_node_providers.push(ic_management_types::Provider { + principal: *principal, + name: None, + website: None, + }); + } } } let reg_node_providers = reg_node_providers