Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ go.sum @dfinity/idx
/rs/tests/ @dfinity/idx
/rs/tests/idx/ @dfinity/idx
/rs/tests/testnets/ @dfinity/idx
/rs/tests/testnets/cloud_engine.rs @dfinity/dre
/rs/tests/testnets/mainnet_nns/ @dfinity/consensus
/rs/tests/testnets/mainnet_nns.rs @dfinity/consensus
/rs/tests/testnets/nns_recovery.rs @dfinity/consensus
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 36 additions & 3 deletions rs/prep/src/internet_computer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,20 @@ impl TopologyConfig {
self.unassigned_nodes.insert(idx, nc);
}

/// Set all node providers to the principal `node_operator`.
/// Set node operator on nodes that don't already have one set.
pub fn with_initial_node_operator(mut self, node_operator: PrincipalId) -> Self {
for (_, sc) in self.subnets.iter_mut() {
for (_, nc) in sc.membership.iter_mut() {
nc.node_operator_principal_id = Some(node_operator);
if nc.node_operator_principal_id.is_none() {
nc.node_operator_principal_id = Some(node_operator);
}
}
}

for (_, nc) in self.unassigned_nodes.iter_mut() {
nc.node_operator_principal_id = Some(node_operator);
if nc.node_operator_principal_id.is_none() {
nc.node_operator_principal_id = Some(node_operator);
}
}
self
}
Expand Down Expand Up @@ -424,6 +428,35 @@ impl IcConfig {
}
}

/// Add a data center record to the initial registry.
pub fn add_data_center_record(&mut self, mut dc_record: DataCenterRecord) {
dc_record.id = dc_record.id.to_lowercase();
self.initial_dc_records.push(dc_record);
}

/// Add a node operator record to the initial registry.
pub fn add_node_operator_record(
&mut self,
name: String,
principal_id: PrincipalId,
node_provider_principal_id: Option<PrincipalId>,
node_allowance: u64,
dc_id: String,
rewardable_nodes: BTreeMap<String, u32>,
) {
self.initial_registry_node_operator_entries
.push(NodeOperatorEntry {
_name: name,
principal_id,
node_provider_principal_id,
node_allowance,
dc_id,
rewardable_nodes: rewardable_nodes.clone(),
ipv6: None,
max_rewardable_nodes: rewardable_nodes,
});
}

