Skip to content

fix(node): rate-limit admit reads and drop voucherless lanes - #3032

Open
alpergundogdu wants to merge 2 commits into
mainfrom
claude/2770-admit-rate-lane-gc-68b381
Open

alpergundogdu wants to merge 2 commits into
mainfrom
claude/2770-admit-rate-lane-gc-68b381

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2770. Finishes what #3016 started.

§1: token buckets on admission chain reads, set per payment chain

Each admission getPool and getAuthorization read is charged to two token buckets before it takes a read slot: one per requesting peer (keyed by its iroh PublicKey, a bounded map pruned past 4096 peers) and one for the whole payment chain. The ADMIT_CHAIN_READ_CONCURRENCY = 16 limit on reads in flight stays. The peer bucket is charged first, so a read that one peer's bucket refuses spends nothing of the chain-wide budget. Only the request that sends the read is charged: a request that waits on another request's read of the same pool or signer is not. A refused read is refused like a slot-wait timeout (PoolUnconfirmed / signer unconfirmed, nothing cached).

The rates are set in each [[blockchain.payment_chains]] entry, since each chain has its own rpc_url and quota. Every pool on a chain shares one budget (AdmitReadBudget, built once per chain in accepted_pools). The defaults are deliberately generous:

Key Default
admit_reads_per_sec 20
admit_read_burst 40
admit_reads_per_peer_per_sec 2
admit_read_burst_per_peer 8

Each key must be at least 1. decdn config validate prints the resolved rates, and the default template lists the four keys.

PoolView gains admit_status / admit_signer_authorization, which take the requester. Their defaults delegate, so test doubles are unchanged. ResolvingPoolView::new takes the chain's Arc<AdmitReadBudget>. New counters: decdn_serve_admit_read_rate_limited_{per_peer,global}_total.

§2: drop voucherless lanes

ClientHandler::forget_voucherless_expired_lanes runs in the 30 s pool refresh loop. It drops each lane that never carried a voucher (last_signature is None) once its capability has expired, from both the live map and the lane store (via forget_lane). The voucher path refuses vouchers inside the expiry margin, so the check under the lane lock cannot race a voucher. New counter: decdn_lanes_dropped_voucherless_total.

Declined or moot

Docs

  • ADR 003 § Pool solvency: the per-chain read-rate buckets.
  • ADR 003 § Off-chain voucher state persistence: when a lane record exists and when it is dropped.
  • architecture.md threat row.
  • appendix-observability.md: rows for the three new counters.

Checks

  • cargo nextest run -p decdn-common -p decdn-cli -p decdn-node: 3336 passed. One retry of the known-flaky node_origin_pull::concurrent_pulls_resume_at_their_own_frontier_not_the_lanes passed.
  • cargo clippy --workspace --all-targets --all-features: clean
  • cargo doc gate: clean
  • cargo test --no-run -p decdn-e2e --features anvil-e2e: builds

🤖 Generated with Claude Code

Admission getPool/getAuthorization reads are charged to a per-peer and a
node-wide token bucket on top of the in-flight slot cap; a refused read
gets the slot-wait refusal. The pool refresh loop drops lanes that never
carried a voucher once their capability expires, from memory and redb.

Closes #2770

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main d769020 claude/2770-admit-ra... c76f433 +/-
78% 78% 0%
View coverage of the 10 most impacted files.
File main d769020 claude/2770-admit-ra... c76f433 +/-
crates/node/src...t_settlement.rs 83% 83% 0%
crates/client/src/lib.rs 89% 89% 0%
crates/common/s...c/config/mod.rs 97% 97% 0%
crates/node/src...s/client/mod.rs 89% 89% 0%
crates/node/src/runtime/mod.rs 28% 28% 0%
crates/cli/src/...mands/config.rs 83% 83% 0%
crates/node/src...ent/dispatch.rs 82% 82% 0%
crates/node/src...ntime/reload.rs 93% 93% 0%
crates/protocol/src/framing.rs 92% 93% +1%
crates/node/src/pool_view.rs 84% 85% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 27, 2026 14:22 UTC

Each [[blockchain.payment_chains]] entry takes admit_reads_per_sec,
admit_read_burst, admit_reads_per_peer_per_sec and
admit_read_burst_per_peer (defaults 20, 40, 2, 8). One budget serves
every pool on a chain, since the chain's RPC endpoint carries the quota.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

node: cheap request paths exhaust chain-RPC quota, lane storage, origin egress, and logs

1 participant