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

specify replica-signed queries #163

Merged
merged 50 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f6b55e3
specify replica-signed queries
mraszyk May 30, 2023
06a4713
drop note
mraszyk May 30, 2023
5924c82
fold content map in the value of request_id field
mraszyk May 31, 2023
41c45dc
update request CDDL
mraszyk May 31, 2023
4c63cd0
nodes -> subnet_nodes
mraszyk May 31, 2023
be66933
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jun 12, 2023
f889ffb
add condition on read_state paths
mraszyk Jun 12, 2023
c2066e2
make node signatures mandatory
mraszyk Jun 15, 2023
a345e0f
specify query call response verification
mraszyk Jun 15, 2023
067d004
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jun 16, 2023
76b0e17
refactor verify_response definition
mraszyk Jun 16, 2023
a16b1cd
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jun 21, 2023
bf990a1
update replica-signed query spec
mraszyk Jun 21, 2023
b40e802
update condition on return values
mraszyk Jun 21, 2023
cd860dc
update return_signature enum variants
mraszyk Jun 21, 2023
fe8c852
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jun 28, 2023
8be2868
rename optional request fields
mraszyk Jun 28, 2023
3e0b99b
Update spec/index.md
mraszyk Jun 29, 2023
d993538
model rejected query call because IC nodes computed different query r…
mraszyk Jun 29, 2023
b204aad
update cddl
mraszyk Jul 1, 2023
c267fe5
spelling
mraszyk Jul 1, 2023
8b5922d
fix variable names
mraszyk Jul 4, 2023
eaf7107
add note on multiple IC nodes evaluating query call
mraszyk Jul 4, 2023
e784e8d
typos
mraszyk Jul 4, 2023
2df3739
typo
mraszyk Jul 6, 2023
b596124
rename CanisterQuery to CanisterSignedQuery in formal spec
mraszyk Jul 8, 2023
11ff673
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jul 8, 2023
43d7fde
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jul 11, 2023
6091110
simplify
mraszyk Jul 11, 2023
640e74f
simplify
mraszyk Jul 11, 2023
cade854
simplify
mraszyk Jul 11, 2023
f5738c1
simplify
mraszyk Jul 11, 2023
2ae11ef
replace CanisterSignedQuery by CanisterQuery in formal text
mraszyk Jul 17, 2023
26b80cd
singleton -> containing one; a note on signatures being a list
mraszyk Jul 17, 2023
f550083
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jul 25, 2023
35425d3
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Jul 25, 2023
11f5997
add note on what recent enough means
mraszyk Jul 25, 2023
e625cf2
nodes -> node
mraszyk Aug 9, 2023
fbc8fe2
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Aug 16, 2023
3103163
make signatures in query responses non-optional
mraszyk Aug 19, 2023
6ac4e03
drop a note on optional signatures
mraszyk Aug 19, 2023
5e673b8
whitelist node paths in read_state requests
mraszyk Aug 22, 2023
ca2374f
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Aug 23, 2023
bf346e5
Update spec/index.md
mraszyk Sep 1, 2023
f8da3de
Update spec/index.md
mraszyk Sep 1, 2023
543745b
typo
mraszyk Sep 1, 2023
d77e24d
reformulation
mraszyk Sep 1, 2023
e79546f
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Sep 10, 2023
16d7ae6
Merge branch 'master' into mraszyk/replica-signed-queries
mraszyk Sep 13, 2023
f3971dc
update changelog
mraszyk Sep 13, 2023
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
54 changes: 46 additions & 8 deletions spec/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ tagged<t> = #6.55799(t) ; the CBOR tag
+
NOTE: Because this uses the lexicographic ordering of princpials, and the byte distinguishing the various classes of ids is at the _end_, this range by construction conceptually includes principals of various classes. This specification needs to take care that the fact that principals that are not canisters may appear in these ranges does not cause confusion.

