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
12 changes: 12 additions & 0 deletions rs/nns/governance/api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ pub mod proposal {
LoadCanisterSnapshot(super::LoadCanisterSnapshot),
/// Create a canister in a (possibly non-NNS) subnet and install code into it.
CreateCanisterAndInstallCode(super::CreateCanisterAndInstallCode),
/// Change what replica version(s) are run by Cloud Engines.
UpdateStandardEngineReplicaVersion(super::UpdateStandardEngineReplicaVersion),
}
}
/// Empty message to use in oneof fields that represent empty
Expand Down Expand Up @@ -1454,6 +1456,7 @@ pub enum ProposalActionRequest {
TakeCanisterSnapshot(TakeCanisterSnapshot),
LoadCanisterSnapshot(LoadCanisterSnapshot),
CreateCanisterAndInstallCode(CreateCanisterAndInstallCodeRequest),
UpdateStandardEngineReplicaVersion(UpdateStandardEngineReplicaVersion),
}

#[derive(
Expand Down Expand Up @@ -2843,6 +2846,15 @@ pub struct BlessAlternativeGuestOsVersion {
pub base_guest_launch_measurements: Option<GuestLaunchMeasurements>,
}

#[derive(
candid::CandidType, candid::Deserialize, serde::Serialize, Clone, PartialEq, Debug, Default,
)]
pub struct UpdateStandardEngineReplicaVersion {
pub new_replica_version_id: Option<String>,
pub old_replica_version_id: Option<String>,
pub deployment_progress: Option<f64>,
}

/// See also the definition of GuestLaunchMeasurements (plural!) in
/// rs/protobuf/def/registry/replica_version/v1/replica_version.proto
#[derive(
Expand Down
9 changes: 9 additions & 0 deletions rs/nns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Action = variant {
TakeCanisterSnapshot : TakeCanisterSnapshot;
LoadCanisterSnapshot : LoadCanisterSnapshot;
CreateCanisterAndInstallCode : CreateCanisterAndInstallCode;
UpdateStandardEngineReplicaVersion : UpdateStandardEngineReplicaVersion;
};

type AddHotKey = record {
Expand Down Expand Up @@ -1096,6 +1097,7 @@ type ProposalActionRequest = variant {
TakeCanisterSnapshot : TakeCanisterSnapshot;
LoadCanisterSnapshot : LoadCanisterSnapshot;
CreateCanisterAndInstallCode : CreateCanisterAndInstallCodeRequest;
UpdateStandardEngineReplicaVersion : UpdateStandardEngineReplicaVersion;
};

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

// Changes what replica version(s) are run by Cloud Engines.
type UpdateStandardEngineReplicaVersion = record {
new_replica_version_id : opt text;
old_replica_version_id : opt text;
deployment_progress : opt float64;
};

type GuestLaunchMeasurements = record {
guest_launch_measurements : opt vec GuestLaunchMeasurement;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ message Proposal {
LoadCanisterSnapshot load_canister_snapshot = 33;
// Create a canister in a (possibly non-NNS) subnet and install code into it.
CreateCanisterAndInstallCode create_canister_and_install_code = 34;
// Change what replica version(s) are run by Cloud Engines.
UpdateStandardEngineReplicaVersion update_standard_engine_replica_version = 35;
}
}

Expand Down Expand Up @@ -2010,6 +2012,14 @@ message BlessAlternativeGuestOsVersion {
registry.replica_version.v1.GuestLaunchMeasurements base_guest_launch_measurements = 3;
}

// Changes what replica version(s) are run by Cloud Engines. See Registry's
// do_update_standard_engine_replica_version for what changes are allowed.
message UpdateStandardEngineReplicaVersion {
string new_replica_version_id = 1;
string old_replica_version_id = 2;
double deployment_progress = 3;
}

message LoadCanisterSnapshot {
// The ID of the canister to load the snapshot into.
ic_base_types.pb.v1.PrincipalId canister_id = 1;
Expand Down
24 changes: 23 additions & 1 deletion rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ pub struct Proposal {
/// take.
#[prost(
oneof = "proposal::Action",
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 29, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34"
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 29, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, 34, 35"
)]
pub action: ::core::option::Option<proposal::Action>,
}
Expand Down Expand Up @@ -585,6 +585,9 @@ pub mod proposal {
/// Create a canister in a (possibly non-NNS) subnet and install code into it.
#[prost(message, tag = "34")]
CreateCanisterAndInstallCode(super::CreateCanisterAndInstallCode),
/// Change what replica version(s) are run by Cloud Engines.
#[prost(message, tag = "35")]
UpdateStandardEngineReplicaVersion(super::UpdateStandardEngineReplicaVersion),
}
}
/// Take a canister snapshot.
Expand Down Expand Up @@ -3159,6 +3162,25 @@ pub struct BlessAlternativeGuestOsVersion {
::ic_protobuf::registry::replica_version::v1::GuestLaunchMeasurements,
>,
}
/// Changes what replica version(s) are run by Cloud Engines. See Registry's
/// do_update_standard_engine_replica_version for what changes are allowed.
#[derive(
candid::CandidType,
candid::Deserialize,
serde::Serialize,
comparable::Comparable,
Clone,
PartialEq,
::prost::Message,
)]
pub struct UpdateStandardEngineReplicaVersion {
#[prost(string, tag = "1")]
pub new_replica_version_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub old_replica_version_id: ::prost::alloc::string::String,
#[prost(double, tag = "3")]
pub deployment_progress: f64,
}
#[derive(
candid::CandidType,
candid::Deserialize,
Expand Down
12 changes: 12 additions & 0 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ impl Action {
Action::TakeCanisterSnapshot(_) => "ACTION_TAKE_CANISTER_SNAPSHOT",
Action::LoadCanisterSnapshot(_) => "ACTION_LOAD_CANISTER_SNAPSHOT",
Action::CreateCanisterAndInstallCode(_) => "ACTION_CREATE_CANISTER_AND_INSTALL_CODE",
Action::UpdateStandardEngineReplicaVersion(_) => {
"ACTION_UPDATE_STANDARD_ENGINE_REPLICA_VERSION"
}
}
}
}
Expand Down Expand Up @@ -4282,6 +4285,12 @@ impl Governance {
self.perform_call_canister(pid, create_canister_and_install_code)
.await;
}
ValidProposalAction::UpdateStandardEngineReplicaVersion(
update_standard_engine_replica_version,
) => {
self.perform_call_canister(pid, update_standard_engine_replica_version)
.await;
}
}
}

