Skip to content
Open
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
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rs/nervous_system/agent/src/nns/cmc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::CallCanisters;
use cycles_minting_canister::{
CanisterSettingsArgs, CreateCanister, NotifyMintCyclesArg, NotifyMintCyclesResult,
CanisterSettings, CreateCanister, NotifyMintCyclesArg, NotifyMintCyclesResult,
SetAuthorizedSubnetworkListArgs, SubnetSelection,
};
use ic_base_types::{CanisterId, PrincipalId, SubnetId};
Expand All @@ -11,7 +11,7 @@ pub mod requests;
pub async fn create_canister<C: CallCanisters>(
agent: &C,
subnet_selection: Option<SubnetSelection>,
settings: Option<CanisterSettingsArgs>,
settings: Option<CanisterSettings>,
) -> Result<CanisterId, C::Error> {
let request = CreateCanister {
subnet_selection,
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/cmc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ DEPENDENCIES = [
"//rs/rust_canisters/dfn_protobuf",
"//rs/rust_canisters/on_wire",
"//rs/types/base_types",
"//rs/types/management_canister_types",
"//rs/types/types",
"@crate_index//:build-info",
"@crate_index//:candid",
"@crate_index//:ic-cdk",
"@crate_index//:ic-management-canister-types",
"@crate_index//:ic-metrics-encoder",
"@crate_index//:ic-xrc-types",
"@crate_index//:lazy_static",
Expand Down
2 changes: 1 addition & 1 deletion rs/nns/cmc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ic-cdk = { workspace = true }
ic-crypto-tree-hash = { path = "../../crypto/tree_hash" }
ic-dummy-getrandom-for-wasm = { path = "../../../packages/ic-dummy-getrandom-for-wasm" }
ic-http-types = { path = "../../../packages/ic-http-types" }
ic-management-canister-types-private = { path = "../../types/management_canister_types" }
ic-management-canister-types = { workspace = true }
ic-ledger-core = { path = "../../ledger_suite/common/ledger_core" }
ic-metrics-encoder = "1"
ic-nervous-system-common = { path = "../../nervous_system/common" }
Expand Down
1 change: 0 additions & 1 deletion rs/nns/cmc/cmc.did
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type CanisterSettings = record {
wasm_memory_limit : opt nat;
wasm_memory_threshold : opt nat;
environment_variables : opt vec environment_variable;
log_memory_limit : opt nat;
};
type Subaccount = opt blob;
type Memo = opt blob;
Expand Down
6 changes: 3 additions & 3 deletions rs/nns/cmc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(deprecated)]
pub use ic_management_canister_types_private::CanisterSettingsArgs;
pub use ic_management_canister_types::CanisterSettings;

use candid::{CandidType, Nat};
use ic_cdk::api::call::{CallResult, RejectionCode};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub struct NotifyCreateCanister {
pub subnet_type: Option<String>,
pub subnet_selection: Option<SubnetSelection>,

pub settings: Option<CanisterSettingsArgs>,
pub settings: Option<CanisterSettings>,
}

/// Error for notify endpoints
Expand All @@ -173,7 +173,7 @@ pub struct CreateCanister {
#[deprecated(note = "use subnet_selection instead")]
pub subnet_type: Option<String>,
pub subnet_selection: Option<SubnetSelection>,
pub settings: Option<CanisterSettingsArgs>,
pub settings: Option<CanisterSettings>,
}

/// Error for create_canister endpoint
Expand Down
34 changes: 17 additions & 17 deletions rs/nns/cmc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ use ic_crypto_tree_hash::{
};
use ic_http_types::{HttpRequest, HttpResponse, HttpResponseBuilder};
use ic_ledger_core::{block::BlockType, tokens::CheckedSub};
use ic_management_canister_types_private::{
BoundedVec, CanisterIdRecord, CanisterSettingsArgs, CanisterSettingsArgsBuilder,
CreateCanisterArgs, IC_00, Method,
};
use ic_management_canister_types::{CanisterIdRecord, CanisterSettings, CreateCanisterArgs};
use ic_nervous_system_common::{
NNS_DAPP_BACKEND_CANISTER_ID, ONE_HOUR_SECONDS, ONE_MONTH_SECONDS, serve_metrics,
};
Expand Down Expand Up @@ -1924,7 +1921,7 @@ async fn process_create_canister(
from: AccountIdentifier,
amount: Tokens,
subnet_selection: Option<SubnetSelection>,
settings: Option<CanisterSettingsArgs>,
settings: Option<CanisterSettings>,
) -> Result<CanisterId, NotifyError> {
let cycles = tokens_to_cycles(amount)?;

Expand Down Expand Up @@ -2115,9 +2112,11 @@ async fn deposit_cycles(
}

let res: CallResult<()> = ic_cdk::api::call::call_with_payment128(
IC_00.get().0,
&Method::DepositCycles.to_string(),
(CanisterIdRecord::from(canister_id),),
candid::Principal::management_canister(),
"deposit_cycles",
(CanisterIdRecord {
canister_id: canister_id.get().0,
},),
u128::from(cycles),
)
.await;
Expand Down Expand Up @@ -2170,7 +2169,7 @@ async fn do_create_canister(
controller_id: PrincipalId,
cycles: Cycles,
subnet_selection: Option<SubnetSelection>,
settings: Option<CanisterSettingsArgs>,
settings: Option<CanisterSettings>,
) -> Result<CanisterId, String> {
// Retrieve randomness from the system to use later to get a random
// permutation of subnets. Performing the asynchronous call before
Expand Down Expand Up @@ -2246,20 +2245,19 @@ async fn do_create_canister(
let canister_settings = settings
.map(|mut settings| {
if settings.controllers.is_none() {
settings.controllers = Some(BoundedVec::new(vec![controller_id]));
settings.controllers = Some(vec![controller_id.0]);
}
settings
})
.unwrap_or_else(|| {
CanisterSettingsArgsBuilder::new()
.with_controllers(vec![controller_id])
.build()
.unwrap_or_else(|| CanisterSettings {
controllers: Some(vec![controller_id.0]),
..Default::default()
});

for subnet_id in subnets {
let result: CallResult<(CanisterIdRecord,)> = ic_cdk::api::call::call_with_payment128(
subnet_id.get().0,
&Method::CreateCanister.to_string(),
"create_canister",
(CreateCanisterArgs {
settings: Some(canister_settings.clone()),
sender_canister_version: Some(ic_cdk::api::canister_version()),
Expand All @@ -2269,7 +2267,9 @@ async fn do_create_canister(
.await;

let canister_id = match result {
Ok(canister_id) => canister_id.0.get_canister_id(),
Ok(record) => {
CanisterId::unchecked_from_principal(PrincipalId::from(record.0.canister_id))
}
Err((code, msg)) => {
let err = format!(
"Creating canister in subnet {} failed with code {}: {}",
Expand Down Expand Up @@ -2334,7 +2334,7 @@ fn get_subnets_for(controller_id: &PrincipalId) -> Vec<SubnetId> {

async fn get_rng() -> Result<StdRng, String> {
let res: CallResult<(Vec<u8>,)> =
ic_cdk::call(IC_00.get().0, &Method::RawRand.to_string(), ()).await;
ic_cdk::call(candid::Principal::management_canister(), "raw_rand", ()).await;

let bytes = res
.map_err(|(code, msg)| {
Expand Down
1 change: 1 addition & 0 deletions rs/nns/integration_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ BASE_DEPENDENCIES = [
"//rs/types/types",
"@crate_index//:crossbeam-channel",
"@crate_index//:hex",
"@crate_index//:ic-management-canister-types",
"@crate_index//:ic-xrc-types",
"@crate_index//:maplit",
"@crate_index//:rand",
Expand Down
1 change: 1 addition & 0 deletions rs/nns/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ic-crypto = { path = "../../crypto" }
ic-crypto-sha2 = { path = "../../crypto/sha2" }
ic-error-types = { path = "../../../packages/ic-error-types" }
ic-http-types = { path = "../../../packages/ic-http-types" }
ic-management-canister-types = { workspace = true }
ic-management-canister-types-private = { path = "../../types/management_canister_types" }
ic-nervous-system-common-test-keys = { path = "../../nervous_system/common/test_keys" }
ic-nervous-system-root = { path = "../../nervous_system/root" }
Expand Down
Loading
Loading