fix: Reserve enough HTTP outcall cycles for any deliverable result to fund itself - #11200
Open
eichhorl wants to merge 14 commits into
Open
fix: Reserve enough HTTP outcall cycles for any deliverable result to fund itself#11200eichhorl wants to merge 14 commits into
eichhorl wants to merge 14 commits into
Conversation
… into eichhorl/scale-consensus-cost
Contributor
There was a problem hiding this comment.
Pull request overview
Scales HTTP outcall consensus reserves so the minimum required contributors can fund response delivery.
Changes:
- Adds a shared canister HTTP consensus-threshold helper.
- Rounds and distributes consensus reserves per replica.
- Expands pricing and payload-validation coverage.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
rs/types/types/src/canister_http.rs |
Adds the shared threshold calculation. |
rs/types/cycles/src/cycles.rs |
Adds ceiling division for cycles. |
rs/https_outcalls/pricing/src/payg.rs |
Verifies per-replica reserves. |
rs/https_outcalls/pricing/src/fees.rs |
Scales and rounds consensus fees. |
rs/https_outcalls/consensus/src/payload_builder/tests.rs |
Tests delivery at the quoted price. |
rs/https_outcalls/consensus/benches/payload_validation.rs |
Uses the shared threshold helper. |
rs/consensus/utils/src/membership.rs |
Centralizes committee threshold calculation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
eichhorl
marked this pull request as ready for review
August 19, 2026 14:55
|
✅ No security or compliance issues detected. Reviewed everything up to 8f1f1cf. Security Overview
Detected Code Changes
|
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.
Background
Under pay-as-you-go pricing, the canister making an HTTP outcall can compute an estimate of the expected cycles cost (and thus the recommended amount of cycles to attach), by calling the
ic0_cost_http_request_v2function.The attached cycles are then split evenly among all participating replicas, into the "per-replica allowances". Each replica consumes some of this allowance while making the HTTP request, and transforming and gossiping the response shares.
Aggregating the shares into the final response, which will be included and delivered as part of a block, costs a separate consensus fee. This consensus fee must be covered by the "unspent allowances" of replicas participating in the response.
Problem
If the recommended amount of cycles returned by
ic0_cost_http_request_v2tightly bounds the real cost of the outcall, this represents a liveness risk for the request.Because the attached cycles are evenly split between participating replicas, this means that also the cycles intended to cover the consensus fee are split evenly between them. In the worst case, this means that aggregating a response into a block requires the unspent allowance of all participating replicas in order to cover the fee. For example:
The same problem exists for flexible outcalls under most configurations. Notably, this problem does not exist for non-replicated outcalls, and more generally flexible outcalls where
min == max == total, since in those cases all nodes making the call need to participate in the response regardless.Proposed Changes
With this PR we therefore increase the recommended amount of cycles to attach to the call.
Specifically, for fully-replicated outcalls, we increase the cycles reserved for the consensus cost such that (after it is split into the allowances) shares from any set of
thresholdmany nodes are enough to cover it.For flexible outcalls, we increase the reserved cycles, such that each replica obtains enough allowance to cover for its own response to be included into the block.