Repository navigation
docs(adr): spec BatchStoreRequest for bootstrap and dense re-publish - #632
Merged
Merged
Conversation
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]>
There was a problem hiding this comment.
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.
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]>
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.
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:
BatchStoreRequest { hashes: Vec<Hash>, holder: NodeId }andBatchStoreAck { results: Vec<(Hash, bool)> }as newDhtMessagevariants. Single holder per batch, checked once against authenticated QUIC NodeId. Per-hash outcomes in request order.**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.**Batch token accounting.**A batch ofnhashes consumesmin(k, n)tokens from each bucket wherekis the minimum remaining budget across the three layers. Firstkadmitted, remainder markedaccepted: falsein the ack. Partial admission means publishers retry only the rejected tail, not the whole batch.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
holderper 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
ksucceed, 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 whethernseparateStoreRequests or oneBatchStoreRequestof sizenis 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
make check-refs— ADR reference hygiene passesmarkdownlintvia pre-commitRelated