Skip to content

fix(node)!: drop floor debt and the per-IP rate layers, lower the default redeem threshold - #2873

Merged
alpergundogdu merged 4 commits into
mainfrom
fix/payments-lower-redeem-floor-drop-floor-debt
Nov 13, 2026
Merged

alpergundogdu merged 4 commits into
mainfrom
fix/payments-lower-redeem-floor-drop-floor-debt

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Problem

Three node-side protections cost honest users more than they cost attackers.

Fix

  • Delete floor debt (commit 1). The debt accounting, 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 current main, 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 (k windows) still bound concurrent un-vouchered floor. The ADR 041 warming allowance does not depend on floor debt and is unchanged.
  • Lower the default redeem threshold to 0.05 USDC (50_000 µUSDC, commit 1). One first-time redeemMany lane 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.
  • Delete the per-IP and per-source rate layers (commit 2). The rate-limit engine (LayeredRateLimiter) keys on NodeId and a global bucket only. ConnectionLimiter is the global concurrency semaphore only. peer_ip stays, 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_ip

decdn/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 in dashboard-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.md matches.

ADR 003, 005, 013, 022, 039, architecture.md, appendix-observability.md, the runbook and the config init template 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: clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings: clean
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: clean
  • cargo test --no-run -p decdn-e2e --features anvil-e2e: builds
  • make -C adr check-refs: clean
  • cargo nextest run -p decdn-node -p decdn-common -p decdn-cli -p decdn-client -p decdn-protocol: 5047 passed (1 flaky, passed on retry)
  • Tests rewritten or deleted: per-IP/per-source tests are gone; the connection-limiter wire tests (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 drive max_concurrent_handlers and use [load_shed] for the invalid-section case; new security_section_rejects_per_source_keys and acquire_admits_many_connections_from_one_address.

🤖 Generated with Claude Code

alpergundogdu and others added 2 commits November 11, 2026 17:37
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]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:21
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 5bd3d25 fix/payments-lower-r... 2b32ecb +/-
77% 77% 0%
View coverage of the 10 most impacted files.
File main 5bd3d25 fix/payments-lower-r... 2b32ecb +/-
crates/node/src/dispatch.rs 93% 86% -7%
crates/node/src...t/rate_limit.rs 89% 85% -4%
crates/node/src...s/client/mod.rs 95% 92% -3%
crates/node/src/dht/publish.rs 78% 77% -1%
crates/common/s...c/config/mod.rs 97% 97% 0%
crates/node/src/runtime/mod.rs 28% 29% +1%
crates/node/src...ent/dispatch.rs 87% 88% +1%
crates/node/src/rate_limit.rs 96% 99% +3%
crates/node/src...e_rate_limit.rs 39% 49% +10%
crates/node/src...e_rate_limit.rs 49% 59% +10%

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


Updated November 11, 2026 20:08 UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_usdc to 50_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

Comment thread adr/013-schema-evolution.md Resolved
Comment thread crates/protocol/src/lib.rs Resolved
alpergundogdu added a commit to decdn/devops that referenced this pull request Nov 11, 2026
…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]>
@alpergundogdu
alpergundogdu merged commit 350fec6 into main Nov 13, 2026
40 checks passed
@alpergundogdu
alpergundogdu deleted the fix/payments-lower-redeem-floor-drop-floor-debt branch November 13, 2026 15:47
alpergundogdu added a commit that referenced this pull request Nov 13, 2026
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]>
alpergundogdu pushed a commit that referenced this pull request Nov 13, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants