Skip to content

Store Cashu proofs in one blob#93

Merged
benthecarman merged 1 commit into
masterfrom
single-key-cashu-proofs
Jul 14, 2026
Merged

Store Cashu proofs in one blob#93
benthecarman merged 1 commit into
masterfrom
single-key-cashu-proofs

Conversation

@benthecarman

Copy link
Copy Markdown
Collaborator

Persist the complete Cashu proof set with one versioned KV write so VSS-backed wallets avoid a round trip per proof. This should make startup much faster for VSS based cashu wallets.

@hash-money

Copy link
Copy Markdown
Contributor

Tested at head 0499e76 against our staging VSS (vss-server behind Caddy, Mutinynet signet, self-hosted Cashu mint) — same setups as the numbers in #90. Two environments: desktop wallet-cli (wired; ~0.6 s cold TLS+HTTP round-trip to the VSS host) and the Samsung A12 on a mobile network. Desktop wallets used fresh seeds; the A12 ran the PR build over its existing long-lived wallet. Workload: 5,000-sat trusted receive (37 proofs), paid by a third node.

Desktop (wallet-cli, fresh wallet, one 5k receive in store):

Metric 4e9d230 (base) PR #93
Cold restart → API ready 78.5 s 18.2 s
Receive: paid → PaymentReceived ~64 s ~30 s
get-invoice (mint quote) 10.7 s 11.5 s (unchanged)

(Local-store control on the PR build: get-invoice 1.2 s, receive ~1 s.)

A12 (existing wallet with channels; baseline re-measured the same afternoon, minutes before the upgrade):

Metric base PR #93
Cold start, pre-LDK phase 163.6 s (matches the 164 s in #90) 31.6 s (5.2×)
Receive: paid → PaymentReceived ~65 s 37.3 s
Receive-URI generation 11.95 s 11.8 s (unchanged)

Reading of the results: startup improves ~4–5× (proofs dominated the key count, and the N serialized reads collapse to one), the receive saga roughly halves (proof writes collapse to one blob write), and the two paths that never touch proofs are — as this PR would predict — unchanged: quote issuance still serializes the mint-quote/counter/saga-state writes, so the remaining gap to local-store (~1 s) is those per-key round-trips plus the bitreq connection churn (rust-bitcoin/corepc#658 / #659).

One thing to flag before this ships: there's no migration from the legacy per-proof keys. load_proofs_from_store reads only proof_set and treats NotFound as an empty proof set, so an existing wallet upgrades into a silently-empty trusted balance:

  • desktop: a base-build wallet holding 5,000 sats read 0 sats under the PR build; reverting the binary showed 5,000 again (legacy keys untouched — recoverable, but silent);
  • A12: the existing wallet's trusted balance vanished from the UI after upgrade, and the subsequent receive minted into the blob — the store is now forked (new build can't see legacy proofs, old build can't see the blob).

A one-time fallback — blob key missing → list + read legacy proof_* keys → write the blob → delete the legacy keys — would close that, and as a bonus deletes the very keys that make today's startup slow. Happy to re-run this capture on any update.

@benthecarman

Copy link
Copy Markdown
Collaborator Author

Do you actually need the migration? I excluded it because i assumed no one is using this on mainnet yet

@hash-money

Copy link
Copy Markdown
Contributor

No — we don't need it. Our Cashu tier is signet-only staging and the affected wallets are disposable test wallets; we'll recreate them when we bump our pin to a rev that includes this. From our side this is good to go as-is — the numbers above stand.

Persist the complete Cashu proof set with one versioned KV write so
VSS-backed wallets avoid a round trip per proof. This should make
startup much faster for VSS based cashu wallets.
@benthecarman benthecarman force-pushed the single-key-cashu-proofs branch from 0499e76 to 1c2eff8 Compare July 14, 2026 20:44
@benthecarman benthecarman merged commit 6bcb34c into master Jul 14, 2026
2 checks passed
@benthecarman benthecarman deleted the single-key-cashu-proofs branch July 14, 2026 22:19
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.

2 participants