From 4556f4850abe505b60ea02a10e0a4d4ad84bff3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Tomi=C4=87?= Date: Mon, 26 Aug 2024 12:50:03 +0200 Subject: [PATCH] chore(decentralization): Remove legacy decentralized node flag and clean up code (#795) --- .../app/src/components/subnets/NodeSearch.tsx | 6 ------ rs/cli/src/operations/hostos_rollout.rs | 1 - rs/decentralization/src/nakamoto/mod.rs | 7 +++---- rs/decentralization/src/network.rs | 15 +++------------ rs/ic-management-backend/src/lazy_registry.rs | 5 ----- rs/ic-management-backend/src/node_labels.rs | 1 - rs/ic-management-backend/src/registry.rs | 5 ----- rs/ic-management-backend/src/subnets.rs | 1 - rs/ic-management-types/src/lib.rs | 3 --- 9 files changed, 6 insertions(+), 38 deletions(-) diff --git a/dashboard/packages/app/src/components/subnets/NodeSearch.tsx b/dashboard/packages/app/src/components/subnets/NodeSearch.tsx index 95e0fe0f4..1420f5199 100644 --- a/dashboard/packages/app/src/components/subnets/NodeSearch.tsx +++ b/dashboard/packages/app/src/components/subnets/NodeSearch.tsx @@ -143,12 +143,6 @@ export default function NodeSearch({ onSearchChange, expand }: { onSearchChange: hidden: false, searchable: true, }, - { - title: 'Decentralized', - field: 'decentralized', - type: 'boolean', - hidden: false, - }, ]; diff --git a/rs/cli/src/operations/hostos_rollout.rs b/rs/cli/src/operations/hostos_rollout.rs index 1f8c3d503..0ba73454d 100644 --- a/rs/cli/src/operations/hostos_rollout.rs +++ b/rs/cli/src/operations/hostos_rollout.rs @@ -704,7 +704,6 @@ pub mod test { hostos_release: None, proposal: None, label: None, - decentralized: false, duplicates: None, subnet_id, hostos_version: hostos_version.clone(), diff --git a/rs/decentralization/src/nakamoto/mod.rs b/rs/decentralization/src/nakamoto/mod.rs index 279938022..e05e816ed 100644 --- a/rs/decentralization/src/nakamoto/mod.rs +++ b/rs/decentralization/src/nakamoto/mod.rs @@ -578,7 +578,7 @@ mod tests { for i in 0..num_nodes { let dfinity_owned = i < num_dfinity_nodes; let node_features = NodeFeatures::new_test_feature_set(&format!("{} {}", feat_prefix, i)); - let node = Node::new_test_node(i as u64, node_features, dfinity_owned, true); + let node = Node::new_test_node(i as u64, node_features, dfinity_owned); subnet_nodes.push(node); } subnet_nodes @@ -602,7 +602,7 @@ mod tests { } None => NodeFeatures::new_test_feature_set(&format!("feat {}", i)), }; - let node = Node::new_test_node((node_number_start + i) as u64, node_features, dfinity_owned, true); + let node = Node::new_test_node((node_number_start + i) as u64, node_features, dfinity_owned); subnet_nodes.push(node); } subnet_nodes @@ -869,7 +869,6 @@ mod tests { .sorted_by(|a, b| a.principal.cmp(&b.principal)) .filter(|n| n.subnet_id.is_none() && n.proposal.is_none()) .map(Node::from) - .map(|n| Node { decentralized: true, ..n }) .collect::>(); subnet_healthy.check_business_rules().expect("Check business rules failed"); @@ -894,7 +893,7 @@ mod tests { #[test] fn test_extend_empty_subnet() { let available_nodes = (0..20) - .map(|i| Node::new_test_node(i, NodeFeatures::new_test_feature_set(&format!("foo{i}")), i % 10 == 0, true)) + .map(|i| Node::new_test_node(i, NodeFeatures::new_test_feature_set(&format!("foo{i}")), i % 10 == 0)) .collect::>(); let empty_subnet = DecentralizedSubnet::default(); diff --git a/rs/decentralization/src/network.rs b/rs/decentralization/src/network.rs index 6d5a60f8f..62fffff97 100644 --- a/rs/decentralization/src/network.rs +++ b/rs/decentralization/src/network.rs @@ -28,26 +28,24 @@ pub struct Node { pub id: PrincipalId, pub features: nakamoto::NodeFeatures, pub dfinity_owned: bool, - pub decentralized: bool, } impl std::fmt::Display for Node { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, - "Node ID: {}\nFeatures:\n{}\nDfinity Owned: {}\nDecentralized: {}", - self.id, self.features, self.dfinity_owned, self.decentralized + "Node ID: {}\nFeatures:\n{}\nDfinity Owned: {}", + self.id, self.features, self.dfinity_owned ) } } impl Node { - pub fn new_test_node(node_number: u64, features: nakamoto::NodeFeatures, dfinity_owned: bool, decentralized: bool) -> Self { + pub fn new_test_node(node_number: u64, features: nakamoto::NodeFeatures, dfinity_owned: bool) -> Self { Node { id: PrincipalId::new_node_test_id(node_number), features, dfinity_owned, - decentralized, } } @@ -129,7 +127,6 @@ impl From<&ic_management_types::Node> for Node { (NodeFeature::NodeProvider, n.operator.provider.principal.to_string()), ]), dfinity_owned: n.dfinity_owned.unwrap_or_default(), - decentralized: n.decentralized, } } } @@ -306,12 +303,6 @@ impl DecentralizedSubnet { penalties += target_dfinity_owned_nodes_count.abs_diff(dfinity_owned_nodes_count) * 1000; } - let count_non_decentralized_nodes = nodes.iter().filter(|n| !n.decentralized).count(); - if count_non_decentralized_nodes > 0 { - checks.push(format!("Subnet has {} non-decentralized node(s)", count_non_decentralized_nodes)); - penalties += count_non_decentralized_nodes * 100; - } - if subnet_id_str == *"uzr34-akd3s-xrdag-3ql62-ocgoh-ld2ao-tamcv-54e7j-krwgb-2gm4z-oqe" || subnet_id_str == *"tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe" || subnet_id_str == *"x33ed-h457x-bsgyx-oqxqf-6pzwv-wkhzr-rm2j3-npodi-purzm-n66cg-gae" diff --git a/rs/ic-management-backend/src/lazy_registry.rs b/rs/ic-management-backend/src/lazy_registry.rs index b83dc0ee0..edb9ac73b 100644 --- a/rs/ic-management-backend/src/lazy_registry.rs +++ b/rs/ic-management-backend/src/lazy_registry.rs @@ -371,7 +371,6 @@ impl LazyRegistry { operator: operator.clone().unwrap_or_default(), proposal: None, label: guest.map(|g| g.name), - decentralized: ip_addr.segments()[4] == 0x6801, duplicates: versioned_node_entries .iter() .filter(|(_, (_, nr2))| Self::node_ip_addr(nr2) == Self::node_ip_addr(nr)) @@ -707,10 +706,6 @@ impl AvailableNodesQuerier for LazyRegistry { .map(|s| matches!(*s, ic_management_types::HealthStatus::Healthy)) .unwrap_or(false) }) - .filter(|n| { - // Keep only the decentralized or DFINITY-owned nodes. - n.decentralized || n.dfinity_owned.unwrap_or(false) - }) .map(decentralization::network::Node::from) .sorted_by(|n1, n2| n1.id.cmp(&n2.id)) .collect()) diff --git a/rs/ic-management-backend/src/node_labels.rs b/rs/ic-management-backend/src/node_labels.rs index 952a16023..443255e19 100644 --- a/rs/ic-management-backend/src/node_labels.rs +++ b/rs/ic-management-backend/src/node_labels.rs @@ -44,7 +44,6 @@ pub async fn query_guests(network: &String) -> anyhow::Result> { ipv6: ip.parse().unwrap(), name: format!("{}-{}", dc, label), dfinity_owned: DFINITY_DCS.contains(dc), - decentralized: true, } }) .collect()) diff --git a/rs/ic-management-backend/src/registry.rs b/rs/ic-management-backend/src/registry.rs index eb4afc27b..ec71567ab 100644 --- a/rs/ic-management-backend/src/registry.rs +++ b/rs/ic-management-backend/src/registry.rs @@ -490,7 +490,6 @@ impl RegistryState { operator, proposal: None, label: guest.map(|g| g.name), - decentralized: ip_addr.segments()[4] == 0x6801, duplicates: node_entries .iter() .filter(|(_, (_, nr2))| node_ip_addr(nr2) == node_ip_addr(nr)) @@ -886,10 +885,6 @@ impl AvailableNodesQuerier for RegistryState { .map(|s| matches!(*s, ic_management_types::HealthStatus::Healthy)) .unwrap_or(false) }) - .filter(|n| { - // Keep only the decentralized or DFINITY-owned nodes. - n.decentralized || n.dfinity_owned.unwrap_or(false) - }) .map(decentralization::network::Node::from) .sorted_by(|n1, n2| n1.id.cmp(&n2.id)) .collect()) diff --git a/rs/ic-management-backend/src/subnets.rs b/rs/ic-management-backend/src/subnets.rs index eb1371ee5..c6d6d2246 100644 --- a/rs/ic-management-backend/src/subnets.rs +++ b/rs/ic-management-backend/src/subnets.rs @@ -152,7 +152,6 @@ mod tests { }, subnet_id: Some(subnet_id), hostos_release: None, - decentralized: true, ip_addr: Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), hostname: None, dfinity_owned: None, diff --git a/rs/ic-management-types/src/lib.rs b/rs/ic-management-types/src/lib.rs index 0427ad8dc..5eedb36c6 100644 --- a/rs/ic-management-types/src/lib.rs +++ b/rs/ic-management-types/src/lib.rs @@ -269,7 +269,6 @@ pub struct Node { pub proposal: Option, pub label: Option, #[serde(default)] - pub decentralized: bool, pub duplicates: Option, pub is_api_boundary_node: bool, } @@ -386,7 +385,6 @@ pub struct Guest { pub ipv6: Ipv6Addr, pub name: String, pub dfinity_owned: bool, - pub decentralized: bool, } #[derive(Clone, Serialize, Deserialize, PartialEq, Hash, Eq)] @@ -406,7 +404,6 @@ impl From for Guest { ipv6: g.ipv6, name: g.physical_system.split('.').next().expect("invalid physical system name").to_string(), dfinity_owned: g.node_type.contains("dfinity"), - decentralized: g.ipv6.segments()[4] == 0x6801, } } }