Repository navigation
fix(node,e2e): don't dead-charge a client on a pre-spend miss refusal (#1598) - #1892
Merged
Merged
Conversation
There was a problem hiding this comment.
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_unspentand use it on pre-spend refusal paths so a refusal before the serve loop does not fold durabledead_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 addNodeFixture::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 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. |
Coverage reportTotal: 82.59% (was 82.59%, ● 0.00%) — 70806/85733 lines
History
|
…#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
force-pushed
the
claude/issue-1598-e2e-tests-3c1d00
branch
from
September 1, 2026 11:22
fb1dff0 to
9db9226
Compare
This was referenced Sep 1, 2026
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.
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
FloorReservationbefore the fill tiers spend. On a refusal taken before the serve loop runs — the pre-serve floor-Mgate, the size gate, or an upstream that refused the free header handshake because itsgetPoolview has not yet caught up to a freshly-opened pool — the leg fronts no upstream USDC and delivers no byte. Yet the reservation'sDropfolded the full reserved amount as a permanentdead_charge, becausesettledwas 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_unspentand 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 behaviorserve_streamalready documents ("a refusal before the serve loop drops withnote_unpaidat 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 testfloor_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_unspenthelper, called at all six pre-spend refusal returns across both miss legs.Verified: new + existing
FloorReservationdrop/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 theNodeFixture::set_buyer_working_deposithelper (with a TOML round-trip unit test). Topology mirrorsnode_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 surfacedWith 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
NotFoundon every attempt. Localized by elimination against the passingnode_to_node_coalesce(same host + fixture, pulls node-to-node at the default ~10 µUSDC/MB rate):node_to_node_coalescepasses here.RelayMode::Disabledremoves the incidental non-loopback dial noise without changing the outcome.reactive_topup{,_refused}never move.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