feat: Flexible HTTPS outcalls and pay-as-you-go pricing - #714
Merged
Merged
Conversation
eichhorl
marked this pull request as ready for review
September 14, 2026 08:28
|
✅ No security or compliance issues detected. Reviewed everything up to fc0b3c4. Security Overview
Detected Code Changes
|
There was a problem hiding this comment.
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Document the cap that the flexible builder applies to the default expected transformed response size, which the previous doc contradicted. - Price every `outcall_type` variant through `cost_http_request_v2` on a replica, including `fully_replicated`, whose `reserved` payload was the one encoding no test exercised. - Cover a flexible outcall over a committee of three nodes with differing responses, so that each node transforming its own response via a closure is pinned down rather than only the single node case. - Mark the breaking CHANGELOG entries and note that pricing version 2 requires a replica providing `ic0.cost_http_request_v2`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lwshang
approved these changes
Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implement support for flexible HTTPS outcalls (
flexible_http_request), which allow a canister to specify how many nodes on the subnet should perform the requests, and out of those, how many responses are required/accepted to be received.Additionally, implement support for the new "pay-as-you-go" pricing for all HTTPS outcalls. Previously, HTTPS outcalls were charged in advance based on the
request_bytesand (user predicted)max_response_bytes. This was problematic, because settingmax_response_bytesto small meant failing the call, whereas setting it too large meant wasting cycles.Pay-as-you-go pricing only charges a base fee in advance, and reserves the remaining cycles that were attached as a budget against which the outcalls are performed by each replica. In the end, unspent cycles of this budget are refunded to the user.
Flexible outcalls always use the new pricing version
2. "Normal" outcalls made viahttp_requesttechnically continue to support (and default to) the old pricing version1. However, this PR switches the CDK's wrappers to always use version2.The recommended cycles budget to attach to a call is calculated via a new system API
cost_http_request_v2. The CDK does so automatically using the maximum sensible values. The maxima may be overwritten by functions of the newHttpRequestbuilder. This allows developers to tighten the cycles reservation which will be locked up throughout the call, by supplying the estimated resource consumption of their call.Added
HttpRequest, a builder forhttp_request. It always selects pricing version2("pay-as-you-go"), which charges for the resources the outcall consumes rather than formax_response_bytes.FlexibleHttpRequest, a builder for the newflexible_http_requestmethod, in which a committee of nodes return their individual HTTP responses instead of the subnet reaching consensus on one.with_expected_roundtrip_time_ms,with_expected_raw_response_bytes,with_expected_transformed_response_bytesandwith_expected_transform_instructionson both builders. Under pricing version2the attached cycles are also the budget each node may spend, so these narrow the reservation from "the most the outcall could consume" to what the caller expects. Anything left unset falls back to the maximum, which yields a reservation the outcall cannot exhaust but which holds far more cycles for the duration of the call.with_transform_closureon both builders, replacing the free functionhttp_request_with_closureand extending closure transforms to flexible outcalls.cost_http_request_v2and its argument typesCostHttpRequestV2ArgsandHttpOutcallType.SnapshotVisibilityandStatusVisibility, the types of theCanisterSettingsandDefiniteCanisterSettingsfields of the same name, and ofRenameCanisterRecordandRenameToRecord, the payload ofChangeDetails::RenameCanister. All four were reachable only by depending onic-management-canister-typesdirectly, which left those fields impossible to construct or match on.ic-management-canister-typesitems:FlexibleHttpRequestArgs,FlexibleHttpRequestResult,FlexibleHttpRequestErr,FlexibleHttpGlobalError,FlexibleHttpNodeDetail,FlexibleHttpNodeError,HttpRequestResourceReport,ReplicationCountsandResourceUsage.api::subnet_self_node_count, returning the number of nodes on the subnet. Useful for computing valid replication bounds forflexible_http_request.api::cost_http_request_v2, pricing a canister HTTPS outcall under pricing version2. It takes the Candid-encoded parameter record; prefer the typed wrappers inic-cdk-management-canister.Removed
http_request,cost_http_requestandhttp_request_with_closure. UseHttpRequestinstead, which prices the outcall with version2. Migrating deliberately rather than switching the pricing version underneath an unchanged call is the reason this is a breaking change rather than a silent one.HttpRequest::from_argsaccepts an existingHttpRequestArgs, so an existing call site can be migrated without rewriting how it builds its arguments.ic_cdk::api::cost_http_requeststill exposes version1pricing for callers that need it.Changed
ic-management-canister-typesbumped from0.7.1to0.10, which adds thepricing_versionfield toHttpRequestArgs, theflexible_http_requesttypes, and three fields toCanisterSettings.How Has This Been Tested?
Checklist: