Repository navigation
Conversation
… fetch end A stored buyer pool that reads with a zero owner keeps its row (a lagging RPC can miss a fresh pool), but every node refuses lanes on it NotFound, so no funding recovery step ever runs and each later run reuses the row. A fetch or bundle pull that fails with no byte paid for now reads the pool once more. When the first read showed no record, no run on the escrow handle saw it live, and the end read still shows no record, the buyer row is dropped via forget_if_pool and the fetch error names the pool; the next run adopts or opens one. ADR 003 now describes this step, and states that admission refuses a pool with no on-chain record (or Closed) NotFound, not Unfunded. Closes #2678
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Code coverage overviewLanguages: Rust, Solidity Rust / code-coverage/cargo-llvm-cov
View coverage of the 7 most impacted files.
Solidity / code-coverage/forge
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
The stale-pool note now reaches the user: a give-up or interrupt prints it under its stop line, and a pass the fetch moves on from prints it as a note. A store that cannot drop the row yields StalePool::Kept, which names the fault instead of ending like a plain miss. The step also holds back while a topUp of the command is unconfirmed or an escrow is untracked, matching replace_unknown, and an interrupted pass reads nothing. The bundle end condition and note folding are pure helpers with tests; new tests cover the compare-and-delete guard, the topUp guard, the store fault and the give-up message. ADR 003 states the Unfunded/NotFound audience split at admission and the retire conditions one per sentence.
Gas snapshotNo gas changes vs base. |
Seed the client store with a buyer row for a pool this deployment never opened. The first decdn get gives up (exit 75), names the stale pool on a note: line, and drops the row. The second run opens a pool and lands the blob byte-identical.
alpergundogdu
left a comment
There was a problem hiding this comment.
Looks good overall. I traced the routes that could delete the row of a pool that exists (failed RPC read, a pool this command opened or topped up, a pending openPool, a row moved to a newer pool, Ctrl-C, a fetch that paid bytes) and each one is guarded. Two changes before merge:
1. Check the RPC's chain id before retiring. The fetch path never checks that the RPC serves the deployment's chain. An RPC pointed at another chain with a PaymentPool at the same address reads a zero owner twice, and the row of a funded pool is dropped. A data-dir buyer that never adopts then opens a second pool. Please read eth_chainId once in retire_stale_pool and skip the retire unless it equals stored.deployment's chain. The same check already exists in sweep.rs, receipt.rs and the node's deployment preflight (runtime/mod.rs), so reuse that shape.
2. Drop the dead Interrupted check (crates/cli/src/commands/fetch.rs:1702). Interrupted only comes from the outer tokio::select! (line 583), which drops fetch_on rather than returning through it, so err.downcast_ref::<Interrupted>().is_none() is always true here. Remove it, and have the doc say a Ctrl-C drops the pass before this step runs.
The cross-process residual in the description (process B opens P, process A's lagging RPC reads P unknown twice and deletes B's row) is accepted as written. No change needed there.
|
Update to item 1 of my review: drop the chain-id check in |
…e pool Interrupted comes only from the outer tokio::select!, which drops fetch_on rather than returning through it, so the check never fired. A Ctrl-C drops the pass before the retire step runs.
|
Removed the dead |
Problem
When
getPoolreads a stored buyer pool with a zero owner (PoolStanding::Unknown), the first lane build keeps the row. That is deliberate: a lagging RPC can miss a pool opened moments ago. But every node refuses lanes on such a pool withNotFound(PoolUnconfirmed). That refusal isFault::Source, not an Unfunded-class one, so the candidate set never exhausts intoNoAffordableSourceand no funding recovery step runs. The fetch retries untilGaveUp, or forever in a terminal, and every later run reuses the dead row until someone deletes it by hand.Fix
At the end of a failed fetch, one authoritative
getPoolre-read decides whether to drop the row.Record:
still_openrecords onRunFundingthat the stored row read with no record. Nothing else changes during the fetch.Retire:
RunFunding::retire_stale_pool(contract, store)acts only when all of these hold:saw_live);topUpof the command is unconfirmed and no escrow is untracked (the same hold-back asreplace_unknown).It re-reads
getPoolonce. If the owner is still zero, it callsforget_if_pooland returnsStalePool::Retired.forget_if_poolis compare-and-delete, so a row another run already moved to a new pool survives. If the store fails, it returnsStalePool::Kept, which names the error and asks for a rerun. If the re-read fails or shows the pool, the row is kept.Call sites:
decdn getpass (cli/src/commands/fetch.rs), skipped when a pool replacement ended the pass (a Ctrl-C drops the pass before this step runs);What the user sees:
note:line under the stop line (stop_message);note:line.Why fetch end, not "every refusal was NotFound"
That signal does not exist. A discovered holder that answers
NotFoundis only cooled (source_set.rsrecord_not_found), never marked absent, so there is nothing to count.NotFoundalso means a miss, a load shed or a stale chain.ADR 003
Unfunded. It is refusedNotFound, like aClosedpool, and that section now says so.Unfundedgoes only to a requester that proves it holds a lane on the pool.Accepted residual
Two lagging reads in a row can retire a pool that another process has just opened, if this fetch fails with no byte paid for an unrelated reason. The lag has to span the whole failed fetch. A buyer that adopts from chain takes the pool back on its next run. A buyer that never adopts, such as one running from a node's data dir, would open a second pool.
Tests
funding/adoption_tests.rs:topUpblocks the step.funding/tests.rs: a store fault yieldsStalePool::Kept.bundle/engine/tests.rs: warning-or-context folding, the end-of-pull condition,retire_allowed, and the manifest error keeping its note.interrupt/tests.rs: a give-up prints the stale-pool note.e2e/tests/cli_fetch_stale_pool.rs(anvil): a stale stored row makes the firstdecdn getgive up (exit 75), print anote:naming the pool, and drop the row. The second run opens a pool and lands the blob byte-identical.Verified
cargo nextest run -p decdn-client -p decdn-cli --no-fail-fast: 2453 passed.cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(cli_fetch_stale_pool)': passed.cargo clippy --workspace --all-targets -- -D warningsandcargo clippy -p decdn-e2e --features anvil-e2e --all-targets -- -D warnings: clean.cargo fmt -- --check: clean.Closes #2678