Repository navigation
fix(node)!: drop floor debt and the per-IP rate layers, lower the default redeem threshold - #2873
Conversation
Floor debt charged an abandoned stream's unpaid floor to the capability signer. Signer keys are free, so a cheater rotates and starts clean, while an honest client that drops stalled lanes fills its cap and is locked out of the node until a restart. The per-stream credit window already bounds what one stream can take, and the pool ceiling and the per-signer live cap bound concurrent floor. The default redeem threshold drops from 1 USDC to 0.05 USDC, which caps the value a lane can leave unredeemed at capability expiry near the gas of one first-time redemption lane. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A relay-routed connection carries no client address, so an attacker that
dials through a relay skips a source-address layer for free, while
honest peers behind one NAT share one bucket. The rate limiters key on
the NodeId and a global bucket; the connection limiter is the global
concurrency cap.
Removed config keys: security.per_source_rate_per_sec,
security.per_source_burst, security.max_tracked_sources, and
{dht,probe,serve}.rate_limit.{per_ip_rate_per_sec,per_ip_burst,
max_tracked_per_ip}.
Closes #2505
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Documentation in ADR 013 and the protocol crate contains internally contradictory guidance about whether error code 0x10/APP_ERR_RATE_LIMITED is delivered via CONNECTION_CLOSE or RESET_STREAM, which could mislead implementers and needs correction before approval.
2 open issues
What changed in this PR
Simplifies node-side protections that were harming honest clients by removing floor-debt accounting and per-IP/per-source rate-limit layers, and lowers the default redeem threshold to reduce sub-floor expiry exposure.
Changes:
- Remove floor-debt tracking/settlement and rely on the credit window, pool ceiling, and per-signer live cap.
- Remove per-IP and per-source rate limiting, keeping per-peer (
NodeId) and global limiting plus a global connection concurrency cap. - Lower default
redeem_threshold_micro_usdcto50_000(0.05 USDC) and update docs/ADRs/metrics/tests accordingly.
| File | Description |
|---|---|
| docs/runbook.md | Updates operator runbook guidance to reflect the removal of floor debt/per-IP layers and the new redeem threshold and cap semantics. |
| crates/protocol/src/lib.rs | Updates protocol documentation for the APP_ERR_RATE_LIMITED (0x10) behavior and related delivery semantics. |
| crates/node/tests/support/mod.rs | Adjusts node test helpers/fixtures to the simplified security configuration shape after removing per-source/per-IP fields. |
| crates/node/tests/sighup_signal.rs | Updates SIGHUP reload tests to validate the new global concurrency-cap and reload validation behavior. |
| crates/node/tests/probe_warm_reconnect.rs | Updates probe warm-reconnect tests/config fixtures to match the two-layer (per-peer/global) limiter model. |
| crates/node/tests/probe_loopback.rs | Updates probe loopback tests to reflect removed per-IP/per-source limiting and updated rate-limit labeling/behavior. |
| crates/node/tests/node_origin_pull.rs | Updates origin pull tests to remove floor-debt/per-IP assumptions and align refusal/limiting behavior with the new model. |
| crates/node/tests/dht_loopback.rs | Updates DHT loopback tests to use the two-layer limiter configuration and remove per-IP/per-source references. |
| crates/node/tests/dht_lookup.rs | Updates DHT lookup tests for the simplified limiter stack and revised config fixtures. |
| crates/node/tests/dht_integration.rs | Updates DHT integration tests/fixtures to align with per-peer/global limiting and removed per-IP/per-source layers. |
| crates/node/tests/dht_bootstrap.rs | Updates DHT bootstrap tests to reflect the new limiter configuration and removed per-IP/per-source knobs. |
| crates/node/tests/client_loopback.rs | Updates client loopback tests to remove floor-debt coverage and per-IP rate-limit expectations. |
| crates/node/tests/anvil_bringup_shutdown_e2e.rs | Updates end-to-end bringup/shutdown fixtures to reflect removed config keys and updated defaults. |
| crates/node/src/runtime/tests.rs | Updates runtime tests for the revised resolved security config and removed limiter layers. |
| crates/node/src/runtime/reload/tests.rs | Adjusts reload tests to cover updated validation paths (including concurrency cap and invalid sections) after config simplification. |
| crates/node/src/runtime/reload.rs | Simplifies runtime reload application/logging to remove per-source/per-IP details and use the updated security config. |
| crates/node/src/runtime/mod.rs | Updates runtime wiring/background tasks to remove dispatch GC related to removed keyed layers and simplify limiter GC plumbing. |
| crates/node/src/rate_limit/tests.rs | Updates rate-limit engine tests for the remaining per-peer/global layers and their stable labeling/config mapping. |
| crates/node/src/prune_guard.rs | Updates prune-guard documentation to match the remaining keyed-map usage after removing per-IP/per-source limiters. |
| crates/node/src/node_origin/ranged_pull.rs | Updates origin ranged pull documentation/comments to reflect per-signer live-cap semantics post floor-debt removal. |
| crates/node/src/node_origin/mod.rs | Updates origin module docs to align refusal meanings and backpressure notes with the new protections model. |
| crates/node/src/metrics/tests.rs | Updates metrics tests/expectations for removed per-IP/per-source series and related naming changes. |
| crates/node/src/handlers/serve_rate_limit.rs | Refactors the serve rate-limiter wrapper to use only per-peer/global limiting and removes per-IP plumbing/metrics hooks. |
| crates/node/src/handlers/probe.rs | Simplifies the probe handler to remove per-IP limiting and align rejection handling with the two-layer limiter model. |
| crates/node/src/handlers/probe_rate_limit/tests.rs | Updates probe rate-limit tests to match the per-peer/global limiter behavior and updated close/reset semantics. |
| crates/node/src/handlers/probe_rate_limit.rs | Refactors probe limiter code to the two-layer limiter model and removes per-IP logic. |
| crates/node/src/handlers/dht.rs | Simplifies DHT handler limiting/plumbing to remove per-IP threads and use per-peer/global rate limiting only. |
| crates/node/src/handlers/client/window.rs | Updates client window logic/comments to reflect removal of floor-debt charging and the remaining reservation semantics. |
| crates/node/src/handlers/client/serve_leg.rs | Removes floor-debt bookkeeping from serve legs and reconciles live reservations based on cumulative paid value. |
| crates/node/src/handlers/client/outcome/tests.rs | Updates outcome tests to remove per-IP rejection-layer coverage and align expectations with the new limiter model. |
| crates/node/src/handlers/client/outcome.rs | Removes per-IP outcome paths/metrics and floor-debt helpers from client outcome handling. |
| crates/node/src/handlers/client/dispatch.rs | Removes per-IP limiter keying/plumbing in dispatch while keeping the remaining request-limiting behavior by peer identity. |
| crates/node/src/handlers/client/delivery.rs | Reworks delivery/reservation handling to eliminate floor-debt settlement and rely on live reservation reconciliation. |
| crates/node/src/dht/rate_limit.rs | Refactors DHT limiter wrapper to the remaining per-peer/global limiter layers and removes per-IP logic. |
| crates/node/src/dht/bucket_refresh.rs | Updates bucket refresh docs/comments to match per-peer (not per-IP) DHT limiting assumptions. |
| crates/node/src/admin/tests.rs | Updates admin tests/fixtures for the simplified security config and removed per-source/per-IP limiter fields. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Updates e2e coverage and narrative around pool floor/ceiling behavior after removing floor debt and lowering the redeem threshold default. |
| crates/e2e/src/node.rs | Updates e2e node fixture documentation/config defaults to match per-signer live-cap semantics and removed keys. |
| crates/common/src/config/types.rs | Removes per-IP/per-source config keys and updates defaults/docs (including the lowered redeem threshold). |
| crates/common/src/config/resolved.rs | Updates resolved config structures/defaults to remove per-IP/per-source layers and reflect the new limiter model. |
| crates/common/src/config/errors/tests.rs | Updates config notice/error tests to match new field names and validation messages after removing keys. |
| crates/common/src/config/errors.rs | Updates config error/notice documentation and examples to reflect the revised schema and field naming. |
| crates/client/src/source_set.rs | Updates client-side comments/docs around refusal meanings to align with per-signer live-cap semantics. |
| crates/client/src/scheduler.rs | Updates scheduler commentary around refusal/backpressure semantics to match the simplified node protections. |
| crates/client/src/rate_limited/tests.rs | Updates client rate-limited parsing/tests to reflect updated labels/semantics after limiter layer removal. |
| crates/client/src/rate_limited.rs | Updates client documentation/examples for upstream rate-limited labeling and behavior post per-source removal. |
| crates/cli/tests/doctor_cli.rs | Updates CLI doctor tests to reflect the revised config notices/fields and removed keys. |
| crates/cli/tests/config_validate.rs | Updates config validation tests/output expectations for removed keys and updated notice/warning fields. |
| crates/cli/tests/admin_rpc.rs | Updates CLI admin RPC tests/fixtures for the simplified security configuration and limiter model. |
| crates/cli/src/commands/doctor/config/tests.rs | Updates doctor-config rendering tests to match new notice field names/messages after schema changes. |
| crates/cli/src/commands/config.rs | Updates config command output/templates to remove deleted keys and reflect the lowered redeem threshold default. |
| Cargo.toml | Updates workspace/dependency notes to match the remaining rate-limiting implementation after simplification. |
| adr/architecture.md | Updates architecture ADR content to remove floor-debt/per-IP references and align threat/mitigation descriptions with the new model. |
| adr/appendix-observability.md | Updates observability appendix to remove per-IP/per-source metrics and reflect current metric families/series. |
| adr/039-multi-source-parallel-fetch.md | Updates ADR text to align backpressure/refusal explanations with per-signer live-cap semantics (no floor debt). |
| adr/022-content-discovery.md | Updates content-discovery ADR to describe two-layer (per-peer/global) rate limiting and remove per-IP rationale/observability. |
| adr/013-schema-evolution.md | Updates schema-evolution ADR sections describing rate-limit error codes/semantics to match the revised limiter model. |
| adr/005-protocol.md | Updates protocol ADR to remove per-IP layer references and align probe/request limiting descriptions with the simplified design. |
| .claude/skills/decdn-spec-discipline/references/decdn-precedents.md | Records updated precedents for removing floor debt and per-IP/per-source rate-limit layers. |
Review effort: Balanced
…ream Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cdn#2873 (#210) decdn/decdn#2873 deletes the per-source dispatch limiter and the per-IP layer of the dht, probe and serve rate limiters, with their config keys and metrics, and lowers the default redeem threshold to 50_000 µUSDC. - node.toml.j2, role defaults, the rate-limit key guard and README: drop security.per_source_*/max_tracked_sources and the per_ip_* / max_tracked_per_ip rate-limit keys. - schema-keys.txt: the 12 removed paths (gen-schema-keys.py output for the #2873 branch). - molecule default/schema/validation and the chart's ci-values: stop setting the removed keys. - Dashboards: drop the per-IP and per-source series and the per-IP term of the unattributed-failures expression. - Redeem threshold default comment: 0.05 USDC. Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Take main's removal of floor debt (#2873), including its floor-debt tests; keep this branch's proven-size Declined row and imports. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…credit Brings in #2879 (the size proof is the only statement of a blob size), #2900 and the squash of #2873, whose code this branch already carries. Conflict resolutions: - node window.rs: main's new unproven-size and out-of-bounds refusals release a floor reservation; this branch has none, so those calls go. - node dispatch.rs, window.rs imports: drop both the floor types and StreamResponseBody. - cli fetch.rs: keep the PayerTrust guard; drop prove_size, which main removes. - client streamer.rs: apply the pay-ahead policy, then read the proven size. - client public_api snapshot regenerated. - e2e pool_floor_ceiling_aggregate.rs stays deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Kpvr4Hsh3j4uw3sPiHpYkv