Expand Down Expand Up @@ -4920,6 +4929,9 @@ impl Governance {
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code) => {
create_canister_and_install_code.validate()
}
ValidProposalAction::UpdateStandardEngineReplicaVersion(
update_standard_engine_replica_version,
) => update_standard_engine_replica_version.validate(),
}
}

Expand Down
33 changes: 33 additions & 0 deletions rs/nns/governance/src/pb/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ impl From<api::proposal::Action> for pb::proposal::Action {
api::proposal::Action::CreateCanisterAndInstallCode(v) => {
pb::proposal::Action::CreateCanisterAndInstallCode(v.into())
}
api::proposal::Action::UpdateStandardEngineReplicaVersion(v) => {
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v.into())
}
}
}
}
Expand Down Expand Up @@ -530,6 +533,9 @@ impl From<api::ProposalActionRequest> for pb::proposal::Action {
api::ProposalActionRequest::CreateCanisterAndInstallCode(v) => {
pb::proposal::Action::CreateCanisterAndInstallCode(v.into())
}
api::ProposalActionRequest::UpdateStandardEngineReplicaVersion(v) => {
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v.into())
}
}
}
}
Expand Down Expand Up @@ -2831,6 +2837,33 @@ impl From<api::BlessAlternativeGuestOsVersion> for pb::BlessAlternativeGuestOsVe
}
}

impl From<pb::UpdateStandardEngineReplicaVersion> for api::UpdateStandardEngineReplicaVersion {
fn from(item: pb::UpdateStandardEngineReplicaVersion) -> Self {
Self {
new_replica_version_id: Some(item.new_replica_version_id),
old_replica_version_id: Some(item.old_replica_version_id),
deployment_progress: Some(item.deployment_progress),
}
}
}

