Repository navigation
feat(node,cli): wire on-chain rate bounds, cache eviction driver, client proxy warming (#1172, #1173, #1174) - #1357
Conversation
…ent proxy warming (#1172, #1173, #1174) Three ADR-to-runtime wiring gaps where a lower-level primitive already existed but was never consumed, so a designed behavior silently did not happen. #1172 — on-chain delivery-rate bounds (ADR 019 §3.1 / ADR 003) - Add `getRateBounds()` + `RateBoundsUpdated` to the `alloy::sol!` binding (the Solidity surface already existed; no contract change, no gas-snapshot regen). - Read bounds authoritatively at startup, refusing to boot on a `U256 -> u64` overflow, and overwrite the config seed before anything is served. - Replace the by-value `delivery_floor`/`delivery_ceiling` handler fields with a shared `RateBounds` handle publishing the pair atomically via `ArcSwap`, so a governance retune reaches the running probe/client handlers without a restart. Publishing `(floor, ceiling)` as one value is load-bearing: two independent atomics let a reader observe a new floor beside an old ceiling, and `u64::clamp` is `assert!(min <= max)` — a panic on the signing hot path. - Track updates with a `RateBoundsUpdated` watcher plus an hourly authoritative re-read (`blockchain.rate_bounds_poll_interval_sec`), wired to liveness and panic metrics because its failure paths deliberately return `Ok`. - The `payment.delivery_*` config knobs are now documented as a pre-chain seed; governance owns the live clamp. #1173 — cache eviction driver (appendix-blob-cache-eviction) - New cache-engine primitives: `size_snapshot`, `total_bytes`, and a soft-evict `release_for_eviction` deliberately distinct from the durable `evict()` DMCA path — a capacity victim must stay freely re-pullable and must not grow the `evicted.log`. - New async driver enforcing `cache.cache_size_mb` with a hysteresis latch and per-sweep budget, plus four governable knobs at the ADR's exact bounds. - Pending-reclaim accounting is what makes it converge: `release_for_eviction` only drops GC protection, so decisions run against `raw - pending_reclaim` rather than raw disk. Without it the latch stayed engaged for a whole GC interval and the driver re-released every tick (~4800 blobs at defaults), draining the cache on one high-water crossing. - Cache-health metrics: `decdn_cache_{bytes,size_limit_bytes,pinned_count}` gauges and `_evictions_{,bytes_,starved_}total`, `_evicted_operator_total`, `_size_measure_failures_total` counters. Warn at boot when `gc_interval_sec == 0`, where released blobs are never reclaimed. #1174 — client proxy warming (ADR 037) - `proxy_warming_order`: the RTT-threshold + margin trigger with RTT-only ranking, wired into the CLI fetch path over probed bonded non-holders. - `RttMap` (EWMA, staleness, capacity-bounded) landed as explicitly staged, not-yet-wired code for the map-backed path. - Ships opt-in (default off), deliberately diverging from ADR 037's "defaults on": the mandated fallback from a declining proxy needs a second payment channel (another on-chain deposit escrow), so it is follow-up work, and a default-on trigger without it could fail a fetch that would have succeeded. Verified: `cargo fmt --check`, `cargo clippy --all-targets` clean workspace-wide, 2236 tests passing across node/cache/common/client-pull/incentive/cli. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (3)
WalkthroughThis change adds chain-backed delivery-rate bounds with event and polling refresh, a configurable cache eviction driver with metrics, and opt-in proxy-warming discovery with RTT-based candidate selection. It also updates configuration schemas, runtime lifecycle wiring, handlers, tests, and CLI output. ChangesLive delivery-rate bounds
Cache eviction driver
Proxy-warming discovery
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant FetchCLI
participant Discovery
participant Holder
participant WarmingProxy
FetchCLI->>Discovery: probe candidates with warming parameters
Discovery->>Holder: measure holder RTT and availability
Discovery->>WarmingProxy: measure bonded non-holder RTT
Discovery-->>FetchCLI: select qualifying proxy or best holder
FetchCLI->>WarmingProxy: route paid fetch when proxy warming qualifies
sequenceDiagram
participant Runtime
participant EvictionDriver
participant CacheEngine
participant BlobGC
Runtime->>EvictionDriver: start with thresholds and sweep budget
EvictionDriver->>CacheEngine: measure size and list candidates
EvictionDriver->>CacheEngine: release unpinned candidates
CacheEngine->>BlobGC: remove named tags
BlobGC-->>EvictionDriver: later reclaim reflected in size measurement
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
Wires three previously-designed but unused primitives into the runtime: (1) on-chain delivery-rate bounds (via PaymentChannel.getRateBounds() + RateBoundsUpdated) into node handlers, (2) an async cache-eviction driver to enforce cache_size_mb, and (3) an opt-in client-side proxy-warming trigger (RTT-threshold + margin) in the CLI fetch discovery path.
Changes:
- Add live
RateBoundshandle (atomic pair viaArcSwap), seed it from config then overwrite from on-chaingetRateBounds()at startup, and keep it current via a watcher + periodic re-read. - Add cache eviction driver loop with hysteresis + budgeted sweeps, plus cache-health metrics and new engine primitives (
size_snapshot,total_bytes,release_for_eviction). - Add opt-in proxy-warming knobs to the CLI and implement RTT-only ordering/selection of a bonded non-holder proxy candidate.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/support/mod.rs | Update test wiring to pass shared RateBounds instead of floor/ceiling scalars. |
| crates/node/tests/sighup_signal.rs | Seed new config fields (rate_bounds_poll_interval_sec, eviction params) in unit test config literal. |
| crates/node/tests/self_hosted_discovery.rs | Update probe handler construction to use RateBounds. |
| crates/node/tests/probe_loopback.rs | Update handler construction paths to pass RateBounds. |
| crates/node/tests/probe_0rtt.rs | Update handler construction to use RateBounds. |
| crates/node/tests/anvil_bringup_shutdown_e2e.rs | Seed new blockchain/cache config knobs for e2e bringup tests. |
| crates/node/src/runtime/reload.rs | Clarify reload semantics: config delivery bounds are now only a pre-chain seed; add cache eviction knobs to restart-required detection. |
| crates/node/src/runtime/mod.rs | Wire on-chain rate-bounds startup read + watcher into runtime bring-up; wire eviction driver background task and shutdown handling. |
| crates/node/src/runtime/eviction.rs | New async eviction driver loop enforcing cache_size_mb with hysteresis, pending-reclaim accounting, and metrics updates. |
| crates/node/src/rate_bounds.rs | New RateBounds/Bounds types with atomic pair publication and non-panicking clamp. |
| crates/node/src/rate_bounds_watcher.rs | New watcher sink for RateBoundsUpdated + periodic authoritative getRateBounds() poll. |
| crates/node/src/metrics.rs | Add rate-bounds watcher liveness/panic metrics; expand metrics tests for new cache eviction/capacity series. |
| crates/node/src/lib.rs | Export new rate_bounds and rate_bounds_watcher modules. |
| crates/node/src/handlers/probe.rs | Switch probe signing clamp from scalar floor/ceiling to shared live RateBounds. |
| crates/node/src/handlers/client/wire.rs | Switch stream signing clamp from scalar floor/ceiling to shared live RateBounds. |
| crates/node/src/handlers/client/voucher.rs | Enforce voucher rate floor against live on-chain-sourced floor. |
| crates/node/src/handlers/client/mod.rs | Thread RateBounds through ClientHandlerDeps/ClientHandler. |
| crates/incentive/src/payment_channel.rs | Extend alloy bindings with getRateBounds() and RateBoundsUpdated event. |
| crates/common/src/config/types.rs | Add TOML schema fields for rate-bounds poll cadence and eviction driver knobs; update docs to reflect seed vs live behavior. |
| crates/common/src/config/resolved.rs | Add resolved config fields for rate-bounds poll cadence and eviction driver knobs. |
| crates/common/src/config/mod.rs | Add defaults/bounds + validation for new blockchain/cache knobs; update payment resolve docs to “pre-chain seed”. |
| crates/common/src/cli/fetch.rs | Add CLI flags for opt-in proxy warming and RTT threshold/margin tuning. |
| crates/client-pull/src/rtt_map.rs | Add staged (not-yet-wired) EWMA RTT map implementation with tests. |
| crates/client-pull/src/lib.rs | Export rtt_map module. |
| crates/client-pull/src/discovery.rs | Add WarmingCandidate and proxy_warming_order logic + tests. |
| crates/cli/tests/config_validate.rs | Update sample resolved config used by CLI config validation tests with new fields. |
| crates/cli/src/commands/fetch.rs | Plumb proxy-warming params into discovery and allow selecting a near non-holder proxy when enabled. |
| crates/cli/src/commands/config.rs | Print new blockchain/cache config fields in config validate summary; update default config template comments. |
| crates/cli/src/commands/bundle_pull.rs | Thread proxy-warming params into bundle pull discovery path. |
| crates/cache/src/metrics.rs | Expand cache metrics doc + add eviction/capacity gauges and counters. |
| crates/cache/src/engine.rs | Add eviction driver primitives (size_snapshot, total_bytes, release_for_eviction) and operator-evict counter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces several key features, including an LRU cache-eviction driver loop to enforce cache size limits, live on-chain delivery-rate bounds tracking with a dedicated watcher, and client-side proxy-warming capabilities to seed regional copies based on latency. It also stages a per-peer RTT map structure for future use and adds corresponding configuration parameters, metrics, and CLI arguments. Feedback on the changes suggests optimizing the eviction driver's tick loop to avoid redundant disk-store walks by fetching the size snapshot once and reusing it across size calculation and sweeping.
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.
Coverage reportTotal: 81.49% (was 81.74%, ▼ 0.25%) — 51937/63732 lines
History
|
…ds logging Addresses automated review feedback on #1357. Eviction driver (Copilot ×2, Gemini): `tick` called `total_bytes()` — itself a `size_snapshot()` store walk — and then `sweep` called `size_snapshot()` again, so sustained eviction pressure did two full walks per tick and the two readings could disagree. Both in-code comments already claimed a single shared walk, describing a refactor that was never completed. `tick` now takes one snapshot, derives the footprint from it, and passes it to `sweep` by reference; the snapshot-failure path collapses to one site. Rate-bounds logging (Copilot ×2): `clamp()` takes an atomic snapshot internally, but the clamp-warning then read `floor()` and `ceiling()` separately — two more `ArcSwap` loads, and a concurrent governance update could make the logged pair one that never produced the logged decision. Both handlers now take a single `snapshot()` and use it for the clamp and the log. Verified: fmt, clippy --all-targets, and cargo doc clean; 2236 tests passing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Conflicts came from #1357 (proxy warming) touching the same two files. `crates/cli/src/commands/fetch.rs`: main threaded a `warming: ProxyWarmingParams` argument through `discover_provider` and `probe_and_rank` while this branch replaced `rpc_url` + `client_region` with a single `chain: &ResolvedChain`. Kept both — `chain` for the region and data dir, `warming` passed on to `probe_and_rank`. Main's `#[allow(clippy::too_many_arguments)]` is dropped: the `chain` consolidation takes the signature from 8 arguments back to 7, and clippy confirms it is no longer needed. `crates/client-pull/src/discovery.rs`: main's `WarmingCandidate` / `proxy_warming_order` merged cleanly; only the test module collided, where both sides are pure additions. Kept both sets. `crates/cli/src/commands/bundle_pull.rs` auto-merged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…1725) Close the ADR 037 § Fallback gaps left open after the proxy-warming trigger shipped (#1357): the fallback used only the first candidate, there was no progress deadline, and the feature stayed default-off, diverging from the ADR. The "second payment channel" that blocked a real fallback is obsolete: the shared payment pool (one pool fans out to every provider, each a distinct lane) means failing over to another provider escrows no new on-chain deposit, and the `ClientRangedStore` (keyed on hash + size) resumes the partial, so a fail-over re-pays nothing already delivered. - Classify each delivery failure (`retry_disposition`) using the retry dispositions already documented on `StreamError`, plus the pool model's global facts: payment-layer rejection, `OriginBlacklisted`, and an over-cap blob are terminal; every node-specific refusal, stall, transport fault, or bao/hash-verify failure fails over. - `probe_and_order` returns the ordered failover list — proxy-warming non-holders first (nearest RTT), then holders nearest RTT — so a walker gets ADR 037's exact shape: proxy → next candidate → direct holder. `fetch` and `bundle pull` walk it, reusing the shared pool. - Reuse the existing pull stall budget as the progress deadline; drop the never-implemented `proxy_warming.max_wait_ms`. - Flip `--proxy-warming` to default-on (ADR 037): a declining or stalled proxy now fails over transparently, so it can no longer regress a fetch. - Retire bundle pull's dormant `pick_excluding`/`fallback_candidates` scaffolding in favor of the shared ordered-list walk. - Update ADR 037 to canon: pinned latency defaults (150 ms / 30 ms), stall-budget progress deadline, default-on with no regression. Unit-tested: the classifier over every failure kind, and the failover ordering (proxies-then-holders, margin filtering, region drop). An end-to-end two-node discovery-failover test is left as follow-up. Co-authored-by: Claude Opus 4.8 <[email protected]>
Closes #1172. Closes #1173. Partially addresses #1174.
Three ADR-to-runtime wiring gaps where a lower-level primitive already existed but was never consumed, so a designed behavior silently did not happen.
#1172 — on-chain delivery-rate bounds (ADR 019 §3.1 / ADR 003)
PaymentChannel.getRateBounds()was never called; bounds came only from local config, so governance retunes were invisible to running nodes.getRateBounds()+RateBoundsUpdatedto thealloy::sol!binding. The Solidity surface already existed — no contract change, so no gas-snapshot regen, aderyn, or slither run.U256 -> u64overflow, overwriting the config seed before anything is served.u64fields to a sharedRateBoundshandle that publishes(floor, ceiling)atomically viaArcSwap. This is load-bearing, not stylistic: two independent atomics let a reader observe a new floor beside an old ceiling, andu64::clampisassert!(min <= max)— i.e. a panic on the probe/client signing path, whichclippy::paniccannot catch because the assert lives instd.RateBoundsUpdatedwatcher + hourly authoritative re-read (blockchain.rate_bounds_poll_interval_sec), wired to a liveness gauge and a panic counter — its poll-failure and undecodable-log paths deliberately returnOk(anErrwould stall the cursor), so without those metrics a wedged watcher is indistinguishable from a healthy one.payment.delivery_floor/delivery_ceilingare now documented as a pre-chain seed; governance owns the live clamp.Behavioural note for operators: the live floor is now always
>= MIN_DEPOSIT_FLOOR (1), where the config default was0. This makes the voucher floor check live for the first time and clampsrate_per_mbupward for anyone relying on the old no-op default.#1173 — cache eviction driver (appendix-blob-cache-eviction)
cache_size_mbwas never enforced; the cache grew unbounded until disk-full.size_snapshot,total_bytes, and a soft-evictrelease_for_evictionkept deliberately distinct from the durableevict()DMCA path — a capacity victim must stay freely re-pullable, and an unbounded takedown log per LRU eviction would be a durability leak.[60,95]/[40,90]/[1,256]/[1,60]) with the 5-point gap enforced as a cross-field invariant.release_for_evictiononly drops GC protection — disk is freed later by the independent iroh-blobs GC sweep (default 300s) — while the driver ticks every 1s. Deciding against raw disk meant the latch stayed engaged for a whole GC interval and the driver re-released every tick (~4800 blobs at defaults) for a pressure event needing one sweep. Decisions now run againstraw - pending_reclaim, with an observed drop crediting pending when GC lands.decdn_cache_{bytes,size_limit_bytes,pinned_count}gauges plus_evictions_total,_evictions_bytes_total,_evictions_starved_total,_evicted_operator_total,_size_measure_failures_total. Boot warns whengc_interval_sec == 0, where released blobs are never reclaimed and the ceiling is unenforceable.#1174 — client proxy warming (ADR 037)
Node-side window-paced pull-through already shipped (#856/#823); the client trigger was absent.
proxy_warming_orderimplements the RTT-threshold + margin trigger with RTT-only ranking, wired into the CLI fetch path over probed bonded non-holders. Region is structurally excluded (WarmingCandidatehas no region field), so a spoofed region cannot attract warming traffic.RttMap(EWMA, staleness, capacity-bounded) lands as explicitly staged, not-yet-wired code for the map-backed path, documented as such rather than presented as live.Remaining #1174 work (gossip peer-table candidate pool, background latency sweep, fallback chain) is why this only partially addresses that issue.
Review
A multi-agent review of this branch found 4 critical issues, all fixed here before commit: the
RateBoundspanic, the eviction non-convergence, a-D warningsclippy failure, and the proxy-warming default. Also fixed:Ok(0)no-op releases being credited as evictions,release_for_evictionforgetting the access-time entry before a fallible tag drop (which permanently retired candidates and leaked bytes), two CLI flags that were parsed but never read, a watcher retry storm, an out-of-range ceiling discarding a valid floor update, and several stale/overpromising doc comments.Verification
cargo fmt --checkcleancargo clippy --all-targetsclean workspace-widecargo docclean (pre-commit gate)node/cache/common/client-pull/incentive/cli, 0 skippedNew tests pin the fixed bugs specifically: the
[10,100] -> [200,500]retune that used to panic, the release-without-GC cycle that used to drain the cache,release_for_evictionnot writingevicted.log, pinned-hash refusal, and all nine new metric series (counters_total-suffixed, gauges not).Not covered: an eviction-driver integration test against a real
CacheEngineunder sustained pressure, and the rate-bounds watcher's event path end-to-end — both pinned at the logic level instead.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes