Skip to content

feat(cli): decdn quote <URI> prices a pull from signed probe rates (#2600) - #2626

Merged
thiras merged 2 commits into
mainfrom
feat/2600-decdn-quote
Oct 26, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/2600-decdn-quote

Conversation

@thiras

@thiras thiras commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What

decdn quote <decdn: URI> prices a pull from the rates the nodes sign in their cdn/probe/v1 answers, before any paid byte.

blob     15.0 GB
nodes    2 of 8 hold it   rates 0.0095–0.0105 USDC/GB   (ceiling: 0.0191 USDC/GB)
estimate 0.14–0.16 USDC   likely 0.15 USDC
  • Census (decdn_client::quote::census): one unpaid probe round over every node a pull can draw from. That is the peer store's or the registry's list, narrowed by the region allowlist and not sampled down; a pinned --node-id is probed alone. Each answer's signed rate is verified against its operator, and the samples are recorded in the peer store.
  • Order and price:
    • HashCensus::serve_order reuses the pull's failover_order. It keeps one node per operator, then drops nodes above --max-rate-per-mb, as the pull refuses those streams at open.
    • price gives low and high (every byte at the extreme rates) and likely. likely splits the bytes evenly over the first --max-sources nodes and is capped at high.
    • Costs are on bao wire bytes, as the nodes meter them, for a fresh pull.
  • Bundles:
    • The size is the manifest's planned download (bundle::planned_downloads): a duplicate blob and a shared chunk count once.
    • The quote probes the 4 largest blobs, which fits the default per-peer probe burst after a manifest fetch. It prices the rest, and any probed blob with no usable rate, at their mean rate. That works because the reference node signs one rate for every hash.
    • A manifest that is not cached costs one small paid pull, which is cached for the get that follows.
  • decdn get --dry-run prints the same block, on a blob URI too, and --json is allowed there with --dry-run. Its JSON plan always carries quote and quote_error. Without a cached manifest it names the decdn quote … -o … command to run.
  • decdn get prints a one-line Estimate: on stderr before the pull (not under --json). It uses the rates its own probe round and the peer store hold, so it adds no probe round.

Closes #2600

Reviewer notes

  • Read first: crates/client/src/quote.rs (census, order, price), then crates/cli/src/commands/quote.rs (plan, view, output, dry-run glue).
  • get --dry-run is no longer offline. It still sends no transaction and opens no keystore, but it reads the registry when the peer store cannot supply it, and it probes.
    • A quote that cannot be set up (for example, no chain config) is a warning, so the cached plan still lists.
    • A ResolveConfigFault fails the dry run, as it fails the real run. That covers a malformed --node-id or --provider-address, and probe signatures that do not recover to their operators.
    • The existing bundle_pull dry-run unit tests now pass an empty config file (offline_config()), so they never read the machine's ~/.decdn config.
  • "Likely" is approximate. It assumes a pull that probed every node and an even split. The real pull samples 5 candidates per round, and tail-stealing moves bytes toward faster nodes.
  • The get estimate may use peer-store rates. It skips failure-suppressed nodes, and is labelled "Estimate".
  • Unchanged on purpose:
    • No config key for the rate ceiling; --max-rate-per-mb stays a flag.
    • No changes to the wire, contracts or the node.
    • No crate dependency edge.
  • Follow-ups, not in this PR: the gateway download-page estimate (gateway: hosted public HTTP gateway at <ns>.decdn.link that pays a pool behind the scenes #2593), and the sponsord onramp estimate. The onramp one needs the installer to pass the URI or size to /fund, which changes the installer contract.

Verification

Always:

  • pre-commit run --all-files: passed. The cargo-deny hook is warn-only; it reports two existing RUSTSEC advisories, and Cargo.lock is unchanged.
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features: ran as cargo clippy --workspace --all-targets --all-features -- -D warnings, exit 0.
  • cargo nextest run: workspace, 5793 passed.
  • PR title uses an allowed type and a lowercase subject.

Only if touched:

  • Public API of decdn-client: .snap regenerated (the quote module, bundle::PlannedBlob, bundle::planned_downloads).
  • adr/: make -C adr check-refs passed. Only appendix-bundles.md § --dry-run changes, so architecture.md needs no update.
  • User-visible change: CHANGELOG.md entry added.

Also:

  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: exit 0.
  • .github/scripts/check_crate_edges.py: OK.
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(cli_quote)': passed against two real nodes at 8 and 12 µUSDC/MiB. It covers:
    • the blob quote, with the even-split likely;
    • the ceiling exclusion;
    • a pinned --node-id;
    • get --dry-run, text and --json;
    • a bundle quote that pays for and caches its manifest, read back by a second quote and by get --dry-run --json;
    • exactly one Estimate: line on a paid get.
  • Not yet run against the Arbitrum Sepolia testnet.

🤖 Generated with Claude Code

…2600)

One unpaid `cdn/probe/v1` round reaches every node a pull can draw from and
verifies each signed rate against its operator. The quote prints the size,
the holders, their rate range in USDC per GB, the `--max-rate-per-mb`
ceiling, and the cost on bao wire bytes: at the cheapest rate, at the most
expensive, and the likely cost over the first `--max-sources` nodes in the
pull's own order (one node per operator, then the ceiling).

A bundle's size is its manifest's planned download. The quote probes the 4
largest blobs and prices the rest at their mean rate; a manifest that is not
cached is a small paid pull, cached for the `get` that follows.

`decdn get --dry-run` prints the same block, on a blob URI too, and its
`--json` plan carries `quote` and `quote_error`. `decdn get` prints a
one-line `Estimate:` on stderr before the pull.

decdn-client gains the `quote` module (`census`, `HashCensus::serve_order`,
`price`, `wire_bytes`) and `bundle::planned_downloads`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras self-assigned this Oct 26, 2026
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:13

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.

🟡 Changes recommended

Bundle wire-byte accounting and dry-run argument validation need correction before approval.

4 open issues
What changed in this PR

Adds decdn quote <URI> to estimate download costs from signed node probe rates, reusing the client’s discovery, provider ordering, and bundle planning.

Changes:

  • Adds unpaid probe census and pricing APIs, plus text and JSON quote output.
  • Integrates quotes into get --dry-run and adds pre-download estimates to paid pulls.
  • Adds unit and end-to-end coverage, public API snapshots, and documentation.
File Description
README.md Documents quote usage.
crates/​e2e/​tests/​cli_quote.rs Tests quotes and downloads against real nodes.
crates/​common/​src/​cli/​quote.rs Defines quote arguments.
crates/​common/​src/​cli/​mod.rs Registers the quote command.
crates/​common/​src/​cli/​get.rs Updates dry-run and JSON help.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records new public APIs.
crates/​client/​src/​targets/​tests.rs Tests rate-hint selection.
crates/​client/​src/​targets.rs Shares discovery helpers and exposes rate hints.
crates/​client/​src/​quote/​tests.rs Tests census, ordering, and pricing.
crates/​client/​src/​quote.rs Implements probe census and cost calculations.
crates/​client/​src/​lib.rs Exports the quote module.
crates/​client/​src/​bundle/​manifest_cache.rs Clarifies dry-run cache documentation.
crates/​client/​src/​bundle/​engine/​tests.rs Tests planned downloads and rate hints.
crates/​client/​src/​bundle/​engine.rs Exposes download plans and collects rates.
crates/​client/​src/​bundle.rs Adds planning and rate-hint APIs.
crates/​cli/​src/​main.rs Dispatches quote commands.
crates/​cli/​src/​commands/​quote/​tests.rs Tests quote planning and output.
crates/​cli/​src/​commands/​quote.rs Implements quotes and dry-run integration.
crates/​cli/​src/​commands/​mod.rs Exports the quote command module.
crates/​cli/​src/​commands/​get/​tests.rs Tests blob dry-run flag handling.
crates/​cli/​src/​commands/​get.rs Routes blob dry runs to quotes.
crates/​cli/​src/​commands/​gateway/​worker/​tests.rs Disables estimates in gateway fixtures.
crates/​cli/​src/​commands/​gateway.rs Disables estimates for gateway responses.
crates/​cli/​src/​commands/​fetch.rs Prints blob download estimates.
crates/​cli/​src/​commands/​bundle_pull/​tests.rs Tests dry-run JSON and isolates configuration.
crates/​cli/​src/​commands/​bundle_pull.rs Integrates bundle estimates and paid manifest fetching.
CHANGELOG.md Records quote and dry-run behavior.
adr/​appendix-bundles.md Documents network-enabled dry runs.

Review effort: Balanced

Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/quote.rs Resolved
Comment thread crates/cli/src/commands/quote.rs Resolved
Comment thread crates/cli/src/commands/quote.rs Resolved
@github-code-quality

github-code-quality Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 779f3aa feat/2600-decdn-quot... 9ad315e +/-
77% 77% 0%
View coverage of the 10 most impacted files.
File main 779f3aa feat/2600-decdn-quot... 9ad315e +/-
crates/cli/src/.../bundle_pull.rs 57% 54% -3%
crates/client/src/bundle.rs 38% 37% -1%
crates/cli/src/main.rs 82% 81% -1%
crates/cli/src/...mmands/fetch.rs 49% 49% 0%
crates/cli/src/commands/get.rs 97% 97% 0%
crates/client/s...undle/engine.rs 65% 66% +1%
crates/protocol/src/framing.rs 92% 93% +1%
crates/client/src/targets.rs 57% 60% +3%
crates/cli/src/...mmands/quote.rs 0% 71% +71%
crates/client/src/quote.rs 0% 74% +74%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 26, 2026 11:50 UTC

…lags first

A bundle's wire bytes are not the wire length of its summed content: each
blob has its own bao tree, and a blob that splices a shared chunk pays for
its download ranges plus the proof path down its own tree.
`bundle::PlannedBlob::wire` gives those bytes per blob, from the same drive
ranges a pull fetches. The quote, its `wire_bytes` JSON field and the `get`
bundle estimate sum them.

`get --dry-run` checks the flag combination and the pinned node's flags
before the quote's set-up, so a dangling `--provider-address` or a
malformed `--node-id` fails the dry run with or without a chain configured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit e3627ad into main Oct 26, 2026
34 checks passed
@thiras
thiras deleted the feat/2600-decdn-quote branch October 26, 2026 12:03
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.

cli: decdn quote <URI> prices a pull from signed probe rates before any paid byte

2 participants