Repository navigation
feat(cli): check the buyer wallet's USDC in setup on a pull-through node - #2755
Merged
Merged
Conversation
A node with pull-through on buys its cache misses from peers and escrows blockchain.buyer_working_deposit_micro_usdc in a PaymentPool pool. With an empty wallet every openPool reverts, and setup, where the operator funds the node, said nothing. Setup now prints a buyer_usdc pre-flight row: the working deposit and the wallet's USDC, read from PaymentPool.usdc(). Below the deposit it warns with the shortfall, the address to fund and the testnet faucet. The row never blocks. --json reports it as preflight.buyer_usdc (null with pull-through off), and the keyless dry run prints it too. Pull-through is derived from the partial config by the daemon's rule, now shared as decdn_common::config::role_derived_pull_through. Closes #2676 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the non-blocking buyer-USDC setup check.
No open issues 🎉
What changed in this PR
Adds a non-blocking buyer-USDC check to decdn setup, helping pull-through node operators fund cache-miss purchases before starting the daemon.
Changes:
- Reports the working deposit, wallet balance, shortfall, and funding guidance in text and JSON, including keyless dry runs.
- Shares the daemon’s pull-through default rule and sanitizes balance-read errors.
- Adds unit and onboarding coverage for warning behavior, configuration, and output.
| File | Description |
|---|---|
crates/e2e/tests/g_node_01_onboarding.rs |
Tests underfunded-wallet warnings and omission when pull-through is off. |
crates/common/src/config/mod.rs |
Extracts the shared pull-through default rule. |
crates/cli/src/known_chains/tests.rs |
Checks the testnet faucet URL. |
crates/cli/src/known_chains.rs |
Adds USDC faucet metadata. |
crates/cli/src/commands/setup/tests.rs |
Tests thresholds, warning details, and JSON output. |
crates/cli/src/commands/setup.rs |
Implements buyer-USDC reads and non-blocking pre-flight reporting. |
crates/cli/src/commands/node.rs |
Exposes USDC formatting for reuse by setup. |
crates/cli/src/commands/chain_ctx/tests.rs |
Tests pull-through derivation and working-deposit configuration. |
crates/cli/src/commands/chain_ctx.rs |
Reads setup’s pull-through and working-deposit settings. |
CHANGELOG.md |
Documents the new setup check. |
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 |
… row state Review follow-ups on the buyer_usdc pre-flight row: - Read the PaymentPool address from DECDN_PAYMENT_POOL_ADDRESS, else blockchain.payment_pool_address, as decdn-node does. Drop the known-chain fallback: it could check a pool the node never uses and pass a config the node refuses to start with. - Split the row's balance into Read / NoWallet / ConfigError / ReadError. A config the daemon refuses (no or zero pool, zero deposit) says so; a failed read says to re-run. --json gains a `state` field, so the keyless dry run's `no_wallet` no longer reads like an empty wallet read from the chain. - Word the shortfall for a pool already open: opening escrows the full deposit, an open pool draws only refills. - Derive the detail text from shortfall() so text and JSON cannot drift. - Tests: the pool plan (env, file, unset, zero, zero deposit, off), the keyless row, the faucet lookup, a failed read's redaction, and present-and-null checks for buyer_usdc. 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.
What
A node with pull-through on (the default with no origin since #2674) buys its cache misses from peers. Opening the pool those pulls pay from escrows
blockchain.buyer_working_deposit_micro_usdc(10 USDC). Before this change,decdn setup, which is where the operator funds the node, did not check USDC at all.buyer_usdcpre-flight row, shown only when pull-through resolves on. It prints the working deposit and the wallet's USDC; the token address comes fromPaymentPool.usdc(). When the balance is below the deposit, the row isWARNand names the shortfall, the operator address and, on Arbitrum Sepolia, the Circle faucet. It also notes that a pool already open draws only refills, so a re-run on a working node does not read as "cannot buy". The row never blocks:all_ok()is unchanged.decdn-noderesolves it:DECDN_PAYMENT_POOL_ADDRESS, elseblockchain.payment_pool_address. There is no known-chain fallback. If the address is missing or zero, or the deposit is zero, the row saysdecdn-noderefuses to start. A failed chain read gives a redacted reason and a hint to re-run.--json:preflight.buyer_usdcisnullwhen pull-through is off. Otherwise it is{state, working_deposit_micro_usdc, balance_micro_usdc, shortfall_micro_usdc, ok, error}, wherestateis one ofcovered,short,no_wallet,config_errororread_error.no_wallet(no chain read). A config error still shows up there.Example (keyless dry run against the testnet, no pool configured):
Closes #2676
Reviewer notes
[cache]: the explicit flag, plus whether an origin table is present. The role rule lives indecdn_common::config::role_derived_pull_through, which both the daemon's resolver andchain_ctx::FileConfig::pull_throughcall. Checking presence rather than resolved origins disagrees with the daemon only on configs it refuses to start with.main's sanitizer. It therefore goes throughsanitize_err_chain. A unit test against a refused…/v3/SECRETURL pins this, and fails when the sanitizer is removed.admin_v1_status'sbuyer_wallet_micro_usdc.Verification
all_okignoring a warning row;short,covered,read_errorandno_walletstates, withnullchecked as present;FileConfig::pull_throughand the deposit default.g_node_01_onboarding(anvil): the livesetup --jsonassertspreflight.buyer_usdcis present andnull(the fixture pins pull-through off). A new step runssetup --dry-runwith pull-through on and the wallet holding 2.5 USDC. It asserts aWARNrow withshort 7.500000and the operator address, and an exit code of 0. All 3 tests pass.setup --dry-runagainst the public Arbitrum Sepolia RPC, both with and withoutDECDN_PAYMENT_POOL_ADDRESS.Always:
pre-commit run(commit hooks on the changed files all pass;cargo denyreports only the existing warn-onlycrypto-bigintadvisory)cargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-cli -p decdn-common(1744 passed) plus theg_node_01_onboardinge2e. I did not run the full workspace suite locally.feat(cli): …, lowercase subjectOnly if touched:
CHANGELOG.mdentry under Added🤖 Generated with Claude Code