Skip to content

feat(node): default node-to-node pull-through on for a node with no origin backend - #2674

Merged
thiras merged 2 commits into
mainfrom
feat/pull-through-default-by-role
Oct 28, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/pull-through-default-by-role

Conversation

@thiras

@thiras thiras commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What

cache.node_to_node_pull_through_enabled was off by default everywhere. A node started from decdn config init or the README refused every miss it could not fill from its own backend. The devops role already derives it on for a node with no origin, so a fleet node and a hand-installed node behaved differently on the same miss.

  • Role-derived default. Absent, the knob resolves origins.is_empty(), the same derivation as cache.relay_foreign_namespaces. It is on for a node with no origin backend, off for an origin node, and an explicit value overrides either. The validate summary, DEFAULT_CONFIG, the config init role docs and the origin block's override lines say so. Validate prints disabled (origin node) for the derived off.

  • Unfunded wallet warning. A new BuyerWallet handle carries the resolved flag and the buyer wallet's last USDC read. publish_buyer_wallet_usdc records each read into it, and on a node with pull-through on it warns when the wallet is empty. It reads at bootstrap and then on the hourly reclaim sweep, so the warning repeats once an hour. The miss path is unchanged: with no USDC the openPool already reverts and the miss serves NotFound. The existing decdn_buyer_wallet_usdc gauge stays the metric, and no duplicate counter is added.

  • decdn node status. StatusResponse carries pull_through: Option<PullThroughStatus { enabled, buyer_wallet_micro_usdc }>, filled from the same BuyerWallet handle via AdminState::with_buyer_wallet. The CLI prints one of:

    • pull_through=off
    • pull_through=on buyer_wallet_usdc=N.NNNNNN
    • pull_through=on buyer_wallet_usdc=(not read yet)
    • pull_through=on buyer_wallet_usdc=0.000000 (unfunded: …)

    The dashboard's api.ts, contract test and pinned fixtures match.

  • Docs: README, runbook, ADR 002 (the pull-through default beside the relay default), appendix-observability.md (decdn_buyer_wallet_usdc row) and the gauge's doc.

Closes #2603

Breaking

  • Config default shift: a node with no origin backend and no explicit cache.node_to_node_pull_through_enabled now buys its misses from peers. It spends USDC from its buyer wallet, bounded by blockchain.buyer_working_deposit_micro_usdc (10 USDC by default, already the default before this PR). Set false to keep the old behaviour. The fleet already runs with it on (devops role).
  • Admin wire: StatusResponse.pull_through is required. A decdn CLI at this release reads admin_v1_status only from a daemon at this release (pre-mainnet, no shim).

Reviewer notes

  • Read first: the resolver line in crates/common/src/config/mod.rs, BuyerWallet and publish_buyer_wallet_usdc in crates/node/src/buyer_pool.rs, and pull_through_line in crates/cli/src/commands/node.rs.
  • Not in this PR, by agreement:
    • decdn setup printing the working deposit and checking the buyer wallet's USDC, which needs PaymentPool.usdc() wired into setup's chain context. Follow-up issue.
    • The devops role dropping its own derivation (decdn_node_to_node_pull_through_enabled: "{{ not … }}") and passing the knob through only when set. That belongs in a decdn/devops PR once a decdn release carries this default.
  • buyer_working_deposit_micro_usdc already defaulted to 10 USDC and was never required, so that part of the issue needed no change.
  • The e2e NodeFixture writes the knob explicitly, so no e2e journey's behaviour changes.

Verification

  • New tests:
    • three resolver tests: on without an origin, off with one, an explicit value overrides either
    • an_empty_buyer_wallet_warns_only_with_pull_through_on: warns only with pull-through on and a zero read, records each read, records nothing on a failed read
    • status_reports_pull_through_from_the_buyer_wallet
    • pull_through_line_names_each_state
    • the admin serde round-trip and the write_status summary assert the new field
  • Smoke: decdn config init with no origin validates as node_to_node_pull: enabled (…). With --origin file://… it validates as disabled (origin node) and prints that both knobs derive to false.
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features
  • cargo nextest run --workspace: 5978 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • Dashboard: vitest run src/contract.test.ts (7 passed), tsc --noEmit, fixtures regenerated with UPDATE_STATUS_FIXTURES=1
  • pre-commit run on the change. cargo deny reports only the existing warn-only advisories.
  • adr/: make -C adr check-refs
  • CHANGELOG: one Changed (BREAKING) entry
  • Public API: decdn-common is outside the snapshot. decdn-protocol and decdn-client are unchanged.

🤖 Generated with Claude Code

…rigin backend

`cache.node_to_node_pull_through_enabled` was off everywhere, so a node
started from `decdn config init` or the README refused every miss it could
not fill from its own backend, while the devops role already turned it on
for a node with no origin. Absent, it now resolves by role, as
`cache.relay_foreign_namespaces` does: on with no origin backend, off with
one. An explicit value overrides either.

The buyer leg shares a `BuyerWallet` handle with the admin server: whether
pull-through is on, and the buyer wallet's USDC as last read. A node with
pull-through on warns at each read of an empty wallet (bootstrap, then the
hourly reclaim sweep), and `decdn node status` prints a `pull_through=`
line that flags it. `StatusResponse` carries the new `pull_through` field.

Closes #2603

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

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

The documentation misleadingly presents the 10 USDC working deposit as a spending cap, even though automatic refills can spend more from a funded wallet.

1 open issue
What changed in this PR

This PR makes nodes without an origin backend buy cache misses from peers by default, aligning hand-installed nodes with fleet behavior. It also exposes pull-through status and buyer-wallet balances to operators.

Changes:

  • Derive the pull-through default from origin configuration while preserving explicit overrides.
  • Share wallet balance reads with admin status and warn when pull-through is enabled but the wallet is empty.
  • Update CLI output, dashboard data types, tests, and operator documentation.
File Description
README.md Explain role-derived defaults and wallet funding.
docs/​runbook.md Document status output and unfunded-wallet warnings.
crates/​node/​tests/​anvil_settlement_e2e.rs Supply the shared buyer-wallet handle.
crates/​node/​src/​runtime/​mod.rs Wire the wallet into buyer and admin services.
crates/​node/​src/​metrics.rs Clarify when wallet balances matter.
crates/​node/​src/​buyer_pool/​tests.rs Test balance recording and warning conditions.
crates/​node/​src/​buyer_pool.rs Record wallet balances and emit unfunded warnings.
crates/​node/​src/​admin/​tests.rs Test pull-through status reporting.
crates/​node/​src/​admin.rs Include shared wallet state in status responses.
crates/​common/​src/​config/​types.rs Document the new configuration default.
crates/​common/​src/​config/​tests.rs Test role-derived defaults and explicit overrides.
crates/​common/​src/​config/​resolved.rs Update resolved-setting documentation.
crates/​common/​src/​config/​mod.rs Derive pull-through from origin presence.
crates/​common/​src/​admin/​tests.rs Extend status serialization coverage.
crates/​common/​src/​admin.rs Define pull-through status fields.
crates/​cli/​src/​commands/​node/​tests.rs Test each pull-through display state.
crates/​cli/​src/​commands/​node.rs Render pull-through and wallet status.
crates/​cli/​src/​commands/​dashboard/​status/​tests.rs Extend dashboard fixture generation.
crates/​cli/​src/​commands/​config.rs Update generated config and validation output.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-full.json Add pull-through data to the full fixture.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-failing.json Add pull-through data to the failure fixture.
crates/​cli/​dashboard/​src/​contract.test.ts Validate the new status shape.
crates/​cli/​dashboard/​src/​api.ts Mirror the Rust status fields in TypeScript.
CHANGELOG.md Announce default and admin-status changes.
adr/​appendix-observability.md Document wallet warnings and status visibility.
adr/​002-content-addressing.md Describe the role-derived pull-through policy.

Review effort: Balanced

Comment thread CHANGELOG.md Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 0273aad feat/pull-through-de... dacef10 +/-
77% 77% 0%
View coverage of the 8 most impacted files.
File main 0273aad feat/pull-through-de... dacef10 +/-
crates/client/src/scheduler.rs 94% 94% 0%
crates/node/src/admin.rs 77% 77% 0%
crates/node/src/runtime/mod.rs 26% 26% 0%
crates/cli/src/...mands/config.rs 84% 84% 0%
crates/node/src/buyer_pool.rs 82% 83% +1%
crates/cli/src/...ommands/node.rs 63% 64% +1%
crates/node/src/metrics.rs 91% 92% +1%
crates/node/src/dht/publish.rs 78% 80% +2%

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


Updated October 28, 2026 04:40 UTC

@thiras
thiras merged commit f3593a7 into main Oct 28, 2026
37 checks passed
@thiras
thiras deleted the feat/pull-through-default-by-role branch October 28, 2026 04:54
thiras added a commit to decdn/devops that referenced this pull request Oct 30, 2026
The daemon now derives cache.node_to_node_pull_through_enabled from the
node's role (decdn/decdn#2674): on with no origin backend, off with one.
The decdn_node role, the chart and `decdn-compose init node` each derived
the same value themselves. They now leave the key unset, so the deployment
paths and a hand-installed node cannot drift apart again. An explicit value
still renders as given.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras added a commit to decdn/devops that referenced this pull request Oct 30, 2026
The daemon now derives cache.node_to_node_pull_through_enabled from the
node's role (decdn/decdn#2674): on with no origin backend, off with one.
The decdn_node role, the chart and `decdn-compose init node` each derived
the same value themselves. They now leave the key unset, so the deployment
paths and a hand-installed node cannot drift apart again. An explicit value
still renders as given.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

node: default node-to-node pull-through on for a node with no origin backend, with a bounded working budget

2 participants