perf: cut offline wallet startup from 60s+ to ~3s#4064
Draft
kaloudis wants to merge 7 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request optimizes the application's startup performance and offline behavior by introducing a fast connectivity probe and skipping network-dependent tasks like VSS synchronization, wallet syncing, and Nostr mint restoration when offline. Additionally, Nostr mint restoration was refactored to fetch from relays in parallel with a tighter timeout. Feedback suggests adding a guard to prevent redundant callback registrations in CashuStore and implementing error handling when executing reconnect callbacks in ConnectivityStore to ensure robustness.
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.
Description
When the device is offline, Zeus's LDK Node and Cashu init paths used to block on a series of internal HTTP timeouts — VSS dual-store build (30–60s),
node.syncWallets()Esplora + RGS fetch (~30s+), and on a fresh recovery, the sequential Nostr relay loop (8 × 10s = up to 80s). End-to-end an offline cold-start could take 60s+ for an existing wallet and several minutes for a fresh recovery.This PR seeds
connectivityStore.isOfflinebefore any wallet implementation init runs, then short-circuits the network-bound work that would otherwise stall on those internal timeouts. Online cold-start is unchanged apart from a one-time probe capped at ~1.5s.Impact
syncWallets()(offline)Online cold-start regresses by at most the new ~1.5s
checkNow()probe; when online, the same VSS build and sync paths run as before. As a secondary benefit, online Nostr mint restore now fans out across all relays in parallel instead of trying them one-at-a-time.Behaviour notes / risks
vssError/esploraError/rgsErrorstayundefined, soWallet.tsxdoesn't surface alerts the user already understands. Online failures alert as before.vssErroralert where the previous 30s budget would have eventually succeeded. The graceful fallback (local-only build, retry on next launch) is unchanged.ConnectivityStorelifecycle (start/stop) is now owned byWallet.fetchData()rather thanCashuStore.initializeWallets(). Cashu still registers its reconnect callback viastartConnectivityMonitoring.Test plan
connectivityStore.onReconnectfires and Cashu pending tokens sweep.vssErroralert.PR Type
This pull request is categorized as a:
Checklist
yarn run tscand made sure my code compiles correctlyyarn run lintand made sure my code didn’t contain any problematic patternsyarn run prettierand made sure my code is formatted correctlyyarn run testand made sure all of the tests passTesting
If you modified or added a utility file, did you add new unit tests?
I have tested this PR on the following platforms (please specify OS version and phone model/VM):
I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):
On-device
Remote
Locales
Third Party Dependencies and Packages
yarnafter this PR is merged inpackage.jsonandyarn.lockhave been properly updatedOther: