Repository navigation
feat(node): probe-time stake-lane probe-acceptance reservation (#757) - #782
Conversation
Implement optional stake-lane prioritization at probe-acceptance time per ADR 003 §Admission and Priority. Under probe-hold-budget pressure, a node reserves the last N hold slots for stake-lane requesters — registered operators issuing node-to-node cache-miss probes — so end-client probe load cannot starve them. Stake-lane eligibility is the CapacityBond.isActive predicate, resolved from the existing chain-followed StakerSet (keyed by iroh NodeId via conn.remote_id()); no per-probe chain read and no new chain wiring. End-client probes over the ceiling get a signed has_blob:false (never a phantom-slash risk), counted by a new decdn_probe_stake_lane_reserved_total metric kept distinct from budget-exhaustion and config-disable. Strictly operator opt-in via the new cache.stake_lane_reserved_holds knob (default 0 ⇒ None policy ⇒ unchanged hot path). The reservation amount is typed NonZeroUsize so "off" is unrepresentable in StakeLanePolicy; a reservation paired with max_probe_holds=0 is warned and left off. - crates/node/src/handlers/probe.rs: StakeLanePolicy + pure stake_lane_reserved_out gate, wired into serve() before try_probe_hold - crates/node/src/runtime/mod.rs: build the staker set before the probe handler; gate policy construction on the config knob - crates/node/src/metrics.rs: decdn_probe_stake_lane_reserved_total - crates/common: [cache] stake_lane_reserved_holds (file + CLI flag + env + resolver + resolved struct + template) - adr/appendix-observability.md: register the new counter Tests: 5 unit tests on the decision fn, 2 loopback integration tests (end-client shed / stake-lane keeps headroom), 3 config-resolution tests, env-var-wiring test updated. Closes #757 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request implements a stake-lane probe-acceptance reservation policy to protect node-to-node cache-miss probes from being starved by end-client load under hold-budget pressure. It introduces the stake_lane_reserved_holds configuration, integrates the active-staker set into the probe handler, adds a dedicated metric, and includes comprehensive tests. The review feedback suggests a valuable performance optimization on the hot path to cache the slots_used value, avoiding a redundant lock acquisition and sweep when updating metrics.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR adds an optional “stake-lane” reservation at probe-acceptance time to prevent end-client probe load from starving registered operators’ node-to-node cache-miss probes, implemented using the existing chain-followed StakerSet and guarded behind an operator opt-in config knob.
Changes:
- Add an optional
StakeLanePolicyto thecdn/probe/v1handler that can reserve the lastNprobe-hold slots for stake-lane requesters and count reserved-out events in a dedicated metric. - Extend configuration (file/CLI/env) with
[cache] stake_lane_reserved_holds(default0), plus resolution tests and updated sample configs. - Add unit + loopback integration tests covering the reserved-out decision, signature correctness, and metric attribution.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/handlers/probe.rs | Implements optional stake-lane reservation gate ahead of try_probe_hold, plus unit tests for the decision function. |
| crates/node/src/metrics.rs | Adds decdn_probe_stake_lane_reserved_total counter and an increment helper. |
| crates/node/src/runtime/mod.rs | Builds shared chain-backed StakerSet, wires optional StakeLanePolicy into ProbeHandler, warns on dead config (reserved>0 with max=0). |
| crates/common/src/config/types.rs | Adds stake_lane_reserved_holds to cache config schema with operator-facing docs. |
| crates/common/src/config/resolved.rs | Adds resolved stake_lane_reserved_holds: usize to ResolvedCache. |
| crates/common/src/config/mod.rs | Adds default constant, resolves the new knob from CLI/file, updates env-var wiring list, and adds resolution tests. |
| crates/common/src/cli/run.rs | Adds CLI flag + env var DECDN_STAKE_LANE_RESERVED_HOLDS. |
| crates/cli/src/commands/config.rs | Updates default config template with commented stake_lane_reserved_holds. |
| adr/appendix-observability.md | Extends canonical metric registry to include decdn_probe_stake_lane_reserved_total. |
| crates/node/tests/probe_loopback.rs | Adds loopback integration tests for end-client shedding vs stake-lane admission, validating signature + metrics. |
| crates/node/tests/probe_0rtt.rs | Updates handler construction for new ProbeHandler::new parameter. |
| crates/node/tests/sighup_signal.rs | Updates resolved-config seeding to include the new cache field. |
| crates/node/src/runtime/reload.rs | Updates resolved-config seeding for runtime reload state/tests to include the new cache field. |
| crates/cli/tests/config_validate.rs | Updates sample resolved config to include stake_lane_reserved_holds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 86.57% (was 86.58%, ● 0.00%) — 25993/30024 lines
History
|
- probe.rs: sample probe_hold_slots_used() once in the stake-lane gate and reuse it for the slots gauge on the shed path, avoiding a redundant lock+sweep on the loaded path the gate fires under. - probe.rs: make stake_lane_reserved_out take is_stake_lane as a lazy FnOnce, evaluated only after the cheap ceiling guards pass, so the staker-set RwLock read + NodeId conversion is skipped on the uncongested common path. Add a test asserting the lookup is short-circuited below the ceiling. - metrics.rs: fix "two counters below" -> "above" (the referenced counters are declared above the field). - types.rs: clarify that reserved >= max_probe_holds sheds every end-client probe whenever holds are enabled, regardless of usage (not only under pressure). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
What
Implements optional stake-lane prioritization at probe-acceptance time (issue #757), per ADR 003 § Admission and Priority.
Under probe-hold-budget pressure, a node reserves the last N probe-hold slots for stake-lane requesters — registered operators issuing node-to-node cache-miss probes — so end-client probe load cannot starve them. Strictly operator opt-in and default-off.
How
CapacityBond.isActive, resolved from the existing chain-followedStakerSet(keyed by irohNodeIdviaconn.remote_id()). No per-probe chain read, no new chain wiring (the issue's constraint).probe_hold_slots_used >= max_probe_holds − stake_lane_reserved_holds), end-client probes get a signedhas_blob: false(never a phantom-slash risk; identical wire behaviour to budget exhaustion). Stake-lane requesters always pass the gate.decdn_probe_stake_lane_reserved_total, kept distinct fromprobe_hold_violations(budget) andprobe_holds_disabled(config) — their alerts have different remedies. The gate fires beforetry_probe_hold, so it's a content-independent admission decision (cache not consulted).[cache] stake_lane_reserved_holds(file + CLI flag--stake-lane-reserved-holds+DECDN_STAKE_LANE_RESERVED_HOLDS). Default0⇒Nonepolicy ⇒ probe hot path unchanged. The amount isNonZeroUsizeso "off" is unrepresentable inStakeLanePolicy;reserved>0withmax_probe_holds=0is warned and left off.Scope note
Stake-lane is the binary
isActivepredicate (registered + bond ≥ minBond), not ADR 003's finerbondOf >= bond_required(declared_capacity)tiering — the latter needs a per-probe capacity read, explicitly out of scope ("no new chain wiring"). End-client lane eligibility (reputation/region/allow-list) andcdn/client/v1stream-time admission remain out of scope per the issue.Tests
stake_lane_reserved_outdecision fn (all guard conditions + both boundary sides)has_blob=falsesignature + correct metric attribution) / stake-lane requester keeps headroomcargo fmt --check,cargo clippy --all-targets, andcargo nextest runall clean locally (full suite 1325/1325).Review
Went through a 5-agent review (code / tests / comments / silent-failure / type-design). Fixes applied: corrected the metric docstrings (the gate is content-independent, not "present, holdable"), added the
NonZeroUsizeinvariant + dead-config warning. Deferred: a staker-set watcher-health metric (pre-existingChainStakerSetobservability gap) — filed as a follow-up.Closes #757
🤖 Generated with Claude Code