Skip to content

Commit 295226f

Browse files
daniel-wong-dfinity-org-twindaniel-wong-dfinity-orgCopilot
authored
feat(governance): Added a new NNS proposal type: UpdateStandardEngineReplicaVersion. (dfinity#10884)
[👈 Previous PR][prev] | [Next PR 👉][next] [prev]: dfinity#10865 [next]: dfinity#10885 --------- Co-authored-by: Daniel Wong <daniel.wong@dfinity.org> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent dd4c052 commit 295226f

11 files changed

Lines changed: 407 additions & 3 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ pub mod proposal {
693693
LoadCanisterSnapshot(super::LoadCanisterSnapshot),
694694
/// Create a canister in a (possibly non-NNS) subnet and install code into it.
695695
CreateCanisterAndInstallCode(super::CreateCanisterAndInstallCode),
696+
/// Change what replica version(s) are run by Cloud Engines.
697+
UpdateStandardEngineReplicaVersion(super::UpdateStandardEngineReplicaVersion),
696698
}
697699
}
698700
/// Empty message to use in oneof fields that represent empty
@@ -1454,6 +1456,7 @@ pub enum ProposalActionRequest {
14541456
TakeCanisterSnapshot(TakeCanisterSnapshot),
14551457
LoadCanisterSnapshot(LoadCanisterSnapshot),
14561458
CreateCanisterAndInstallCode(CreateCanisterAndInstallCodeRequest),
1459+
UpdateStandardEngineReplicaVersion(UpdateStandardEngineReplicaVersion),
14571460
}
14581461

14591462
#[derive(
@@ -2843,6 +2846,15 @@ pub struct BlessAlternativeGuestOsVersion {
28432846
pub base_guest_launch_measurements: Option<GuestLaunchMeasurements>,
28442847
}
28452848

2849+
#[derive(
2850+
candid::CandidType, candid::Deserialize, serde::Serialize, Clone, PartialEq, Debug, Default,
2851+
)]
2852+
pub struct UpdateStandardEngineReplicaVersion {
2853+
pub new_replica_version_id: Option<String>,
2854+
pub old_replica_version_id: Option<String>,
2855+
pub deployment_progress: Option<f64>,
2856+
}
2857+
28462858
/// See also the definition of GuestLaunchMeasurements (plural!) in
28472859
/// rs/protobuf/def/registry/replica_version/v1/replica_version.proto
28482860
#[derive(

rs/nns/governance/canister/governance.did

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Action = variant {
2525
TakeCanisterSnapshot : TakeCanisterSnapshot;
2626
LoadCanisterSnapshot : LoadCanisterSnapshot;
2727
CreateCanisterAndInstallCode : CreateCanisterAndInstallCode;
28+
UpdateStandardEngineReplicaVersion : UpdateStandardEngineReplicaVersion;
2829
};
2930

3031
type AddHotKey = record {
@@ -1096,6 +1097,7 @@ type ProposalActionRequest = variant {
10961097
TakeCanisterSnapshot : TakeCanisterSnapshot;
10971098
LoadCanisterSnapshot : LoadCanisterSnapshot;
10981099
CreateCanisterAndInstallCode : CreateCanisterAndInstallCodeRequest;
1100+
UpdateStandardEngineReplicaVersion : UpdateStandardEngineReplicaVersion;
10991101
};
11001102

11011103
// Creates a rented subnet from a rental request (in the Subnet Rental
@@ -1151,6 +1153,13 @@ type BlessAlternativeGuestOsVersion = record {
11511153
// (Here, we refer to the version being replaced as the "base" version.)
11521154
base_guest_launch_measurements : opt GuestLaunchMeasurements; };
11531155

1156+
// Changes what replica version(s) are run by Cloud Engines.
1157+
type UpdateStandardEngineReplicaVersion = record {
1158+
new_replica_version_id : opt text;
1159+
old_replica_version_id : opt text;
1160+
deployment_progress : opt float64;
1161+
};
1162+
11541163
type GuestLaunchMeasurements = record {
11551164
guest_launch_measurements : opt vec GuestLaunchMeasurement;
11561165
};

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,8 @@ message Proposal {
730730
LoadCanisterSnapshot load_canister_snapshot = 33;
731731
// Create a canister in a (possibly non-NNS) subnet and install code into it.
732732
CreateCanisterAndInstallCode create_canister_and_install_code = 34;
733+
// Change what replica version(s) are run by Cloud Engines.
734+
UpdateStandardEngineReplicaVersion update_standard_engine_replica_version = 35;
733735
}
734736
}
735737

@@ -2010,6 +2012,14 @@ message BlessAlternativeGuestOsVersion {
20102012
registry.replica_version.v1.GuestLaunchMeasurements base_guest_launch_measurements = 3;
20112013
}
20122014

