Skip to content

docs(adr): spec BatchStoreRequest for bootstrap and dense re-publish - #632

Merged
alpergundogdu merged 2 commits into
mainfrom
batch-store-request
May 21, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
batch-store-request

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Adds the batched STORE variant to ADR 022, motivated by the bandwidth analysis landed in #631 (bottleneck-regimes section identified QUIC stream-setup overhead as the dominant bootstrap cost at moderate C, with batched STORE projected to save ~60% of bootstrap bytes-on-wire).

Four touches:

  • § Message Types — adds BatchStoreRequest { hashes: Vec<Hash>, holder: NodeId } and BatchStoreAck { results: Vec<(Hash, bool)> } as new DhtMessage variants. Single holder per batch, checked once against authenticated QUIC NodeId. Per-hash outcomes in request order.
  • § STORE Flow — adds **Batched STORE.** paragraph specifying when to use the variant (cold start, concentrated re-publish windows), the 256-hash batch ceiling, and the unknown-variant fallback negotiation.
  • § DHT Rate Limiting — adds **Batch token accounting.** A batch of n hashes consumes min(k, n) tokens from each bucket where k is the minimum remaining budget across the three layers. First k admitted, remainder marked accepted: false in the ack. Partial admission means publishers retry only the rejected tail, not the whole batch.
  • § Schema Evolution — notes new optional variants with per-hash fallback are minor changes (no ALPN bump), using stream-close-without-ack as the natural negotiation signal under the existing "unknown variants are silently dropped" rule.

Acceptance criteria 17–20 cover batched STORE behavior (per-hash admission semantics match unbatched, batch token accounting, oversized-batch rejection, fallback negotiation).

Closes #630.

Why this shape

The wire types match what the bandwidth analysis in #631 assumed when it derived the ~60% savings figure — single holder per batch (de-duplication source), Vec<(Hash, bool)> ack (explicit per-hash debugging at the cost of ack size). A more compact ack (bitmap) would save more bytes but lose the request-recovery-on-misorder property; given bootstrap is the load-bearing case and ack size is dominated by request size anyway, the explicit form is a reasonable tradeoff.

Partial admission under rate-limit pressure (first k succeed, rest fail in the ack) is more publisher-friendly than all-or-nothing rejection — when only the tail of a batch is over budget, the publisher retries only the rejected entries instead of resubmitting the whole batch. The token-accounting spirit is preserved: total work per second is identical whether n separate StoreRequests or one BatchStoreRequest of size n is sent.

Unknown-variant negotiation (stream close without ack → publisher falls back to per-hash STORE) leverages the existing schema-evolution rule that "unknown variants are silently dropped," so no new error codes or capability-discovery mechanism is needed.

Test plan

Related

Adds the batched STORE variant motivated by the bandwidth analysis in
ADR 022 § DHT Bandwidth Analysis bottleneck regimes section. Wire-bytes
reduction at bootstrap is ~60% (~30pp from framing elimination, ~20pp
from holder-field de-duplication).

§ Message Types — adds BatchStoreRequest { hashes: Vec<Hash>, holder:
NodeId } and BatchStoreAck { results: Vec<(Hash, bool)> } as new
DhtMessage variants. Single holder per batch is checked once against
the authenticated QUIC NodeId; per-hash outcomes ship in request order.

§ STORE Flow — adds a Batched STORE paragraph specifying when to use
the batched variant (cold start, concentrated re-publish windows), the
256-hash batch ceiling, and the unknown-variant fallback negotiation.
Receiver-anchored TTL still applies per-hash from a single batch
receive_us.

§ DHT Rate Limiting — adds batch token accounting. A batch of n hashes
consumes min(k, n) tokens from each bucket where k is the minimum
remaining budget across the three layers; first k hashes admitted for
per-hash processing, remainder marked accepted: false in the ack.
Partial admission lets publishers retry only the rejected tail rather
than the entire batch.

§ Schema Evolution — notes new optional variants are minor changes (no
ALPN bump) when they have an existing per-hash equivalent, with
stream-close-without-ack as the natural negotiation signal under the
existing "unknown variants are silently dropped" rule.

Acceptance criteria 17–20 added for batched STORE behavior.

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a batched STORE mechanism to the DHT protocol to optimize bandwidth during bootstrap and re-publication. It adds BatchStoreRequest and BatchStoreAck messages, defines a batch size limit of 256 hashes, and implements a partial admission strategy for rate limiting. Feedback focuses on optimizing the acknowledgement payload by removing redundant hashes, ensuring internal consistency regarding message type inspection, addressing potential resource exhaustion during deserialization, and clarifying specific error codes for protocol violations.

Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Comment thread adr/022-content-discovery.md Resolved
Nine refinements caught in code review:

§ Message Types — BatchStoreAck changed from Vec<(Hash, bool)> to
Vec<bool>. Hash was redundant since results are required to be in
request order; removing it saves ~7 MB across modeled bootstrap traffic
and brings batched bootstrap savings from ~60% to ~80%.

§ STORE Flow — explicit error code (MALFORMED_MESSAGE / 0x03) for
oversized batches per ADR 013. Batched STORE paragraph clarifies that
holder is a single batch-level field, not per-hash, so the equality
check vs authenticated QUIC NodeId fires once per batch rather than
per hash.

§ DHT Rate Limiting — clarified that the uniform-per-message-type rule
covers FindValue/FindNode/Store while BatchStore uses a two-stage
variant. Rate-limit accounting rewritten as two stages so cheapest-first
ordering is preserved: stage 1 charges 1 token before deserialization
(rate-limits attackers spamming oversized batch frames at the cheapest
possible check); stage 2 charges up to n-1 more after parsing the
header. Total tokens consumed match the per-hash equivalent. Holder
check moved into stage 2 (with MALFORMED_MESSAGE on mismatch). Minus
signs U+2212 replaced with hyphen-minus throughout.

§ DHT Bandwidth Analysis bottleneck regimes — updated to reflect
Vec<bool> ack: total bootstrap bytes drop from ~15 MB to ~8 MB
(~80% reduction, ~30pp framing + ~20pp holder dedup + ~20pp ack-shape
compaction). Replaced "Specified in a follow-up" with cross-references
to the relevant sections now that the spec lives in this ADR.

Acceptance criteria 17, 18, 19 updated to match the spec changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@alpergundogdu
alpergundogdu merged commit 29dee80 into main May 21, 2026
11 checks passed
@alpergundogdu
alpergundogdu deleted the batch-store-request branch May 21, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DHT: batch StoreRequest for bootstrap and dense re-publish

1 participant