pub fn set_use_specified_ids_allocation_range(
&mut self,
use_specified_ids_allocation_range: bool,
Expand Down
18 changes: 16 additions & 2 deletions rs/tests/driver/src/driver/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ pub fn init_ic(

ic_config.set_use_specified_ids_allocation_range(specific_ids);

for dc_record in &ic.data_centers {
ic_config.add_data_center_record(dc_record.clone());
}
for no in &ic.node_operators {
ic_config.add_node_operator_record(
no.name.clone(),
no.principal_id,
no.node_provider_principal_id,
no.node_allowance,
no.dc_id.clone(),
no.rewardable_nodes.clone(),
);
}

if let Some(UnassignedRecordConfig::Skip) = ic.unassigned_record_config {
ic_config.skip_unassigned_record();
}
Expand Down Expand Up @@ -611,8 +625,8 @@ fn node_to_config(node: &Node) -> NodeConfiguration {
NodeConfiguration {
xnet_api,
public_api,
// this value will be overridden by IcConfig::with_node_operator()
node_operator_principal_id: None,
// If not set per-node, this will be overridden by IcConfig's initial_node_operator
node_operator_principal_id: node.node_operator_principal_id,
secret_key_store: node.secret_key_store.clone(),
domain: node.domain.clone(),
node_reward_type: None,
Expand Down
40 changes: 40 additions & 0 deletions rs/tests/driver/src/driver/ic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::driver::{
use anyhow::Result;
use ic_prep_lib::prep_state_directory::IcPrepStateDir;
use ic_prep_lib::{node::NodeSecretKeyStore, subnet_configuration::SubnetRunningState};
use ic_protobuf::registry::dc::v1::DataCenterRecord;
use ic_regedit;
use ic_registry_canister_api::IPv4Config;
use ic_registry_subnet_features::{ChainKeyConfig, SubnetFeatures};
Expand Down Expand Up @@ -50,6 +51,19 @@ pub struct InternetComputer {
use_specified_ids_allocation_range: bool,
pub unassigned_record_config: Option<UnassignedRecordConfig>,
pub api_boundary_nodes: Vec<Node>,
pub data_centers: Vec<DataCenterRecord>,
pub node_operators: Vec<NodeOperatorConfig>,
}

/// Configuration for a node operator to be added to the initial registry.
#[derive(Clone, Debug, Default)]
pub struct NodeOperatorConfig {
pub name: String,
pub principal_id: PrincipalId,
pub node_provider_principal_id: Option<PrincipalId>,
pub node_allowance: u64,
pub dc_id: String,
pub rewardable_nodes: BTreeMap<String, u32>,
}

#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -119,6 +133,26 @@ impl InternetComputer {
self
}

pub fn add_data_center(mut self, dc_record: DataCenterRecord) -> Self {
Comment thread
severin-amrein marked this conversation as resolved.
if self
.data_centers
.iter()
.any(|existing| existing.id.eq_ignore_ascii_case(&dc_record.id))
{
panic!(
"Duplicate data center id (case-insensitive) in IC config: {}",
dc_record.id
);
}
self.data_centers.push(dc_record);
self
}

pub fn add_node_operator(mut self, node_operator: NodeOperatorConfig) -> Self {
self.node_operators.push(node_operator);
self
}

/// Add the given number of unassigned nodes to the IC.
pub fn with_unassigned_nodes(mut self, no_of_nodes: usize) -> Self {
for _ in 0..no_of_nodes {
Expand Down Expand Up @@ -862,6 +896,7 @@ pub struct Node {
pub domain: Option<String>,
pub recovery_hash: Option<String>,
pub boot_image: BootImage,
pub node_operator_principal_id: Option<PrincipalId>,
}

impl Node {
Expand Down Expand Up @@ -899,6 +934,11 @@ impl Node {
self
}

pub fn with_node_operator_principal_id(mut self, principal_id: PrincipalId) -> Self {
self.node_operator_principal_id = Some(principal_id);
self
}

pub fn with_malicious_behavior(mut self, malicious_behavior: MaliciousBehavior) -> Self {
self.malicious_behavior = Some(malicious_behavior);
self
Expand Down
26 changes: 26 additions & 0 deletions rs/tests/testnets/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,32 @@ system_test_nns(
],
)

system_test_nns(
name = "cloud_engine",
enable_metrics = True,
tags = [
"dynamic_testnet",
"manual",
],
runtime_deps = IC_GATEWAY_RUNTIME_DEPS | {
"II_BACKEND_WASM_PATH": "@mainnet_canisters//:internet_identity_backend.wasm.gz",
"II_FRONTEND_WASM_PATH": "@mainnet_canisters//:internet_identity_frontend.wasm.gz",
"NNS_DAPP_WASM_PATH": "@mainnet_canisters//:nns_dapp_test.wasm.gz",
"SUBNET_RENTAL_WASM_PATH": "@mainnet_canisters//:subnet_rental.wasm.gz",
},
deps = [
# Keep sorted.
"//rs/protobuf",
"//rs/registry/subnet_type",
"//rs/tests/consensus/utils",
"//rs/tests/driver:ic-system-test-driver",
"//rs/tests/nns/nns_dapp",
"//rs/types/cycles",
"//rs/types/types",
"@crate_index//:anyhow",
],
)

system_test_nns(
name = "medium",
enable_metrics = True,
Expand Down
7 changes: 7 additions & 0 deletions rs/tests/testnets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ anyhow = { workspace = true }
candid = { workspace = true }
ic-base-types = { path = "../../types/base_types" }
ic-limits = { path = "../../limits" }
ic-protobuf = { path = "../../protobuf" }
ic-registry-subnet-features = { path = "../../registry/subnet_features" }
ic-types = { path = "../../types/types" }
ic-types-cycles = { path = "../../types/cycles" }
ic-registry-subnet-type = { path = "../../registry/subnet_type" }
ic-system-test-driver = { path = "../driver" }
ic-testnet-mainnet-nns = { path = "./mainnet_nns" }
Expand Down Expand Up @@ -74,6 +77,10 @@ path = "sns_testing.rs"
name = "src_testing"
path = "src_testing.rs"

[[bin]]
name = "cloud_engine"
path = "cloud_engine.rs"

[[bin]]
name = "from_config"
path = "from_config.rs"
Expand Down
Loading
Loading