diff --git a/rs/nervous_system/clients/src/canister_status.rs b/rs/nervous_system/clients/src/canister_status.rs index 816875edb8f..1b95ee0692e 100644 --- a/rs/nervous_system/clients/src/canister_status.rs +++ b/rs/nervous_system/clients/src/canister_status.rs @@ -66,6 +66,7 @@ pub struct DefiniteCanisterSettings { pub reserved_cycles_limit: Option, pub wasm_memory_limit: Option, pub log_visibility: Option, + pub wasm_memory_threshold: Option, } /// Partial copy-paste of ic-types::ic_00::CanisterStatusResult. @@ -111,6 +112,7 @@ pub struct DefiniteCanisterSettingsFromManagementCanister { pub reserved_cycles_limit: candid::Nat, pub wasm_memory_limit: candid::Nat, pub log_visibility: LogVisibility, + pub wasm_memory_threshold: candid::Nat, } impl From for CanisterStatusResult { @@ -152,6 +154,7 @@ impl From for DefiniteCanisterSe reserved_cycles_limit, wasm_memory_limit, log_visibility, + wasm_memory_threshold, } = value; let compute_allocation = Some(compute_allocation); @@ -160,6 +163,7 @@ impl From for DefiniteCanisterSe let reserved_cycles_limit = Some(reserved_cycles_limit); let wasm_memory_limit = Some(wasm_memory_limit); let log_visibility = Some(log_visibility); + let wasm_memory_threshold = Some(wasm_memory_threshold); DefiniteCanisterSettings { controllers, @@ -169,6 +173,7 @@ impl From for DefiniteCanisterSe reserved_cycles_limit, wasm_memory_limit, log_visibility, + wasm_memory_threshold, } } } @@ -193,6 +198,7 @@ impl CanisterStatusResultFromManagementCanister { reserved_cycles_limit: candid::Nat::from(47_u32), wasm_memory_limit: candid::Nat::from(48_u32), log_visibility: LogVisibility::Controllers, + wasm_memory_threshold: candid::Nat::from(49_u32), }, cycles: candid::Nat::from(47_u32), idle_cycles_burned_per_day: candid::Nat::from(48_u32), @@ -237,6 +243,7 @@ impl CanisterStatusResultV2 { freezing_threshold: u64, idle_cycles_burned_per_day: u128, wasm_memory_limit: u64, + wasm_memory_threshold: u64, ) -> Self { Self { status, @@ -251,6 +258,7 @@ impl CanisterStatusResultV2 { memory_allocation, freezing_threshold, Some(wasm_memory_limit), + Some(wasm_memory_threshold), ), idle_cycles_burned_per_day: candid::Nat::from(idle_cycles_burned_per_day), } @@ -297,6 +305,7 @@ impl CanisterStatusResultV2 { 45, // freezing_threshold 46, // idle_cycles_burned_per_day 47, // wasm_memory_limit + 41, // wasm_memory_threshold ) } @@ -318,6 +327,7 @@ pub struct DefiniteCanisterSettingsArgs { pub memory_allocation: candid::Nat, pub freezing_threshold: candid::Nat, pub wasm_memory_limit: Option, + pub wasm_memory_threshold: Option, } impl From @@ -330,6 +340,7 @@ impl From memory_allocation: settings.memory_allocation(), freezing_threshold: settings.freezing_threshold(), wasm_memory_limit: Some(settings.wasm_memory_limit()), + wasm_memory_threshold: Some(settings.wasm_memory_threshold()), } } } @@ -341,6 +352,7 @@ impl DefiniteCanisterSettingsArgs { memory_allocation: Option, freezing_threshold: u64, wasm_memory_limit: Option, + wasm_memory_threshold: Option, ) -> Self { let memory_allocation = match memory_allocation { None => candid::Nat::from(0_u32), @@ -352,6 +364,7 @@ impl DefiniteCanisterSettingsArgs { memory_allocation, freezing_threshold: candid::Nat::from(freezing_threshold), wasm_memory_limit: wasm_memory_limit.map(candid::Nat::from), + wasm_memory_threshold: wasm_memory_threshold.map(candid::Nat::from), } } @@ -383,6 +396,7 @@ impl From for CanisterStatusResultV2 memory_allocation: value.settings.memory_allocation, freezing_threshold: value.settings.freezing_threshold, wasm_memory_limit: Some(value.settings.wasm_memory_limit), + wasm_memory_threshold: Some(value.settings.wasm_memory_threshold), }, memory_size: value.memory_size, cycles: value.cycles, @@ -417,6 +431,7 @@ mod tests { reserved_cycles_limit: candid::Nat::from(96_u32), wasm_memory_limit: candid::Nat::from(95_u32), log_visibility: LogVisibility::Controllers, + wasm_memory_threshold: candid::Nat::from(94_u32), }, cycles: candid::Nat::from(999_u32), idle_cycles_burned_per_day: candid::Nat::from(998_u32), @@ -435,6 +450,7 @@ mod tests { reserved_cycles_limit: Some(candid::Nat::from(96_u32)), wasm_memory_limit: Some(candid::Nat::from(95_u32)), log_visibility: Some(LogVisibility::Controllers), + wasm_memory_threshold: Some(candid::Nat::from(94_u32)), }, cycles: candid::Nat::from(999_u32), idle_cycles_burned_per_day: Some(candid::Nat::from(998_u32)), diff --git a/rs/nervous_system/clients/src/management_canister_client/tests.rs b/rs/nervous_system/clients/src/management_canister_client/tests.rs index 7dd0c0a3042..fe6cd4ca7c1 100644 --- a/rs/nervous_system/clients/src/management_canister_client/tests.rs +++ b/rs/nervous_system/clients/src/management_canister_client/tests.rs @@ -115,6 +115,7 @@ async fn test_limit_outstanding_calls() { reserved_cycles_limit: zero.clone(), wasm_memory_limit: zero.clone(), log_visibility: LogVisibility::Controllers, + wasm_memory_threshold: zero.clone(), }, status: CanisterStatusType::Running, reserved_cycles: zero.clone(), diff --git a/rs/nervous_system/clients/src/update_settings.rs b/rs/nervous_system/clients/src/update_settings.rs index 14fa3efdf0d..56acee4adbf 100644 --- a/rs/nervous_system/clients/src/update_settings.rs +++ b/rs/nervous_system/clients/src/update_settings.rs @@ -33,6 +33,7 @@ pub struct CanisterSettings { pub reserved_cycles_limit: Option, pub log_visibility: Option, pub wasm_memory_limit: Option, + pub wasm_memory_threshold: Option, } /// A wrapper call to the management canister `update_settings` API. diff --git a/rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs b/rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs index 93cf0fe101f..ee7f9705904 100644 --- a/rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs +++ b/rs/nns/governance/api/src/ic_nns_governance.pb.v1.rs @@ -2713,6 +2713,8 @@ pub mod update_canister_settings { pub log_visibility: Option, #[prost(uint64, optional, tag = "6")] pub wasm_memory_limit: Option, + #[prost(uint64, optional, tag = "7")] + pub wasm_memory_threshold: Option, } /// Log visibility of a canister. #[derive( diff --git a/rs/nns/governance/canister/governance.did b/rs/nns/governance/canister/governance.did index e1e6dd57a4a..ea1acbcdec5 100644 --- a/rs/nns/governance/canister/governance.did +++ b/rs/nns/governance/canister/governance.did @@ -64,6 +64,7 @@ type CanisterSettings = record { wasm_memory_limit : opt nat64; memory_allocation : opt nat64; compute_allocation : opt nat64; + wasm_memory_threshold : opt nat64; }; type CanisterStatusResultV2 = record { diff --git a/rs/nns/governance/canister/governance_test.did b/rs/nns/governance/canister/governance_test.did index d08d42a0258..691764b9a11 100644 --- a/rs/nns/governance/canister/governance_test.did +++ b/rs/nns/governance/canister/governance_test.did @@ -64,6 +64,7 @@ type CanisterSettings = record { wasm_memory_limit : opt nat64; memory_allocation : opt nat64; compute_allocation : opt nat64; + wasm_memory_threshold : opt nat64; }; type CanisterStatusResultV2 = record { diff --git a/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto b/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto index 8aeefb110ef..7db94271fc0 100644 --- a/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto +++ b/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto @@ -2257,6 +2257,7 @@ message UpdateCanisterSettings { optional uint64 freezing_threshold = 4; optional LogVisibility log_visibility = 5; optional uint64 wasm_memory_limit = 6; + optional uint64 wasm_memory_threshold = 7; } // The settings to update. Required. diff --git a/rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs b/rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs index cfd451ee5cb..bfc6f5d5de3 100644 --- a/rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs +++ b/rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs @@ -3263,6 +3263,8 @@ pub mod update_canister_settings { pub log_visibility: ::core::option::Option, #[prost(uint64, optional, tag = "6")] pub wasm_memory_limit: ::core::option::Option, + #[prost(uint64, optional, tag = "7")] + pub wasm_memory_threshold: ::core::option::Option, } /// Log visibility of a canister. #[derive( diff --git a/rs/nns/governance/src/pb/conversions.rs b/rs/nns/governance/src/pb/conversions.rs index dbd26f37952..e25e507ab52 100644 --- a/rs/nns/governance/src/pb/conversions.rs +++ b/rs/nns/governance/src/pb/conversions.rs @@ -3060,6 +3060,7 @@ impl From freezing_threshold: item.freezing_threshold, log_visibility: item.log_visibility, wasm_memory_limit: item.wasm_memory_limit, + wasm_memory_threshold: item.wasm_memory_threshold, } } } @@ -3075,6 +3076,7 @@ impl From freezing_threshold: item.freezing_threshold, log_visibility: item.log_visibility, wasm_memory_limit: item.wasm_memory_limit, + wasm_memory_threshold: item.wasm_memory_threshold, } } } diff --git a/rs/nns/governance/src/proposals/update_canister_settings.rs b/rs/nns/governance/src/proposals/update_canister_settings.rs index da4e33b95e1..c008ec352a9 100644 --- a/rs/nns/governance/src/proposals/update_canister_settings.rs +++ b/rs/nns/governance/src/proposals/update_canister_settings.rs @@ -61,6 +61,7 @@ impl UpdateCanisterSettings { && settings.freezing_threshold.is_none() && settings.log_visibility.is_none() && settings.wasm_memory_limit.is_none() + && settings.wasm_memory_threshold.is_none() { return Err(invalid_proposal_error( "At least one setting must be provided", @@ -75,6 +76,7 @@ impl UpdateCanisterSettings { let memory_allocation = settings.memory_allocation.map(Nat::from); let freezing_threshold = settings.freezing_threshold.map(Nat::from); let wasm_memory_limit = settings.wasm_memory_limit.map(Nat::from); + let wasm_memory_threshold = settings.wasm_memory_threshold.map(Nat::from); let log_visibility = match settings.log_visibility { Some(log_visibility) => Some(Self::valid_log_visibility(log_visibility)?), None => None, @@ -89,6 +91,7 @@ impl UpdateCanisterSettings { wasm_memory_limit, log_visibility, reserved_cycles_limit, + wasm_memory_threshold, }) } @@ -223,6 +226,7 @@ mod tests { }), memory_allocation: Some(1 << 32), wasm_memory_limit: Some(1 << 31), + wasm_memory_threshold: Some(1 << 30), compute_allocation: Some(10), freezing_threshold: Some(100), log_visibility: Some(LogVisibility::Public as i32), @@ -257,6 +261,7 @@ mod tests { freezing_threshold: Some(Nat::from(100u64)), log_visibility: Some(RootLogVisibility::Public), reserved_cycles_limit: None, + wasm_memory_threshold: Some(Nat::from(1u64 << 30)), } } ); @@ -273,6 +278,7 @@ mod tests { }), memory_allocation: Some(1 << 32), wasm_memory_limit: Some(1 << 31), + wasm_memory_threshold: Some(1 << 30), compute_allocation: Some(10), freezing_threshold: Some(100), log_visibility: Some(LogVisibility::Public as i32), @@ -305,6 +311,7 @@ mod tests { freezing_threshold: Some(Nat::from(100u64)), log_visibility: Some(RootLogVisibility::Public), reserved_cycles_limit: None, + wasm_memory_threshold: Some(Nat::from(1u64 << 30)), } ); } diff --git a/rs/nns/governance/tests/governance.rs b/rs/nns/governance/tests/governance.rs index a749d273bfd..e62a2d89de3 100644 --- a/rs/nns/governance/tests/governance.rs +++ b/rs/nns/governance/tests/governance.rs @@ -12644,6 +12644,7 @@ lazy_static! { 448076, // freezing_threshold 268693, // idle_cycles_burned_per_day (3.5 * (1 << 30) as f32) as u64, // wasm_memory_limit (3.5gb) + 123478, // wasm_memory_threshold )), }), governance: Some(ic_sns_root::CanisterSummary { diff --git a/rs/nns/handlers/lifeline/impl/lifeline.did b/rs/nns/handlers/lifeline/impl/lifeline.did index a591df91ee6..e3f5b403b57 100644 --- a/rs/nns/handlers/lifeline/impl/lifeline.did +++ b/rs/nns/handlers/lifeline/impl/lifeline.did @@ -15,6 +15,7 @@ type CanisterSettings = record { reserved_cycles_limit: opt nat; wasm_memory_limit: opt nat; log_visibility: opt LogVisibility; + wasm_memory_threshold: opt nat; }; type LogVisibility = variant { controllers; public }; diff --git a/rs/nns/handlers/lifeline/impl/lifeline.mo b/rs/nns/handlers/lifeline/impl/lifeline.mo index 07129722c29..76a4dbb2cdd 100644 --- a/rs/nns/handlers/lifeline/impl/lifeline.mo +++ b/rs/nns/handlers/lifeline/impl/lifeline.mo @@ -31,6 +31,7 @@ actor { reserved_cycles_limit: ?Nat; wasm_memory_limit: ?Nat; log_visibility: ?LogVisibility; + wasm_memory_threshold: ?Nat; }; // IC00 is the management canister. We rely on it for the four diff --git a/rs/nns/handlers/root/impl/canister/root.did b/rs/nns/handlers/root/impl/canister/root.did index 974d6bde7e2..ee6ab152c0b 100644 --- a/rs/nns/handlers/root/impl/canister/root.did +++ b/rs/nns/handlers/root/impl/canister/root.did @@ -30,6 +30,7 @@ type CanisterSettings = record { wasm_memory_limit : opt nat; memory_allocation : opt nat; compute_allocation : opt nat; + wasm_memory_threshold : opt nat; }; type CanisterStatusResult = record { @@ -85,6 +86,7 @@ type DefiniteCanisterSettings = record { wasm_memory_limit : opt nat; memory_allocation : opt nat; compute_allocation : opt nat; + wasm_memory_threshold : opt nat; }; type LogVisibility = variant { diff --git a/rs/nns/handlers/root/interface/src/client.rs b/rs/nns/handlers/root/interface/src/client.rs index f848ddcfabc..09d556152c0 100644 --- a/rs/nns/handlers/root/interface/src/client.rs +++ b/rs/nns/handlers/root/interface/src/client.rs @@ -220,6 +220,7 @@ impl SpyNnsRootCanisterClientReply { reserved_cycles_limit: Some(candid::Nat::from(10_u32)), wasm_memory_limit: Some(candid::Nat::from(11_u32)), log_visibility: Some(LogVisibility::Controllers), + wasm_memory_threshold: Some(candid::Nat::from(6_u32)), }, cycles: candid::Nat::from(42_u32), idle_cycles_burned_per_day: Some(candid::Nat::from(43_u32)), diff --git a/rs/nns/integration_tests/src/update_canister_settings.rs b/rs/nns/integration_tests/src/update_canister_settings.rs index d6197e954d2..5bb879388dc 100644 --- a/rs/nns/integration_tests/src/update_canister_settings.rs +++ b/rs/nns/integration_tests/src/update_canister_settings.rs @@ -36,7 +36,9 @@ fn test_update_canister_settings_proposal( let target_memory_allocation = 1u64 << 33; let target_compute_allocation = 10u64; let target_freezing_threshold = 100_000u64; - let target_wasm_memory_limit = 1u64 << 32; + // `target_wasm_memory_limit` needs to be larger than `target_wasm_memory_threshold`. + let target_wasm_memory_limit = 1u64 << 36; + let target_wasm_memory_threshold = 1u64 << 34; let target_log_visibility = Some(LogVisibility::Public); let canister_settings = || -> DefiniteCanisterSettings { get_canister_status( @@ -66,6 +68,10 @@ fn test_update_canister_settings_proposal( original_settings.wasm_memory_limit, Some(Nat::from(target_wasm_memory_limit)) ); + assert_ne!( + original_settings.wasm_memory_threshold, + Some(Nat::from(target_wasm_memory_threshold)) + ); assert_ne!(original_settings.log_visibility, target_log_visibility); // Step 3: Make a proposal to update settings of the registry canister and make sure the @@ -88,6 +94,7 @@ fn test_update_canister_settings_proposal( freezing_threshold: Some(target_freezing_threshold), wasm_memory_limit: Some(target_wasm_memory_limit), log_visibility: Some(GovernanceLogVisibility::Public as i32), + wasm_memory_threshold: Some(target_wasm_memory_threshold), }), }, )), @@ -119,6 +126,10 @@ fn test_update_canister_settings_proposal( updated_settings.wasm_memory_limit, Some(Nat::from(target_wasm_memory_limit)) ); + assert_eq!( + updated_settings.wasm_memory_threshold, + Some(Nat::from(target_wasm_memory_threshold)) + ); assert_eq!(updated_settings.log_visibility, target_log_visibility); } diff --git a/rs/registry/admin/src/main.rs b/rs/registry/admin/src/main.rs index 57c58eb69b2..f254b3d677b 100644 --- a/rs/registry/admin/src/main.rs +++ b/rs/registry/admin/src/main.rs @@ -1198,11 +1198,14 @@ struct ProposeToUpdateCanisterSettingsCmd { /// If set, it will update the canister's freezing threshold to this value. freezing_threshold: Option, #[clap(long)] - /// If set, it will update the canister's log wasm memory limit to this value. + /// If set, it will update the canister's wasm memory limit to this value. wasm_memory_limit: Option, #[clap(long)] /// If set, it will update the canister's log visibility to this value. log_visibility: Option, + #[clap(long)] + /// If set, it will update the canister's wasm memory threshold to this value. + wasm_memory_threshold: Option, } impl ProposalTitle for ProposeToUpdateCanisterSettingsCmd { @@ -1232,6 +1235,7 @@ impl ProposalAction for ProposeToUpdateCanisterSettingsCmd { let memory_allocation = self.memory_allocation; let freezing_threshold = self.freezing_threshold; let wasm_memory_limit = self.wasm_memory_limit; + let wasm_memory_threshold = self.wasm_memory_threshold; let log_visibility = match self.log_visibility { Some(LogVisibility::Controllers) => Some(GovernanceLogVisibility::Controllers as i32), Some(LogVisibility::Public) => Some(GovernanceLogVisibility::Public as i32), @@ -1247,6 +1251,7 @@ impl ProposalAction for ProposeToUpdateCanisterSettingsCmd { freezing_threshold, wasm_memory_limit, log_visibility, + wasm_memory_threshold, }), }; diff --git a/rs/sns/governance/api/src/ic_sns_governance.pb.v1.rs b/rs/sns/governance/api/src/ic_sns_governance.pb.v1.rs index e3e254480dd..da87417e25f 100644 --- a/rs/sns/governance/api/src/ic_sns_governance.pb.v1.rs +++ b/rs/sns/governance/api/src/ic_sns_governance.pb.v1.rs @@ -612,6 +612,8 @@ pub struct ManageDappCanisterSettings { pub log_visibility: ::core::option::Option, #[prost(uint64, optional, tag = "7")] pub wasm_memory_limit: ::core::option::Option, + #[prost(uint64, optional, tag = "8")] + pub wasm_memory_threshold: ::core::option::Option, } /// Unlike `Governance.Version`, this message has optional fields and is the recommended one /// to use in APIs that can evolve. For example, the SNS Governance could eventually support diff --git a/rs/sns/governance/canister/governance.did b/rs/sns/governance/canister/governance.did index df24217066d..b379d8687eb 100644 --- a/rs/sns/governance/canister/governance.did +++ b/rs/sns/governance/canister/governance.did @@ -157,6 +157,7 @@ type DefiniteCanisterSettingsArgs = record { wasm_memory_limit : opt nat; memory_allocation : nat; compute_allocation : nat; + wasm_memory_threshold : opt nat; }; type DeregisterDappCanisters = record { @@ -375,6 +376,7 @@ type ManageDappCanisterSettings = record { wasm_memory_limit : opt nat64; memory_allocation : opt nat64; compute_allocation : opt nat64; + wasm_memory_threshold : opt nat64; }; type SnsVersion = record { diff --git a/rs/sns/governance/canister/governance_test.did b/rs/sns/governance/canister/governance_test.did index 27737ff3313..4ba441aabda 100644 --- a/rs/sns/governance/canister/governance_test.did +++ b/rs/sns/governance/canister/governance_test.did @@ -166,6 +166,7 @@ type DefiniteCanisterSettingsArgs = record { wasm_memory_limit : opt nat; memory_allocation : nat; compute_allocation : nat; + wasm_memory_threshold : opt nat; }; type DeregisterDappCanisters = record { @@ -384,6 +385,7 @@ type ManageDappCanisterSettings = record { wasm_memory_limit : opt nat64; memory_allocation : opt nat64; compute_allocation : opt nat64; + wasm_memory_threshold : opt nat64; }; type SnsVersion = record { diff --git a/rs/sns/governance/proto/ic_sns_governance/pb/v1/governance.proto b/rs/sns/governance/proto/ic_sns_governance/pb/v1/governance.proto index 2b2fbcb0714..f26318098b2 100644 --- a/rs/sns/governance/proto/ic_sns_governance/pb/v1/governance.proto +++ b/rs/sns/governance/proto/ic_sns_governance/pb/v1/governance.proto @@ -437,6 +437,7 @@ message ManageDappCanisterSettings { optional LogVisibility log_visibility = 6; optional uint64 wasm_memory_limit = 7; + optional uint64 wasm_memory_threshold = 8; } // Unlike `Governance.Version`, this message has optional fields and is the recommended one diff --git a/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs b/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs index 55691a9792d..543f636048e 100644 --- a/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs +++ b/rs/sns/governance/src/gen/ic_sns_governance.pb.v1.rs @@ -612,6 +612,8 @@ pub struct ManageDappCanisterSettings { pub log_visibility: ::core::option::Option, #[prost(uint64, optional, tag = "7")] pub wasm_memory_limit: ::core::option::Option, + #[prost(uint64, optional, tag = "8")] + pub wasm_memory_threshold: ::core::option::Option, } /// Unlike `Governance.Version`, this message has optional fields and is the recommended one /// to use in APIs that can evolve. For example, the SNS Governance could eventually support diff --git a/rs/sns/governance/src/pb/conversions.rs b/rs/sns/governance/src/pb/conversions.rs index eeb0c4e114a..7a14fbd1ad9 100644 --- a/rs/sns/governance/src/pb/conversions.rs +++ b/rs/sns/governance/src/pb/conversions.rs @@ -479,6 +479,7 @@ impl From for pb_api::ManageDappCanisterSettings reserved_cycles_limit: item.reserved_cycles_limit, log_visibility: item.log_visibility, wasm_memory_limit: item.wasm_memory_limit, + wasm_memory_threshold: item.wasm_memory_threshold, } } } @@ -492,6 +493,7 @@ impl From for pb::ManageDappCanisterSettings reserved_cycles_limit: item.reserved_cycles_limit, log_visibility: item.log_visibility, wasm_memory_limit: item.wasm_memory_limit, + wasm_memory_threshold: item.wasm_memory_threshold, } } } diff --git a/rs/sns/governance/src/proposal.rs b/rs/sns/governance/src/proposal.rs index 80777539e9d..6aaae38eddc 100644 --- a/rs/sns/governance/src/proposal.rs +++ b/rs/sns/governance/src/proposal.rs @@ -3234,6 +3234,7 @@ mod tests { 0, 0, 0, + 0, ) } @@ -4544,6 +4545,7 @@ Version { reserved_cycles_limit: Some(1_000_000_000_000), log_visibility: Some(LogVisibility::Public as i32), wasm_memory_limit: Some(1_000_000_000), + wasm_memory_threshold: Some(1_000_000), }) .unwrap(); } @@ -4670,6 +4672,7 @@ Payload rendering here"# reserved_cycles_limit: Some(1_000_000_000_000), log_visibility: Some(LogVisibility::Public as i32), wasm_memory_limit: Some(1_000_000_000), + wasm_memory_threshold: Some(1_000_000), }) .unwrap(); assert_eq!( diff --git a/rs/sns/governance/src/sns_root_types.rs b/rs/sns/governance/src/sns_root_types.rs index a3743604941..3b3212810f4 100644 --- a/rs/sns/governance/src/sns_root_types.rs +++ b/rs/sns/governance/src/sns_root_types.rs @@ -184,6 +184,8 @@ pub struct ManageDappCanisterSettingsRequest { pub log_visibility: ::core::option::Option, #[prost(uint64, optional, tag = "7")] pub wasm_memory_limit: ::core::option::Option, + #[prost(uint64, optional, tag = "8")] + pub wasm_memory_threshold: ::core::option::Option, } #[derive(candid::CandidType, candid::Deserialize, comparable::Comparable)] diff --git a/rs/sns/governance/src/types.rs b/rs/sns/governance/src/types.rs index 0dcd9df51fe..4b171aa20ed 100644 --- a/rs/sns/governance/src/types.rs +++ b/rs/sns/governance/src/types.rs @@ -2445,6 +2445,7 @@ impl From for ManageDappCanisterSettingsRequest { reserved_cycles_limit, log_visibility, wasm_memory_limit, + wasm_memory_threshold, } = manage_dapp_canister_settings; ManageDappCanisterSettingsRequest { @@ -2455,6 +2456,7 @@ impl From for ManageDappCanisterSettingsRequest { reserved_cycles_limit, log_visibility, wasm_memory_limit, + wasm_memory_threshold, } } } diff --git a/rs/sns/integration_tests/src/manage_dapp_canister_settings.rs b/rs/sns/integration_tests/src/manage_dapp_canister_settings.rs index 4c1f0a8a90d..6f667f5e141 100644 --- a/rs/sns/integration_tests/src/manage_dapp_canister_settings.rs +++ b/rs/sns/integration_tests/src/manage_dapp_canister_settings.rs @@ -106,6 +106,7 @@ fn test_manage_dapp_canister_settings_successful() { Some(1 << 30), 100_000, Some(1_000_000_000), + Some(0), ), ); @@ -121,6 +122,7 @@ fn test_manage_dapp_canister_settings_successful() { reserved_cycles_limit: Some(0), log_visibility: Some(LogVisibility::Controllers as i32), wasm_memory_limit: Some(2_000_000_000), + wasm_memory_threshold: Some(0), }, )), ..Default::default() @@ -157,6 +159,7 @@ fn test_manage_dapp_canister_settings_successful() { Some(0), 0, Some(2_000_000_000), + Some(0), ), ); } @@ -232,6 +235,7 @@ fn test_manage_dapp_canister_settings_failure() { Some(1 << 30), 100_000, Some(1_000_000_000), + Some(0), ), ); @@ -303,6 +307,7 @@ fn test_manage_dapp_canister_settings_failure() { Some(1 << 30), 100_000, Some(1_000_000_000), + Some(0), ), ); diff --git a/rs/sns/root/canister/root.did b/rs/sns/root/canister/root.did index 0790711d95a..bc3856b691d 100644 --- a/rs/sns/root/canister/root.did +++ b/rs/sns/root/canister/root.did @@ -61,6 +61,7 @@ type DefiniteCanisterSettings = record { wasm_memory_limit : opt nat; memory_allocation : opt nat; compute_allocation : opt nat; + wasm_memory_threshold : opt nat; }; type DefiniteCanisterSettingsArgs = record { @@ -69,6 +70,7 @@ type DefiniteCanisterSettingsArgs = record { wasm_memory_limit : opt nat; memory_allocation : nat; compute_allocation : nat; + wasm_memory_threshold : opt nat; }; type FailedUpdate = record { @@ -113,6 +115,7 @@ type ManageDappCanisterSettingsRequest = record { wasm_memory_limit : opt nat64; memory_allocation : opt nat64; compute_allocation : opt nat64; + wasm_memory_threshold : opt nat64; }; type ManageDappCanisterSettingsResponse = record { diff --git a/rs/sns/root/proto/ic_sns_root/pb/v1/root.proto b/rs/sns/root/proto/ic_sns_root/pb/v1/root.proto index 198da97129e..13a307d16b0 100644 --- a/rs/sns/root/proto/ic_sns_root/pb/v1/root.proto +++ b/rs/sns/root/proto/ic_sns_root/pb/v1/root.proto @@ -128,6 +128,7 @@ message ManageDappCanisterSettingsRequest { optional uint64 reserved_cycles_limit = 5; optional LogVisibility log_visibility = 6; optional uint64 wasm_memory_limit = 7; + optional uint64 wasm_memory_threshold = 8; } message ManageDappCanisterSettingsResponse { diff --git a/rs/sns/root/src/gen/ic_sns_root.pb.v1.rs b/rs/sns/root/src/gen/ic_sns_root.pb.v1.rs index 60ea81783e4..182d0b49bd4 100644 --- a/rs/sns/root/src/gen/ic_sns_root.pb.v1.rs +++ b/rs/sns/root/src/gen/ic_sns_root.pb.v1.rs @@ -234,6 +234,8 @@ pub struct ManageDappCanisterSettingsRequest { pub log_visibility: ::core::option::Option, #[prost(uint64, optional, tag = "7")] pub wasm_memory_limit: ::core::option::Option, + #[prost(uint64, optional, tag = "8")] + pub wasm_memory_threshold: ::core::option::Option, } #[derive( candid::CandidType, diff --git a/rs/sns/root/src/lib.rs b/rs/sns/root/src/lib.rs index 84811ab333d..e866d94c17d 100644 --- a/rs/sns/root/src/lib.rs +++ b/rs/sns/root/src/lib.rs @@ -195,6 +195,7 @@ impl ValidatedManageDappCanisterSettingsRequest { reserved_cycles_limit: request.reserved_cycles_limit.map(Nat::from), log_visibility: LogVisibility::try_from(request.log_visibility()).ok(), wasm_memory_limit: request.wasm_memory_limit.map(Nat::from), + wasm_memory_threshold: request.wasm_memory_threshold.map(Nat::from), }; let invalid_dapp_canister_ids = request .canister_ids @@ -2201,6 +2202,7 @@ mod tests { reserved_cycles_limit: Some(1_000_000_000_000), log_visibility: Some(crate::pb::v1::LogVisibility::Controllers as i32), wasm_memory_limit: Some(1_000_000_000), + wasm_memory_threshold: Some(1_000_000), }; let validated_request = ValidatedManageDappCanisterSettingsRequest::try_from( request, @@ -2226,6 +2228,7 @@ mod tests { reserved_cycles_limit: Some(Nat::from(1_000_000_000_000u64)), log_visibility: Some(LogVisibility::Controllers), wasm_memory_limit: Some(Nat::from(1_000_000_000u64)), + wasm_memory_threshold: Some(Nat::from(1_000_000u64)), }, } ); @@ -2245,6 +2248,7 @@ mod tests { reserved_cycles_limit: Some(1_000_000_000_000), log_visibility: Some(crate::pb::v1::LogVisibility::Controllers as i32), wasm_memory_limit: Some(1_000_000_000), + wasm_memory_threshold: Some(1_000_000), }; let failure_reason = ValidatedManageDappCanisterSettingsRequest::try_from( request, diff --git a/rs/sns/swap/canister/swap.did b/rs/sns/swap/canister/swap.did index 295231a8624..2f1ab199496 100644 --- a/rs/sns/swap/canister/swap.did +++ b/rs/sns/swap/canister/swap.did @@ -53,6 +53,7 @@ type DefiniteCanisterSettingsArgs = record { wasm_memory_limit : opt nat; memory_allocation : nat; compute_allocation : nat; + wasm_memory_threshold : opt nat; }; type DerivedState = record { diff --git a/rs/sns/swap/canister/tests.rs b/rs/sns/swap/canister/tests.rs index 4466a377cac..a968c631482 100644 --- a/rs/sns/swap/canister/tests.rs +++ b/rs/sns/swap/canister/tests.rs @@ -54,6 +54,7 @@ async fn test_get_canister_status() { memory_allocation: candid::Nat::from(0_u32), freezing_threshold: candid::Nat::from(0_u32), wasm_memory_limit: Some(candid::Nat::from(0_u32)), + wasm_memory_threshold: Some(candid::Nat::from(0_u32)), }, memory_size: candid::Nat::from(0_u32), cycles: candid::Nat::from(0_u32), @@ -74,6 +75,7 @@ async fn test_get_canister_status() { reserved_cycles_limit: candid::Nat::from(0_u32), wasm_memory_limit: candid::Nat::from(0_u32), log_visibility: LogVisibility::Controllers, + wasm_memory_threshold: candid::Nat::from(0_u32), }, cycles: candid::Nat::from(0_u32), idle_cycles_burned_per_day: candid::Nat::from(0_u32), diff --git a/rs/types/management_canister_types/src/lib.rs b/rs/types/management_canister_types/src/lib.rs index 8087b39fe36..e55a3d88925 100644 --- a/rs/types/management_canister_types/src/lib.rs +++ b/rs/types/management_canister_types/src/lib.rs @@ -937,6 +937,10 @@ impl DefiniteCanisterSettingsArgs { self.wasm_memory_limit.clone() } + pub fn wasm_memory_threshold(&self) -> candid::Nat { + self.wasm_memory_threshold.clone() + } + pub fn compute_allocation(&self) -> candid::Nat { self.compute_allocation.clone() }