Skip to content

Commit

Permalink
chore(decentralization): Remove legacy decentralized node flag and cl…
Browse files Browse the repository at this point in the history
…ean up code (#795)
  • Loading branch information
sasa-tomic authored Aug 26, 2024
1 parent 9e99906 commit 4556f48
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 38 deletions.
6 changes: 0 additions & 6 deletions dashboard/packages/app/src/components/subnets/NodeSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ export default function NodeSearch({ onSearchChange, expand }: { onSearchChange:
hidden: false,
searchable: true,
},
{
title: 'Decentralized',
field: 'decentralized',
type: 'boolean',
hidden: false,
},
];


Expand Down
1 change: 0 additions & 1 deletion rs/cli/src/operations/hostos_rollout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
7 changes: 3 additions & 4 deletions rs/decentralization/src/nakamoto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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::<Vec<_>>();

subnet_healthy.check_business_rules().expect("Check business rules failed");
Expand All @@ -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::<Vec<_>>();
let empty_subnet = DecentralizedSubnet::default();

Expand Down
15 changes: 3 additions & 12 deletions rs/decentralization/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions rs/ic-management-backend/src/lazy_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion rs/ic-management-backend/src/node_labels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub async fn query_guests(network: &String) -> anyhow::Result<Vec<Guest>> {
ipv6: ip.parse().unwrap(),
name: format!("{}-{}", dc, label),
dfinity_owned: DFINITY_DCS.contains(dc),
decentralized: true,
}
})
.collect())
Expand Down
5 changes: 0 additions & 5 deletions rs/ic-management-backend/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion rs/ic-management-backend/src/subnets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions rs/ic-management-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ pub struct Node {
pub proposal: Option<TopologyChangeProposal>,
pub label: Option<String>,
#[serde(default)]
pub decentralized: bool,
pub duplicates: Option<PrincipalId>,
pub is_api_boundary_node: bool,
}
Expand Down Expand Up @@ -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)]
Expand All @@ -406,7 +404,6 @@ impl From<FactsDBGuest> 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,
}
}
}
Expand Down

0 comments on commit 4556f48

Please sign in to comment.