Repository navigation
fix(node): confirm a pool on-chain before admitting a serve - #1956
Merged
Merged
Conversation
A node served a cache hit for any pool its in-memory projection had not confirmed, failing open on a `None` pool status and trusting an on-chain redeem "backstop" that cannot exist for an unconfirmed pool. An unconfirmed, nonexistent, or drained pool was served indefinitely, granting one credit window after another for vouchers the node can never cash — the laziest attack, needing at most one dust pool. Confirm the pool on-chain at admission instead. On a projection miss the admit-path `PoolView::status()` does ONE `getPool`, folds a servable pool into the shared projection, and refuses an absent, closed, or errored one (retryable; wire `NotFound`). The mid-stream `cached_status()` stays in-memory, so a repeat fetch on a confirmed pool does no eth_call. This deletes the async fire-and-forget pool-owner resolver, its hint channel, and the intake silent-drop-on-unknown-owner path; `intake_capability` now takes a confirmed owner. With no pool-view wired (dev/test, no chain) the prior fail-open behavior is unchanged. Amends ADR 003 Pool solvency with the confirm-before-serve admission precondition. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
There are remaining correctness/operability issues in the updated documentation and rejection/metrics classification that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens the node’s paid serve admission path by requiring on-chain confirmation of a pool (via a projection-first getPool fallback) before admitting a stream when a pool-view is wired, preventing indefinite service against unconfirmed/nonexistent/drained pools.
Changes:
- Introduces an admit-time
ResolvingPoolViewthat does a one-timegetPoolon projection miss, seeds the shared projection on success, and uses a short negative cache on non-servable/error results. - Updates the serve dispatcher to refuse admission when a wired pool-view cannot confirm a pool, and tightens capability intake to require a confirmed pool owner.
- Removes the prior background pool-owner resolve-hint channel/resolver plumbing and amends ADR 003 to document confirm-before-serve admission.
File summaries
| File | Description |
|---|---|
| crates/node/tests/anvil_settlement_e2e.rs | Removes the now-deleted pool resolve-hint channel wiring in the E2E harness. |
| crates/node/src/runtime/mod.rs | Wires ResolvingPoolView into handler deps and removes resolve-hint channel setup. |
| crates/node/src/pool_view.rs | Updates PoolView/projection docs to reflect admission vs mid-stream behavior. |
| crates/node/src/payment_settlement.rs | Deletes the background resolver and adds ResolvingPoolView + unit tests. |
| crates/node/src/handlers/client/mod.rs | Removes resolve-hint plumbing and makes intake require a confirmed owner. |
| crates/node/src/handlers/client/dispatch.rs | Adds the refuse-on-unconfirmed-pool admission gate and gates intake on confirmed status. |
| adr/003-payments.md | Documents confirm-before-serve admission and capability validity as admission gates. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…tatus doc Address PR review: the confirm-before-serve gate reused `InsufficientDeposit`, conflating an unconfirmed/absent/RPC-faulted pool with real deposit exhaustion in the per-reason metric. Add a distinct `ServeRejectReason::PoolUnconfirmed` (wire-collapses to `NotFound` like its siblings, so no balance/existence leak) with its own `decdn_serve_stream_rejected_pool_unconfirmed_total` counter, so an operator can tell a chain/RPC problem from a drained pool. Also correct the `pool_view` module doc: a mid-stream `cached_status()` `None` does not mean the entry "aged out" — the projection never ages entries out; a seeded entry persists until `PoolReclaimed` removes it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 82.76% (was 82.73%, ▲ +0.03%) — 75646/91404 lines
History
|
alpergundogdu
added a commit
that referenced
this pull request
Sep 9, 2026
…rve (#1958) * fix(node): confirm signer cap headroom on-chain before admitting a serve The signer-level twin of #1956. A capability's `spending_cap` is shared across every provider, so a signer that has drawn its full cap at other nodes is uncashable — yet the pool-confirm gate only checks pool-level solvency. A "spent" capability presented to a new/unaware node passed admission and got served for vouchers the node can never redeem (`redeemMany` pays `min(desired, cap − spent) = 0`), and the same exhausted capability sprayed across N fresh nodes yields N × cap free bytes. Confirm the signer at admission too. `PoolView` gains `signer_cap_headroom_micro`; the production `ResolvingPoolView` reads the signer's on-chain `{cap, spent}` with one `getAuthorization` (briefly cached, so a repeat fetch does no eth_call) and the admit gate refuses `SignerCapExhausted` when a registered signer's `cap − spent` cannot cover a serve floor. An unregistered signer has spent nothing on-chain, so it admits on its off-chain capability; a `getAuthorization` fault refuses. Wire-collapses to `NotFound` (no leak) with its own `decdn_serve_stream_rejected_signer_cap_exhausted_total` counter. No chain wired (dev/test) keeps prior behavior. Amends ADR 003 §Pool solvency with the signer cap-headroom admission precondition. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(node): address PR review on the signer cap-headroom gate - Fail-open fix: a registered signer with a zero `spendingCap` (`cap == 0` but `expiry != 0`) is NOT the all-zero unregistered authorization. Treat only `cap == 0 && expiry == 0` as unconstrained; a registered zero-cap (or fully-spent) signer now reports `0` headroom and is refused instead of admitted as uncashable. Adds a test. - Bound the signer-auth cache (`AUTH_CACHE_MAX`): at the cap, prune expired entries and skip caching if still full, so a flood of distinct `(pool, signer)` pairs cannot grow the map without bound (mirrors the negative cache). - Reword the `SIGNER_AUTH_TTL` doc: the stale-cache exposure is TTL-bounded, not "one more stream". Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
alpergundogdu
added a commit
that referenced
this pull request
Sep 9, 2026
) The hint-driven redeemer re-issued a `getAuthorizations` eth_call for a lane on every accepted voucher (~1 per MiB) whenever the signer was not yet marked registered. The read only answered "is this signer registered, so should I attach a CapabilityReg?" — a question the node can answer locally: it already holds a validated `owner_sig` (captured and verified against the pool owner at admit, #1956/#1958), stored in the same fsynced row as the frontier (#1906), so a lane with redeemable value always has the material to register its signer. And `_registerCapability` is idempotent, so re-attaching a CapabilityReg for a signer another provider already registered is a harmless no-op. The read was dead weight issued per voucher — thousands of billed eth_calls per stuck lane. Resolve registration locally instead: a lane is Registered iff this node has landed its registration (persisted `registered_until` still live), else Unregistered → attach a CapabilityReg from the held `owner_sig`. The first landed redemption persists `registered_until`, so every later pass attaches nothing. The redeemer's only on-chain-derived gate is now pool solvency (the event-fed projection), exactly like the serve path. The no-`owner_sig` case stops telling the client to "re-send its capability" — the client sent it once; a redeemable lane without `owner_sig` is a node durability fault, logged at error! and skipped. Deletes `batched_authorizations` and the `RegistrationStatus::Fetched` read path. Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A node served a cache hit for any pool its in-memory projection had not confirmed. When
pool_statuswasNone(a pool opened before the settlement watcher's cold-start head, an unknown/nonexistent pool, or an RPC-blind window), the floor-solvency gate failed open and the node signedok: trueand streamed — trusting "the on-chain redeem is the backstop." That backstop cannot exist for a pool the node never confirmed: the mid-stream re-check also fails open onNone, so an unconfirmed, nonexistent, or drained pool was served indefinitely, granting one credit window after another for cryptographically-valid but uncashable vouchers.This is the laziest attack surface — open one dust pool, then pull unlimited data during any solvency-blind window, paying in vouchers the node can never redeem — and it quietly undercuts the per-byte payment model the capability machinery exists to enforce.
Fix
Confirm the pool on-chain at admission instead of failing open. This reuses the existing
PoolViewsplit (status()may block at admit;cached_status()must not, mid-stream):ResolvingPoolView: on a projection miss,status()does onegetPool, folds a servable pool into the shared projection viarecord_resolved, and refuses an absent / closed / errored pool (retryable — wire-collapses toNotFound). A short-TTL negative cache stops a dead-pool request flood from storminggetPool.cached_status()(mid-stream re-check) stays in-memory — no per-vouchergetPool. Once seeded, the settlement watcher foldsPoolRedeemeddeltas, soremainingstays fresh with no further chain reads. A repeat fetch on a confirmed pool does zero eth_calls.dispatch.rs: refuse when a pool-view is wired andstatus()returnsNone;intake_capabilitynow takes a confirmed owner.ADR
Amends ADR 003 §Pool solvency with the confirm-before-serve admission precondition ("Admission confirms the pool on-chain", "Capability validity is an admission gate") and scopes "serve partly blind" to other parties' vouchers only.
Scope
Deliberately limited to pool existence + solvency. The concurrency fan-out reservations (per-lane cap #1697, per-pool floor reservation, abandonment buckets) are untouched and being scrutinized separately.
Testing
All gates pass locally (independently re-run):
cargo build·cargo clippy --all-targets --all-features -D warnings·cargo fmt --check·RUSTDOCFLAGS="-D warnings" cargo doc … --document-private-items— cleancargo nextest run -p decdn-node— 1116 passed, 0 skippedgetPool→admit (+ repeat = no eth_call); absent/closed→refuse+negative-cache;getPoolfault→refuse+negative-cache;cached_statusnever callsgetPool.🤖 Generated with Claude Code