Skip to content

Commit

Permalink
Merge branch 'master' into skaestle/query-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk authored Jul 25, 2023
2 parents feaf77d + 2b80d94 commit 0cf56ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions spec/_attachments/interface-spec-changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Changelog {#changelog}

### ∞ (unreleased)
* Canister cycle balance cannot decrease below the freezing limit after executing `install_code` on the management canister.

### 0.20.0 (2023-07-11) {#0_20_0}
* IC Bitcoin API, ECDSA API, canister HTTPS outcalls API, and 128-bit cycles System API are considered stable.
* Add conditions on requested paths in read state requests.
* Add composite queries.
Expand Down
5 changes: 4 additions & 1 deletion spec/http-gateway-protocol-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ HEADER = 'IC-CertificateExpression: ', HEADER-VALUE
The request hash is calculated as follows:

1. Let `request_headers_hash` be the [representation-independent hash](https://internetcomputer.org/docs/current/references/ic-interface-spec#hash-of-map) of the request headers:
- The header names are lower-cased.
- Only include headers listed in the `certified_request_headers` field of [the certificate expression header](#the-certificate-expression-header).
- If the field is empty or no value was supplied, no headers are included.
- Headers can be repeated and each repetition should be included.
Expand All @@ -305,6 +306,7 @@ The request hash is calculated as follows:
The response hash is calculated as follows:

1. Let `response_headers_hash` be the [representation-independent hash](https://internetcomputer.org/docs/current/references/ic-interface-spec#hash-of-map) of the response headers:
- The header names are lower-cased.
- The `IC-Certificate` header is always excluded.
- The `IC-CertificateExpression` header is always included.
- If the `no_certification` field of [the certificate expression header](#the-certificate-expression-header) is present:
Expand All @@ -316,6 +318,7 @@ The response hash is calculated as follows:
- All headers listed (except for the `IC-CertificateExpression` header) are excluded from the certification
- All other headers (except for the IC-Certificate header) are included in the certification
- Headers can be repeated and each repetition should be included.
- Include an additional `:ic-cert-status` header that contains the numerical HTTP status code of the response.
2. Let `response_body_hash` be the sha256 of the response body.
3. Concatenate `response_headers_hash` and `response_body_hash` and calculate the sha256 of that concatenation.

Expand Down Expand Up @@ -372,7 +375,7 @@ The steps for response verification are as follows:

## Response Verification Version Assertion

Canisters can report the versions of response verification that they support using public metadata in the [system state tree](https://internetcomputer.org/docs/current/references/ic-interface-spec/#state-tree-canister-information). This metadata will be read by the HTTP Gateway using a [read_state request](https://internetcomputer.org/docs/current/references/ic-interface-spec/#http-read-state). This metadata is a comma-delimited string of versions under the key "supported_certificate_versions”, for example: "1,2". This is treated as an optional, additional layer of security for canisters supporting multiple versions. If the metadata has not been added, then the HTTP Gateway will allow for whatever version the canister has responded with.
Canisters can report the versions of response verification that they support using public metadata in the [system state tree](https://internetcomputer.org/docs/current/references/ic-interface-spec/#state-tree-canister-information). This metadata will be read by the HTTP Gateway using a [read_state request](https://internetcomputer.org/docs/current/references/ic-interface-spec/#http-read-state). This metadata is a comma-delimited string of versions under the key "supported_certificate_versions”, for example: "1,2". This is treated as an optional, additional layer of security for canisters supporting multiple versions. If the metadata has not been added (i.e. the lookup of this metadata in the `read_state` response returns `Absent`), then the HTTP Gateway will allow for whatever version the canister has responded with.

The request for the metadata will only be made by the HTTP Gateway if there is a downgrade. If the HTTP Gateway requests v2 and the canister responds with v2, then a request will not be made. If the HTTP Gateway requests v2 and the canister responds with v1, a request will be made. If a request is made, the HTTP Gateway will not accept any response from the canister that is below the max version supported by both the HTTP Gateway and the canister. This will guarantee that a canister supporting both v1 and v2 will always have v2 security when accessed by an HTTP Gateway that supports v2.

Expand Down
9 changes: 5 additions & 4 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ Canister methods that do not change the canister state (except for cycle balance
### Effective canister id {#http-effective-canister-id}

The `<effective_canister_id>` in the URL paths of requests is the *effective* destination of the request.
It must be contained in the canister ranges of a subnet, otherwise the corresponding HTTP request is rejected.

- If the request is an update call to the Management Canister (`aaaaa-aa`), then:

Expand All @@ -745,8 +746,6 @@ The `<effective_canister_id>` in the URL paths of requests is the *effective* de

The expectation is that user-side agent code shields users and developers from the notion of effective canister ID, in analogy to how the System API interface shields canister developers from worrying about routing.

The Internet Computer blockchain mainnet rejects all requests whose effective canister id is in no subnet's canister ranges, independently of whether the remaining conditions on the effective canister id are satisfied.

The Internet Computer blockchain mainnet does not support `provisional_create_canister_with_cycles` and thus all calls to this method are rejected independently of the effective canister id.

In development instances of the Internet Computer Protocol (e.g. testnets), the effective canister id of a request submitted to a node must be a canister id from the canister ranges of the subnet to which the node belongs.
Expand Down Expand Up @@ -1836,6 +1835,8 @@ The `wasm_module` field specifies the canister module to be installed. The syste

The optional `sender_canister_version` parameter can contain the caller's canister version. If provided, its value must be equal to `ic0.canister_version`.

This method traps if the canister's cycle balance decreases below the canister's freezing limit after executing the method.

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

This method removes a canister's code and state, making the canister *empty* again.
Expand Down Expand Up @@ -3642,7 +3643,7 @@ Env = {
canister_version = S.canister_version[A.canister_id] + 1;
}
Mod.init(A.canister_id, A.arg, M.caller, Env) = Return {new_state = New_state; new_certified_data = New_certified_data; new_global_timer = New_global_timer; cycles_used = Cycles_used;}
Cycles_used S.balances[A.canister_id]
freezing_limit(S, A.canister_id) + Cycles_used S.balances[A.canister_id]
dom(Mod.update_methods) dom(Mod.query_methods) =
dom(Mod.update_methods) dom(Mod.composite_query_methods) =
dom(Mod.query_methods) dom(Mod.composite_query_methods) =
Expand Down Expand Up @@ -3731,7 +3732,7 @@ Env2 = Env with {
canister_version = S.canister_version[A.canister_id] + 1;
}
Mod.post_upgrade(A.canister_id, Stable_memory, A.arg, M.caller, Env2) = Return {new_state = New_state; new_certified_data = New_certified_data'; new_global_timer = New_global_timer; cycles_used = Cycles_used';}
Cycles_used + Cycles_used' ≤ S.balances[A.canister_id]
freezing_limit(S, A.canister_id) + Cycles_used + Cycles_used' ≤ S.balances[A.canister_id]
dom(Mod.update_methods) ∩ dom(Mod.query_methods) = ∅
dom(Mod.update_methods) ∩ dom(Mod.composite_query_methods) = ∅
dom(Mod.query_methods) ∩ dom(Mod.composite_query_methods) = ∅
Expand Down

0 comments on commit 0cf56ac

Please sign in to comment.