Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions docs/references/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ type http_request_result = record {
body : blob;
};

type http_request_resource_report = record {
downloaded_bytes: opt variant { used: nat64; exceeded: reserved };
request_time_ms: opt variant { used: nat64; exceeded: reserved };
transform_instructions: opt variant { used: nat64; exceeded: reserved };
transformed_response_size: opt variant { used: nat64; exceeded: reserved };
}

multi_response_http_request_err = record {
cause: opt variant {
timeout : vec (principal, http_request_resource_report);
invalid_parameters: reserved;
limits_exceeded: vec (principal, http_request_resource_report);
out_of_cycles : vec (principal, http_request_resource_report);
};
message: text;
}


type multi_response_http_request_result = record {
ok: vec http_request_result;
err: multi_response_http_request_err;
};

type ecdsa_curve = variant {
secp256k1;
};
Expand Down Expand Up @@ -317,6 +340,22 @@ type http_request_args = record {
};
};

type multi_response_http_request_args = record {
url : text;
method : variant { get; head; post };
headers : vec http_header;
body : opt blob;
transform : opt record {
function : func(record { response : http_request_result; context : blob }) -> (http_request_result) query;
context : blob;
};
node_counts: opt record {
min_responses: nat64;
max_responses: nat64;
total_requests: nat64;
};
}

type ecdsa_public_key_args = record {
canister_id : opt canister_id;
derivation_path : vec blob;
Expand Down Expand Up @@ -489,6 +528,7 @@ service ic : {
deposit_cycles : (deposit_cycles_args) -> ();
raw_rand : () -> (raw_rand_result);
http_request : (http_request_args) -> (http_request_result);
multi_response_http_request : (multi_response_http_request_args) -> multi_response_http_request_response;

// Threshold ECDSA signature
ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result);
Expand Down
34 changes: 32 additions & 2 deletions docs/references/ic-interface-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ defaulting to `I = i32` if the canister declares no memory.

ic0.subnet_self_size : () -> I; // *
ic0.subnet_self_copy : (dst : I, offset : I, size : I) -> (); // *
ic0.subnet_self_node_count : () -> i32; // *

ic0.msg_method_name_size : () -> I; // F
ic0.msg_method_name_copy : (dst : I, offset : I, size : I) -> (); // F
Expand Down Expand Up @@ -1749,9 +1750,10 @@ A canister can learn about its own identity:

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

- `ic0.subnet_self_size : () → I` and `ic0.subnet_self_copy: (dst : I, offset : I, size : I) → ()`; `I ∈ {i32, i64}`
- `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`

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.

These functions allow the canister to query the subnet id (as a blob) of the subnet on which the canister is running.

### Canister status {#system-api-canister-status}

Expand Down Expand Up @@ -2820,6 +2822,34 @@ If you do not specify the `max_response_bytes` parameter, the maximum of a `2MB`

:::

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

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).

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

- 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`.

- the deprecated `max_response_bytes` argument is not supported.

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.

As for `http_request`, the endpoint specified by the provided `url` should be idempotent. The one exception is when a `replica_count` of 1 is used in `responses_from`. The request restrictions are also the same as for the `http_request` method:

- The total number of bytes in the request must not exceed `2MB` (`2,000,000`) bytes.

- Only the `GET`, `HEAD`, and `POST` methods are supported.

- The number of headers must not exceed `64`.

- The number of bytes representing a header name or value must not exceed `8KiB`.

- The total number of bytes representing the header names and values must not exceed `48KiB`.

The response from the remote server must not exceed `2MB`. Moreover, the total size of the result, that is, the sum of the responses returned by the different replicas (possibly after the transform function), must also not exceed 2MB.

Cycles to pay for the call must be explicitly transferred with the call, i.e., they are not automatically deducted from the caller's balance implicitly (e.g., as for inter-canister calls). The upfront cycles cost covers a call that maxes out the resource usage during processing, for example, hitting the `2MB` limit on the size of the response. The unused cycles are then refunded to the caller.

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

This method can only be called by canisters, i.e., it cannot be called by external users via ingress messages.
Expand Down
Loading