Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions rs/nns/governance/api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4334,6 +4334,12 @@ pub enum NnsFunction {
/// `SetupInitialDKG` requests without an explicit subnet id are routed to the
/// calling subnet (NNS).
SetDefaultInitialDkgSubnet = 58,
/// Merge a subnet into another subnet: the canister ID ranges of the source
/// subnet are merged into the canister ID range set of the destination subnet,
/// a recovery catch-up package is created for the destination subnet (whose
/// state is expected to have been extended with the state of the canisters of
/// the source subnet) and the destination subnet is brought back online.
MergeSubnets = 59,
}
impl NnsFunction {
/// String value of the enum field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -4422,6 +4428,7 @@ impl NnsFunction {
NnsFunction::SetDefaultInitialDkgSubnet => {
"NNS_FUNCTION_SET_DEFAULT_INITIAL_DKG_SUBNET"
}
NnsFunction::MergeSubnets => "NNS_FUNCTION_MERGE_SUBNETS",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -4505,6 +4512,7 @@ impl NnsFunction {
"NNS_FUNCTION_SPLIT_SUBNET" => Some(Self::SplitSubnet),
"NNS_FUNCTION_DELETE_SUBNET" => Some(Self::DeleteSubnet),
"NNS_FUNCTION_SET_DEFAULT_INITIAL_DKG_SUBNET" => Some(Self::SetDefaultInitialDkgSubnet),
"NNS_FUNCTION_MERGE_SUBNETS" => Some(Self::MergeSubnets),
_ => None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,13 @@ enum NnsFunction {
// `SetupInitialDKG` requests without an explicit subnet id are routed to the
// calling subnet (NNS).
NNS_FUNCTION_SET_DEFAULT_INITIAL_DKG_SUBNET = 58;

// Merge a subnet into another subnet: the canister ID ranges of the source
// subnet are merged into the canister ID range set of the destination subnet,
// a recovery catch-up package is created for the destination subnet (whose
// state is expected to have been extended with the state of the canisters of
// the source subnet) and the destination subnet is brought back online.
NNS_FUNCTION_MERGE_SUBNETS = 59;
}

// Payload of a proposal that calls a function on another NNS
Expand Down
8 changes: 8 additions & 0 deletions rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5548,6 +5548,12 @@ pub enum NnsFunction {
/// `SetupInitialDKG` requests without an explicit subnet id are routed to the
/// calling subnet (NNS).
SetDefaultInitialDkgSubnet = 58,
/// Merge a subnet into another subnet: the canister ID ranges of the source
/// subnet are merged into the canister ID range set of the destination subnet,
/// a recovery catch-up package is created for the destination subnet (whose
/// state is expected to have been extended with the state of the canisters of
/// the source subnet) and the destination subnet is brought back online.
MergeSubnets = 59,
}
impl NnsFunction {
/// String value of the enum field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -5624,6 +5630,7 @@ impl NnsFunction {
Self::SplitSubnet => "NNS_FUNCTION_SPLIT_SUBNET",
Self::DeleteSubnet => "NNS_FUNCTION_DELETE_SUBNET",
Self::SetDefaultInitialDkgSubnet => "NNS_FUNCTION_SET_DEFAULT_INITIAL_DKG_SUBNET",
Self::MergeSubnets => "NNS_FUNCTION_MERGE_SUBNETS",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand Down Expand Up @@ -5707,6 +5714,7 @@ impl NnsFunction {
"NNS_FUNCTION_SPLIT_SUBNET" => Some(Self::SplitSubnet),
"NNS_FUNCTION_DELETE_SUBNET" => Some(Self::DeleteSubnet),
"NNS_FUNCTION_SET_DEFAULT_INITIAL_DKG_SUBNET" => Some(Self::SetDefaultInitialDkgSubnet),
"NNS_FUNCTION_MERGE_SUBNETS" => Some(Self::MergeSubnets),
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions rs/nns/governance/src/pb/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3940,6 +3940,7 @@ impl From<pb::NnsFunction> for api::NnsFunction {
api::NnsFunction::SetSubnetOperationalLevel
}
pb::NnsFunction::SplitSubnet => api::NnsFunction::SplitSubnet,
pb::NnsFunction::MergeSubnets => api::NnsFunction::MergeSubnets,
pb::NnsFunction::DeleteSubnet => api::NnsFunction::DeleteSubnet,
pb::NnsFunction::SetDefaultInitialDkgSubnet => {
api::NnsFunction::SetDefaultInitialDkgSubnet
Expand Down Expand Up @@ -4040,6 +4041,7 @@ impl From<api::NnsFunction> for pb::NnsFunction {
pb::NnsFunction::SetSubnetOperationalLevel
}
api::NnsFunction::SplitSubnet => pb::NnsFunction::SplitSubnet,
api::NnsFunction::MergeSubnets => pb::NnsFunction::MergeSubnets,
api::NnsFunction::DeleteSubnet => pb::NnsFunction::DeleteSubnet,
api::NnsFunction::SetDefaultInitialDkgSubnet => {
pb::NnsFunction::SetDefaultInitialDkgSubnet
Expand Down
16 changes: 15 additions & 1 deletion rs/nns/governance/src/proposals/execute_nns_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ pub enum ValidNnsFunction {
SplitSubnet,
DeleteSubnet,
SetDefaultInitialDkgSubnet,
MergeSubnets,
}

impl ValidNnsFunction {
Expand Down Expand Up @@ -592,6 +593,7 @@ impl ValidNnsFunction {
ValidNnsFunction::SetDefaultInitialDkgSubnet => {
(REGISTRY_CANISTER_ID, "set_default_initial_dkg_subnet")
}
ValidNnsFunction::MergeSubnets => (REGISTRY_CANISTER_ID, "merge_subnets"),
}
}

Expand Down Expand Up @@ -623,7 +625,8 @@ impl ValidNnsFunction {
| ValidNnsFunction::SetSubnetOperationalLevel
| ValidNnsFunction::SplitSubnet
| ValidNnsFunction::DeleteSubnet
| ValidNnsFunction::SetDefaultInitialDkgSubnet => Topic::SubnetManagement,
| ValidNnsFunction::SetDefaultInitialDkgSubnet
| ValidNnsFunction::MergeSubnets => Topic::SubnetManagement,

ValidNnsFunction::ReviseElectedGuestosVersions
| ValidNnsFunction::ReviseElectedHostosVersions => Topic::IcOsVersionElection,
Expand Down Expand Up @@ -714,6 +717,7 @@ impl ValidNnsFunction {
ValidNnsFunction::SplitSubnet => "Split subnet",
ValidNnsFunction::DeleteSubnet => "Delete Subnet",
ValidNnsFunction::SetDefaultInitialDkgSubnet => "Set Default Initial DKG Subnet",
ValidNnsFunction::MergeSubnets => "Merge subnets",
}
}

Expand Down Expand Up @@ -944,6 +948,15 @@ impl ValidNnsFunction {
calls are routed when no subnet is specified explicitly in the request. If unset, \
such requests are routed to the calling subnet (NNS)."
}
ValidNnsFunction::MergeSubnets => {
"Merge a subnet into another subnet. The canister ID ranges of the source subnet \
are merged into the canister ID range set of the destination subnet, so that all \
canisters that used to be hosted by the source subnet are routed to the \
destination subnet; a recovery catch-up package is created for the destination \
subnet, whose state is expected to have been extended with the state of the \
canisters of the source subnet while both subnets were offline; and the \
destination subnet is brought back online."
}
Comment on lines +951 to +955

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6a8dd69. This one is the proposal-facing description, so it also keeps "The source subnet is not deleted.".

}
}
}
Expand Down Expand Up @@ -1033,6 +1046,7 @@ impl TryFrom<NnsFunction> for ValidNnsFunction {
Ok(ValidNnsFunction::SetSubnetOperationalLevel)
}
NnsFunction::SplitSubnet => Ok(ValidNnsFunction::SplitSubnet),
NnsFunction::MergeSubnets => Ok(ValidNnsFunction::MergeSubnets),
NnsFunction::DeleteSubnet => Ok(ValidNnsFunction::DeleteSubnet),
NnsFunction::SetDefaultInitialDkgSubnet => {
Ok(ValidNnsFunction::SetDefaultInitialDkgSubnet)
Expand Down
7 changes: 7 additions & 0 deletions rs/nns/governance/unreleased_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ on the process that this file is part of, see

## Added

* Added a new `NnsFunction` variant `MergeSubnets`, which proposes to merge a
subnet into another subnet: the canister ID ranges of the source subnet are
merged into the canister ID range set of the destination subnet, a recovery
catch-up package is created for the destination subnet (whose state is
expected to have been extended with the state of the canisters of the source
subnet) and the destination subnet is brought back online.

## Changed

## Deprecated
Expand Down
22 changes: 22 additions & 0 deletions rs/registry/canister/canister/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ use registry_canister::{
firewall::{
AddFirewallRulesPayload, RemoveFirewallRulesPayload, UpdateFirewallRulesPayload,
},
merge_subnets::MergeSubnetsPayload,
node_management::{
do_remove_node_directly::RemoveNodeDirectlyPayload,
do_remove_nodes::RemoveNodesPayload,
Expand Down Expand Up @@ -1085,6 +1086,27 @@ fn reroute_canister_ranges_(payload: RerouteCanisterRangesPayload) {
recertify_registry();
}

#[unsafe(export_name = "canister_update merge_subnets")]
fn merge_subnets() {
check_caller_is_governance_and_log("merge_subnets");
over_async(candid_one, |payload: MergeSubnetsPayload| async move {
merge_subnets_(payload).await
});
}

#[candid_method(update, rename = "merge_subnets")]
async fn merge_subnets_(payload: MergeSubnetsPayload) {
registry_mut()
.merge_subnets(payload)
.await
.unwrap_or_else(|error_message| {
trap_with(&format!(
"{LOG_PREFIX} Merge subnets failed: {error_message}"
))
});
Comment thread
daniel-wong-dfinity-org-twin marked this conversation as resolved.
recertify_registry();
}

#[unsafe(export_name = "canister_update split_subnet")]
fn split_subnet() {
check_caller_is_governance_and_log("split_subnet");
Expand Down
10 changes: 10 additions & 0 deletions rs/registry/canister/canister/registry.did
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ type IPv4Config = record {
ip_addr : text;
};

type MergeSubnetsPayload = record {
source_subnet : principal;
destination_subnet : principal;
height : nat64;
time_ns : nat64;
state_hash : blob;
initial_dkg_subnet_id : opt principal;
};

type MigrateCanistersPayload = record {
canister_ids : vec principal;
target_subnet_id : principal;
Expand Down Expand Up @@ -646,6 +655,7 @@ service : {
get_node_providers_monthly_xdr_rewards : (opt GetNodeProvidersMonthlyXdrRewardsRequest) -> (GetNodeProvidersMonthlyXdrRewardsResponse) query;
get_subnet : (GetSubnetRequest) -> (GetSubnetResponse) query;
get_subnet_for_canister : (GetSubnetForCanisterRequest) -> (GetSubnetForCanisterResponse) query;
merge_subnets : (MergeSubnetsPayload) -> ();
migrate_canisters: (MigrateCanistersPayload) -> (MigrateCanistersResponse);
migrate_node_operator_directly : (MigrateNodeOperatorPayload) -> ();
prepare_canister_migration : (PrepareCanisterMigrationPayload) -> ();
Expand Down
10 changes: 10 additions & 0 deletions rs/registry/canister/canister/registry_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ type IPv4Config = record {
ip_addr : text;
};

type MergeSubnetsPayload = record {
source_subnet : principal;
destination_subnet : principal;
height : nat64;
time_ns : nat64;
state_hash : blob;
initial_dkg_subnet_id : opt principal;
};

type MigrateCanistersPayload = record {
canister_ids : vec principal;
target_subnet_id : principal;
Expand Down Expand Up @@ -646,6 +655,7 @@ service : {
get_node_providers_monthly_xdr_rewards : (opt GetNodeProvidersMonthlyXdrRewardsRequest) -> (GetNodeProvidersMonthlyXdrRewardsResponse) query;
get_subnet : (GetSubnetRequest) -> (GetSubnetResponse) query;
get_subnet_for_canister : (GetSubnetForCanisterRequest) -> (GetSubnetForCanisterResponse) query;
merge_subnets : (MergeSubnetsPayload) -> ();
migrate_canisters: (MigrateCanistersPayload) -> (MigrateCanistersResponse);
migrate_node_operator_directly : (MigrateNodeOperatorPayload) -> ();
prepare_canister_migration : (PrepareCanisterMigrationPayload) -> ();
Expand Down
2 changes: 1 addition & 1 deletion rs/registry/canister/src/mutations/do_recover_subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl TryFrom<KeyConfigRequest> for KeyConfigRequestInternal {
}
}

fn panic_if_record_changed_across_versions(
pub(crate) fn panic_if_record_changed_across_versions(
registry: &Registry,
key: &str,
initial_registry_version: Version,
Expand Down
Loading
Loading