feat: Async HTTP outcalls refunds - #11113
Merged
Merged
Conversation
…y/ic into eichhorl/switch-to-spent-receipts
…ity/ic into eichhorl/use-ctxt-size-and-schedule
…ichhorl/deliver-spent
Contributor
There was a problem hiding this comment.
Pull request overview
Implements asynchronous HTTP outcall refund receipts across consensus, validation, gossip, delivery, and metrics.
Changes:
- Adds async receipts to payload encoding and accounting.
- Retains, validates, and gossips late response shares.
- Adds receipt validation, tests, benchmarks, and metrics.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
rs/types/types/src/batch/canister_http.rs |
Adds async receipts to payload types. |
rs/protobuf/src/gen/types/types.v1.rs |
Adds generated receipt variant. |
rs/protobuf/def/types/v1/canister_http.proto |
Defines receipt wire encoding. |
rs/interfaces/src/canister_http.rs |
Adds validation errors. |
rs/https_outcalls/consensus/src/test_utils.rs |
Updates test payload construction. |
rs/https_outcalls/consensus/src/pool_manager.rs |
Retains and validates late shares. |
rs/https_outcalls/consensus/src/payload_builder/utils.rs |
Selects eligible receipts. |
rs/https_outcalls/consensus/src/payload_builder/tests.rs |
Tests receipt behavior. |
rs/https_outcalls/consensus/src/payload_builder/parse.rs |
Encodes and tracks receipts. |
rs/https_outcalls/consensus/src/payload_builder.rs |
Builds, validates, and delivers receipts. |
rs/https_outcalls/consensus/src/gossip.rs |
Requests shares for delivered contexts. |
rs/https_outcalls/consensus/benches/payload_validation.rs |
Updates validation benchmark. |
rs/consensus/src/consensus/metrics.rs |
Records delivered receipt metrics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅ No security or compliance issues detected. Reviewed everything up to eda9f49. Security Overview
Detected Code Changes
|
pierugo-dfinity
approved these changes
Aug 17, 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.
Background
The new pay-as-you-go pricing for HTTP outcalls consists of four phases:
In #10897, we implemented the infrastructure required for phases 3 and 4, and partly implemented phase 3: After a response for a "pay-as-you-go" context is delivered, the initial refund is applied, and the context is moved into a new collection
delivered_canister_http_contexts, where it waits for further asynchronous receipts to be delivered. After two minutes since the creation of the original context, the "delivered context" times out, refunding the allowances of all replicas that haven't reported a receipt yet, in full.Proposed Changes
This PR implements the inclusion, validation and delivery of asynchronous refund receipts (phase 4):
Client (pool manager):
delivered_canister_http_contextsare no longer purgeddelivered_canister_http_contexts. No work was done, so the replica's allowance will be refunded in full on timeout.delivered_canister_http_contexts. This is to report the work that was done.delivered_canister_http_contextsPayload builder:
delivered_canister_http_request_contextsand have not yet expired.Future Work
For flexible and non-replicated outcalls, the gossiped receipts still contain the full response bodies (just like normal shares for these replication types). However, these responses will never be included into a block, so we should avoid wasting bandwidth by only transmitting the share (like we do for fully replicated outcalls).