Skip to content

Commit

Permalink
feat: Add wasm_memory_limit to the management canister
Browse files Browse the repository at this point in the history
This adds `wasm_memory_limit` to `CanisterSettings` and
`DefiniteCanisterSettings`.

The corresponding spec change:

- dfinity/interface-spec#278
  • Loading branch information
ulan committed Apr 17, 2024
1 parent 2797f87 commit 670a00e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2e-tests/canisters/canister_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async fn canister_lifecycle() -> Principal {
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: None,
wasm_memory_limit: None,
},
canister_id: canister_id.canister_id,
})
Expand Down
2 changes: 2 additions & 0 deletions e2e-tests/canisters/management_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod main {
memory_allocation: Some(10000u16.into()),
freezing_threshold: Some(10000u16.into()),
reserved_cycles_limit: Some(10000u16.into()),
wasm_memory_limit: Some(10000u16.into()),
}),
};
let canister_id = create_canister(arg, 100_000_000_000u128 / 13)
Expand Down Expand Up @@ -61,6 +62,7 @@ mod provisional {
memory_allocation: Some(10000u16.into()),
freezing_threshold: Some(10000u16.into()),
reserved_cycles_limit: Some(10000u16.into()),
wasm_memory_limit: Some(10000u16.into()),
};
let arg = ProvisionalCreateCanisterWithCyclesArgument {
amount: Some(1_000_000_000u64.into()),
Expand Down
6 changes: 6 additions & 0 deletions src/ic-cdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Added

- Add `wasm_memory_limit` to the management canister API types:
* `CanisterSettings`
* `DefiniteCanisterSettings`.

## [0.13.2] - 2024-04-08

### Added
Expand Down
8 changes: 8 additions & 0 deletions src/ic-cdk/src/api/management_canister/main/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pub struct CanisterSettings {
/// Must be a number between 0 and 2^128^-1, inclusively, and indicates the
/// upper limit on cycles in the `reserved_cycles` balance of the canister.
pub reserved_cycles_limit: Option<Nat>,
/// A soft limit on the Wasm memory usage of the canister. Update calls,
/// timers, heartbeats, install, and post-upgrade fail if the Wasm memory
/// usage exceeds this limit. The main purpose of this field is to protect
/// against the case when the canister reaches the hard 4GiB limit.
/// Must be a number between 0 and 2^48^ (i.e 256TB), inclusively.
pub wasm_memory_limit: Option<Nat>,
}

/// Argument type of [create_canister](super::create_canister).
Expand Down Expand Up @@ -281,6 +287,8 @@ pub struct DefiniteCanisterSettings {
pub freezing_threshold: Nat,
/// Reserved cycles limit.
pub reserved_cycles_limit: Nat,
/// The Wasm memory limit.
pub wasm_memory_limit: Nat,
}

/// Query statistics, returned by [canister_status](super::canister_status).
Expand Down

0 comments on commit 670a00e

Please sign in to comment.