fix(file): pace chunks to fit rendezvous rate limit #22

Merged
sirius merged 2 commits from wt/t_fc02d8b6 into main 2026-09-12 04:11:10 +00:00
Owner

Summary

File transfer was silently truncated by the incoming rendezvous token bucket (30/60s, burst 10). A 1 MiB file is 17 one-shot Noise sessions; anything past the burst of 10 could be dropped with no retry.

This PR is a latency trade, not a protocol change and not a security fix. The DoS control is unchanged: same bucket constants, same pre-handshake drop, friends and floods still indistinguishable at accept.

Sender-side only:

  • First chunk attempt fires immediately.
  • Every later attempt (retries and later chunks) waits 3s (margin under the 0.5/s refill; 2s sits on the boundary).
  • 3 attempts per chunk, then fail closed. No outbox, no resume, no new xfer_id continuation.
  • fil frame layout unchanged.

Wall-clock cost (1 MiB / 17 chunks)

Pacing floor is 16 × 3s = 48s between the first and last attempt on the happy path, plus 17 Tor connect + Noise handshakes. Retries add another 3s each. That is the cost of fitting the published budget instead of being truncated by it.

Tests

  • Real TokenBucket::default(): unpaced 17 chunks drop 7; paced at 3s drop 0.
  • Transient per-chunk failure is retried and the transfer completes.
  • Exhausted retries return Err and do not continue later chunks / success report.

cargo test --locked green (148 passed / 3 ignored). cargo clippy --locked --all-targets -- -D warnings green. src/ratelimit.rs byte-identical to origin/main (blob 629f2bf182dbdfd96c0a1d04202ecba929da9270).

## Summary File transfer was silently truncated by the incoming rendezvous token bucket (30/60s, burst 10). A 1 MiB file is 17 one-shot Noise sessions; anything past the burst of 10 could be dropped with no retry. This PR is a **latency trade**, not a protocol change and not a security fix. The DoS control is unchanged: same bucket constants, same pre-handshake drop, friends and floods still indistinguishable at accept. Sender-side only: - First chunk attempt fires immediately. - Every later attempt (retries and later chunks) waits **3s** (margin under the 0.5/s refill; 2s sits on the boundary). - **3 attempts per chunk**, then fail closed. No outbox, no resume, no new `xfer_id` continuation. - `fil ` frame layout unchanged. ## Wall-clock cost (1 MiB / 17 chunks) Pacing floor is **16 × 3s = 48s** between the first and last attempt on the happy path, plus 17 Tor connect + Noise handshakes. Retries add another 3s each. That is the cost of fitting the published budget instead of being truncated by it. ## Tests - Real `TokenBucket::default()`: unpaced 17 chunks drop 7; paced at 3s drop 0. - Transient per-chunk failure is retried and the transfer completes. - Exhausted retries return Err and do not continue later chunks / success report. `cargo test --locked` green (148 passed / 3 ignored). `cargo clippy --locked --all-targets -- -D warnings` green. `src/ratelimit.rs` byte-identical to `origin/main` (blob `629f2bf182dbdfd96c0a1d04202ecba929da9270`).
[verified] fix(file): pace chunks to fit rendezvous rate limit
All checks were successful
ci / test (pull_request) Successful in 2m42s
4bbc2de9ab
Sender-side only. First chunk attempt is immediate; later attempts
(retries and later chunks) wait 3s. Three attempts per chunk, then
fail closed. Token bucket 30/60s burst 10 is unchanged.

A 1 MiB file is 17 one-shot sessions; pacing floor is 16*3s = 48s
plus handshake time. Latency trade, not a security fix.
Merge branch 'main' into wt/t_fc02d8b6
All checks were successful
ci / test (pull_request) Successful in 3m2s
dcb98132e2
sirius merged commit 175f5dd943 into main 2026-09-12 04:11:10 +00:00
sirius deleted branch wt/t_fc02d8b6 2026-09-12 04:12:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!22
No description provided.