impl From<api::UpdateStandardEngineReplicaVersion> for pb::UpdateStandardEngineReplicaVersion {
fn from(item: api::UpdateStandardEngineReplicaVersion) -> Self {
Self {
// These are string fields. Therefore, if no value is supplied,
// unwrap_or_default returns an empty string, which will be rejected
// later (during proposal creation time), because we require that
// these fields have the shape of a git commit ID.
new_replica_version_id: item.new_replica_version_id.unwrap_or_default(),
old_replica_version_id: item.old_replica_version_id.unwrap_or_default(),
// -1.0 is a "poison" value. That way, we do not make the unfounded
// assumption that the user intended that deployment_progress be set
// to 0.0.
deployment_progress: item.deployment_progress.unwrap_or(-1.0),
}
}
}

impl From<pb::LoadCanisterSnapshot> for api::LoadCanisterSnapshot {
fn from(item: pb::LoadCanisterSnapshot) -> Self {
Self {
Expand Down
3 changes: 3 additions & 0 deletions rs/nns/governance/src/pb/proposal_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ fn convert_action(
pb::proposal::Action::LoadCanisterSnapshot(v) => {
api::proposal::Action::LoadCanisterSnapshot(v.clone().into())
}
pb::proposal::Action::UpdateStandardEngineReplicaVersion(v) => {
api::proposal::Action::UpdateStandardEngineReplicaVersion(v.clone().into())
}

// The action types with potentially large fields need to be converted in a way that avoids
// cloning the action first.
Expand Down
19 changes: 17 additions & 2 deletions rs/nns/governance/src/proposals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
CreateServiceNervousSystem, DeregisterKnownNeuron, GovernanceError, InstallCode,
KnownNeuron, LoadCanisterSnapshot, ManageNeuron, Motion, NetworkEconomics, ProposalData,
RewardNodeProvider, RewardNodeProviders, SelfDescribingProposalAction, StopOrStartCanister,
TakeCanisterSnapshot, Topic, UpdateCanisterSettings, Vote, governance_error::ErrorType,
proposal::Action,
TakeCanisterSnapshot, Topic, UpdateCanisterSettings, UpdateStandardEngineReplicaVersion,
Vote, governance_error::ErrorType, proposal::Action,
},
proposals::{
add_or_remove_node_provider::ValidAddOrRemoveNodeProvider,
Expand Down Expand Up @@ -36,6 +36,7 @@ pub mod self_describing;
pub mod stop_or_start_canister;
pub mod take_canister_snapshot;
pub mod update_canister_settings;
pub mod update_standard_engine_replica_version;
pub mod wasm_module;

mod decode_candid_args_to_self_describing_value;
Expand Down Expand Up @@ -64,6 +65,7 @@ pub(crate) enum ValidProposalAction {
TakeCanisterSnapshot(TakeCanisterSnapshot),
LoadCanisterSnapshot(LoadCanisterSnapshot),
CreateCanisterAndInstallCode(CreateCanisterAndInstallCode),
UpdateStandardEngineReplicaVersion(UpdateStandardEngineReplicaVersion),
}

impl TryFrom<Option<Action>> for ValidProposalAction {
Expand Down Expand Up @@ -133,6 +135,11 @@ impl TryFrom<Option<Action>> for ValidProposalAction {
Action::CreateCanisterAndInstallCode(create_canister_and_install_code) => Ok(
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code),
),
Action::UpdateStandardEngineReplicaVersion(update_standard_engine_replica_version) => {
Ok(ValidProposalAction::UpdateStandardEngineReplicaVersion(
update_standard_engine_replica_version,
))
}

// Obsolete actions
Action::SetDefaultFollowees(_) => Err(GovernanceError::new_with_message(
Expand Down Expand Up @@ -186,6 +193,9 @@ impl ValidProposalAction {
ValidProposalAction::CreateCanisterAndInstallCode(create_canister_and_install_code) => {
create_canister_and_install_code.valid_topic()?
}
ValidProposalAction::UpdateStandardEngineReplicaVersion(
update_standard_engine_replica_version,
) => update_standard_engine_replica_version.valid_topic(),
};
Ok(topic)
}
Expand Down Expand Up @@ -282,6 +292,11 @@ impl ValidProposalAction {
create_canister_and_install_code.abridge(),
))
}
ValidProposalAction::UpdateStandardEngineReplicaVersion(
update_standard_engine_replica_version,
) => Ok(SelfDescribingProposalAction::from(
update_standard_engine_replica_version.clone(),
)),
ValidProposalAction::RewardNodeProvider(reward_node_provider) => Ok(
SelfDescribingProposalAction::from(reward_node_provider.clone()),
),
Expand Down
Loading
Loading