Skip to content

chore(protobuf): add the canister HTTP hashes-in-blocks messages - #11716

Merged
eichhorl merged 2 commits into
masterfrom
eichhorl/ch-hib-1-protos
Oct 1, 2026
Merged

eichhorl merged 2 commits into
masterfrom
eichhorl/ch-hib-1-protos

Conversation

@eichhorl

@eichhorl eichhorl commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds the protobuf definitions that stripping the canister HTTP responses from a
block proposal needs, without using any of them yet.

  • GetCanisterHttpResponseInBlock{Request,Response} — the RPC a replica will use
    to fetch a response content that was stripped from a block it is reassembling.
  • StrippedBlockProposal::stripped_canister_http_responses — the content hashes
    of the responses that were stripped from a block proposal.

The one Rust change is the struct literal that the new field forces, which leaves
it empty: nothing strips canister HTTP responses yet.

Stack

  1. chore(protobuf): add the canister HTTP hashes-in-blocks messages #11716 — protobuf definitions ← this PR
  2. feat(p2p): serve canister HTTP responses out of a block #11717 — serve canister HTTP responses out of a block
  3. feat(p2p): reassemble blocks whose canister HTTP responses were stripped #11718 — reassemble blocks whose canister HTTP responses were stripped
  4. feat(p2p): strip canister HTTP responses from block proposals #11719 — strip canister HTTP responses from block proposals (turns it on)

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema and generated bindings are consistent, and the existing conversion safely preserves current behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Adds protobuf contracts needed to strip and later retrieve canister HTTP responses from block proposals.

Changes:

  • Adds request/response messages for fetching stripped responses.
  • Adds response hashes to stripped block proposals.
  • Initializes the unused field as empty in current conversions.
File Description
rs/​protobuf/​def/​types/​v1/​consensus.proto Defines the new protobuf messages and field.
rs/​protobuf/​src/​gen/​types/​types.v1.rs Updates generated Rust protobuf bindings.
rs/​p2p/​artifact_downloader/​src/​fetch_stripped_artifact/​types/​stripped.rs Initializes the new field while stripping remains disabled.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@eichhorl
eichhorl added this pull request to stack #11725 October 1, 2026 07:50
@eichhorl
eichhorl marked this pull request as ready for review October 1, 2026 08:52
@eichhorl
eichhorl requested a review from a team as a code owner October 1, 2026 08:52
@zeropath-ai

zeropath-ai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to a7394e2.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/p2p/artifact_downloader/src/fetch_stripped_artifact/types/stripped.rs
· Add stripped_canister_http_responses field to StrippedBlockProposal
Enhancement ► rs/protobuf/def/types/v1/consensus.proto
· Import types/v1/canister_http.proto
· Add GetCanisterHttpResponseInBlockRequest message
· Add GetCanisterHttpResponseInBlockResponse message
· Extend StrippedBlockProposal with stripped_canister_http_responses field
· Add StrippedCanisterHttpResponse message
Enhancement ► rs/protobuf/src/gen/types/types.v1.rs
· Add GetCanisterHttpResponseInBlockRequest message struct
· Add GetCanisterHttpResponseInBlockResponse message struct
· Extend StrippedBlockProposal struct with stripped_canister_http_responses field
· Add StrippedCanisterHttpResponse struct

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema and generated bindings are consistent, and the placeholder initialization matches the staged rollout.

Review effort: Balanced
Findings: None

eichhorl and others added 2 commits October 1, 2026 14:00
Adds the protobuf definitions that stripping the canister HTTP responses
from a block proposal needs, without using any of them yet:

* `GetCanisterHttpResponseInBlock{Request,Response}`, the RPC a replica
  will use to fetch a response content that was stripped from a block it
  is trying to reassemble.
* `StrippedBlockProposal::stripped_canister_http_responses`, the content
  hashes of the responses that were stripped from a block proposal.

The one Rust change is the struct literal that the new field forces, which
leaves it empty: nothing strips canister HTTP responses yet.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…essage

Addresses the review suggestion to declare the stripped responses as a
`repeated StrippedCanisterHttpResponse` rather than a `repeated bytes`, so
that all three lists of stripped artifacts on `StrippedBlockProposal` have
the same shape, and so that the entry can gain a field later without needing
a new field number.

The wrapper costs two encoded bytes per entry, 36 instead of 34, which is
about a kilobyte on a block carrying the maximum number of responses. That is
a fraction of a percent of what stripping those responses saves.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@eichhorl
eichhorl force-pushed the eichhorl/ch-hib-1-protos branch from 28f97c8 to a7394e2 Compare October 1, 2026 12:00
@eichhorl
eichhorl added this pull request to the merge queue Oct 1, 2026
Merged via the queue into master with commit 687e6a4 Oct 1, 2026
38 checks passed
@eichhorl
eichhorl deleted the eichhorl/ch-hib-1-protos branch October 1, 2026 13:10
AleDema pushed a commit to AleDema/ic that referenced this pull request Oct 11, 2026
Teaches a replica to hand a peer the content of a canister HTTP response
that was
stripped from a block proposal — the half of hashes in blocks that has
to be in
place before anything starts stripping.

A new `/block/canister_http_response/rpc` endpoint answers a content
hash with the
matching `CanisterHttpResponse`, taken from the canister HTTP pool or,
once the pool
has dropped it, out of the block that delivers it. The new
`canister_http` module
knows how to walk the response slots of a canister HTTP payload, and
documents why
**every** response a payload delivers may be stripped from it: in each
case the
replicas that signed for it are already holding its content.

* A fully replicated response is proved by a quorum of `n - f`
signatures, one per
  replica that ran the outcall itself and signed that very content.
* A non-replicated or flexible response is produced by a single replica,
which
  therefore gossips it to everyone along with its share.

Note that serving a response deliberately looks past the
`ResponseVisibility` of its
share. Withholding a fully replicated response only keeps us from
*pushing* it at
peers that can produce it themselves; it says nothing about answering a
peer that is
missing one and asks for it by hash.

Nothing strips canister HTTP responses yet, so no peer asks and the
endpoint is
unreachable in practice.

### Stack

