Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 6bd7d7d

Browse files
committed
Add canister limit
1 parent b7cbca2 commit 6bd7d7d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ The following sections describe various System API functions, also referred to a
14691469
14701470
ic0.time : () -> (timestamp : i64); // *
14711471
ic0.global_timer_set : (timestamp : i64) -> i64; // I G U Ry Rt C T
1472+
ic0.canister_limit : (limit_type : i32) -> (limit : i64); // * s
14721473
ic0.performance_counter : (counter_type : i32) -> (counter : i64); // * s
14731474
ic0.is_controller: (src: i32, size: i32) -> ( result: i32); // * s
14741475
ic0.in_replicated_execution: () -> (result: i32); // * s
@@ -1944,6 +1945,26 @@ The argument `type` decides which performance counter to return:
19441945

19451946
In the future, the IC might expose more performance counters.
19461947

1948+
### Canister limit {#system-api-canister-limit}
1949+
1950+
The canister can query one of the "canister limits", which denotes a resource limit of the canister imposed by the current configuration of the IC and/or canister. This allows runtime logic, such garbage collector or persistence mechanism, to adapt to the system limits without recompilation and redeployment.
1951+
1952+
`ic0.canister_limit : (limit_type : i32) -> i64`
1953+
1954+
The argument `limit_type` determines which resource limit to return:
1955+
1956+
- 0 : The [soft Wasm heap memory limit](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit), or the IC-defined [hard Wasm memory limit](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/resource-limits#resource-constraints-and-limits), whatever is smaller. The limit is specific to the canister, depending on the canister configuration (for the soft limit) and on whether it uses 32-bit or 64-bit Wasm memory.
1957+
1958+
- 1 : The [instruction limit per update message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
1959+
1960+
- 2 : The [instruction limit per upgrade message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
1961+
1962+
- 3 : The [maximum number of stable memory Wasm pages that can be accessed per update message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
1963+
1964+
- 4 : The [maximum number of stable memory Wasm pages that can be accessed per upgrade message](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/settings#wasm-memory-limit).
1965+
1966+
In the future, this IC method might expose more canister limits.
1967+
19471968
### Replicated execution check {#system-api-replicated-execution-check}
19481969

19491970
The canister can check whether it is currently running in replicated or non replicated execution.
@@ -7338,6 +7359,9 @@ ic0.global_timer_set<es>(timestamp: i64) : i64 =
73387359
then return es.params.sysenv.global_timer
73397360
else return prev_global_timer
73407361

7362+
ic0.canister_limit<es>(limit_type : i32) : i64 =
7363+
arbitrary()
7364+
73417365
ic0.performance_counter<es>(counter_type : i32) : i64 =
73427366
arbitrary()
73437367

0 commit comments

Comments
 (0)