Skip to content

fix(node): stop partial holders pulling a blob from each other in a loop - #2227

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/pull-ring-guards
Sep 28, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/pull-ring-guards

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

  • Bug: a serve-miss learns the blob size with a first "handshake" open to its top-ranked candidate. When that candidate did not cover the pull's first block, the handshake opened the whole blob (offset 0, len 0), even at a partial holder. The holder cannot serve the whole blob from part of it, so it treats the open as a miss and starts its own pull, often from another partial holder or from the node that asked it. Nobody in that ring holds the missing bytes, so every leg idles until it is abandoned.
  • Fix 1 (pull_leg.rs): the size handshake opens one chunk group of the first block the candidate advertised, so any holder answers it from what it holds. The whole blob is opened only when no trusted size is known (no probe hint, or the primed open just proved the hint wrong).
  • Fix 2 (pull_leg.rs, window.rs): open_pull_leg takes the requesting node and drops it from the probe-cache list, the discovered providers, and the ranked candidates (which covers the origin-directory supplement). A node never pulls a blob back from the node that asked for it.
  • ADR 037 states both rules under its existing "a proxy never chains its pull through another non-holding proxy" invariant.

Evidence (testnet, 2026-09-28)

  • From ~14:15 UTC, fra1 / hel1 / nbg1 / lon1 sent each other whole-blob requests for Mistral's 7cbb… while outside clients pulled it; failed node-to-node streams reached 93–166 per node per 5 min. Example: Tempo trace 520eeaf646811fae1571c3ec8de252f7 (fra1 asked by hel1, opens nbg1 → NotFound, then opens hel1 itself, idle 88 s).
  • The same pattern appears at 10:07, 11:39 and 12:04 on the previous binary, so it predates fix(node,cache): let a serve-miss pull draw for its parked leg past a sibling's demand #2219.

Test plan

  • RED then GREEN: a_serve_miss_asks_a_partial_holder_only_for_blocks_it_holds. A real partial holder (holds only block 1) ranks first; before the fix it refused 1 miss (the whole-blob handshake), after it refuses none.
  • RED then GREEN: a_serve_miss_never_pulls_from_its_requester. The leaf is itself a holder and ranks first; before the fix S pulled the whole blob from it (the full holder served nothing), after it pulls from the other holder only.
  • spawn_block_holder test helper: a holder whose cache holds only the given blocks (shared body with spawn_partial_holder).
  • cargo nextest run --workspace: 4218/4218 passed.
  • cargo clippy --workspace --all-targets --all-features, cargo fmt --check, RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items clean.
  • cargo test --no-run -p decdn-e2e --features anvil-e2e builds.

🤖 Generated with Claude Code

A serve-miss read the blob size by opening the whole blob (offset 0,
len 0) at its top-ranked candidate whenever that candidate did not cover
the pull's first block, partial holders included. The holder treated the
open as a miss and started its own pull, often from another partial
holder or from the node that asked it, and nobody in that ring held the
missing bytes. On the testnet fra1, hel1, nbg1 and lon1 asked each other
for a Mistral shard at up to 166 failed streams per node per 5 minutes
(Tempo trace 520eeaf646811fae1571c3ec8de252f7).

- The size handshake opens one chunk group of the first block the
  candidate advertises; the whole blob only when no trusted size is known.
- open_pull_leg takes the requesting node and drops it from the probe
  cache, the discovered providers and the ranked candidates.
- ADR 037 states both rules under its "never chains through a
  non-holding proxy" invariant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 28, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A new test helper (spawn_block_holder) has unchecked arithmetic that can panic (overflow/underflow) on invalid block indices and should return a structured error instead.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes a node-origin pull-through failure mode where partial holders could trigger whole-blob “size handshake” pulls against each other (or back to the requester), creating self-sustaining miss loops and stalled streams. This aligns the implementation with ADR 037’s invariant that a proxy pull targets actual holders and avoids chaining through non-holding proxies.

Changes:

  • Make the size/header handshake open only a single chunk group within a block the candidate explicitly advertised (instead of whole-blob open at offset 0, len 0 when a size hint exists).
  • Thread the requesting node ID into open_pull_leg and filter it out from probe-cache candidates, discovered providers, and ranked candidates to prevent pulling back from the requester.
  • Add/extend integration tests and fixtures to model real partial holders and assert both invariants (handshake stays within advertised coverage; requester is never selected upstream).
