Skip to content

Anvil e2e for the node-to-node reactive mid-pull top-up #1598

Closed

Description

@yigitdot

Follow-up to #1530, which landed the reactive mid-pull deposit top-up on the daemon's node-to-node cache-miss buyer leg with loopback coverage only.

Why an e2e is warranted

The loopback tests in crates/node/tests/node_origin_pull.rs (a_pull_larger_than_the_initial_deposit_tops_up_once_and_completes, the_resumed_leg_does_not_re_pay_for_delivered_bytes, and siblings) drive a FundingOpener double whose top_up_channel just raises an in-memory cell. Three things they therefore cannot exercise:

  1. A real topUp receipt. decdn_client_pull::buyer_channel::top_up submits and waits on get_receipt(); Node reactive mid-pull top-up (node-to-node buyer leg) #1530 runs that on a detached task awaited through a oneshot precisely because the foreground pull future gets dropped at outer_pull_deadline. Nothing today proves the credit still lands when the caller goes away.
  2. The upstream's chain-watcher lag. The settle wait is sized at two blockchain.event_poll_interval_ms intervals (14s at the 7s default), because the serving node refuses to serve until its watcher observes ChannelToppedUp. The loopback fixture accepts the resumed open immediately, so the budget is never actually spent against a real watcher.
  3. The seller-side pre-serve deposit gate (feat: enforce the seller-side deposit floor before serving, drop the on-chain minDeposit #1518), which is what collapses to a wire NotFound during that window.

Shape

crates/e2e/tests/node_pull_topup.rs, mirroring crates/e2e/tests/cli_fetch_topup.rs::fetch_larger_than_initial_deposit_tops_up_and_completes but with the daemon's buyer leg instead of the CLI's:

  • ChainFixture + two NodeFixtures: a seeder holding the blob, and a cold node with node_to_node_pull_through_enabled.
  • Reuse the HIGH_RATE_PER_MB trick from the CLI test (set the seeder's rate so a ~2 MiB blob outruns the cold node's buyer_initial_deposit_micro_usdc).
  • Request the blob from the cold node; assert it ends up holding it, that decdn_node_pull_reactive_topup_total is exactly 1, and that the on-chain deposit rose to the working target.

Note on existing coverage

crates/e2e has no node-to-node paid-pull e2e at all today. NodeFixture::launch_pull_through_cache exists but its only three call sites (crates/e2e/tests/origin_stream_while_store.rs) all pass discovery_peers = &[], i.e. a single node with no peers — so they exercise the local-origin stream-while-store tier, never a peer pull. This issue is the first one.

Activity

  1. added
    prio:medium
    rust
    kind:test
    on Aug 4, 2026
  2. moved this from Backlog to Ready in deCDNon Aug 20, 2026
  3. alpergundogdu commented on Aug 25, 2026

    @alpergundogdu
    Contributor

    Pick-up note: e2e drafted, blocked on a daemon-side non-recovery (not merged)

    I built the crates/e2e/tests/node_pull_topup.rs journey this issue asks for and got it to the point where the only thing standing between it and green is a persistent daemon-side non-recovery on the node's first upstream miss-pull, not test scaffolding. Capturing the full state here so whoever resumes starts from the blocker rather than re-deriving it. Nothing was pushed/merged.

    The blocker (this is where to pick up)

    The server opens its buyer pool lazily on its first upstream pull and requests from the seeder within milliseconds. The seeder's cached getPool view refreshes on event_poll_interval_ms, so that first request loses the race: the seeder can't yet verify the capability against the pool owner → drops the capability → stream request on unknown lane; refusing pre-serve → the buyer classifies it Transient and negative-caches (seeder, hash) for REFUSAL_SUPPRESSION_TTL (30s). That first refusal is a clean pre-reservation NotFound (good — no floor dead-charge).

    The problem: after that one refusal the server never re-attempts the upstream pull. Across a 60s downstream retry loop (12 attempts, 5s apart, well past the 30s TTL and long past the pool-view resolving) there is exactly one node_origin line in the whole run, then 60s of local-origin-only misses (reactive local-origin pull-through found no source) and a final NotFound. So the retry never gets the server back to the node-to-node tier even after suppression should have lifted and the seeder's view is warm.

    Suspected root cause to chase (didn't confirm): the first miss-pull to a peer during seller pool-view lag leaves the (peer, hash) path stuck longer than the refusal-suppression TTL — either the negative-cache/suppression isn't clearing on the retry path, or the serve-miss orchestration isn't re-reaching open_pull_leg on a subsequent request for the same hash. Plausibly entangled with #1675 (ephemeral per-serve runtimes stranding connection drivers). This is daemon behavior, so closing it is beyond a test-only change — hence not shipping the e2e yet.

    Why the analogous paths are green but this one isn't

    • node_to_node_coalesce.rs drives node-to-node pulls green using default rate/deposit and a node-to-node warm-up whose 250ms-cadence retry happens to catch the pool-view resolving before any long suppression sets in.
    • This reactive-topup journey can't use defaults: the server's working deposit must be shrunk below the blob's wire cost to force exhaustion, and the exhausting fetch's coarse retry lands squarely in the suppression window.
    • The mechanism under test is already proven green by the loopback suite (node_origin_pull.rs::a_pull_larger_than_the_working_deposit_tops_up_once_and_completes and siblings) and by the CLI e2e (cli_fetch_topup.rs). This issue is specifically the node-to-node on-chain e2e, which is the first of its kind and where the harness fragility lives.

    Findings worth keeping (sizing + traps already solved)

    1. Warm-ups must be own-origin. A node-to-node warm-up loops open_session's 250ms retry through the pool-view lag, and each admitted-then-failed serve folds the server's own upstream stumble into the client pool's durable floor dead-charge (FloorReservation drop path), locking the 10 USDC client pool out within seconds (observed headroom=9000000 ceiling=500000 yet refused, via pool_budget_covers_reserve). Seed the warm blob into the server's own fs origin so session set-up never rides the upstream leg.
    2. Economic sizing that opens correctly: 0.5 USDC/MB on both hops (the margin buy gate, ADR 041, caps the server's upstream buy at its own sell rate, so a higher seeder rate is refused as below-margin); server working deposit 4 USDC (its working − M = 3 USDC headroom must hold several concurrent one-chunk floor reservations that the gap-driven pull's in-flight requests reserve on the seeder side, or the pull deadlocks against its own concurrency); blob ~10 MiB (~5.02 USDC wire) so it exceeds the working deposit by enough for exactly one reactive top-up.
    3. Reusable fixture helper written and unit-tested: NodeFixture::set_buyer_working_deposit(micro_usdc) in crates/e2e/src/node.rs (config rewrite + restart, mirroring set_rate_per_mb, with a rewrite_buyer_working_deposit TOML round-trip guard). This is independently useful and can be salvaged even if the e2e itself waits.

    Suggested next step

    Fix (or characterize) the upstream-pull non-recovery on the daemon side first — a node whose first miss-pull to a peer races the seller's pool-view lag should recover on a subsequent request once the view resolves, well inside the deploy budget. With that fixed, the journey above (own-origin warm-up + shrunk deposit + one-top-up sizing) should go green without the retry gymnastics, and the coarse downstream retry can drop back to a single fetch.


    Generated by Claude Code

  4. self-assigned this
    on Sep 1, 2026
  5. moved this from Ready to In progress in deCDNon Sep 1, 2026
  6. alpergundogdu commented on Sep 1, 2026

    @alpergundogdu
    Contributor

    Done in #1892 (merged): the node-to-node reactive mid-pull top-up e2e is authored at crates/e2e/tests/node_pull_topup.rs, along with the NodeFixture::set_buyer_working_deposit helper — and the prerequisite daemon fix (the pre-spend-refusal dead-charge that previously locked the client out) landed with it.

    The test is currently #[ignore]d because it surfaced a separate daemon issue — a high-rate node-to-node pull that fails deterministically — now tracked in #1893, which is the gate for dropping the #[ignore] and turning this into live coverage. Closing here; #1893 carries the remaining work.

  7. moved this from In progress to Done in deCDNon Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:testprio:mediumrust

Type

Fields

Priority

Medium

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions