Skip to content

Commit e14bba0

Browse files
committed
New version (after feature review)
1 parent b40ad06 commit e14bba0

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

docs/references/_attachments/ic.did

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,29 @@ type http_request_result = record {
8585
body : blob;
8686
};
8787

88+
type http_request_resource_report = record {
89+
downloaded_bytes: opt variant { used: nat64; exceeded: reserved };
90+
request_time_ms: opt variant { used: nat64; exceeded: reserved };
91+
transform_instructions: opt variant { used: nat64; exceeded: reserved };
92+
transformed_response_size: opt variant { used: nat64; exceeded: reserved };
93+
}
94+
95+
multi_response_http_request_err = record {
96+
cause: opt variant {
97+
timeout : vec (principal, http_request_resource_report);
98+
invalid_parameters: reserved;
99+
limits_exceeded: vec (principal, http_request_resource_report);
100+
out_of_cycles : vec (principal, http_request_resource_report);
101+
};
102+
message: text;
103+
}
104+
105+
106+
type multi_response_http_request_result = record {
107+
ok: vec http_request_result;
108+
err: multi_response_http_request_err;
109+
};
110+
88111
type ecdsa_curve = variant {
89112
secp256k1;
90113
};
@@ -317,7 +340,7 @@ type http_request_args = record {
317340
};
318341
};
319342

