Repository navigation
fix(gateway): pull a non-manifest once, reuse verified sizes, count live spend on /_status - #2643
Merged
Merged
Conversation
…ive spend on /_status - #2478: the gateway keeps up to 1024 hashes it found to be no bundle manifest (over the manifest cap, unparsable, or malformed), with the verdict but not the asker's raw-blob hint, so a repeat request answers the same 404 with no pull. Upstream and funding failures are not kept. - #2632: FetchHost keeps the verified size of up to 4096 blobs pulled whole and passes it as ProbeOpts::known_size, so a pinned gateway's repeat bare-hash pull sends no probe. It never reaches held_cap. The gateway e2e asserts zero probes across the repeat pulls. - #2640: each /_status delegate_lanes row gains spent_micro_usdc and bytes_delivered, per lane the larger of the stored watermark and the live ledger of a pull in flight (LaneLedgers::committed_lanes). The dashboard reads them and marks a capability with pulls in flight. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Cached diagnostics can exhaust gateway memory, and payer retirement can race with status reads and omit committed spending.
2 open issues
What changed in this PR
This PR reduces repeat gateway download costs and improves visibility into capability spending, addressing #2478, #2632, and #2640.
Changes:
- Caches non-manifest verdicts so repeat bundle requests avoid another paid pull.
- Reuses verified blob sizes to skip repeat probes of pinned nodes.
- Includes live ledger spending in
/_statusand displays active pulls in the dashboard.
| File | Description |
|---|---|
| crates/e2e/tests/gateway_public.rs | Checks that repeat pulls send no probes. |
| crates/client/src/ledgers.rs | Exposes committed values for registered lanes. |
| crates/cli/src/commands/gateway/worker/tests.rs | Tests live spending and watermark merging. |
| crates/cli/src/commands/gateway/worker.rs | Merges live ledger values into capability totals. |
| crates/cli/src/commands/gateway/tests.rs | Tests cached verdicts, retries, and namespace hints. |
| crates/cli/src/commands/gateway/status/tests.rs | Updates status fixture construction. |
| crates/cli/src/commands/gateway.rs | Adds negative caching and separates manifest pulling. |
| crates/cli/src/commands/fetch/tests.rs | Tests size-cache eviction and lookup precedence. |
| crates/cli/src/commands/fetch.rs | Caches verified sizes and exposes payer ledger totals. |
| crates/cli/dashboard/src/view.ts | Uses live spend totals and counts active pulls. |
| crates/cli/dashboard/src/view.test.ts | Tests capability totals and active-pull counts. |
| crates/cli/dashboard/src/fixtures/status-loopback.json | Adds capability spend and byte totals. |
| crates/cli/dashboard/src/contract.test.ts | Checks the new status fields. |
| crates/cli/dashboard/src/components/Capabilities.tsx | Displays pulls in flight. |
| crates/cli/dashboard/src/api.ts | Defines the added capability total fields. |
| CHANGELOG.md | Documents the three gateway fixes. |
| adr/appendix-gateway.md | Describes negative caching and live-spend reporting. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
- /_status read the store before the live ledgers: a pull that ended during the blocking store read persisted after the snapshot and dropped its payer, so its key's spend dipped for one poll. The ledgers are now read first. DelegateLanes::include_live recomputes from the stored lanes (idempotent) and the struct's fields are private. - SizeHints keeps the first size a hash records. - Docs: no false "a ledger only grows"; the not-manifest cache is bounded (ADR, STE wording); ProbeOpts::known_size names the verified-size source. - Tests: funding and allowance stops are not remembered, a mid-read cap stop is, a cached Unparsed verdict carries the asker's ?ns=, LaneLedgers::committed_lanes, the pool payer's live lanes, and the e2e probe check also counts shed probes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ad race - A malformed manifest's parse error quotes its publisher's paths and hash strings, so 1024 remembered verdicts from crafted manifests under the 64 MiB cap could hold gigabytes. Each verdict keeps at most MAX_VERDICT_TEXT (1 KiB), cut on a character boundary, from the first answer on. - A worker test ends a pull, and drops its payer, during the store read; its spend still counts because the ledgers are read first. It fails with the old read order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.


Three gateway follow-ups in one PR.
#2478: a blob that is no bundle manifest is pulled once
NotManifestskeeps up to 1024 hashes besideManifestCache. It is checked beforemanifest_filland again after taking it, as the manifest cache is.OverCap/Unparsed/Plain) holds no raw-blob hint. Each request renders the 404 with its own?ns=, and the text is the same as before.NotManifestoutcome is recorded. Allowance, funding and upstream failures still pull again.Gateway::manifestis split: the pull and parse moved intopull_manifest, which returns aManifestStop.#2632: a pinned gateway does not re-probe for a size it verified
FetchHostkeeps aSizeHintsmap of up to 4096 entries, filled only from verified whole-blob sizes, never from a node's unverified claim.ProbeOpts::known_size, so a--node-idgateway sends no probe for a repeat bare-hash pull.held_cap: only a declared size caps a fetch.gateway_publice2e now asserts 0decdn_probe_requests_totalacross step (3)'s repeat pulls. With the lookup reverted it fails with "probed the pinned node 4 time(s)".#2640:
/_statuscounts a capability's pulls in flightLaneLedgers::committed_lanes()andPayer::committed_lanes()expose each live lane's committed cumulative.Poolshandler reads the live ledgers after the store read, and eachdelegate_lanesrow gainsspent_micro_usdcandbytes_delivered.lanes,BuyerLaneSnapshot, the pool rows andGET /_capability(the SDK contract) are unchanged.adr/appendix-gateway.md§ State and § Payment and allowance describe both behaviours.Closes #2478
Closes #2632
Closes #2640
Test plan
cargo nextest run -p decdn-cli -p decdn-client: 2306 passedcargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt --check, thecargo docdeny gategateway_publicanvil e2e passes; a mutation check shows the new probe assertion fails without the fixpnpm lint,typecheck,test(65 passed); status fixtures regenerated withUPDATE_STATUS_FIXTURES=1make -C adr check-refs,pre-commit run🤖 Generated with Claude Code