2015+
// Changes what replica version(s) are run by Cloud Engines. See Registry's
2016+
// do_update_standard_engine_replica_version for what changes are allowed.
2017+
message UpdateStandardEngineReplicaVersion {
2018+
string new_replica_version_id = 1;
2019+
string old_replica_version_id = 2;
2020+
double deployment_progress = 3;
2021+
}
2022+
20132023
message LoadCanisterSnapshot {
20142024
// The ID of the canister to load the snapshot into.
20152025
ic_base_types.pb.v1.PrincipalId canister_id = 1;

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub struct Proposal {
466466
/// take.
467467
#[prost(
468468
oneof = "proposal::Action",
469-
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 29, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34"
469+
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 29, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35"
470470
)]
471471
pub action: ::core::option::Option<proposal::Action>,
472472
}
@@ -585,6 +585,9 @@ pub mod proposal {
585585
/// Create a canister in a (possibly non-NNS) subnet and install code into it.
586586
#[prost(message, tag = "34")]
587587
CreateCanisterAndInstallCode(super::CreateCanisterAndInstallCode),
588+
/// Change what replica version(s) are run by Cloud Engines.
589+
#[prost(message, tag = "35")]
590+
UpdateStandardEngineReplicaVersion(super::UpdateStandardEngineReplicaVersion),
588591
}
589592
}
590593
/// Take a canister snapshot.
@@ -3159,6 +3162,25 @@ pub struct BlessAlternativeGuestOsVersion {
31593162
::ic_protobuf::registry::replica_version::v1::GuestLaunchMeasurements,
31603163
>,
31613164
}
3165+
/// Changes what replica version(s) are run by Cloud Engines. See Registry's
3166+
/// do_update_standard_engine_replica_version for what changes are allowed.
3167+
#[derive(
3168+
candid::CandidType,
3169+
candid::Deserialize,
3170+
serde::Serialize,
3171+
comparable::Comparable,
3172+
Clone,
3173+
PartialEq,
3174+
::prost::Message,
3175+
)]
3176+
pub struct UpdateStandardEngineReplicaVersion {
3177+
#[prost(string, tag = "1")]
3178+
pub new_replica_version_id: ::prost::alloc::string::String,
3179+
#[prost(string, tag = "2")]
3180+
pub old_replica_version_id: ::prost::alloc::string::String,
3181+
#[prost(double, tag = "3")]
3182+
pub deployment_progress: f64,
3183+
}
31623184
#[derive(
31633185
candid::CandidType,
31643186
candid::Deserialize,

rs/nns/governance/src/governance.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ impl Action {
541541
Action::TakeCanisterSnapshot(_) => "ACTION_TAKE_CANISTER_SNAPSHOT",
542542
Action::LoadCanisterSnapshot(_) => "ACTION_LOAD_CANISTER_SNAPSHOT",
543543
Action::CreateCanisterAndInstallCode(_) => "ACTION_CREATE_CANISTER_AND_INSTALL_CODE",
544+
Action::UpdateStandardEngineReplicaVersion(_) => {
545+
"ACTION_UPDATE_STANDARD_ENGINE_REPLICA_VERSION"
546+
}
544547
}
545548
}
546549
}
@@ -4282,6 +4285,12 @@ impl Governance {
42824285
self.perform_call_canister(pid, create_canister_and_install_code)
42834286
.await;
42844287
}
4288+
ValidProposalAction::UpdateStandardEngineReplicaVersion(
4289+
update_standard_engine_replica_version,
4290+
) => {
4291+
self.perform_call_canister(pid, update_standard_engine_replica_version)
4292+
.await;
4293+
}
42854294
}
42864295
}
42874296

@@ -4920,6 +4929,9 @@ impl Governance {
49204929
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code) => {
49214930
create_canister_and_install_code.validate()
49224931
}
4932+
ValidProposalAction::UpdateStandardEngineReplicaVersion(
4933+
update_standard_engine_replica_version,
4934+
) => update_standard_engine_replica_version.validate(),
49234935
}
49244936
}
49254937

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ impl From<api::proposal::Action> for pb::proposal::Action {
469469
api::proposal::Action::CreateCanisterAndInstallCode(v) => {
470470
pb::proposal::Action::CreateCanisterAndInstallCode(v.into())
471471
}
472+
api::proposal::Action::UpdateStandardEngineReplicaVersion(v) => {
473+
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v.into())
474+
}
472475
}
473476
}
474477
}
@@ -530,6 +533,9 @@ impl From<api::ProposalActionRequest> for pb::proposal::Action {
530533
api::ProposalActionRequest::CreateCanisterAndInstallCode(v) => {
531534
pb::proposal::Action::CreateCanisterAndInstallCode(v.into())
532535
}
536+
api::ProposalActionRequest::UpdateStandardEngineReplicaVersion(v) => {
537+
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v.into())
538+
}
533539
}
534540
}
535541
}
@@ -2831,6 +2837,33 @@ impl From<api::BlessAlternativeGuestOsVersion> for pb::BlessAlternativeGuestOsVe
28312837
}
28322838
}
28332839

