Repository navigation
feat!: discovery is a voucher-less stream open; retire cdn/probe/v1 and rate-manipulation slashing - #2912
Conversation
StreamRequestExt gains pull_through and StreamResponseExt gains the node's discovery-block coverage. StreamResponseExt::consistent_with checks the coverage against the signed ok for the requested span, and the client drops a response that fails it as a fault of the node. Every client open asks for pull_through. The node answers a complete hit, an own-origin fill and a pull-through with full coverage, a covering partial hit with its held blocks plus the served span, and every refusal with none. A refusal class in a StreamError frame before the first ChunkData is a typed refusal.
A blob past MAX_DISCOVERABLE_BLOB_BYTES made the node build a coverage bitmap longer than MAX_COVERAGE_BYTES, which every payer refused to decode, so the blob could not be served. Coverage::for_wire cuts the bitmap at MAX_COVERAGE_BLOCKS; the node builds every served coverage with it, and consistent_with judges only the part of the span inside that bound.
…s blob An open that does no fill work (a hit, a partial that covers the span, or the node's own origin with a proven size) answers ok:true before funding admission. The funding gates (pool status, signer authorization, funder deny, capability intake, lane and clamp, closing pool, capability expiry, deposit gate) run once the payer's first proof is on the stream. A refusal there rides in a StreamError before any ChunkData. A miss answers NotFound at once unless the request sets pull_through; one that sets it runs the funding gates and then the fill tiers, as before. The stream holds its blob against capacity eviction (InUse) while it lives. A connection holds at most MAX_UNADMITTED_STREAMS_PER_CONNECTION (10) answered opens that wait for their first proof; the next one resets with RATE_LIMITED. An open the requester leaves before it sends anything after its request counts on decdn_serve_stream_unclaimed_total. EvictedSinceProbe is now Withdrawn (decdn_serve_stream_rejected_withdrawn_total).
…s only A stream reserves its unadmitted slot when it is accepted, with an atomic try_take, so a burst of opens cannot pass MAX_UNADMITTED_STREAMS_PER_CONNECTION. The slot moves into the deferred admission, or drops once the stream is admitted at open or ends. An open that answers before admission holds no load-shed slot: it takes the node-wide and per-client slots at admission, and a shed there rides in a pre-chunk StreamError. A miss that pulls through takes its slot before the funding gates, as before. The empty blob sells no byte, so its open skips admission: no shed slot and no chain read; it answers and ends with StreamEnd. The pre-admission own-origin probe goes through the memoised origin_probe_presence, so repeat opens of a hash reach the origin once per TTL. The engine already keeps a size proof it read and remembers an origin that serves none.
… winner `decdn get` discovers holders with voucher-less `cdn/client/v1` opens instead of `cdn/probe/v1` probes. Each open names the payer's pool, binding and capability, asks for no pull-through, and returns a verified answer: the signed quote, the proven size and the coverage. The fetch adopts the winner's stream as its first leg and resets the rest on the shared connection. - Split the paid open into `discovery_open`/`OpenedStream` and `OpenedStream::into_pull`; RTT is the QUIC path RTT. - Rank holders by RTT band, then quote, then coverage; a quote above --max-rate-per-mb drops the holder. Holders start in that order. - Unlock the payer and name its pool before discovery (`funding::discovery_ctx`, predicted pool ids). - Remove the probe-relative rate ceiling and the RateAboveCeiling evidence (closes #2861). - Order the past-end check before the coverage check in verify_response.
…-only claims - A miss that asks for no pull-through refuses NotFound with the blocks the node holds, and discovery reads that refusal as a partial holder. - The winner's stream is adopted for every download: a primed pull of a longer range narrows to the first leg from its start and stops there, and the first plan stripes the blob across every holder the pass builds. - A size lookup takes the answer's proven size with no lane and no open.
A pull narrowed to a prefix of its range paid ahead toward the end of its whole range, so the node sent, and the payer paid for, up to a credit window past the stripe. Bound the pay-ahead at the prefix's wire end.
…m opens The quote census, get --dry-run, bundle entries, decdn probe and decdn node lookup --probe ask nodes with voucher-less cdn/client/v1 opens that name the payer's pool, and cancel or adopt each stream. A Connections map holds at most eight discovery opens per node, below the node's bound on unadmitted streams per connection. The client's probe-era discovery helpers are gone. decdn quote --json reports nodes_opened; decdn probe takes the get payer flags, needs --provider-address, uses --open-timeout-ms, and reports ok and coverage_blocks; fetch timings log discovery_start_ms.
…es its own flags node lookup --probe signs its sentinel opens under a key made for the run, with an in-memory buyer store and a placeholder pool: a node answers the miss before any funding gate, so the lookup loads no keystore and opens no buyer store. It takes --slash-judge-address. decdn probe takes only the node, chain, keystore, data-dir and capability flags, and --timeout-ms bounds its open.
node_origin opens a voucher-less cdn/client/v1 stream (pull_through=false) on each candidate instead of probing it. The open's signed quote, proven size, coverage and path RTT rank the candidate; a NotFound with no held block goes to the negative cache; a quote above max_rate_per_mb is excluded. The pool context and client binding are built once, before the fan-out. The winner's served stream becomes the handshake's primed pull (narrowed to the first leg), or the buffered fetch's whole-blob pull, so no second stream opens; every other stream is cancelled. A NotFound that arrives before any delivered byte (an admission refusal of a hit) now counts as backpressure: the client marks it (UpstreamRefused::at_admission / before_delivery). Renames: PositiveProbeCache -> CandidateCache (TTL 30 s, shared with the refusal suppression), probe_cache_* -> candidate_cache_* and probe_collection_latency_seconds -> open_collection_latency_seconds, cache.node_pull_probe_fanout -> cache.node_pull_open_fanout, PROBE_TIMEOUT -> OPEN_TIMEOUT with OPEN_CEILING bounding one open.
…argets An assigned origin (attested, or the origin directory's) that answers a flag-off discovery open NotFound with no block needs a fill: it is not negative-cached. When no holder serves the span, such origins join the candidate walk as a cold tail, nearest first like the client's cold order, and are opened with pull_through=true. Once the handshake proves the size they cover every block. A NotFound from any other peer, and a Declined from anyone, is still negative-cached.
The cold assigned origins join the candidate walk only when no holder the walk can use served the span: decided after the requester is dropped and under the serve-economics buy cap, so a holder the walk would skip no longer hides them. A served discovery answer that proves no size is a handshake fault, never a size of 0. Tests cover the serve-miss pull-leg cold path, the requester case, and assigned_origins, append_cold_tail and cover_cold.
Discovery runs on voucher-less cdn/client/v1 opens, so the probe ALPN, its handler, rate limiter, eviction holds, hold budget and stake-lane reservation go. The [probe] config table, cache.max_probe_holds, cache.stake_lane_reserved_holds and their CLI flags are gone, and an unknown [probe] table fails the config parse. The probe metrics are removed from the exporter and the observability registry. NegativeProbeCache is renamed NegativeCandidateCache and discovery::Probed is renamed DiscoveredHolder. The e2e fixture discovers with discovery_open, and the blacklist journey asserts open refusals and a takedown of a blob an open stream pins. Refs #2901
…dence is stream-only SlashJudge drops submitRateChallenge, the probe evidence type and the rate-only errors and constants. submitBlacklistChallenge takes a signed StreamResponse only, and OffenseType has one variant, Blacklist (0). decdn-incentive drops probe_sig; the SlashJudge domain lives in stream_sig. The ordinal readers (admin DTO, slash watcher, CLI, dashboard) name 0 as Blacklist. The e2e slashing journeys drive blacklist challenges through one shared ChainFixture helper, and G-GOV-03 slashes on a StreamResponse the running daemon signed.
… only slash ADR 005 drops the probe protocol and specifies the voucher-less cdn/client/v1 discovery open: pull_through, coverage consistency, deferred admission, the open-stream pin with its unadmitted-stream cap, and rate self-enforcement through the voucher price. ADR 014 names one offense, blacklist violation, with StreamResponse evidence only. ADRs 001, 003, 011-041, the appendices, the overview, the glossary, the runbook, the READMEs, CONTRIBUTING and CLAUDE.md follow: the candidate cache, open response collection, cold pull-through targets, the discovery-open load threat, and the current metric names. The g_gov_03 module doc quotes the reworded ADR 014 bond-handling sentence.
The admission phase ends at the tier pick and holds no funding admission. A pull-through miss admits in the response phase; every other serve admits at the payer's first proof, in the first-frame phase, so the first-byte total holds the payer's time to that proof.
An open that answers before admission waits for the payer's first proof. That wait is the payer's time, so FirstByteClock leaves the span from the response written to the proof out of the first-frame phase and the total. The deferred admission after the proof stays in. A pull-through miss is unchanged.
Each lane's rate ceiling is its node's first verified quote in the fetch (the discovery answer, or the first lane open), under max_rate_per_mb. A later stream quoted above it is refused unpaid with RateAboveCeiling, and the node leaves the fetch (DeclineReason::RateAboveCeiling), so the scheduler fails over. PeerSource::new takes a shared RateCeiling. The verified floor prices each byte at the rate of the stream that verified it, so a later rate never re-prices earlier bytes.
Before admission an own-origin open reads only memoised HEADs: the data
object, the size proof, and the {H}.obao4 outboard (new
Origin::has_outboard, CacheEngine::origin_outboard_published). The
outboard fetch and the first range window run after admission at the
first proof; an unusable range refuses the stream before any chunk and
memoises the hash as having no outboard, so the next open degrades. An
origin without an outboard still answers NotFound with no block.
…rst voucher The unadmitted-stream cap moves to decdn_protocol (MAX_UNADMITTED_STREAMS_PER_CONNECTION). A node frees a stream's slot at admission: a pull-through miss before its funding gates, any other stream at its first voucher. Every client open on a node's connection, discovery, lane, gap fill, retry and node_origin upstream opens alike, holds one of that many places until its first voucher is sent, so busy shared connections no longer reset their own streams; discovery keeps a sub-budget of 8. A node-wide budget (MAX_UNADMITTED_PINS, 256) bounds the pins held by unadmitted streams; an open past it answers without a pin and admission pins its blob. The first-proof wait of an unadmitted stream is a fixed VOUCHER_READ_TIMEOUT that sibling-stream traffic does not extend.
…e blob A real node answers a span that starts past the blob's end with RangeNotSatisfiable, a Declined refusal with no size. Mirroring node_origin's discovery_answer, the client opens (0, 0) once on a Declined sub-span, so the node still reads as a holder and the range error comes from its proven size instead of a no-serve-target failure.
- fetch_coverage publishes Coverage::for_wire, so the record of a blob past 100 GiB still decodes. - decdn_open_collection_latency_seconds gains a 5 s bucket above the 2.5 s open ceiling. - Doc reflows and stale references: StreamRequest, PrimedSource, open_puller, the fetch flags, spawn_a_dead_server, the size gate, origin_probe_presence; node lookup help names no fixed sample size.
Holder::probed_holder is Holder::discovered_holder. Docs, comments and test names across the client, node and CLI crates that named the deleted probe protocol name discovery opens and answers instead.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Main splits the governance chain from the payment chains (#2899). Its payment_pools hint lived on the probe answer, which this branch deletes. StreamResponseExt now carries one payment_pools field, appended after coverage, and the node fills it on every answer, served or refused. A discovery open names the route's first pool; a node that refuses that pool names the pools it accepts and stays a serve target for their pass.
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
Solidity / code-coverage/forge
View coverage of the 1 most impacted file.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Gas snapshotNo gas changes vs base. |
- protocol: the crate doctest's StreamRequest names its payment_pool. - e2e: the bundle range-dedup tests count admitted opens (hits less unclaimed). A ranged recipient cancels its whole-blob discovery open unpaid, so it is not a leg. - cli: node lookup --probe draws its placeholder pool id from the throwaway key, not a hard-coded pool nonce (CodeQL).
alpergundogdu
left a comment
There was a problem hiding this comment.
Proposal: a simpler design for the open
Keep the core of this PR: retire cdn/probe/v1, sign the quote into the stream answer, have the payer protect itself by signing chunk_price into every voucher, and drop RateManipulation. The complexity comes from a stream that has not paid yet having four sets of rules: the deferred-admission split, the unadmitted pin and its three bounds, the pool check before the voucher, and pull_through. Most of the added machinery exists to manage that state. The proposal is to build everything on one rule:
Every
StreamRequestis a free, signed quote. Before the first voucher, a node does a store lookup, at most one memoised{H}.sizeproofread and, for a requester that is not an active staker, a DHT lookup plus unpaid opens to upstream nodes. It holds no pin, checks no pool and reads no chain. The first voucher starts admission, pinning and any fill.
What goes
1. Pinning the blob for a stream that has not paid. This also removes MAX_UNADMITTED_PINS and the drop-the-pin-on-miss, take-it-again-on-fill logic. The pin protects only against an honest node evicting the blob in the few seconds between its answer and the first voucher. When that happens, the node refuses at admission and the client fails over to another node. A hostile node can cause the same result for free, so the client must handle it anyway. Take the pin at admission instead.
2. MAX_UNADMITTED_STREAMS_PER_CONNECTION, the client's matching limit and the "8 of 10 for discovery" split. These exist only to cap the pins. Once the pin is gone, the existing limits cover the node: MAX_CLIENT_STREAMS (100), the per-peer and global token buckets, and VOUCHER_READ_TIMEOUT.
3. Checking the pool before the voucher. This removes the pool Declined refusal, declines_pool, the "retry once on a listed contract" rule, and "a node that refuses the pool is a serve target with unknown coverage". The pool affects neither whether the node holds the blob nor its quote. The node answers the blob status whatever pool the request names, and lists payment_pools. The requester picks a contract both sides accept. It uses the winner's stream as its first lane only if that stream named the chosen contract.
4. StreamRequestExt.pull_through and the second admission timing. Only the node knows whether it can pull a blob through, so the client cannot set the flag usefully. Getting a size proof costs a node very little: one DHT lookup and one unpaid open, which costs the upstream nothing under the rule above. A proxy that is missing the blob forwards the size proof it verified from its upstream, which ADR 005 already allows, so it can sign ok:true without filling. The paid fill starts at the first voucher, and the voucher already says "pull this through". Admission then runs at the first voucher on every stream, and discovery opens and lane opens become the same message. The peer-store fast path and a pinned --node-id stop being special cases.
The flag also kept proxies from chaining: a discovery open never set it, so a proxy never ran its miss path for another node. Replace it with a rule on who is asking, which the node already knows: a node runs its network miss path only for a requester that is not an active staker. Serving from its own origin backend is not a miss path, so origins still answer node-to-node pulls. This reuses staker_set.is_active from refuses_whole_blob and also replaces that check, because a node that never fills for another node cannot enter the partial-holder pull loop. A node that dials with a throwaway non-staker key gets one level of fan-out, like any client. The rate limits and the candidate cache bound it.
5. Make {H}.obao4 required alongside {H}.sizeproof. Size proofs are already required, and the only writer of {H}.sizeproof is decdn origin import, which writes the outboard in the same pass. In practice, no origin the node can serve from lacks an outboard. Requiring both removes:
origin_outboard_publishedand its memo, andorigin_probe_presence(the size proof gives the exact size, so the data-objectHEAD, theContent-Lengthread and theContent-Encodingcase go too);origin_range_serviceable, the "no outboard" memo and the degraded next open;- the fallback that pulls and imports the whole blob from the origin, along with the ADR 037 text "Fallback is always correct";
- the cold tail (
append_cold_tail,OpenSet.cold), because an assigned origin then answersok:truefrom its backend; - two accepted costs in the PR description: "an origin that cannot serve a range answers
ok:true, then refuses after admission" and "every miss spends one pull-through open on a cold assigned origin".
A deleted or misconfigured object becomes an ordinary origin fault: a StreamError before any ChunkData, then the client fails over, with no memo and no special path. Before deleting the import path, check whether commit_buffered_bytes and default_buffered_max_bytes also serve the buffered whole-blob pull from another node (ADR 037, about line 126). If they do, that path stays.
What stays
- The lane's rate limit (the first verified quote, capped by
--max-rate-per-mb). The client enforces it itself, so it holds whatever code the node runs, and it closes #2861. coverageandconsistent_with. Striping across partial holders needs them.- Reusing the winner's stream as the first lane. After item 3, the rule for when to reuse it is simple. A proxy can do the same with its upstream stream when the client's voucher arrives, and cancel upstream if the client cancels.
Things to watch
- A proxy's answer arrives later than a holder's, because it waits for its own DHT lookup and upstream open (bounded by
OPEN_CEILING). Ranking uses path RTT, not answer time, so the proxy is not penalised. The client waits up to its 5 s bound. - After this change, the discovery section of ADR 005 covers four things: the answer, coverage, the rule for who gets a miss path, and the payer's price protection. The Deferred admission, Open-stream pin and Discovery on several contracts subsections go away.
Generated by Claude Code
Follow-up: the design is too complicated, so let's simplifyThis adds to the review above. The open has picked up too many states, windows and special cases. The whole design should fit in a few rules:
Rules 1, 2 and 5 are covered in the review. Rules 3 and 4 are new. Rule 3: pay the first holder, add the rest as they answerPart of this is already in place:
Each answer, as it arrives: if it is verified and consistent, quotes at or under the lane's rate limit, uses an operator the fetch doesn't already have, covers useful blocks, and a lane is free, it becomes a lane and is paid now. Otherwise it is cancelled now. Open question: when the lanes are full, should a cheaper late holder replace the most expensive running lane? Without that, nodes win by answering fast rather than by being cheap. Rule 4: a short first-voucher deadlineUnder rule 3, the time from an answer to its first voucher is about one round trip. The first voucher therefore gets its own deadline of about 2 s, separate from Net effectRules 1–5 replace these sections: deferred admission, the pin before payment and its three bounds, pool routing before payment, I suggest rewriting ADR 005 against these five rules first, then cutting the code to match. That should be easier than trimming this branch piece by piece. Generated by Claude Code |
alpergundogdu
left a comment
There was a problem hiding this comment.
Correctness review
10 inline findings. Five are marked [fix before merge]:
- A refusal at admission leaves the first voucher committed, so the next stream on the lane can pay for bytes the node never delivered (
client/src/lib.rs:4528). payment_pools_hintdoes not truncate toMAX_PAYMENT_POOLS, which breaks pool routing at 9 or more pools and can exceed the 8 KiB response frame (handlers/client/mod.rs:1487).- Unpaid opens refresh eviction recency and the hit metrics, so any peer can protect blobs from eviction at no cost (
delivery.rs:227). - The wait for a per-node open permit has no deadline, so discovery can hang in a gateway (
opened.rs:596,source.rs:484). consistent_withaccepts any coverage on a refusal for a span that runs to the end, so a contradictoryNotFoundcan complete the coverage union (protocol/src/client.rs:656).
The #2913 cuts remove three findings: the permit/slot race, the DIRECT_PATH_GRACE wait, and the duplicated ask_whole retry. The last two are minor: the opens map that only grows, and the placeholder structs in miss_coverage.
Suggested order: fix 1–5 on this branch, merge, then do the #2913 cuts.
Generated by Claude Code
| @@ -4563,19 +4525,26 @@ fn voucher_rejection( | |||
| proof_generation, | |||
| }) | |||
| } | |||
| other if before_delivery => anyhow::Error::new(UpstreamRefused::at_admission(other)), | |||
There was a problem hiding this comment.
[fix before merge] A refusal at admission leaves the first voucher committed in the ledger.
The at_admission arm never calls ledger.resolve_reject(meter.last_proof). Only the VoucherRejected arm rewinds the ledger.
Failure case: a hit answers ok:true. The pull's first voucher pays ahead one or more chunks. The node then refuses at admission (load shed, InsufficientDeposit, CapabilityExpired) and drops that proof unread. The ledger still holds the cumulative claim. The next stream on the same lane to that node signs a cumulative voucher that includes it, and the node can redeem it for bytes it never delivered. Each refusal at admission leaks up to one pay-ahead window.
Fix: rewind meter.last_proof on the before_delivery path too.
Generated by Claude Code
| pub(super) fn accepted_pools(&self) -> Vec<decdn_protocol::PoolAccount> { | ||
| self.pools | ||
| .iter() | ||
| .map(|route| route.deployment.pool_account()) | ||
| .collect() | ||
| } | ||
|
|
||
| /// The `payment_pools` hint every answer carries: the pools this node | ||
| /// accepts ([`Self::accepted_pools`]), or `None` when it accepts none. | ||
| pub(super) fn payment_pools_hint(&self) -> Option<Vec<decdn_protocol::PoolAccount>> { |
There was a problem hiding this comment.
[fix before merge] payment_pools_hint does not truncate to MAX_PAYMENT_POOLS.
The deleted pool_declined path truncated the list. Now every answer carries every accepted pool, receivers cut the list to 8 at decode, and the pool-routing decisions read that cut list on every answer.
Failure case: a node accepts 9 or more pools, and the requester's pool is the 9th.
- A blob-level
Declined(for exampleHashDeniedorInternalError) decodes with a list that leaves out the requested pool.declines_pool()returns true, so the answer reads as a pool refusal. BuyerRoute::pays()andPoolPasses::admits()return false even on a served answer, sonode_origindrops the holder asPoolNotAccepted.- With enough pools, the list can push the response past
MAX_STREAM_RESPONSE_FRAME(8 KiB), and every answer fails.
Fix: truncate here. Ideally, also reject a config with more than MAX_PAYMENT_POOLS pools.
Generated by Claude Code
There was a problem hiding this comment.
[fix before merge] Unpaid opens refresh eviction recency (delivery.rs:227, outside this diff's hunks).
deliver calls self.cache.touch_recency(hash) before deferred admission waits for the first proof. The path before admission also counts serve_cache_hit, and observe_hit for the empty blob.
Failure case: every fetch fans out voucher-less opens and cancels all but the winner. Each losing hit still bumps LRU recency and the hit-rate metric. Any peer can keep chosen blobs from eviction at no cost with opens it cancels. That skews the ADR 040 eviction policy and the hit-rate dashboards.
Fix: move the touch and the hit metrics after admit_on_first_proof succeeds.
Generated by Claude Code
| ) -> anyhow::Result<OpenedStream> { | ||
| // Taken before the timestamp is stamped: a wait for a permit must not | ||
| // age the request. | ||
| let permit = conns.discovery_permit(target.id).await?; |
There was a problem hiding this comment.
[fix before merge] The wait for a per-node permit has no deadline.
discovery_permit (and open_permit at source.rs:484) awaits the per-node semaphore without a timeout. The open duration bounds only the dial and the exchange.
Failure case: in a gateway, 8 concurrent fetches each park a discovery stream for node N in an OpenedSlot while they open a pool on-chain, which can take many seconds. The node reaps those streams after VOUCHER_READ_TIMEOUT, but the client keeps their permits until each fetch uses or drops its stream. Every other discovery open to N then blocks on acquire_owned().await with no deadline, settle_opens cannot end the round, and requests hang instead of timing out.
Fix: put the permit wait inside the open's deadline.
Generated by Claude Code
| Some(proven_size.map_or(end, |size| end.min(size))) | ||
| }; | ||
| let Some(end) = end else { | ||
| return !body.ok; |
There was a problem hiding this comment.
[fix before merge] consistent_with accepts any coverage on an ok:false answer to a span that runs to the end.
With byte_len == 0 and no size proof, end is None and this returns !body.ok. That is true for every refusal, whatever its coverage. CoverageUnionTracker::add then counts a refusal without a size proof as holder_blocks = u32::MAX.
Failure case: node_origin opens with span (0,0). A node answers NotFound with a full bitmap, claiming every block while it refuses the whole blob. The answer passes as a partial holder. Once any served holder proves the size, spans() returns true, so the early exit and the coverage-union gather skip the origin-directory supplement. The ranged pull then plans ranges on a node that serves none of them.
Fix: a refusal without a size proof should count no blocks in the union, or the coverage it claims should be ignored.
Generated by Claude Code
| .await; | ||
| // The first voucher admits the stream at the node, so its place on the | ||
| // node's connection frees for the next open. | ||
| drop(self.open_permit.take()); |
There was a problem hiding this comment.
The client frees its open permit before the node frees the stream's unadmitted slot. (#2913 step 2 removes this cap.)
The client drops open_permit when it sends the first voucher, and at once on cancel(). The node frees the slot only after it reads that proof or sees the reset. So MAX_OPENS_PER_NODE does not keep the client under MAX_UNADMITTED_STREAMS_PER_CONNECTION.
Failure case: 10 unadmitted streams on one connection. Stream A pays, or a declined open is cancelled and reopened at (0,0). The freed permit lets the next open go out, and it can reach accept_bi before A's serve task frees its slot. That open is reset RATE_LIMITED (UnadmittedCapFull). The client reads it as UpstreamRateLimited, and node_origin negative-caches an honest holder for REFUSAL_SUPPRESSION_TTL.
Generated by Claude Code
| .map_err(|e| e.context(crate::LocalPullFault))?; | ||
| let answered_at = tokio::time::Instant::now(); | ||
| let rtt = if measure_rtt { | ||
| path_rtt(&conn, DIRECT_PATH_GRACE).await |
There was a problem hiding this comment.
Every discovery open waits up to DIRECT_PATH_GRACE (500 ms) after the answer. (#2913 step 5 removes this.)
The wait sits on the critical path of every fetch and every node-to-node miss. A peer reachable only through the relay, or a slow hole punch, adds 500 ms to each open. In node_origin the wait comes before the downstream StreamResponse, so a pull-through client's time to first byte grows by 500 ms. Sample the RTT after the stream is adopted instead.
Generated by Claude Code
| let declined = |opened: &decdn_client::OpenedStream| { | ||
| !opened.served() && opened.ext().error() == Some(&StreamError::Declined) | ||
| }; | ||
| let ask_whole = spec.span != (0, 0) |
There was a problem hiding this comment.
ask_whole duplicates targets::open_at's whole-blob retry and fires on every Declined. (#2913 step 3 removes most of this.)
Both copies retry on pool refusals (declines_pool()) and on denylisted or withdrawn hashes, where a whole-blob reopen gets the same refusal. That costs two signed opens and two ECDSA signatures for one answer, and the cancel-then-reopen can trip the unadmitted-cap race. Leave out declines_pool() and a Declined that is not about the range, and share one helper from decdn_client.
Generated by Claude Code
| } | ||
|
|
||
| /// `node`'s open permits. | ||
| fn node_opens(&self, node: PublicKey) -> Arc<NodeOpens> { |
There was a problem hiding this comment.
ConnectionsInner::opens only grows.
node_opens inserts one NodeOpens (two semaphores) for each remote node and never removes it, unlike the connection slots. A long-running gateway or node that contacts many distinct peers through DHT churn and discovery fan-out grows this map without bound. Prune an entry that has no outstanding permits when the node's slot is dropped.
Generated by Claude Code
| rate_per_mb: 0, | ||
| timestamp_us: req.timestamp_us, | ||
| }; | ||
| if refusal.consistent_with(&body, req.byte_offset, req.byte_len) { |
There was a problem hiding this comment.
miss_coverage builds placeholder structs to reuse a check meant for receivers.
It builds a StreamResponseExt (a clone of the coverage) and a StreamResponseBody with rate_per_mb: 0 only to call consistent_with. The predicate it needs is !coverage.covers_byte_range(offset, end) on the requested span. As written, a later change to the receiver rules in consistent_with (for example the to-the-end span) silently changes what the node advertises.
Generated by Claude Code
- client: a refusal at admission rewinds the stream's own last proof. The node refuses before it reads the proof, so it stays unredeemed. - node: the payment_pools hint keeps MAX_PAYMENT_POOLS entries, and the config resolver refuses more than MAX_PAYMENT_POOLS accepted pools. - node: eviction recency refreshes only once a stream is admitted, so an unpaid open cannot keep a blob resident. - client: the wait for a per-node open permit runs under the open's budget and times out with PullTimeout. - node: a size-less refusal that claims every block counts no blocks in the coverage union once a size is proven. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The property drew frames as small as one byte and stopped after 4096 steps, so a large transfer of tiny frames ended the loop unfinished and failed. A node cuts frames by chunk group, so the smallest drawn frame is one chunk group, the step bound follows from the transfer size, and a step that delivers nothing fails as a stall. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
A requester discovers holders by opening
cdn/client/v1streams with no voucher. The node answers with the signedStreamResponse(quote), the size proof and an unsigned coverage hint. The requester ranks the answers by path RTT, quote and coverage, pays on the winner's stream and cancels the rest. The winner's stream becomes the first lane, so the winner costs no second round trip. Node-to-node cache-miss pulls discover the same way.StreamRequestExt.pull_throughopts in to fill work. Without it a miss answers at once with a signed refusal and no upstream work.StreamErrorbefore any chunk.MAX_UNADMITTED_STREAMS_PER_CONNECTION), node-wide for pins (MAX_UNADMITTED_PINS), and by a fixed first-voucher deadline. An unpaid open reads only memoised origin presence and size proof, never the outboard.chunk_price, and a lane pays no more than its node's first verified quote in the fetch (min'd with--max-rate-per-mb).SlashJudgekeeps one offense,Blacklist(ordinal 0), with stream-response evidence only.decdn probeanddecdn node lookup --probestay as diagnostics built on discovery opens.decdn quoteandget --dry-rununlock the keystore and use the pool.Closes #2901, Closes #2861
Merge with main (#2899)
3238b745merges main's governance/payment chain split. Main's probe-side behaviour moves onto the discovery open:StreamResponseExt.payment_pools, appended aftercoverage. The node fills it on every answer, served or refused.PaymentPoolsOutsideDeclinedis gone;declines_pool(&requested)tells a pool refusal from a blobDeclined.PoolRoute::first(): a held pool, else the first configured).first_passthen picks the pass from the hints on every answer. A winner stream opened on another contract is not adopted; that lane opens its own.Unfunded, not a holder. It is found and paid in its own pool's pass, but its coverage is unknown until then. There is no re-open on a second pool.deploymentforpool_view,intake_capability,clamp_lane_to_registrationandLaneId.decdn probetakes main's--governance-*and--pool*flags.node lookup --probeopens on a placeholder deployment and gets poolDeclinedanswers; the RTT ranking is unchanged.slash_appeal(main's test) now waits until the whole blob is redeemed before the sweep. With deferred admission the first poll caught a partial redemption, so B's vote weight fell below quorum.decdn_serve_stream_rejected_unaccepted_pool_total.StreamResponseis 6,272 B (ceiling 8 KiB); ADR 013 updated.Breaking
cdn/probe/v1ALPN and its messages are gone.StreamRequestExtgainspull_through;StreamResponseExtgainscoverage, andpayment_poolsfollows it on every answer;StreamErrormay arrive before the first chunk.submitRateChallenge,ProbeMsg,PROBE_RESPONSE_TYPEHASHandSLASH_WINDOW_USare gone;submitBlacklistChallengedropsisStreamResponse;OffenseTypeis{ Blacklist }. Needs a redeploy.[probe],cache.max_probe_holds,cache.stake_lane_reserved_holdsand--max-probe-holdsare gone (an old[probe]table is now a config error).node_pull_probe_fanoutisnode_pull_open_fanout.decdn_probe_*families are gone;probe_cache_*iscandidate_cache_*;probe_collection_latency_secondsisopen_collection_latency_seconds. The decdn/devops rules and dashboards need the same changes (theDecdnProbeHoldViolationsalert names deleted metrics).nodes_probedisnodes_opened;has_blobisok, pluscoverage_blocks.decdn_client::probeis gone;Holder::probed_holderisdiscovered_holder; public-API snapshot regenerated.Reviewer notes
Read in this order:
crates/protocol/src/client.rs(flag, coverage,consistent_with,payment_pools),crates/node/src/handlers/client/{dispatch,admission}.rs(gate order, pin, deferred admission),crates/client/src/{opened,targets,lane_sources,rate_ceiling}.rs(open, rank, adopt, cancel, rate ceiling), thencrates/node/src/node_origin/(node-side discovery, cold pull-through targets for assigned origins that need a fill).Accepted costs:
ok:true, then refuses after admission.The serve first-byte histograms leave out the payer's wait between the answer and its first voucher. The SDK gateway HTTP contract is unchanged, so no SDK pin moves.
Verification
At
3238b745(the merge):cargo fmt -- --check,CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features -- -D warnings, the doc gate,pre-commit run --all-files: clean.cargo nextest run --workspace --no-fail-fast: 6164 run; the one merge failure (requests_route_to_the_pool_they_name) fixed and rerun green.(cd contracts && forge fmt --check && FOUNDRY_PROFILE=ci forge build --sizes --deny warnings && forge test): 876 passed, 3 skipped;forge snapshot --checkand the deployment mirror pass; slither has only informational findings.g_node_04,g_gov_03,slash_appeal,warm_upstream_connection,node_pull_topup,peer_store_probeless,gateway_public,cli_quote,cli_fetch_multi_source,cli_bundle_pull_two_pools,node_pull_pool_redeploy: pass.decdn-protocolanddecdn-clientregenerated;make -C adr check-refs check-book-listpasses.At
026d7926(CI fixes after the merge):cargo test --doc --workspacepasses; the full anvil e2e journeys suite passes locally (141/141). The bundle range-dedup tests now count admitted opens, because a ranged recipient cancels its whole-blob discovery open unpaid.