320-
type flexible_http_request_args = record {
343+
type multi_response_http_request_args = record {
321344
url : text;
322345
method : variant { get; head; post };
323346
headers : vec http_header;
@@ -326,9 +349,10 @@ type flexible_http_request_args = record {
326349
function : func(record { response : http_request_result; context : blob }) -> (http_request_result) query;
327350
context : blob;
328351
};
329-
responses_from : variant {
330-
all_replicas;
331-
replica_count: nat32;
352+
node_counts: opt record {
353+
min_responses: nat64;
354+
max_responses: nat64;
355+
total_requests: nat64;
332356
};
333357
}
334358

@@ -504,7 +528,7 @@ service ic : {
504528
deposit_cycles : (deposit_cycles_args) -> ();
505529
raw_rand : () -> (raw_rand_result);
506530
http_request : (http_request_args) -> (http_request_result);
507-
flexible_http_request : (flexible_http_request_args) -> (vec http_request_result);
531+
multi_response_http_request : (multi_response_http_request_args) -> multi_response_http_request_response;
508532

509533
// Threshold ECDSA signature
510534
ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result);

docs/references/ic-interface-spec.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ defaulting to `I = i32` if the canister declares no memory.
15271527
15281528
ic0.subnet_self_size : () -> I; // *
15291529
ic0.subnet_self_copy : (dst : I, offset : I, size : I) -> (); // *
1530-
ic0.subnet_self_replica_count : () -> i32; // *
1530+
ic0.subnet_self_node_count : () -> i32; // *
15311531
15321532
ic0.msg_method_name_size : () -> I; // F
15331533
ic0.msg_method_name_copy : (dst : I, offset : I, size : I) -> (); // F
@@ -1570,8 +1570,6 @@ defaulting to `I = i32` if the canister declares no memory.
15701570
ic0.cost_call : (method_name_size: i64, payload_size : i64, dst : I) -> (); // * s
15711571
ic0.cost_create_canister : (dst : I) -> (); // * s
15721572
ic0.cost_http_request : (request_size : i64, max_res_bytes : i64, dst : I) -> (); // * s
1573-
ic0.cost_flexible_http_request :
1574-
(request_size : i64, replica_count: i32, dst : I) -> (); // * s
15751573
ic0.cost_sign_with_ecdsa : (src : I, size : I, ecdsa_curve: i32, dst : I) -> i32; // * s
15761574
ic0.cost_sign_with_schnorr : (src : I, size : I, algorithm: i32, dst : I) -> i32; // * s
15771575
ic0.cost_vetkd_derive_key : (src : I, size : I, vetkd_curve: i32, dst : I) -> i32; // * s
@@ -1752,9 +1750,9 @@ A canister can learn about its own identity:
17521750

17531751
A canister can learn about the subnet it is running on:
17541752

1755-
- `ic0.subnet_self_size : () → I`, `ic0.subnet_self_copy: (dst : I, offset : I, size : I) → ()`; `I ∈ {i32, i64}`, and `ic0.subnet_self_replica_count : () -> i32`
1753+
- `ic0.subnet_self_size : () → I`, `ic0.subnet_self_copy: (dst : I, offset : I, size : I) → ()`; `I ∈ {i32, i64}`, and `ic0.subnet_self_node_count : () -> i32`
17561754

1757-
These functions allow the canister to query the subnet id (as a blob) of the subnet on which the canister is running, and to retrieve the number of replicas that are currently on the subnet.
1755+
These functions allow the canister to query the subnet id (as a blob) of the subnet on which the canister is running, and to retrieve the number of nodes that are currently on the subnet.
17581756

17591757

17601758
### Canister status {#system-api-canister-status}
@@ -2168,10 +2166,6 @@ These system calls return costs in Cycles, represented by 128 bits, which will b
21682166

21692167
`max_res_bytes` is the maximum response length the caller wishes to accept (the caller should provide the default value of `2,000,000` if no maximum response length is provided in the actual request to the management canister).
21702168

2171-
- `ic0.cost_flexible_http_request(request_size : i64, replica_count: i32, dst : I) -> ()`; `I ∈ {i32, i64}`
2172-
2173-
The cost of a canister http outcall via [`flexible_http_request`](#ic-flexible_http_request). The `request_size` is same as for `cost_http_request` and covers the url, headers, body and transform. The `replica_count` is the number to be used in the call to `flexible_http_request`.
2174-
21752169
- `ic0.cost_sign_with_ecdsa(src : I, size : I, ecdsa_curve: i32, dst : I) -> i32`; `I ∈ {i32, i64}`
21762170

21772171
- `ic0.cost_sign_with_schnorr(src : I, size : I, algorithm: i32, dst : I) -> i32`; `I ∈ {i32, i64}`
@@ -2828,15 +2822,15 @@ If you do not specify the `max_response_bytes` parameter, the maximum of a `2MB`
28282822

28292823
:::
28302824

2831-
### IC method `flexible_http_request` {#ic-flexible_http_request}
2825+
### IC method `multi_response_http_request` {#ic-multi_response_http_request}
28322826

2833-
This is a variant of the [`http_request`](#ic-http_request) method that allows the caller to select how many IC replicas issue the request, and returns potentially multiple responses instead of a single one, one from each replica issuing the request. Use cases include calling HTTP endpoints that provide rapidly changing information, calling non-idempotent endpoints (by issuing the request from a single replica only), calling endpoints that provide signed data whose authenticity can be checked without trusting the endpoint, and letting the user pick a trade-off between cheaper calls (fewer replicas responding) and stronger integrity guarantees (more replicas responding).
2827+
This is a variant of the [`http_request`](#ic-http_request) method where nodes return their individual HTTP responses to the caller instead of trying to reach consensus on the response, letting the caller do its own HTTP response processing. Use cases include calling HTTP endpoints that provide rapidly changing information (where achieving consensus s unlikely) and letting the user pick a trade-off between cheaper calls (fewer replicas requesting/responding) and stronger integrity guarantees (more replicas requesting/responding).
28342828

28352829
The arguments of the call are as for `http_request`, except that:
28362830

2837-
- there is an additional argument `responses_from`, which can be set to either `all_replicas` or to a particular `replica_count` with a given (positive) number of replicas. The number of replicas must not exceed the subnet size.
2831+
- there is an additional optional argument `node_counts`. When set, the caller can specify how many nodes should issue an HTTP outcall, the minimum number of HTTP responses from nodes in order for the outcall to succeed (`min_responses`), and the maximum number of HTTP responses the caller is willing to receive as the result of the outcall (`max_responses`). That is, a successful HTTP outcall is guaranteed to return between `min_responses` and `max_responses`. If `node_counts` are set, then the caller must ensure that `1 <= min_responses <= max_responses <= total_requests <= N`, where `N` is the number of the nodes on the caller's subnet, otherwise the call will fail. The caller may use the `ic0.subnet_self_node_count` System API call to determine `N`. If `node_count` is not provided, the defaults of `floor(2 / 3 * N) + 1`, `N` and `N` are used for `min_responses`, `max_responses` and `total_requests`.
28382832

2839-
- `max_response_bytes` argument is not needed.
2833+
- the deprecated `max_response_bytes` argument is not supported.
28402834

28412835
The other arguments, `url`, `method`, `headers`, `body`, and `transform` are the same as for `http_request`. The result is a vector of responses, with each individual response having the same structure as a `http_request` response, providing `status`, `headers`, and `body` fields.
28422836

0 commit comments

Comments
 (0)