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

Commit d80ee16

Browse files
committed
install_chunked_wasm management canister method added
1 parent 5537898 commit d80ee16

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

spec/_attachments/ic.did

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ service ic : {
152152
};
153153
target_canister: canister_id;
154154
storage_canister: opt canister_id;
155-
wasm_module_hash: blob;
156155
chunk_hashes_list: vec chunk_hash;
156+
wasm_module_hash: blob;
157157
arg : blob;
158158
sender_canister_version : opt nat64;
159159
})

spec/index.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,7 @@ The `mode, arg, sender_canister_version` parameters are as above.
19531953
The optional `storage_canister` parameters specifies the canister where the chunks are stored.
19541954
The caller must be a controller of the `storage_canister` or the caller must be the `storage_canister` and `storage_canister` must be on the same subnet as the target canister.
19551955

1956-
The `chunk_hashse_list` specifies a list of hash values `[h0,h1,...,hk]` with `k <= MAX_CHUNKS_IN_LARGE_WASM`. The system looks up in the chunk store of `storage_canister` (or that of the target canister if this parameter is not provided) blobs corresponding to `h1,...,hk`, concatenates them to obtain a blob of bytes `wasm_module` and checks that `h0` is the hash of the resulting blob.
1957-
It then calls `install_code` with parameters (`mode,target_canister,wasm_module,arg,sender_canister_version`).
1956+
The `chunk_hashse_list` specifies a list of hash values `[h1,...,hk]` with `k <= MAX_CHUNKS_IN_LARGE_WASM`. The system looks up in the chunk store of `storage_canister` (or that of the target canister if this parameter is not provided) blobs corresponding to `h1,...,hk`, concatenates them to obtain a blob of bytes `wasm_module`. It then checks that the SHA256 hash of `wasm_module` is equal to the `wasm_module_hash` parameter of the call, and calls `install_code` with parameters (`mode,target_canister,wasm_module,arg,sender_canister_version`).
19581957

19591958
### IC method `uninstall_code` {#ic-uninstall_code}
19601959

@@ -3045,7 +3044,7 @@ is_effective_canister_id(E.content, ECID)
30453044
E.content.arg = candid({canister_id = CanisterId, …})
30463045
E.content.sender ∈ S.controllers[CanisterId]
30473046
E.content.method_name ∈
3048-
{ "install_code", "uninstall_code", "update_settings", "start_canister", "stop_canister",
3047+
{ "install_code", "install_chunked_code", "uninstall_code", "update_settings", "start_canister", "stop_canister",
30493048
"canister_status", "delete_canister",
30503049
"provisional_create_canister_with_cycles", "provisional_top_up_canister" }
30513050
) ∨ (
@@ -3509,7 +3508,7 @@ Note that returning does *not* imply that the call associated with this message
35093508
The function `validate_sender_canister_version` checks that `sender_canister_version` matches the actual canister version of the sender in all calls to the methods of the management canister that take `sender_canister_version`:
35103509

35113510
validate_sender_canister_version(new_calls, canister_version_from_system) =
3512-
∀ call ∈ new_calls. (call.callee = ic_principal and (call.method = 'create_canister' or call.method = 'update_settings' or call.method = 'install_code' or call.method = 'uninstall_code' or call.method = 'provisional_create_canister_with_cycles') and call.arg = candid(A) and A.sender_canister_version = n) => n = canister_version_from_system
3511+
∀ call ∈ new_calls. (call.callee = ic_principal and (call.method = 'create_canister' or call.method = 'update_settings' or call.method = 'install_code' or call.method = `install_chunked_code` or call.method = 'uninstall_code' or call.method = 'provisional_create_canister_with_cycles') and call.arg = candid(A) and A.sender_canister_version = n) => n = canister_version_from_system
35133512

35143513
The functions `query_as_update` and `system_task_as_update` turns a query function (note that composite query methods cannot be called when executing a message during this transition) resp the heartbeat or global timer into an update function; this is merely a notational trick to simplify the rule:
35153514

@@ -4091,6 +4090,7 @@ S with
40914090

40924091
```
40934092

4093+
40944094
#### IC Management Canister: Code upgrade
40954095

40964096
Only the controllers of the given canister can install new code. This changes the code of an *existing* canister, preserving the state in the stable memory. This involves invoking the `canister_pre_upgrade` method, if the `skip_pre_upgrade` flag is not set to `opt true`, on the old and `canister_post_upgrade` method on the new canister, which must succeed and must not invoke other methods.
@@ -4225,6 +4225,46 @@ S with
42254225

42264226
```
42274227

4228+
4229+
#### IC Management Canister: Install chunked code
4230+
4231+
4232+
4233+
4234+
Conditions
4235+
4236+
```html
4237+
S.messages = Older_messages · CallMessage M · Younger_messages
4238+
(M.queue = Unordered) or (∀ msg ∈ Older_messages. msg.queue ≠ M.queue)
4239+
M.callee = ic_principal
4240+
M.method_name = 'install_chunked_code'
4241+
if A.storage_canister = None then
4242+
let storage_canister = A.target_canister
4243+
else let storage_canister A. storage_canister
4244+
M.caller ∈ S.controllers[storage_canister] ∩ S.controllers[target_canister]
4245+
∀ h ∈ A.chunk_hashes_list = [h1,h2,...,hk]: h ∈ dom(S.chunk_store[storage_canister])
4246+
module = S.chunk_store[storage_canister][h1] || ... || S.chunk_store[storage_canister][hk]
4247+
A.wasm_module_hash = SHA256(module)
4248+
4249+
4250+
```
4251+
4252+
State after
4253+
```html
4254+
S.messages = Older_messages ·
4255+
CallMessage {
4256+
caller = M.caller
4257+
mode = A.mode
4258+
canister_id = A.target_canister
4259+
wasm_module = module
4260+
args = A.args
4261+
sender_canister_version = M.sender_canister_version
4262+
} · Younger_messages
4263+
4264+
```
4265+
4266+
4267+
42284268
#### IC Management Canister: Code uninstallation {#rule-uninstall}
42294269

42304270
Upon uninstallation, the canister is reverted to an empty canister, and all outstanding call contexts are rejected and marked as deleted.

0 commit comments

Comments
 (0)