Skip to content

Commit

Permalink
fix: not merging lists if a custom height is used (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaMilosa authored Feb 27, 2025
1 parent f21d46c commit 23db26f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions rs/cli/src/commands/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
})
}
}
Expand Down Expand Up @@ -423,7 +423,12 @@ fn get_api_boundary_nodes(local_registry: &Arc<dyn LazyRegistry>) -> anyhow::Res
Ok(api_bns)
}

async fn get_node_providers(local_registry: &Arc<dyn LazyRegistry>, network: &Network, offline: bool) -> anyhow::Result<Vec<NodeProvider>> {
async fn get_node_providers(
local_registry: &Arc<dyn LazyRegistry>,
network: &Network,
offline: bool,
latest_height: bool,
) -> anyhow::Result<Vec<NodeProvider>> {
let all_nodes = local_registry.nodes().await?;

// Get the node providers from the node operator records, and from the governance canister, and merge them
Expand Down Expand Up @@ -455,13 +460,18 @@ async fn get_node_providers(local_registry: &Arc<dyn LazyRegistry>, network: &Ne
.map(|operator| operator.provider.clone())
.collect_vec();
let reg_provider_ids = reg_node_providers.iter().map(|provider| provider.principal).collect::<HashSet<_>>();
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
Expand Down

0 comments on commit 23db26f

Please sign in to comment.