Repository navigation
Conversation
This was referenced Oct 19, 2026
Rust-Checks has failed on main since the NU6.3 toolchain bump: rustfmt differs in nine files, and clippy on nightly-2025-06-15 rejects ten uninlined format arguments in webzjs-keys and one map iteration in webzjs-requests under -D warnings. Apply rustfmt and clippy's own suggestions; no behaviour changes.
…yncs The resync form was rendered only while no sync was running, and fullResync refused with "Sync already in progress" if a periodic rescan happened to be in flight. With a 35 s rescan interval that made the dialog vanish mid-typing and reject Confirm at random. Syncs are now serialised on the JS side instead of refused: a small module-level scheduler owns `syncInProgress`, periodic rescans skip their turn while a sync runs, and a full resync waits behind an in-flight rescan. This also closes the race where a rescan that had passed its guard could clear `syncInProgress` while a full resync was still running. (The wasm wallet runs syncs on one serial worker in a separate change; this one stands alone.) The form stays mounted during background syncs. While the resync waits for a running sync it can still be cancelled, which drops it from the queue; once it starts, Confirm and Cancel are disabled until it settles, and a card mounted while a resync is in flight shows that instead of offering another. The birthday is validated against the chain height inline instead of an alert. A custom birthday is written to the snap only once the resync succeeds, and before the fresh wallet is swapped into state, so a failed resync never leaves a birthday the old wallet never used (a birthday above the tip previously broke auto-recovery with "block is not in the main chain"), and a failed snap write leaves state, the snap and IndexedDB describing the same wallet.
…writes Twice in one day a correct wallet was replaced in IndexedDB by a worse one. A second tab kept saving its old copy over a completed Full Resync, because every tab wrote the single `wallet` key unconditionally and the last writer won. Earlier, stored bytes that failed to load were replaced by auto-recovery with an account-only wallet built from the chain tip. All wallet storage now goes through one module, src/storage/walletStore.ts, which enforces one rule: a save lands only if the instance saving descends from what is stored right now, or it is an explicit resync or recovery that is allowed to win. - The stored value is a versioned record with metadata; `epoch` increments on every write and is checked and written in one IndexedDB transaction. A legacy byte array counts as epoch 0 and is converted on its first save. - The epoch is bound to the WebWallet instance through a registry, not to React state, so a stale closure, an old hook or another tab is rejected by construction. A superseded instance can never write again. - Full Resync persists the fresh wallet as a forced write, with its birthday, before it becomes visible, then retires the old instance. Snap state is updated afterwards and repaired later if that fails. - Stored bytes that fail to decode are backed up and left in place. The empty wallet built instead is never registered, so no save, including auto-recovery, can replace them. The home page offers an explicit "Discard unreadable wallet data and recover from MetaMask" action. - A rejected writer reloads the wallet from storage instead of fighting; tabs learn of saves through a BroadcastChannel and reload when visible. One tab per origin holds a Web Locks writer lock and runs the periodic rescan; the others follow. Both are for freshness and efficiency only, the epoch check keeps every configuration safe. - The blob's own account birthday, read straight from the stored bytes, is authoritative. The snap value is repaired downward when it is later, never raised. Tests: the store module under fake-indexeddb (stale write rejected with storage untouched, forced resync wins, superseded instance blocked, legacy migration, unreadable bytes quarantined, concurrent saves serialized, and a two-tab simulation), the hook ordering (persist before swap, birthday precedence, reload on stale write, recovery guard) and the home page guard.
sqhell
force-pushed
the
fix/wallet-store-epochs
branch
from
October 19, 2026 16:51
6f46aaa to
16fdfde
Compare
This branch has not been deployed
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
src/storage/walletStore.ts, with one rule: a save lands only if the instance saving descends from what is stored right now, or it is an explicit resync or recovery allowed to win.epochis checked and written in one IndexedDB transaction; a legacy byte array counts as epoch 0 and converts on first save.WebWalletinstance through a registry, so a stale closure, old hook or other tab is rejected by construction; a superseded instance can never write again.Why
Twice in one day a correct wallet was replaced in IndexedDB by a worse one: a second tab kept saving its old copy over a completed Full Resync (every tab wrote the single
walletkey unconditionally, last writer won), and stored bytes that failed to load were replaced by auto-recovery with an account-only wallet built from the chain tip. Stacked on the resync-dialog PR because it rewrites the same resync flow.Stack
Position 10 of 15 in the WebZjs release order, to be merged in this order into
main. Builds on #8 (fix/resync-dialog). GitHub shows the whole stack againstmainuntil those merge; the commits of this PR alone are here: sqhell/WebZjs@fix/resync-dialog...fix/wallet-store-epochschore/rust-checksfix/reuse-sync-workerfix/grpc-web-trailers-onlyfix/resync-dialogfeat/send-againfix/pczt-parse-errorfix/sign-change-paired-spendsfix/historic-sync-oomfeat/history-resync-hintfix/wallet-store-epochs(this PR)feat/ironwood-poolfix/history-from-spendsfeat/wallet-statsfeat/resumable-syncfeat/resync-resumeRust pins reference
sqhell/zcash_client_memoryandsqhell/librustzcashby revision so CI builds exactly what was tested; once the zcash_client_memory stack (red-dev-inc/zcash_client_memory #16 to #21) merges, the memory pin goes back tored-dev-inc/zcash_client_memoryfeat/snap-nu63. The integration branchtest/all-fixeson the fork merges all fourteen and is the build that was tested end to end.Tests