Problem
Three node-side protections cost honest users more than they cost attackers.
redeem_threshold, and an expired capability pays nothing, so a pool owner can take up to the threshold per capability at each node. The default threshold was 1 USDC.Fix
owes_floor_debt/settle_end,track_unpaid/reconcile_paid, the debt half of the per-signer cap refusal, and their tests are gone (a revert of fix(node): keep an abandoned stream's free floor as floor debt #2779 onto currentmain, with two conflicts resolved by hand). The per-stream credit window bounds what one stream can take; the pool ceiling (remaining − M) and the per-signer live cap (kwindows) still bound concurrent un-vouchered floor. The ADR 041 warming allowance does not depend on floor debt and is unchanged.50_000µUSDC, commit 1). One first-timeredeemManylane costs about 63.4k gas, about $0.002 on Arbitrum One at a 0.01 gwei base fee and $3,000 ETH. So 0.05 USDC keeps a lane's gas near 4% of what it redeems, with room for a 10x fee spike. This shrinks the redeemer: a sub-floor lane that reaches capability expiry is never redeemed, so a pool owner can take up to redeem_threshold per capability lifetime for free #2836 exposure from 1 USDC to 0.05 USDC per capability per node. It does not remove it: a value that stays below the threshold until expiry still pays nothing. ADR 003 states the residual.LayeredRateLimiter) keys onNodeIdand a global bucket only.ConnectionLimiteris the global concurrency semaphore only.peer_ipstays, only to count inbound connections as direct or relayed.Config keys removed (a config that sets one no longer parses, since every section denies unknown fields):
security.per_source_rate_per_sec,security.per_source_burst,security.max_tracked_sources{dht,probe,serve}.rate_limit.per_ip_rate_per_sec,.per_ip_burst,.max_tracked_per_ipdecdn/devops needs a re-sync: the schema-key inventory (
ansible/molecule/schema/files/schema-keys.txt),node.toml.j2,defaults/main.yml,charts/decdn-node/ci/ci-values.yaml, and the per-IP panels indashboard-node.json.Metrics removed:
decdn_dispatch_rejected_per_source_total,decdn_dispatch_per_source_skipped_no_addr_total, and the{probe,dht,serve}_rate_limit_{rejected_per_ip_total,prune_sweeps_per_ip_total,tracked_per_ip}series.adr/appendix-observability.mdmatches.ADR 003, 005, 013, 022, 039,
architecture.md,appendix-observability.md, the runbook and theconfig inittemplate are updated. The spec-discipline precedents record floor debt and the per-IP layers beside the #1957 leaky bucket.Closes #2831
Closes #2841
Closes #2780
Closes #2505
Refs #2836: the exposure shrinks to the 0.05 USDC threshold per capability per node; the issue stays open.
Testing
cargo fmt -- --check: cleancargo clippy --workspace --all-targets --all-features -- -D warnings: cleanCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: cleancargo test --no-run -p decdn-e2e --features anvil-e2e: buildsmake -C adr check-refs: cleancargo nextest run -p decdn-node -p decdn-common -p decdn-cli -p decdn-client -p decdn-protocol: 5047 passed (1 flaky, passed on retry)probe_rate_limit_returns_rate_limited_close_code,probe_once_types_a_rate_limit_close_as_upstream_rate_limited) hold the global cap; the security reload and SIGHUP tests drivemax_concurrent_handlersand use[load_shed]for the invalid-section case; newsecurity_section_rejects_per_source_keysandacquire_admits_many_connections_from_one_address.🤖 Generated with Claude Code