2840+
impl From<pb::UpdateStandardEngineReplicaVersion> for api::UpdateStandardEngineReplicaVersion {
2841+
fn from(item: pb::UpdateStandardEngineReplicaVersion) -> Self {
2842+
Self {
2843+
new_replica_version_id: Some(item.new_replica_version_id),
2844+
old_replica_version_id: Some(item.old_replica_version_id),
2845+
deployment_progress: Some(item.deployment_progress),
2846+
}
2847+
}
2848+
}
2849+
2850+
impl From<api::UpdateStandardEngineReplicaVersion> for pb::UpdateStandardEngineReplicaVersion {
2851+
fn from(item: api::UpdateStandardEngineReplicaVersion) -> Self {
2852+
Self {
2853+
// These are string fields. Therefore, if no value is supplied,
2854+
// unwrap_or_default returns an empty string, which will be rejected
2855+
// later (during proposal creation time), because we require that
2856+
// these fields have the shape of a git commit ID.
2857+
new_replica_version_id: item.new_replica_version_id.unwrap_or_default(),
2858+
old_replica_version_id: item.old_replica_version_id.unwrap_or_default(),
2859+
// -1.0 is a "poison" value. That way, we do not make the unfounded
2860+
// assumption that the user intended that deployment_progress be set
2861+
// to 0.0.
2862+
deployment_progress: item.deployment_progress.unwrap_or(-1.0),
2863+
}
2864+
}
2865+
}
2866+
28342867
impl From<pb::LoadCanisterSnapshot> for api::LoadCanisterSnapshot {
28352868
fn from(item: pb::LoadCanisterSnapshot) -> Self {
28362869
Self {

rs/nns/governance/src/pb/proposal_conversions.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ fn convert_action(
273273
pb::proposal::Action::LoadCanisterSnapshot(v) => {
274274
api::proposal::Action::LoadCanisterSnapshot(v.clone().into())
275275
}
276+
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v) => {
277+
api::proposal::Action::UpdateStandardEngineReplicaVersion(v.clone().into())
278+
}
276279

277280
// The action types with potentially large fields need to be converted in a way that avoids
278281
// cloning the action first.

rs/nns/governance/src/proposals/mod.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::{
55
CreateServiceNervousSystem, DeregisterKnownNeuron, GovernanceError, InstallCode,
66
KnownNeuron, LoadCanisterSnapshot, ManageNeuron, Motion, NetworkEconomics, ProposalData,
77
RewardNodeProvider, RewardNodeProviders, SelfDescribingProposalAction, StopOrStartCanister,
8-
TakeCanisterSnapshot, Topic, UpdateCanisterSettings, Vote, governance_error::ErrorType,
9-
proposal::Action,
8+
TakeCanisterSnapshot, Topic, UpdateCanisterSettings, UpdateStandardEngineReplicaVersion,
9+
Vote, governance_error::ErrorType, proposal::Action,
1010
},
1111
proposals::{
1212
add_or_remove_node_provider::ValidAddOrRemoveNodeProvider,
@@ -36,6 +36,7 @@ pub mod self_describing;
3636
pub mod stop_or_start_canister;
3737
pub mod take_canister_snapshot;
3838
pub mod update_canister_settings;
39+
pub mod update_standard_engine_replica_version;
3940
pub mod wasm_module;
4041

4142
mod decode_candid_args_to_self_describing_value;
@@ -64,6 +65,7 @@ pub(crate) enum ValidProposalAction {
6465
TakeCanisterSnapshot(TakeCanisterSnapshot),
6566
LoadCanisterSnapshot(LoadCanisterSnapshot),
6667
CreateCanisterAndInstallCode(CreateCanisterAndInstallCode),
68+
UpdateStandardEngineReplicaVersion(UpdateStandardEngineReplicaVersion),
6769
}
6870

6971
impl TryFrom<Option<Action>> for ValidProposalAction {
@@ -133,6 +135,11 @@ impl TryFrom<Option<Action>> for ValidProposalAction {
133135
Action::CreateCanisterAndInstallCode(create_canister_and_install_code) => Ok(
134136
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code),
135137
),
138+
Action::UpdateStandardEngineReplicaVersion(update_standard_engine_replica_version) => {
139+
Ok(ValidProposalAction::UpdateStandardEngineReplicaVersion(
140+
update_standard_engine_replica_version,
141+
))
142+
}
136143

137144
// Obsolete actions
138145
Action::SetDefaultFollowees(_) => Err(GovernanceError::new_with_message(
@@ -186,6 +193,9 @@ impl ValidProposalAction {
186193
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code) => {
187194
create_canister_and_install_code.valid_topic()?
188195
}
196+
ValidProposalAction::UpdateStandardEngineReplicaVersion(
197+
update_standard_engine_replica_version,
198+
) => update_standard_engine_replica_version.valid_topic(),
189199
};
190200
Ok(topic)
191201
}
@@ -282,6 +292,11 @@ impl ValidProposalAction {
282292
create_canister_and_install_code.abridge(),
283293
))
284294
}
295+
ValidProposalAction::UpdateStandardEngineReplicaVersion(
296+
update_standard_engine_replica_version,
297+
) => Ok(SelfDescribingProposalAction::from(
298+
update_standard_engine_replica_version.clone(),
299+
)),
285300
ValidProposalAction::RewardNodeProvider(reward_node_provider) => Ok(
286301
SelfDescribingProposalAction::from(reward_node_provider.clone()),
287302
),

0 commit comments

Comments
 (0)