1. dfinity#11716 — protobuf definitions
2. **dfinity#11717 — serve canister HTTP responses out of a block ← this PR**
3. dfinity#11718 — reassemble blocks whose canister HTTP responses were
stripped
4. dfinity#11719 — strip canister HTTP responses from block proposals (turns it
on)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
AleDema pushed a commit to AleDema/ic that referenced this pull request Oct 18, 2026
…ped (dfinity#11718)

Teaches a replica to put the canister HTTP response contents back into a
block
proposal that was stripped of them — the other half that has to be in
place before
anything starts stripping.

A stripped block proposal now declares the content hashes of the
responses that were
pruned from its canister HTTP payload, the way it already does for its
ingress
messages and IDKG dealings. For each of them the assembler looks in the
canister HTTP
pool, which is indexed by exactly that hash and holds the content until
the outcall
has been answered, and otherwise fetches it from a peer over the
endpoint added in
dfinity#11717.

Declaring the hashes rather than re-deriving them from the payload
matters for cost: a
fully replicated response leaves its `n - f` signatures behind in the
stripped payload,
and scanning those back out of it measured **2.4 ms** per block on a
full 2 MiB payload
of fully replicated responses with a 40-node quorum — about 26% of block
assembly, in a
back-to-back A/B with the scan added back (p = 0.00). Recovering the
hashes needs a full
decode, since prost cannot decode part of a message, and the cost is
dominated by the
per-field allocations rather than the payload size.

A wrong or missing response can only make the block unwanted, never
mangle it: the
fetched response is checked against the hash that was asked for, and the
reassembled
block against the hash of the proposal that was claimed.

Nothing strips canister HTTP responses yet, so no block declares any and
the new code
paths stay unreached in practice; the tests exercise them by stripping a
proposal by
hand.

### Stack

1. dfinity#11716 — protobuf definitions
2. dfinity#11717 — serve canister HTTP responses out of a block
3. **this PR — reassemble blocks whose canister HTTP responses were
stripped**
4. next — strip canister HTTP responses from block proposals (turns it
on)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
AleDema pushed a commit to AleDema/ic that referenced this pull request Oct 18, 2026
…y#11719)

**This is the PR that turns hashes in blocks on for canister HTTP
responses.** A block
proposal now goes out without the contents of the responses it delivers,
naming them by
the content hash it already carries alongside each of them. Receivers
have been able to
serve (dfinity#11717) and reassemble (dfinity#11718) those contents since the previous
two PRs, so
this is where the bandwidth saving starts.

An outcall response can be up to 2 MB and the block used to carry it to
every peer, on
top of the copy the replicas already gossip to each other. A payload
with nothing to
strip is left untouched byte for byte, so a block without an outcall
response never pays
for being re-encoded.

Declaring a stripped content costs 36 bytes in the stripped proposal,
its 32-byte hash
plus framing, and only contents of at least 64 bytes are stripped, each
of which saves
at least 70 bytes for every slot it is taken out of. So **stripping a
response never
makes the proposal that goes out bigger** than the stripped proposal
that every data
block already goes out as. Break-even is at about 30 bytes of content,
and the threshold
deliberately stays close to it: the declared hash and the content it
replaces both go to
every peer, so the comparison is the same whatever the subnet size, and
with up to 500
responses per block each byte of slack is multiplied by five hundred —
at a 1 KiB
threshold a block could have carried half a megabyte of unstripped
content to every
peer. It also keeps the replica's own terse rejects in the block, which
save little or
nothing when stripped.

A response is stripped whatever kind of outcall it answers, because in
each case the
replicas that signed for it are already holding its content — see the
module docs of
`canister_http.rs`.

The assembler benchmark gains the canister HTTP dimension, parameterized
by the number
of signatures a response carries, since that is what dominates the cost
of stripping and
reassembling. At the 500-response cap with a 40-node quorum, stripping a
block costs
**5.4 ms** and reassembling one **9.8 ms**. That case uses 1 KiB
responses and the
10-byte node ids of the test utilities; with real, 29-byte node ids, 500
responses with
27 signatures each only fit into the 2 MiB payload limit with bodies of
about 800 bytes,
but the signatures that dominate the cost stay the same.

> Earlier revisions of this description quoted 3.4 ms and 6.4 ms for
those cases. Two
> benchmark cases exceeded `MAX_CANISTER_HTTP_PAYLOAD_SIZE`, and
`iterator_to_bytes`
> silently drops what does not fit, so they measured roughly 300
responses under a label
> claiming 500. The cases are now sized to fit and
`fake_canister_http_payload` panics
> rather than let that happen again.

### Worth a reviewer's attention

For a fully replicated outcall, a node whose own adapter has not
produced the response
yet when the block arrives used to get the bytes in the block and now
does a round trip
for them. It is bounded — at least `n - f` peers hold the content, and
it is no worse on
bandwidth — but it is a new dependency of block assembly on a peer fetch
in the common
outcall mode, not just the non-replicated one.

A receiver puts the payload back together by encoding what it decodes,
which only
reproduces the bytes the block hash covers because payload validation
accepts nothing
but canonically encoded canister HTTP payloads (dfinity#11751).

### Stack

1. dfinity#11716 — protobuf definitions (merged)
2. dfinity#11717 — serve canister HTTP responses out of a block (merged)
3. dfinity#11718 — reassemble blocks whose canister HTTP responses were
stripped (merged)
4. **this PR — strip canister HTTP responses from block proposals**

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants