feat(digstore-chain): migrate off dig-l1-wallet onto dig-wallet-backend engine seam - #27
Merged
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
…end engine seam Replace the deprecated dig-l1-wallet coin-selection primitive with dig-wallet-backend v0.4 (engine seam), per epic #998. The new engine seam speaks in chia_protocol::Coin natively, so the chia-query CoinRecord conversion dance (to_record/from_record + bytes32_to_hex/ coin_record_to_protocol_coin) is removed and the chia-query direct dep dropped. select_for_spend is now infallible; select_for_consolidation maps WalletError to ChainError. digstore keeps its own COIN_CAP of 50 (bundle cost ceiling) rather than the backend's general default of 500. Also removes the now-obsolete [patch] redirect for dig-l1-wallet's transitive dig-keystore in the root Cargo.toml and the dig-l1-wallet entry from deny.toml's git-source allowlist. Adds a regression test asserting the absence of any dig-l1-wallet dependency. Consumer adapts to the new interface; the backend is not reshaped. Closes #1005. Refs #998. Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
marked this pull request as ready for review
July 18, 2026 23:53
MichaelTaylor3d
commented
Jul 19, 2026
MichaelTaylor3d
left a comment
Contributor
Author
There was a problem hiding this comment.
Review verdict: CHANGES-REQUIRED
The code migration is clean and behaviour-preserving — nice work. Confirmed:
dig-l1-wallet→dig-wallet-backend = { version="0.4", default-features=false, features=["engine"] }(engine-only, never signs). ✓select_for_spend/select_for_consolidationnowchia_protocol::Coin-native; the CoinRecordto_record/from_recordglue + the directchia-querydep rightly dropped — a sound simplification, not a behaviour change. ✓- COIN_CAP = 50 preserved everywhere.
select_xch_coinscallsselect_xch(coins, target, COIN_CAP); everysingleton.rs/send.rscaller routes through it or passesCOIN_CAPexplicitly. No silent jump to the backend's default of 500.coin_cap_default_is_50green. ✓ - Cleanup correct:
[patch]removed from rootCargo.toml,dig-l1-walletremoved fromdeny.tomlallowlist,Cargo.lockregenerated (no dig-l1-wallet; dig-wallet-backend 0.4.0 from crates.io). Regression guardno_dig_l1_wallet_dependencypresent. ✓ - All 10 gates GREEN (build&test ubuntu+windows, version-increment, CodeQL rust/js/actions, commitlint, windows CI, dig-client-wasm gate, supply-chain audit). Zero open review threads. Version
0.16.0→0.17.0(minor) is correct — public API + behaviour unchanged. ✓
GATING — §4.2 coherence: SPEC.md left describing the old dependency
SPEC.md §10.1 (XCH coin selection & consolidation) was NOT updated in this unit of work and is now stale/wrong. It is the normative spec, not history:
- Line ~257: "the shared primitive is
dig-l1-wallet" → must bedig-wallet-backend. - Line ~271: "Caps the attempt at 50 coins (the shared
DEFAULT_COIN_CAP…)" — now factually wrong: dig-wallet-backend'sDEFAULT_COIN_CAPis 500; this PR deliberately fixes digstore's own localCOIN_CAP = 50(bundle cost ceiling). The spec must state 50 is digstore-local and distinct from the backend default. - Line ~285: "both are the
dig-l1-walletprimitives (select_for_spend/select_for_consolidation)" → must bedig-wallet-backend(dig_wallet_backend::engine::selection).
Per §4.2 a change that leaves SPEC.md describing old behaviour is INCOMPLETE. Update these three references in the same PR. (Inline anchors weren't possible — SPEC.md is untouched by the diff.)
dig-constants check (HARD RULE — please answer)
- Does anything here belong in
dig-constants? — COIN_CAP = 50 is now a bare local literal, and the code comment + SPEC both state "the browser/JS spend layer uses this same boundary." If a second repo (the browser/JS spend layer) must match 50, it is a shared cross-repo constant and should live indig-constants(+ its wasm/npm binding) and be consumed by version, not re-hardcoded in each repo. Previously it rode in via the wallet crate's sharedDEFAULT_COIN_CAP; moving it to a local literal risks the exact byte-drift §4.1 forbids. Either (a) source 50 fromdig-constants, or (b) if the JS layer independently pins its own 50 and the two are intentionally decoupled, correct the SPEC claim that they "agree on the exact boundary." Please confirm which. - Should anything here be USING
dig-constants? — same COIN_CAP question; otherwise the swap looks clean.
Minor (non-gating)
- The branch commit subject uses
feat(digstore-chain)!:(breaking!) but the change is non-breaking and the bump is minor. Harmless since the squash merge uses the PR title (no!) — just noting the inconsistency.
Not merging (orchestrator owns merge). Resolve the SPEC.md §10.1 staleness and answer the dig-constants question, then I'll re-review + resolve.
…re-local (#1005) Update SPEC.md coherence on §10.1 coin-management contract: - Replace stale dig-l1-wallet references with dig-wallet-backend's engine::selection primitive - Fix FACTUALLY WRONG claim that browser/JS uses COIN_CAP=50: digstore uses LOCAL COIN_CAP=50 (distinct from dig-wallet-backend's DEFAULT_COIN_CAP=500) for mempool cost tuning, NOT a shared cross-repo contract. JS layer doesn't pin a cap. This resolves the SPEC coherence blocker for feat/migrate-dig-wallet-backend. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtR1bZXpDNp2VFNJDtwsph
MichaelTaylor3d
force-pushed
the
feat/migrate-dig-wallet-backend
branch
from
July 19, 2026 00:30
9073ff3 to
14c669d
Compare
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.
Summary
Migrates
digstore-chaincoin selection off the deprecated dig-l1-wallet onto dig-wallet-backend v0.4 (engine seam), per epic #998. Consumer adapts to the new interface; the backend is not reshaped. Replicates the proven #1004 recipe (chia-l2-consensus).Closes #1005. Refs #998.
Call-site mapping
digstore-chain/Cargo.toml:dig-l1-wallet = { git=…, tag=v0.3.0 }dig-wallet-backend = { version = "0.4", default-features = false, features = ["engine"] }(engine-only — this crate never signs)dig_l1_wallet::coins::selection::{select_for_spend, select_for_consolidation}dig_wallet_backend::engine::selection::{select_for_spend, select_for_consolidation}dig_l1_wallet::{SelectionOutcome, DEFAULT_COIN_CAP}dig_wallet_backend::engine::selection::SelectionOutcome;COIN_CAPnow a digstore-localconst = 50(bundle cost ceiling) — backend's general default is 500select_for_spend(&records, target, "XCH", cap) -> Result<SelectionOutcome>over chia-queryCoinRecordsselect_for_spend(coins, target, cap) -> SelectionOutcome— speaks inchia_protocol::Coinnatively (infallible)select_for_consolidation(&records, cap)select_for_consolidation(coins, cap) -> WalletResult<Vec<Coin>>→ mapped toChainError::Chainbytes32_to_hex/coin_record_to_protocol_coin+to_record/from_recordCoinRecord dancechia-querydirect dep droppedOther cleanup (#1005-specific)
[patch."…/dig-l1-wallet"](transitivedig-keystore = =0.1.3) from the rootCargo.toml.dig-l1-walletentry fromdeny.toml's git-source allowlist.Cargo.lock— nodig-l1-wallet,dig-wallet-backend v0.4.0resolves from crates.io.Behavior
No runtime behavior change: selection ordering (high-value-first, tie-broken by coin id), the 50-coin cap, and the NeedsConsolidation/InsufficientFunds distinction are identical. digstore's public API (
select_xch,select_xch_coins,select_xch_for_consolidation,COIN_CAP,XchSelection) is unchanged.Blast radius (gitnexus/grep)
Fully internal to
digstore-chain: callers (send.rs,singleton.rs) useselect_xch_coins/select_xch_for_consolidation/COIN_CAP— all signatures preserved, zero downstream change. No public API of the crate changed. No capability gap: every dig-l1-wallet primitive digstore used has a dig-wallet-backend equivalent (the CoinRecord glue helpers became unnecessary since the new seam is Coin-native).Tests / gates (local)
cargo build -p digstore-chain— GREEN against dig-wallet-backend v0.4.0.cargo test -p digstore-chain— GREEN (236 tests + newno_dig_l1_wallet_dependencyregression guard).cargo fmt -p digstore-chain -- --check+cargo clippy -p digstore-chain --all-targets --all-features -- -D warnings— GREEN.Version
Workspace
0.16.0→0.17.0(minor): dependency swap + internal cleanup, no public-API break, no behavior change.Co-Authored-By: Claude