File Description
crates/​node/​tests/​node_origin_pull.rs Adds partial-holder fixture that holds only selected blocks and new RED→GREEN tests for handshake coverage + requester filtering.
crates/​node/​src/​node_origin/​pull_leg.rs Implements coverage-scoped handshake range selection and removes requester from all candidate sources.
crates/​node/​src/​handlers/​client/​window.rs Passes requester node ID into NodeOrigin::open_pull_leg from the serve-miss path.
CHANGELOG.md Documents the production symptom and the behavioral fix.
adr/​037-regional-proxy-warming.md Makes the “no proxy chaining / requester exclusion / coverage-respecting opens” invariant explicit in the ADR text.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/node/tests/node_origin_pull.rs Resolved
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 43c2405 in the claude/pull-ring-gua... branch remains at 86%, unchanged from commit 6f024ba in the main branch.

@alpergundogdu
alpergundogdu merged commit b9e30ae into main Sep 28, 2026
30 checks passed
@alpergundogdu
alpergundogdu deleted the claude/pull-ring-guards branch September 28, 2026 17:41
thiras added a commit that referenced this pull request Oct 1, 2026
…l-through loop, watcher flapping (#2270)

* fix(node,client,cli): redact RPC URLs in chain-read logs

Chain-read warnings logged raw alloy errors, whose Display can carry the
reqwest URL and so a provider API key. Route them through
sanitize_rpc_display / sanitize_err_chain, and pin it with a test that
logs an owned-pool read fault whose URL holds a key.

Closes #2264

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): fall back to the cached signer authorization on a read fault

A getAuthorization RPC fault at admission returned None, and the admit
gate refused it as SignerCapExhausted, so a paying client was refused
and the cap-exhausted counter blamed the signer. On a fault the view now
answers with the last cached read whatever its age (spent raised to the
projection's fold); with no earlier read the gate refuses as
PoolUnconfirmed instead.

Closes #2220

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): refuse a node's whole-blob request while this node's open runs

#2227 excludes the requester and sends ranged handshakes when a size
hint exists, but without a hint the handshake is still (0, 0), and
three or more partial holders can pull a blob from each other in a loop:
the fill is claimed only after the open, so a node mid-open looks like it
has no fill and recurses.

NodeOrigin now marks each upstream open in progress, and the window
pull-through path refuses a whole-blob request for that hash from an
active staker as a miss (NotFound) while one runs. Ranged requests and
clients are never refused for this reason. The origin-directory
candidates also drop this node's own id, as the DHT lookup already does.
ADR 037 states the guard.

Closes #2224

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): defer an exhausted getLogs window instead of failing the tick

dRPC code-19 failures cluster in time, so a window that fails its two
in-tick retries often fails again seconds later, and each such tick
marked every route down and bumped all five *_watcher_restarts_total
counters, keeping DecdnChainWatcherFlapping firing fleet-wide while no
event was lost.

A window that fails every retry now ends the tick early: earlier
windows keep their progress and the next tick resumes at the deferred
window. A tick fails only when no window has completed for
GET_LOGS_STALL_BUDGET (2 min, below the 180 s stalled alerts); a
deferred tick that completed no window fires no hook. New counter
decdn_chain_get_logs_deferred_total, wired, documented and plotted.

Closes #2253

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): trust only a cached registration on a getAuthorization fault

A cached Unregistered read is not safe to reuse after its TTL: any
provider's next redemption registers the signer, possibly with its cap
already spent, so admitting on the old read fails open. The fault
fallback now answers only with a cached Registered read (cap and expiry
are write-once); otherwise the signer is refused as unconfirmed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): run the getLogs stall clock until a tick reaches head

Clearing the stall clock on any completed window let ticks that each
complete one window and then defer the next fall behind head without
bound while still stamping every watcher healthy. The clock now clears
only on a tick that reaches head, and the budget applies to every
deferral, with or without progress.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(node): give the pull-loop guard its own reason; align signer-auth docs

The #2224 guard refused through FillOutcome::miss_reason(fault_seen),
so after an earlier tier's backend fault it answered InternalError,
which feeds the internal-error alert and makes the requester score this
node degraded for a deliberate loop guard. It now refuses as
ServeRejectReason::PullLoopGuard: always wire NotFound, counted in the
new decdn_serve_stream_rejected_pull_loop_guard_total (listed in
INBOUND_FAILURE_REASONS and both dashboards), with the requester in the
debug line. The integration test also pins that a staker with no open in
progress and a staker's ranged request are served. PendingOpen is now
private and #[must_use].

For #2220, the pool_unconfirmed and signer_cap_exhausted metric docs no
longer describe a getAuthorization fault as a cap-exhausted refusal,
ADR 003 states the read-fault rule, and a test pins that the stale
fallback takes the larger of the cached and projection-folded spent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(node): correct the poller deferral docs and pin post-stall recovery

The module doc still said a long tick succeeds only if every window
does, listed the stall failure as pre-route-loop, and the stall budget
doc overstated its margin to the stalled alerts. Extend the stall test
past the first failure: the next deferral fails at once and a tick that
reaches head clears the stall and recovers every route.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants