Skip to content

fix(node,e2e): don't dead-charge a client on a pre-spend miss refusal (#1598) - #1892

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/issue-1598-e2e-tests-3c1d00
Sep 1, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/issue-1598-e2e-tests-3c1d00

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1530 / addresses the daemon-side blocker on #1598.

The daemon fix (the shippable core)

A cache-miss serve leg opens a per-pool FloorReservation before the fill tiers spend. On a refusal taken before the serve loop runs — the pre-serve floor-M gate, the size gate, or an upstream that refused the free header handshake because its getPool view has not yet caught up to a freshly-opened pool — the leg fronts no upstream USDC and delivers no byte. Yet the reservation's Drop folded the full reserved amount as a permanent dead_charge, because settled was never set (the conservative full-fold is meant to bound aborts that happen after fronting USDC).

The consequence is a real correctness/DoS problem on a pull-through node: a handful of transient upstream refusals permanently strand the requesting client's whole per-signer floor share, and the node then refuses that innocent, solvent client (serve_stream_rejected_signer_floor_at_cap) until the pool is reclaimed on-chain. This is exactly the "durable floor dead-charge" the previous #1598 attempt hit and could not get past.

Fix: add FloorReservation::release_unspent and call it on the window and own-origin miss legs' pre-spend refusal paths. A refusal before any spend now releases the live reservation and folds no dead charge — restoring the behavior serve_stream already documents ("a refusal before the serve loop drops with note_unpaid at 0, so no dead charge is folded"). The abnormal-exit full-fold that bounds sequential abuse after fronting USDC is unchanged.

  • crates/node/src/handlers/client/mod.rs — release_unspent + unit test floor_reservation_refused_unspent_folds_no_dead_charge (counterpart to the existing ..._abnormal_exit_folds_full_reserved).
  • crates/node/src/handlers/client/window.rs — release_reservation_unspent helper, called at all six pre-spend refusal returns across both miss legs.

Verified: new + existing FloorReservation drop/per-signer-cap tests pass; node clippy/fmt/doc/deny clean.

The e2e (#1598)

crates/e2e/tests/node_pull_topup.rs — the first node-to-node paid-pull reactive mid-pull top-up e2e — plus the NodeFixture::set_buyer_working_deposit helper (with a TOML round-trip unit test). Topology mirrors node_to_node_coalesce.rs: a cold pull-through server satisfies a client miss only by a paid pull from a seeder, with the server's working deposit shrunk below the blob's wire cost to force the reactive top-up. The dead-charge fix above is its prerequisite — with it, the node-to-node warm-up now completes where it previously locked the client out.

Why the e2e is #[ignore]d — a SECOND daemon issue it surfaced

With the fix the journey gets past the warm-up and then fails at the deposit-exhausting fetch: the server's node-to-node pull of the ~9 MiB blob deterministically clean-misses, so the client is refused NotFound on every attempt. Localized by elimination against the passing node_to_node_coalesce (same host + fixture, pulls node-to-node at the default ~10 µUSDC/MB rate):

  • NOT environmental — node_to_node_coalesce passes here.
  • NOT flakiness/connectivity — deterministic (a 90 s, ~160-attempt retry never lands one success); forcing RelayMode::Disabled removes the incidental non-loopback dial noise without changing the outcome.
  • NOT the top-up / deposit / exhaustion — an ample 20 USDC deposit (no top-up needed) fails identically; reactive_topup{,_refused} never move.
  • NOT a seeder refusal, buy-margin, warming, blob-size, or voucher rejection — every reject/refuse counter on both nodes stays flat (only a single startup pool-view-lag unknown_lane).

The one systematic difference from the green path is the rate: this scenario must price at ~0.5 USDC/MB, because the seeder-side refundable floor M (default 1 USDC) forces the working deposit above ~1 USDC, and only an elevated per-MB rate lets a sane-sized blob's wire cost exceed that deposit to trigger the reactive branch at all. So the high rate is intrinsic, not incidental — and something on the high-rate node-to-node pull path fails where the default-rate path does not. Pinning the exact step needs daemon-side pull-leg instrumentation (the subprocess daemon's debug logs don't surface through the e2e harness); tracking that as a separate fix. The test is ignored (not deleted) with the full elimination in its doc comment, so it's ready to un-ignore once the high-rate pull is fixed.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 1, 2026 10:35

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.

Pull request overview

This PR fixes a correctness issue in the node’s per-pool floor-reservation accounting on cache-miss refusal paths (avoiding “dead-charging” when no upstream spend and no downstream delivery occurred), and adds/extends anvil-backed e2e scaffolding to exercise node-to-node reactive mid-pull top-ups.

Changes:

  • Add FloorReservation::release_unspent and use it on pre-spend refusal paths so a refusal before the serve loop does not fold durable dead_charge.
  • Add a unit test covering the refused-before-spend reservation release behavior.
  • Introduce an anvil-backed (currently #[ignore]) node-to-node reactive top-up e2e and add NodeFixture::set_buyer_working_deposit + TOML round-trip test support.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/node/src/handlers/client/window.rs Releases floor reservations on all pre-spend refusal returns in the window/own-origin miss legs.
crates/node/src/handlers/client/mod.rs Adds release_unspent on FloorReservation and a regression unit test to ensure no dead charge is folded on pre-spend refusals.
crates/e2e/tests/node_pull_topup.rs Adds a new anvil e2e for node-to-node reactive top-up (currently ignored due to an environment-sensitive dial flake).
crates/e2e/src/node.rs Adds set_buyer_working_deposit config rewrite + restart helper and a TOML round-trip unit test.

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

Comment thread crates/e2e/src/node.rs
Comment on lines +225 to +226
pub async fn set_buyer_working_deposit(&self, micro_usdc: u64) -> anyhow::Result<u64> {
let config = std::fs::read_to_string(&self.config_path).context("read node config")?;
Comment on lines +588 to +593
/// a signer's whole floor share. That is the behavior `serve_stream` documents
/// as "a refusal before the serve loop drops with `note_unpaid` at 0, so no
/// dead charge is folded"; this restores it. Mechanically a refused-unspent
/// serve and a fully-repaid one both owe nothing, so this delegates to
/// [`Self::release_live_repaid`]; the distinct name states the intent at the
/// refusal call sites.
Comment on lines +153 to +160
/// The blocker the prior attempt hit — a pre-spend upstream refusal permanently
/// dead-charging the requesting client's per-signer floor credit — is FIXED in
/// this same change ([`decdn_node`]'s `FloorReservation::release_unspent`, called
/// on the window/own-origin miss legs' pre-serve refusal paths). Before it, the
/// node-to-node warm-up below could not even complete: each pool-view-lag refusal
/// folded a permanent dead charge, and a handful stranded the client's whole
/// floor share (`serve_stream_rejected_signer_floor_at_cap`), so the session
/// never opened. With the fix the warm-up completes and the session opens.
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.59% (was 82.59%, ● 0.00%) — 70806/85733 lines

File Coverage Lines Δ
crates/e2e/src/node.rs 26.18% 144/550 ▲ +2.88%
crates/node/src/handlers/client/mod.rs 94.84% 2501/2637 ▲ +0.05%
crates/node/src/handlers/client/window.rs 74.81% 303/405 ▼ 0.31%
History
Commit Total Δ vs base
fb1dff0 82.59% ● 0.00%
9db9226 (HEAD) 82.59% ● 0.00%

…#1598)

A cache-miss serve leg opens a per-pool `FloorReservation` before the fill
tiers spend. On a refusal taken BEFORE the serve loop runs — the pre-serve
floor-M gate, the size gate, or an upstream that refused the free header
handshake (e.g. its `getPool` view has not yet caught up) — the leg fronts no
USDC and delivers no byte, yet the reservation's `Drop` folded the FULL
reserved amount as a permanent dead charge because `settled` was never set. A
handful of such transient refusals stranded the requesting client's whole
per-signer floor share, refusing an innocent paying client until the pool is
reclaimed on-chain — the blocker the prior #1598 attempt hit.

Add `FloorReservation::release_unspent` and call it on the window and
own-origin miss legs' pre-spend refusal paths, so a refusal before any spend
releases the live reservation and folds no dead charge — restoring what
`serve_stream` already documents ("a refusal before the serve loop drops with
`note_unpaid` at 0, so no dead charge is folded"). The abnormal-exit full-fold
that bounds sequential abuse AFTER fronting USDC is unchanged.

Add `crates/e2e/tests/node_pull_topup.rs`, the first node-to-node paid-pull
reactive mid-pull top-up e2e (#1598), plus the
`NodeFixture::set_buyer_working_deposit` helper it needs. The dead-charge fix
is its prerequisite: the node-to-node warm-up could not otherwise complete.

The journey is `#[ignore]`d because it surfaces a SECOND, separate daemon
issue it is the first to exercise: a high-rate node-to-node pull fails
deterministically. Localized by elimination against the passing
`node_to_node_coalesce` (which pulls node-to-node at the default rate): it is
NOT environmental, NOT flakiness/connectivity, NOT the top-up/deposit, and NOT
a seeder refusal — the sole systematic difference is the elevated per-MB rate
this scenario intrinsically needs (the 1 USDC seeder floor forces the deposit
above 1 USDC, so only a high rate lets a sane blob's cost exceed it). Pinning
the exact step needs daemon-side pull-leg instrumentation; that is a separate
fix. The test's doc comment records the full elimination.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the claude/issue-1598-e2e-tests-3c1d00 branch from fb1dff0 to 9db9226 Compare September 1, 2026 11:22
@alpergundogdu
alpergundogdu merged commit ce8ff91 into main Sep 1, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/issue-1598-e2e-tests-3c1d00 branch September 1, 2026 11:43
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