Repository navigation
Description
Decision (2026-07 ADR simplification audit). Filed under the Protocol simplifications milestone — sibling to #1396, #1394, #1419. Verdict: DROP. A special-case allow-list bypass whose benefit the default limiter headroom already covers; raise the numeric limit instead.
Drop the trusted-IP rate-limit exemption (probe + DHT)
Status: proposal for discussion, not a decision.
Summary
Both cdn/probe/v1 (ADR 005 §Probe rate limiting) and cdn/dht/v1 (ADR 022
§DHT Rate Limiting) run the same three-layer token-bucket limiter: global →
per-IP → per-peer. On top of that shared limiter, each ALPN carries a
trusted_ips allow-list that lets an operator exempt configured source IPs
from the middle (per-IP) layer only. This proposes removing that allow-list
from both ADRs and the code. Keep all three limiter layers exactly as they are;
an operator who needs more per-IP headroom raises per_ip_rate_per_sec /
per_ip_burst instead of maintaining a list of IPs that skip the layer.
This is a special-case bypass whose stated benefit the default headroom already
covers. It is scale-independent — dropping it does not lower any ceiling.
Motivation
-
The stated use cases already sit under the default limits. The ADRs
justify the exemption with "peer operators with predictable cache-miss / DHT
traffic" and "in-cluster monitoring." Node-to-node traffic uses stable IPs
and, per ADR 022 §Headroom against rate limits, realistic steady-state load
runs ~two orders of magnitude below the per-peer cap — nowhere near the
per-IP cap either (DHT per-IP default 100/s burst 200; probe per-IP default
50/s burst 200). Nothing in the modeled traffic needs the middle layer
lifted. -
On the probe path the exemption barely does anything. The probe handler
runs the ADR 005 per-IP layer and the always-onConnectionLimiter
per-source IP bucket (security.per_source_*, default 100/s), which
trusted_ipsdoes not bypass (documented at
crates/node/src/handlers/probe_rate_limit.rs:24). So exempting a probe
trusted IP only raises its effective per-IP ceiling from 50/s to the 100/s
dispatch cap — never to unbounded. A knob that moves one number to another
number the operator could have just set is not carrying its weight. -
In-cluster monitoring is local. A monitoring host scraping a node's
admin/metrics surface does not go throughcdn/probe/v1orcdn/dht/v1at
the rates that would trip a token bucket. This is not a real pressure on the
per-IP layer. -
It is a standing allow-list to maintain and a misconfiguration/abuse
vector. Every exempted IP is an operator-curated hole in the middle
defense layer. It has to be parsed, validated, IPv6-/64-masked to match the
inbound key (crates/node/src/rate_limit.rs:244), kept current as peer IPs
change, and reasoned about during incidents. A stale or shared-NAT entry
silently widens the bypass. The fix for "this peer needs headroom" —
raising the numeric per-IP limit — has none of that surface. -
It is redundant with the knob it shadows. The per-IP layer is already
fully governable per node. "Exempt these IPs from the per-IP layer" and
"raise the per-IP layer" solve the same problem; the numeric knob is the
general one and keeps the layer's invariant (every IP is bounded) intact.
What removal touches
Blast radius is contained — the exemption is one field threaded through the
shared limiter, plus doc paragraphs and tests. No wire-format or contract
change.
-
ADRs.
- ADR 005 (
adr/005-protocol.md): delete the Trusted-IP exemption
paragraph (line 104) under §Probe rate limiting. - ADR 022 (
adr/022-content-discovery.md): delete the Trusted-IP
exemption paragraph (line 164) under §DHT Rate Limiting; drop the
dht.rate_limit.trusted_ipsmention in the §DHT config-key prose.
- ADR 005 (
-
Rust — shared limiter engine (
crates/node/src/rate_limit.rs).- Remove the
trusted_ipsfield fromRateLimitConfig(line 89) and from
ThreeLayerRateLimiter(line 225) plus itsDefaultinit (line 106) and
the mask-into-set innew()(line 244). - Delete the per-IP bypass branch in
try_admit_one
(if !self.trusted_ips.contains(&ip), lines 302–316) — the per-IP layer
then always charges when an IP key is present. Update the module-level
"Trusted-IP exemption" doc block (lines 35–41). - Drop the field from both
From<&Resolved{Dht,Probe}>impls (lines 128,
144).
- Remove the
-
Rust — per-ALPN wrappers.
crates/node/src/dht/rate_limit.rsand
crates/node/src/handlers/probe_rate_limit.rs: trim the trusted-IP mentions
in the header docs (dht line 1-block; probe lines 8–9, 24–27). -
Rust — config resolver (
crates/common/src/config/).types.rs: removetrusted_ips: Option<Vec<String>>from
DhtRateLimitConfig(line 942) andProbeRateLimitConfig(line 996) plus
their doc comments and the two section-doc references to the config key.mod.rs: delete theparse_trusted_ipshelper (lines 2885–2911) and its
two call sites (lines 2725–2727, 2838–2840); droptrusted_ipsfrom the
two resolved-struct constructions (lines 2760, 2872). Remove the
malformed-IP testresolve_probe_malformed_trusted_ip_reports_probe_key
(line 10331) and the empty-set assertion at line 10293.resolved.rs: removetrusted_ipsfromResolvedDhtandResolvedProbe
(lines 503, 542) and theirDefaultinits (lines 520, 559); update the
field doc at line 487.
-
Config keys. Retire
probe.rate_limit.trusted_ipsand
dht.rate_limit.trusted_ips. Delete the two commented example lines in
crates/cli/src/commands/config.rs(lines 531, 542) and the
warn_ignored("dht.* (rate-limit, trusted_ips)")text at
crates/node/src/runtime/reload.rs:1153. (Because the config structs use
#[serde(deny_unknown_fields)], a leftovertrusted_ipsin a node's TOML
becomes a hard config error — call out in release notes.) -
Tests. Remove the ~7 dedicated exemption tests
(trusted_ip_bypasses_per_ip_layer_only,
trusted_ip_does_not_bypass_per_peer_or_global,
trusted_ip_still_subject_to_per_peer_layer,
trusted_ipv6_matches_masked_inbound_keyindht/rate_limit.rs;
trusted_ip_exempts_per_ip_onlyinprobe_rate_limit.rs; the two resolver
tests above). Delete thetrusted_ips: HashSet::new()line from the ~15
config-construction sites acrosscrates/node/tests/*(dht_bootstrap,
dht_lookup, dht_loopback, dht_integration, self_hosted_discovery,
probe_0rtt, probe_loopback) and the in-module test fixtures — these are
mechanical struct-literal edits once the field is gone.
What we keep
The three-layer token-bucket limiter is unchanged and stays fully governable:
- Global layer (default 1000/s burst 2000, both ALPNs).
- Per-IP layer (DHT 100/s burst 200; probe 50/s burst 200) — now with no
bypass; every source IP is bounded. - Per-peer (
NodeId) layer (DHT 20/s burst 40; probe 5/s burst 5). - Cheapest-first ordering, batch-token accounting for
BatchStoreRequest, the
keyspace bound (DHT rate limiter: bound per-IP / per-peer keyed limiter keyspace #645) and its GC sweeps, and all per-layer rejection metrics. - The always-on
ConnectionLimiterper-source bucket that already sits in
front of the probe path.
An operator who genuinely needs more per-IP headroom raises
per_ip_rate_per_sec / per_ip_burst for that node. That keeps the layer's
invariant — no IP is ever unbounded — while giving the exact same relief the
allow-list was for.
Counter-argument
[your call] The one scenario the numeric knob covers less precisely: an
operator who wants one specific peer or monitoring host to have a much
higher per-IP ceiling than everyone else. With the allow-list you lift the cap
for just that IP; with the numeric knob you raise the per-IP cap for all
sources on that node. If a deployment has a heavily-trafficked peering partner
(say a co-located sibling node doing bursty cross-peer DHT STOREs at cold
start) and the operator wants to keep a tight per-IP cap for strangers while
uncapping the partner, per-IP-raise is a blunter instrument. Whether that
precision is worth a standing allow-list — versus setting a per-IP cap high
enough to cover the partner and leaning on the per-peer + global layers (which
still bound the partner and still bound the aggregate) — is the judgment call
here. Note the partner is still bounded by per-peer and global even when
per-IP-exempt today, so the exemption never removed all bounds; it only removed
the middle one.
Open questions
- Is there any current or near-term deployment that actually sets a non-empty
trusted_ipson either ALPN? If the field is unset everywhere (the default
is empty), removal is pure surface reduction with zero behavioral change for
live nodes. - On the probe path the exemption only lifts 50/s to the 100/s dispatch cap
(motivation 2) — does anyone view even that narrow bump as load-bearing, or
does it confirm the probe-side exemption is dead weight regardless of the
DHT decision? (We could drop probe-side only and keep DHT, but the symmetry
argument cuts the other way.) #[serde(deny_unknown_fields)]turns a staletrusted_ipskey into a
startup error. Acceptable as a loud migration signal, or do we want a
one-release grace where the key is ignored with a warning (via the existing
warn_ignoredpath) before hard-removing it?
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
altanoruc commentedon Jul 24, 2026
Automated implementation triage note for a later run: the decision header resolves removal, but the config migration remains open. Because deny_unknown_fields makes a stale trusted_ips key a startup error, please choose immediate hard removal versus a one-release warn-and-ignore grace period. Also confirm whether any current deployment uses a non-empty allow-list. Once the migration behavior is pinned, the code scope is otherwise prescriptive.
fix: address review findings on the #1438/#1440 removal
fix(rate-limit): pin the From<&Resolved*> mappings and make limiter w…