Skip to content

Commit cbd88f0

Browse files
Added LoadCanisterSnapshot proposal type.
1 parent 16756cd commit cbd88f0

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

rs/nns/governance/api/src/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,6 +4206,8 @@ pub enum NnsFunction {
42064206
/// controlled by the NNS Root canister. This restriction could be relaxed
42074207
/// later. See nns/.../root.did for the payload type.
42084208
TakeCanisterSnapshot = 56,
4209+
/// Loads a canister snapshot.
4210+
LoadCanisterSnapshot = 57,
42094211
}
42104212
impl NnsFunction {
42114213
/// String value of the enum field names used in the ProtoBuf definition.
@@ -4290,6 +4292,7 @@ impl NnsFunction {
42904292
NnsFunction::UnpauseCanisterMigrations => "NNS_FUNCTION_UNPAUSE_CANISTER_MIGRATIONS",
42914293
NnsFunction::SetSubnetOperationalLevel => "NNS_FUNCTION_SET_SUBNET_OPERATIONAL_LEVEL",
42924294
NnsFunction::TakeCanisterSnapshot => "NNS_FUNCTION_TAKE_CANISTER_SNAPSHOT",
4295+
NnsFunction::LoadCanisterSnapshot => "NNS_FUNCTION_LOAD_CANISTER_SNAPSHOT",
42934296
}
42944297
}
42954298
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -4371,6 +4374,7 @@ impl NnsFunction {
43714374
"NNS_FUNCTION_UNPAUSE_CANISTER_MIGRATIONS" => Some(Self::UnpauseCanisterMigrations),
43724375
"NNS_FUNCTION_SET_SUBNET_OPERATIONAL_LEVEL" => Some(Self::SetSubnetOperationalLevel),
43734376
"NNS_FUNCTION_TAKE_CANISTER_SNAPSHOT" => Some(Self::TakeCanisterSnapshot),
4377+
"NNS_FUNCTION_LOAD_CANISTER_SNAPSHOT" => Some(Self::LoadCanisterSnapshot),
43744378
_ => None,
43754379
}
43764380
}

rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ enum NnsFunction {
498498

499499
// Take a canister snapshot.
500500
NNS_FUNCTION_TAKE_CANISTER_SNAPSHOT = 56;
501+
502+
// Load a canister snapshot.
503+
NNS_FUNCTION_LOAD_CANISTER_SNAPSHOT = 57;
501504
}
502505

503506
// Payload of a proposal that calls a function on another NNS

rs/nns/governance/src/canister_state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ fn get_effective_payload(
395395
| ValidNnsFunction::PauseCanisterMigrations
396396
| ValidNnsFunction::UnpauseCanisterMigrations
397397
| ValidNnsFunction::SetSubnetOperationalLevel
398-
| ValidNnsFunction::TakeCanisterSnapshot => Ok(payload.clone()),
398+
| ValidNnsFunction::TakeCanisterSnapshot
399+
| ValidNnsFunction::LoadCanisterSnapshot => Ok(payload.clone()),
399400
}
400401
}
401402

rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,6 +4822,8 @@ pub enum NnsFunction {
48224822
SetSubnetOperationalLevel = 55,
48234823
/// Take a canister snapshot.
48244824
TakeCanisterSnapshot = 56,
4825+
/// Load a canister snapshot.
4826+
LoadCanisterSnapshot = 57,
48254827
}
48264828
impl NnsFunction {
48274829
/// String value of the enum field names used in the ProtoBuf definition.
@@ -4896,6 +4898,7 @@ impl NnsFunction {
48964898
Self::UnpauseCanisterMigrations => "NNS_FUNCTION_UNPAUSE_CANISTER_MIGRATIONS",
48974899
Self::SetSubnetOperationalLevel => "NNS_FUNCTION_SET_SUBNET_OPERATIONAL_LEVEL",
48984900
Self::TakeCanisterSnapshot => "NNS_FUNCTION_TAKE_CANISTER_SNAPSHOT",
4901+
Self::LoadCanisterSnapshot => "NNS_FUNCTION_LOAD_CANISTER_SNAPSHOT",
48994902
}
49004903
}
49014904
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -4977,6 +4980,7 @@ impl NnsFunction {
49774980
"NNS_FUNCTION_UNPAUSE_CANISTER_MIGRATIONS" => Some(Self::UnpauseCanisterMigrations),
49784981
"NNS_FUNCTION_SET_SUBNET_OPERATIONAL_LEVEL" => Some(Self::SetSubnetOperationalLevel),
49794982
"NNS_FUNCTION_TAKE_CANISTER_SNAPSHOT" => Some(Self::TakeCanisterSnapshot),
4983+
"NNS_FUNCTION_LOAD_CANISTER_SNAPSHOT" => Some(Self::LoadCanisterSnapshot),
49804984
_ => None,
49814985
}
49824986
}

rs/nns/governance/src/governance.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4815,6 +4815,13 @@ impl Governance {
48154815
));
48164816
}
48174817
}
4818+
ValidNnsFunction::LoadCanisterSnapshot => {
4819+
if !are_canister_snapshot_proposals_enabled() {
4820+
return Err(invalid_proposal_error(
4821+
"LoadCanisterSnapshot proposals are not yet enabled.".to_string(),
4822+
));
4823+
}
4824+
}
48184825
_ => {}
48194826
};
48204827

rs/nns/governance/src/pb/conversions/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,6 +3988,7 @@ impl From<pb::NnsFunction> for pb_api::NnsFunction {
39883988
pb_api::NnsFunction::SetSubnetOperationalLevel
39893989
}
39903990
pb::NnsFunction::TakeCanisterSnapshot => pb_api::NnsFunction::TakeCanisterSnapshot,
3991+
pb::NnsFunction::LoadCanisterSnapshot => pb_api::NnsFunction::LoadCanisterSnapshot,
39913992
}
39923993
}
39933994
}
@@ -4098,6 +4099,7 @@ impl From<pb_api::NnsFunction> for pb::NnsFunction {
40984099
pb::NnsFunction::SetSubnetOperationalLevel
40994100
}
41004101
pb_api::NnsFunction::TakeCanisterSnapshot => pb::NnsFunction::TakeCanisterSnapshot,
4102+
pb_api::NnsFunction::LoadCanisterSnapshot => pb::NnsFunction::LoadCanisterSnapshot,
41014103
}
41024104
}
41034105
}

rs/nns/governance/src/proposals/execute_nns_function.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ pub enum ValidNnsFunction {
154154
UnpauseCanisterMigrations,
155155
SetSubnetOperationalLevel,
156156
TakeCanisterSnapshot,
157+
LoadCanisterSnapshot,
157158
}
158159

159160
impl ValidNnsFunction {
@@ -283,6 +284,7 @@ impl ValidNnsFunction {
283284
(REGISTRY_CANISTER_ID, "set_subnet_operational_level")
284285
}
285286
ValidNnsFunction::TakeCanisterSnapshot => (ROOT_CANISTER_ID, "take_canister_snapshot"),
287+
ValidNnsFunction::LoadCanisterSnapshot => (ROOT_CANISTER_ID, "load_canister_snapshot"),
286288
}
287289
}
288290

@@ -338,13 +340,13 @@ impl ValidNnsFunction {
338340
| ValidNnsFunction::HardResetNnsRootToVersion
339341
| ValidNnsFunction::BitcoinSetConfig
340342
| ValidNnsFunction::PauseCanisterMigrations
341-
| ValidNnsFunction::UnpauseCanisterMigrations => Topic::ProtocolCanisterManagement,
343+
| ValidNnsFunction::UnpauseCanisterMigrations
344+
| ValidNnsFunction::TakeCanisterSnapshot
345+
| ValidNnsFunction::LoadCanisterSnapshot => Topic::ProtocolCanisterManagement,
342346

343347
ValidNnsFunction::AddSnsWasm | ValidNnsFunction::InsertSnsWasmUpgradePathEntries => {
344348
Topic::ServiceNervousSystemManagement
345349
}
346-
347-
ValidNnsFunction::TakeCanisterSnapshot => Topic::ProtocolCanisterManagement,
348350
}
349351
}
350352

@@ -402,6 +404,7 @@ impl ValidNnsFunction {
402404
ValidNnsFunction::UnpauseCanisterMigrations => "Unpause Canister Migrations",
403405
ValidNnsFunction::SetSubnetOperationalLevel => "Set Subnet Operational Level",
404406
ValidNnsFunction::TakeCanisterSnapshot => "Take Canister Snapshot",
407+
ValidNnsFunction::LoadCanisterSnapshot => "Load Canister Snapshot",
405408
}
406409
}
407410

@@ -633,6 +636,13 @@ impl ValidNnsFunction {
633636
For an introduction to canister snapshots in general, see \
634637
https://docs.internetcomputer.org/building-apps/canister-management/snapshots ."
635638
}
639+
ValidNnsFunction::LoadCanisterSnapshot => {
640+
"A proposal to load a canister snapshot into a canister controlled the NNS. \
641+
In other words, to restore the canister to an earlier recorded state, \
642+
which including the code and memory (including stable memory). \
643+
For an introduction to canister snapshots in general, see \
644+
https://docs.internetcomputer.org/building-apps/canister-management/snapshots ."
645+
}
636646
}
637647
}
638648
}
@@ -722,6 +732,7 @@ impl TryFrom<NnsFunction> for ValidNnsFunction {
722732
Ok(ValidNnsFunction::SetSubnetOperationalLevel)
723733
}
724734
NnsFunction::TakeCanisterSnapshot => Ok(ValidNnsFunction::TakeCanisterSnapshot),
735+
NnsFunction::LoadCanisterSnapshot => Ok(ValidNnsFunction::LoadCanisterSnapshot),
725736

726737
// Obsolete functions - based on check_obsolete
727738
NnsFunction::BlessReplicaVersion | NnsFunction::RetireReplicaVersion => {

0 commit comments

Comments
 (0)