Skip to content

Commit

Permalink
Support update_canister_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonz-dfinity committed Jul 22, 2024
1 parent b3ac417 commit 1449ef6
Show file tree
Hide file tree
Showing 10 changed files with 620 additions and 4 deletions.
94 changes: 93 additions & 1 deletion rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ pub struct Proposal {
/// take.
#[prost(
oneof = "proposal::Action",
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26"
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27"
)]
pub action: ::core::option::Option<proposal::Action>,
}
Expand Down Expand Up @@ -651,6 +651,9 @@ pub mod proposal {
/// Stops or starts a canister controlled by Root.
#[prost(message, tag = "26")]
StopOrStartCanister(super::StopOrStartCanister),
/// Updates canister settings for those controlled by NNS Root.
#[prost(message, tag = "27")]
UpdateCanisterSettings(super::UpdateCanisterSettings),
}
}
/// Empty message to use in oneof fields that represent empty
Expand Down Expand Up @@ -2432,6 +2435,95 @@ pub mod stop_or_start_canister {
}
}
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateCanisterSettings {
/// The target canister ID to call update_settings on. Required.
#[prost(message, optional, tag = "1")]
pub canister_id: ::core::option::Option<::ic_base_types::PrincipalId>,
/// The settings to update. Required.
#[prost(message, optional, tag = "2")]
pub settings: ::core::option::Option<update_canister_settings::CanisterSettings>,
}
/// Nested message and enum types in `UpdateCanisterSettings`.
pub mod update_canister_settings {
/// The controllers of the canister. We use a message to wrap the repeated field because prost does
/// not generate `Option<Vec<T>>` for repeated fields.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Controllers {
/// The controllers of the canister.
#[prost(message, repeated, tag = "1")]
pub controllers: ::prost::alloc::vec::Vec<::ic_base_types::PrincipalId>,
}
/// The CanisterSettings struct as defined in the ic-interface-spec
/// <https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-candid.>
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CanisterSettings {
#[prost(message, optional, tag = "1")]
pub controllers: ::core::option::Option<Controllers>,
#[prost(uint64, optional, tag = "2")]
pub compute_allocation: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "3")]
pub memory_allocation: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "4")]
pub freezing_threshold: ::core::option::Option<u64>,
#[prost(enumeration = "LogVisibility", optional, tag = "5")]
pub log_visibility: ::core::option::Option<i32>,
#[prost(uint64, optional, tag = "6")]
pub wasm_memory_limit: ::core::option::Option<u64>,
}
/// Log visibility of a canister.
#[derive(
candid::CandidType,
candid::Deserialize,
serde::Serialize,
comparable::Comparable,
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration,
)]
#[repr(i32)]
pub enum LogVisibility {
Unspecified = 0,
/// The log is visible to the controllers of the dapp canister.
Controllers = 1,
/// The log is visible to the public.
Public = 2,
}
impl LogVisibility {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
LogVisibility::Unspecified => "LOG_VISIBILITY_UNSPECIFIED",
LogVisibility::Controllers => "LOG_VISIBILITY_CONTROLLERS",
LogVisibility::Public => "LOG_VISIBILITY_PUBLIC",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"LOG_VISIBILITY_UNSPECIFIED" => Some(Self::Unspecified),
"LOG_VISIBILITY_CONTROLLERS" => Some(Self::Controllers),
"LOG_VISIBILITY_PUBLIC" => Some(Self::Public),
_ => None,
}
}
}
}
/// This represents the whole NNS governance system. It contains all
/// information about the NNS governance system that must be kept
/// across upgrades of the NNS governance system.
Expand Down
14 changes: 14 additions & 0 deletions rs/nns/governance/canister/governance.did
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type AccountIdentifier = record { hash : blob };
type Action = variant {
RegisterKnownNeuron : KnownNeuron;
ManageNeuron : ManageNeuron;
UpdateCanisterSettings : UpdateCanisterSettings;
InstallCode : InstallCode;
StopOrStartCanister : StopOrStartCanister;
CreateServiceNervousSystem : CreateServiceNervousSystem;
Expand All @@ -28,6 +29,14 @@ type By = variant {
Memo : nat64;
};
type Canister = record { id : opt principal };
type CanisterSettings = record {
freezing_threshold : opt nat64;
controllers : opt Controllers;
log_visibility : opt int32;
wasm_memory_limit : opt nat64;
memory_allocation : opt nat64;
compute_allocation : opt nat64;
};
type CanisterStatusResultV2 = record {
status : opt int32;
freezing_threshold : opt nat64;
Expand Down Expand Up @@ -114,6 +123,7 @@ type Committed_1 = record {
sns_governance_canister_id : opt principal;
};
type Configure = record { operation : opt Operation };
type Controllers = record { controllers : vec principal };
type Countries = record { iso_codes : vec text };
type CreateServiceNervousSystem = record {
url : opt text;
Expand Down Expand Up @@ -689,6 +699,10 @@ type TimeWindow = record {
end_timestamp_seconds : nat64;
};
type Tokens = record { e8s : opt nat64 };
type UpdateCanisterSettings = record {
canister_id : opt principal;
settings : opt CanisterSettings;
};
type UpdateNodeProvider = record { reward_account : opt AccountIdentifier };
type VotingRewardParameters = record {
reward_rate_transition_duration : opt Duration;
Expand Down
14 changes: 14 additions & 0 deletions rs/nns/governance/canister/governance_test.did
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type AccountIdentifier = record { hash : blob };
type Action = variant {
RegisterKnownNeuron : KnownNeuron;
ManageNeuron : ManageNeuron;
UpdateCanisterSettings : UpdateCanisterSettings;
InstallCode : InstallCode;
StopOrStartCanister : StopOrStartCanister;
CreateServiceNervousSystem : CreateServiceNervousSystem;
Expand All @@ -28,6 +29,14 @@ type By = variant {
Memo : nat64;
};
type Canister = record { id : opt principal };
type CanisterSettings = record {
freezing_threshold : opt nat64;
controllers : opt Controllers;
log_visibility : opt int32;
wasm_memory_limit : opt nat64;
memory_allocation : opt nat64;
compute_allocation : opt nat64;
};
type CanisterStatusResultV2 = record {
status : opt int32;
freezing_threshold : opt nat64;
Expand Down Expand Up @@ -114,6 +123,7 @@ type Committed_1 = record {
sns_governance_canister_id : opt principal;
};
type Configure = record { operation : opt Operation };
type Controllers = record { controllers : vec principal };
type Countries = record { iso_codes : vec text };
type CreateServiceNervousSystem = record {
url : opt text;
Expand Down Expand Up @@ -689,6 +699,10 @@ type TimeWindow = record {
end_timestamp_seconds : nat64;
};
type Tokens = record { e8s : opt nat64 };
type UpdateCanisterSettings = record {
canister_id : opt principal;
settings : opt CanisterSettings;
};
type UpdateNodeProvider = record { reward_account : opt AccountIdentifier };
type VotingRewardParameters = record {
reward_rate_transition_duration : opt Duration;
Expand Down
37 changes: 37 additions & 0 deletions rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ message Proposal {
InstallCode install_code = 25;
// Stops or starts a canister controlled by Root.
StopOrStartCanister stop_or_start_canister = 26;
// Updates canister settings for those controlled by NNS Root.
UpdateCanisterSettings update_canister_settings = 27;
}
}

Expand Down Expand Up @@ -2086,6 +2088,41 @@ message StopOrStartCanister {
optional CanisterAction action = 2;
}

message UpdateCanisterSettings {
// The target canister ID to call update_settings on. Required.
optional ic_base_types.pb.v1.PrincipalId canister_id = 1;

// Log visibility of a canister.
enum LogVisibility {
LOG_VISIBILITY_UNSPECIFIED = 0;
// The log is visible to the controllers of the dapp canister.
LOG_VISIBILITY_CONTROLLERS = 1;
// The log is visible to the public.
LOG_VISIBILITY_PUBLIC = 2;
}

// The controllers of the canister. We use a message to wrap the repeated field because prost does
// not generate `Option<Vec<T>>` for repeated fields.
message Controllers {
// The controllers of the canister.
repeated ic_base_types.pb.v1.PrincipalId controllers = 1;
}

// The CanisterSettings struct as defined in the ic-interface-spec
// https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-candid.
message CanisterSettings {
optional Controllers controllers = 1;
optional uint64 compute_allocation = 2;
optional uint64 memory_allocation = 3;
optional uint64 freezing_threshold = 4;
optional LogVisibility log_visibility = 5;
optional uint64 wasm_memory_limit = 6;
}

// The settings to update. Required.
optional CanisterSettings settings = 2;
}

// This represents the whole NNS governance system. It contains all
// information about the NNS governance system that must be kept
// across upgrades of the NNS governance system.
Expand Down
94 changes: 93 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 @@ -560,7 +560,7 @@ pub struct Proposal {
/// take.
#[prost(
oneof = "proposal::Action",
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26"
tags = "10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27"
)]
pub action: ::core::option::Option<proposal::Action>,
}
Expand Down Expand Up @@ -651,6 +651,9 @@ pub mod proposal {
/// Stops or starts a canister controlled by Root.
#[prost(message, tag = "26")]
StopOrStartCanister(super::StopOrStartCanister),
/// Updates canister settings for those controlled by NNS Root.
#[prost(message, tag = "27")]
UpdateCanisterSettings(super::UpdateCanisterSettings),
}
}
/// Empty message to use in oneof fields that represent empty
Expand Down Expand Up @@ -2432,6 +2435,95 @@ pub mod stop_or_start_canister {
}
}
}
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateCanisterSettings {
/// The target canister ID to call update_settings on. Required.
#[prost(message, optional, tag = "1")]
pub canister_id: ::core::option::Option<::ic_base_types::PrincipalId>,
/// The settings to update. Required.
#[prost(message, optional, tag = "2")]
pub settings: ::core::option::Option<update_canister_settings::CanisterSettings>,
}
/// Nested message and enum types in `UpdateCanisterSettings`.
pub mod update_canister_settings {
/// The controllers of the canister. We use a message to wrap the repeated field because prost does
/// not generate `Option<Vec<T>>` for repeated fields.
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Controllers {
/// The controllers of the canister.
#[prost(message, repeated, tag = "1")]
pub controllers: ::prost::alloc::vec::Vec<::ic_base_types::PrincipalId>,
}
/// The CanisterSettings struct as defined in the ic-interface-spec
/// <https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-candid.>
#[derive(candid::CandidType, candid::Deserialize, serde::Serialize, comparable::Comparable)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CanisterSettings {
#[prost(message, optional, tag = "1")]
pub controllers: ::core::option::Option<Controllers>,
#[prost(uint64, optional, tag = "2")]
pub compute_allocation: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "3")]
pub memory_allocation: ::core::option::Option<u64>,
#[prost(uint64, optional, tag = "4")]
pub freezing_threshold: ::core::option::Option<u64>,
#[prost(enumeration = "LogVisibility", optional, tag = "5")]
pub log_visibility: ::core::option::Option<i32>,
#[prost(uint64, optional, tag = "6")]
pub wasm_memory_limit: ::core::option::Option<u64>,
}
/// Log visibility of a canister.
#[derive(
candid::CandidType,
candid::Deserialize,
serde::Serialize,
comparable::Comparable,
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration,
)]
#[repr(i32)]
pub enum LogVisibility {
Unspecified = 0,
/// The log is visible to the controllers of the dapp canister.
Controllers = 1,
/// The log is visible to the public.
Public = 2,
}
impl LogVisibility {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
LogVisibility::Unspecified => "LOG_VISIBILITY_UNSPECIFIED",
LogVisibility::Controllers => "LOG_VISIBILITY_CONTROLLERS",
LogVisibility::Public => "LOG_VISIBILITY_PUBLIC",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"LOG_VISIBILITY_UNSPECIFIED" => Some(Self::Unspecified),
"LOG_VISIBILITY_CONTROLLERS" => Some(Self::Controllers),
"LOG_VISIBILITY_PUBLIC" => Some(Self::Public),
_ => None,
}
}
}
}
/// This represents the whole NNS governance system. It contains all
/// information about the NNS governance system that must be kept
/// across upgrades of the NNS governance system.
Expand Down
Loading

0 comments on commit 1449ef6

Please sign in to comment.