fix(peer): enforce the #30 egress budget on the module-range serve path - #137
Merged
Merged
Conversation
MichaelTaylor3d
force-pushed
the
fix/1616-module-range-egress-budget
branch
from
August 2, 2026 06:35
3d1df61 to
6d68ad1
Compare
stream_module_range (the whole-capsule dig.fetchModuleRange serve — the largest transfer in the system) consulted only the FCFS serve_limiter and recorded outgoing bytes, but never consulted the operator-configured #30 egress budget the way stream_range does. So a configured egress cap was silently bypassed on exactly the path where it matters most. Check bandwidth_redirect once before the first frame, against the window this stream will actually serve: over budget with a known alternate holder, decline with the redirect frame (same {"error": …} shape the not-held answer already uses, which the puller handles by sourcing the window elsewhere); no alternate holder, serve anyway (never drop a request only this node can answer) — identical semantics to stream_range. Tests (mutation-verified): over-cap + a known provider declines/redirects; over-cap + no provider still streams the window. Closes #1616 Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
force-pushed
the
fix/1616-module-range-egress-budget
branch
from
August 2, 2026 07:04
6d68ad1 to
60488cd
Compare
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.
What changed
stream_module_range— the whole-capsuledig.fetchModuleRangeserve, the largest transfer in the system — consulted only the FCFSserve_limiterand recorded outgoing bytes, but never consulted the operator-configured #30 egress budget the waystream_rangedoes (bandwidth_redirect/would_exceed). An operator's configured egress cap was silently bypassed on exactly the path where it matters most.This adds the same budget gate
stream_rangeuses, checked once before the first frame against the window this stream will actually serve:{"error": …}withdata.redirect) — the same shape the not-held answer already emits, which the module-range puller (read_module_window) handles by sourcing the window from another provider.bandwidth_redirectreturnsNone, so serve anyway (never drop a request only this node can answer).Semantics are identical to
stream_range. The capsule-granularityContentId::capsule(store, root)is used for the provider lookup.Why this is wire-safe
The decline reuses the exact mechanism the not-held path already uses in production (
write_framed(out, &{"error": …})): the reshare/module-pull puller already treats such a frame as "this holder can't serve → try another provider." No change to the frame wire or the puller.Blast radius (gitnexus/manual)
stream_module_range(peer.rs) only — the change is a pre-stream guard. The puller (module_transport::read_module_window) is unchanged and already handles the{"error": …}decline.bandwidth_redirectandavailability_content_idare reused unchanged.Verification
stream_module_range_over_cap_with_a_provider_declines_instead_of_streaming— over the 10-byte cap with a known capsule provider, the serve returns theCONTENT_REDIRECTframe naming the provider. Confirmed to FAIL when the guard is removed (it otherwise streams).stream_module_range_over_cap_with_no_provider_still_streams— over the cap with no known holder, the module window streams anyway.cargo fmt --all -- --checkclean ·cargo clippy -p dig-node-core --all-targets --all-features -D warningsclean.Note:
stream_range's PR#108 body claimed the module path was "paced by the same limiter" — true only of the FCFS limiter, not the #30 egress budget; this closes that gap.Version
fix:→ patch bump[workspace.package].version0.72.6 → 0.72.7.Closes #1616.
Generated by Claude Code