* `/subnet/<subnet_id>/nodes/<node_id>/public_key` (blob)
+
The public key of a node (a DER-encoded Ed25519 signing key, see https://tools.ietf.org/html/rfc8410[RFC 8410] for reference) with principal `<node_id>` belonging to the subnet with principal `<subnet_id>`.
Dfinity-Bjoern marked this conversation as resolved.
Show resolved Hide resolved

[#state-tree-request-status]
=== Request status
Expand Down Expand Up @@ -629,17 +632,52 @@ In order to make a query call to canister, the user makes a POST request to `/ap
* `method_name` (`text`): Name of the canister method to call
* `arg` (`blob`): Argument to pass to the canister method

The HTTP response to a query call can contain a list of signatures for the returned response produced by the individual IC nodes that computed the same returned response.
Every such signature (whose type is denoted as `node-signature-of-query-response`) is a CBOR (see <<cbor>>) map with the following fields:

* `timestamp` (`nat`): the timestamp of the signature.
* `signature` (`blob`): the actual signature.
* `identity` (`principal`): the principal of the node producing the signature.

If the call resulted in a reply, the response is a CBOR (see <<cbor>>) map with the following fields:

* `status` (`text`): `replied`
* `reply`: a CBOR map with the field `arg` (`blob`) which contains the reply data.
* `status` (`text`): `"replied"`
* `reply`: a CBOR map with the field `arg` (`blob`) which contains the reply data `<R>`.
* `node_signatures` (`[* node-signature-of-query-response]`): a list of node signatures for the returned query response
computed for the following value
+
....
hash_of_map({
status: "replied",
reply: {arg: <R>},
timestamp: <t>,
request_id: hash_of_map(content)
})
....
+
where `hash_of_map` is the <<hash-of-map, representation-independent hash>>, `content` is the CBOR map from the request, and `<t>` is the timestamp of the node when the signature was produced.

If the call resulted in a reject, the response is a CBOR map with the following fields:

* `status` (`text`): `rejected`
* `status` (`text`): `"rejected"`
* `reject_code` (`nat`): The reject code (see <<reject-codes>>).
* `reject_message` (`text`): a textual diagnostic message.
* `error_code` (text): an optional implementation-specific textual error code (see <<error-codes>>).
* `error_code` (`text`): an optional implementation-specific textual error code (see <<error-codes>>).
* `node_signatures` (`[* node-signature-of-query-response]`): a list of node signatures for the returned query response
computed for the following value
+
....
hash_of_map({
status: "rejected",
reject_code: <reject_code>,
reject_message: <reject_message>,
error_code: <error_code>,
timestamp: <t>,
request_id: hash_of_map(content)
})
....
+
where `hash_of_map` is the <<hash-of-map, representation-independent hash>>, `content` is the CBOR map from the request, and `<t>` is the timestamp of the node when the signature was produced.

Canister methods that do not change the canister state can be executed more efficiently. This method provides that ability, and returns the canister’s response directly within the HTTP response.

Expand Down Expand Up @@ -3910,17 +3948,17 @@ Read response::
* If `F(Q.Arg, Q.sender, Env) = Trap trap` then
+
....
{status: rejected; reject_code: CANISTER_ERROR, reject_message: <implementation-specific>, error_code: <implementation-specific>}
{status: rejected; reject_code: CANISTER_ERROR, reject_message: <implementation-specific>, error_code: <implementation-specific>, node_signatures: <implementation-specific>}
mraszyk marked this conversation as resolved.
Show resolved Hide resolved
....
* Else if `F(Q.Arg, Q.sender, Env) = Return {response = Reject (code, msg); …}` then
+
....
{status: rejected; reject_code: <code>: reject_message: <msg>, error_code: <implementation-specific>}
{status: rejected; reject_code: <code>: reject_message: <msg>, error_code: <implementation-specific>, node_signatures: <implementation-specific>}
....
* Else if `F(Q.Arg, Q.sender, Env) = Return {response = Reply R; …}` then
+
....
{status: success; reply: { arg : <R> } }
{status: replied; reply: { arg : <R> }, node_signatures: <implementation-specific>}
....

==== Certified state reads
Expand Down Expand Up @@ -3967,7 +4005,7 @@ where `state_tree` constructs a labeled tree from the IC state `S` and the (so f
....
state_tree(S) = {
"time": S.system_time;
"subnet": { subnet_id : { "public_key" : subnet_pk, "canister_ranges" : subnet_ranges } | (subnet_id, subnet_pk, subnet_ranges) ∈ subnets };
"subnet": { subnet_id : { "public_key" : subnet_pk, "canister_ranges" : subnet_ranges, "nodes": { node_id : { "public_key" : node_pk } | (node_id, node_pk) ∈ subnet_nodes } } | (subnet_id, subnet_pk, subnet_ranges, subnet_nodes) ∈ subnets };
"request_status": { request_id(R): request_status_tree(T) | (R ↦ (T, _)) ∈ S.requests };
"canister":
{ canister_id :
Expand Down
8 changes: 8 additions & 0 deletions spec/requests.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,21 @@ query-content = {
query-response = tagged<{
status: "replied"
reply: call-reply
node_signatures: [* node-signature-of-query-response]
ShuoWangNSL marked this conversation as resolved.
Show resolved Hide resolved
//
status: "rejected"
reject_code: unsigned
reject_message: text
? error_code: text
node_signatures: [* node-signature-of-query-response]
}>

node-signature-of-query-response = {
timestamp: timestamp
mraszyk marked this conversation as resolved.
Show resolved Hide resolved
signature: bytes
identity: principal
}
ShuoWangNSL marked this conversation as resolved.
Show resolved Hide resolved

call-reply = {
arg : bytes
}
Expand Down