Skip to content

test(node): pin the stall-loop rank and credit stale proofs in the deposit-capped fixture - #2177

Merged
thiras merged 3 commits into
mainfrom
fix/2174-node-origin-pull-flakes
Sep 27, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2174-node-origin-pull-flakes

Conversation

@thiras

@thiras thiras commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Both #2174 flakes are fixture bugs, not node bugs. The fixes change tests only.

silent_upstreams_do_not_starve_the_candidate_loop: the rank depended on live-probe RTT. The test ranked candidates by live probe, and RTT multiplies the selection score. Under load, the honest node could rank ahead of a silent candidate, which gave stalled_total 1 (A ranked 2nd; these runs end in about 6.5 s, one 5 s stall) or 0. The test now uses build_origin_seeded_ranking, the same fix its sibling node_origin_pull_falls_through_a_stalled_candidate already carries.

concurrent_pulls_resume_at_their_own_frontier_not_the_channels: the scripted upstream deadlocked on a stale proof. The two pulls share one lane but pay on separate connections. settle_voucher accepted a proof only if it advanced the lane claim. When a sibling's later proof reached the server first, the overtaken proof advanced nothing. The server then waited for a proof the payer never sends, until the 60 s stall window fired. The DIAG trails of failing runs on main confirm both shapes:

  • topups=[]: P(idx=2) adv=true → P(idx=1) adv=false, and nothing more on that stream.
  • topups=[(…, 4000)]: after the top-up, B's closing V(72,b3) arrives before A's resume voucher V(71,b3), and A's voucher is stale. It is the same bug, not a frontier overshoot.

The fixture now mirrors the node's credit_stale / voucher_credit_delta:

  • A stale reveal, a sealed voucher, or a voucher closing a partial chunk pays its chunk from lane headroom.
  • A stale metering re-anchor on a whole chunk pays nothing.
  • A reveal is checked against its own stream's root.
  • One lock covers evaluate, the deposit check and the store; before, a sibling's update could be lost in between.

Measurements

Stress repro from the issue (parallel copies of the test binary, --test-threads 3):

Run main this branch
3 tests, 6 copies 6/30 failed 0/90
concurrent_pulls alone, 8 copies 3/64 (first fixture iteration, reveal-only stale arm) 0/128

In the 0/128 run the stale arm fired 9 times (8 stale reveals, 1 stale closing voucher), and every one of those runs passed.

Follow-up (not in this PR)

After a sibling pull's top-up, a pull keeps a stale ctx.deposit (crates/client/src/driver.rs, None arm of the funding result). It can cause an extra top-up, not a stall. It is worth its own issue if it matters.

Test plan

  • cargo nextest run -p decdn-node --test node_origin_pull: 76/76 passed
  • Stress repro: 0/90 (3 tests) and 0/128 (concurrent_pulls alone at 8 copies)
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt --check, pre-commit

Closes #2174

🤖 Generated with Claude Code

…posit-capped fixture

silent_upstreams_do_not_starve_the_candidate_loop ranked candidates by live
probe. RTT is a multiplicative score term, so under load the honest node could
rank ahead of a silent one and the stall count read 1 or 0. It now seeds the
probe cache through build_origin_seeded_ranking, like its fallthrough sibling.

concurrent_pulls_resume_at_their_own_frontier_not_the_channels wedged in the
scripted upstream. Two pulls share one lane but pay on separate connections;
when a sibling's higher reveal (or closing voucher) reached the server first,
the overtaken proof did not advance the claim and settle_voucher waited for a
proof the payer never sends, until the 60 s stall window. The fixture now
credits a stale proof from lane headroom, as the node's credit_stale does,
checks a reveal against its own stream's root, and holds the lane lock across
evaluate and store.

Closes #2174

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 82a80f3 in the fix/2174-node-origin... branch remains at 86%, unchanged from commit e862222 in the main branch.

Show a line coverage summary of the most impacted files.
File main e862222 fix/2174-node-origin... 82a80f3 +/-
crates/client/src/lib.rs 93% 92% -1%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...lient/window.rs 71% 71% 0%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/cli/src/...mmands/fetch.rs 52% 52% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/client/src/driver.rs 97% 97% 0%
crates/cli/src/.../bundle_pull.rs 77% 77% 0%
crates/node/src...s/client/mod.rs 95% 96% +1%
crates/node/src.../client/ramp.rs 0% 97% +97%

Updated September 27, 2026 05:07 UTC

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

Three moderate fixture-correctness issues remain in sealed-voucher pricing, zero-root handling, and partial-credit accounting.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Test-only fixes stabilize node-origin pull fixtures by making ranking deterministic and modeling stale concurrent payment proofs.

Changes:

  • Seeds probe rankings to remove RTT-dependent flakes.
  • Adds shared-lane credit tracking, stream-root handling, and atomic settlement.
File Description
crates/​node/​tests/​node_origin_pull.rs Updates deterministic ranking and deposit-capped payment fixtures.

💡 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
Comment thread crates/node/tests/node_origin_pull.rs Resolved
…e capped fixture

A sealed voucher clears the stream anchor, as StreamAnchor::adopt does, and a
reveal on an unanchored stream is refused UnanchoredPreimage. A metering
voucher on a whole chunk credits nothing even when it advances the claim
(voucher_credit_delta); the reveal after it settles the chunk.

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

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

Two moderate review findings remain regarding stale or rejected voucher state mutation.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)

Comment thread crates/node/tests/node_origin_pull.rs Resolved
…anchor

A stale proof that lane headroom cannot pay is refused AmountRegression and
changes nothing, as the node's credit_stale path does; only an accepted voucher
re-anchors the stream. A voucher below the lane anchor is stale and no longer
resets the lane's root and frontier.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit e0b358d into main Sep 27, 2026
30 checks passed
@thiras
thiras deleted the fix/2174-node-origin-pull-flakes branch September 27, 2026 05:12
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.

test(node): two node_origin_pull tests flake under load on main

2 participants