Repository navigation
Conversation
Build the node without the Paykit Server accounts, each of which added about 2 s to the build, and load them into the running node from a WorkManager worker queued after every start that tracks accounts, so the load survives the app closing. - Reconcile unloads and completes pending removals in one lock hold, then loads each account in its own LDK queue hop and lock hold, re-checking tracking before each load. - Wallet sync no longer reconciles accounts; the worker retries a transient failure with WorkManager backoff instead of the in-process retry loop. Verified: ./gradlew testDevDebugUnitTest detekt
Verified: none (docs only)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Confidence Score: 3/5
[Medium impact] The change affects startup and account loading for wallets that track Paykit Server accounts. Fix node ownership during background loading and the startup tracking race before merging. FindingsSummaryMoves Paykit Server account loading out of node construction and into
Verification: Source review only; no builds or tests were run. GitHub draft-status checks were blocked by missing authentication. Reviewer model: gpt-6.1-sol DiagramsequenceDiagram
participant R as LightningRepo
participant N as LightningService
participant W as WorkManager worker
participant U as App lifecycle
R->>N: Start node without server accounts
R->>W: Queue account loading
W->>N: Load accounts one at a time
U->>R: App closes without background service
R->>N: Stop node after five seconds
W->>N: Continue loading
N-->>W: Skip released node
W-->>W: Finish successfully
Reviews (1) · Last reviewed commit: "docs: run app-close-proof network work i..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a84d871370
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews.
worth doing, does not block
- Expedited worker shows a foreground notification on Android 9 to 11 at every start (app/src/main/java/to/bitkit/repositories/WatchOnlyAccountsWorker.kt:43)
- Transient load failures now back off exponentially, up to 5 hours (app/src/main/java/to/bitkit/repositories/WatchOnlyAccountsWorker.kt:71)
- Journey for the reworked load path is not listed, and one step is now stale (journeys/pubky-marketplace/approval-while-node-restarts.xml:21).
approval-while-node-restarts.xmlis the existing end-to-end check that an account approved while the node is down is tracked once the node starts. That load now goes through the worker instead of the build, so this PR changes the journey's route. Step 21 still accepts "Loaded configured wallet for OnchainWalletAccount" as evidence, and nothing can log that line now that the build loads no accounts. The repo's journey rules ask for a route-changed journey to be listed under Journeys and updated. Step 21 should expect only "Registered derived on-chain wallet account".
nits
- Account load failures are logged twice, and the success log can mislead (app/src/main/java/to/bitkit/repositories/WatchOnlyAccountsWorker.kt:77)
the reviewers disagree, your call
- PR description is missing the Source line, QA case IDs and Setup (general). Objection: The repository requires all three items in this situation. I could not retrieve the PR description to confirm they were missing. Answer: I fetched the body with
gh pr view 2248at head a84d871. The reference block is onlyRefs: #2238, which closes nothing, and there is noSource:line, which pr.md:127 requires in that case. The three Manual Tests are- [ ] mainnet wallet...with no1./2./3.IDs (pr.md:198), and QA Notes has no#### Setup,#### Evidenceor#### Gaps(pr.md:203-212), even though the tests need a mainnet wallet with several approved Paykit servers. - Startup can miss the first Paykit account approved during a rebuild (app/src/main/java/to/bitkit/repositories/LightningRepo.kt:672-675)
- Post-load sync makes sends and approvals wait for account scans (app/src/main/java/to/bitkit/repositories/WatchOnlyAccountsWorker.kt:79-81)
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Builds the node with no Paykit Server accounts and loads them afterwards in a WorkManager worker queued on each start and on adopting a running node, one account per LDK queue hop. Reviewed a84d871, full tier, static: not built here, CI is the gate.
What I checked, and 5 candidates I ruled out
Read in full: WatchOnlyAccountsWorker.kt, the LightningService.kt and LightningRepo.kt diffs, WatchOnlyAccountsWorkerTest.kt
Call sites traced: reconcileWatchOnlyAccounts (worker, BackupRepo.restoreWalletBackup), hasTrackedWatchOnlyAccounts, setAccountTracking in WatchOnlyAccountRepo.kt, listOnchainWalletAccounts in CoreService.kt
Upstream checked: ldk-node add_onchain_wallet_account / remove_onchain_wallet_account at v0.7.0-rc.85
CI: build, build-and-test, lint, detekt, compose-ui green; e2e shards still running at review time
Ruled out
- History lost by loading at runtime instead of at build: ldk-node reloads a persisted account's BDK store and full-scans an account it has not synced this session, so a runtime add sees the same history a build-time add did.
- Pending removals cleared while new ones are queued:
unloadUnwantedWatchOnlyAccountsunloads and callscompleteReconciliationin one lock hold, before any load. - Tracking toggled off mid-load:
loadWatchOnlyAccountre-reads the store under the lock before each add; covered byreconciliation skips an account whose tracking was turned off while others loaded. - Worker loading into a replaced node:
REPLACEon each start, plus thenode !==check inside every queue hop. - Rejected xpub retried forever:
isRejectedPaykitServerAccountreturns success, and a transient failure is rethrown ahead of a rejected one so it retries; both are tested.
Merge confidence: 4/5, the behaviour hinges on WorkManager timing after app close, which no automated test covers; manual tests 2 and 3 on a device are the evidence.
Reviewer model: Claude Opus 5.5
Reasoning effort: Unknown (not exposed to the reviewing session)
The worker is plain unique work with a network constraint, so Android 9 to 11 show no foreground notification at each start, and a transient failure retries on a linear 15 s backoff instead of an exponential one. It is queued once the node runs and keeps its network graph. The check before queuing reads the store under the lifecycle lock, so an approval that began before the node ran counts, and it also counts removals a restore left pending. The load stops once the node is stopped or replaced, and the worker then skips the sync. Each failure is logged once, and "Loaded Paykit Server accounts" logs only for a current node. The approval-while-node-restarts journey no longer expects the build log line, since the build loads no accounts. Verified: ./gradlew compileDevDebugKotlin testDevDebugUnitTest (WatchOnlyAccountsWorkerTest, LightningServiceTest, LightningRepoTest, WatchOnlyAccount*, BackupRepoTest) detekt
The worker is queued right after the node reaches Running, so a later start step that fails or is cancelled no longer leaves the Paykit Server accounts unloaded, and it is also queued when the tracked read fails. Adds tests for the tracked check, the work request and the sync after a rejected account, and corrects the companion claims doc, which still said the accounts load before the node starts. Verified: ./gradlew compileDevDebugKotlin testDevDebugUnitTest (WatchOnlyAccountsWorkerTest, LightningServiceTest, LightningRepoTest, WatchOnlyAccount*, BackupRepoTest) detekt
|
Description updated: |
|
QA for 6f2d58d: 🟢 J1, 1. Cold start, 2. Close right after start, 3. Toggle trackingJ1: approval-while-node-restarts With the node stopped and VSS held, the setup completed on the first Authorize, with no toast, and the account's tracking was stored without a node. Once VSS was released,
1. Cold start With three tracked accounts, the node built in 1.2 s and started without them; the worker registered all three within 5 s of start.
2. Close right after start The app was killed right after the node started, before any account loaded. On reopen the worker loaded all three accounts, and Savings shows the 50,000 sats held by account 1.
3. Toggle tracking Tracking off unloaded account 1 and Savings dropped to 0 at the next balance refresh; tracking on loaded it again and the 50,000 sats returned.
|
Refs: #2238
Twin: synonymdev/bitkit-ios#1584
Source: self, #2238
Description
WatchOnlyAccountsWorker, plain unique work with a network constraint (no foreground notification), queued byLightningRepoas soon as the node runs (and when adopting a running node) whenever the wallet tracks accounts or has removals pending, or the read fails; it reads under the account lock, so an approval in flight at start counts. The accounts load into the running node and keep loading when the app closes right after start; a transient failure retries on a linear 15 s backoff, a rejected xpub does notsync()and the in-process retry loop, which the worker replacesAGENTS.mdrule: network work that must survive the app closing runs in WorkManager workersdocs/pubky-auth-companion-claims.md, which said the accounts load before the node startsOut of Scope
Design
N/A — no UI changes.
Preview
N/A — no user-visible changes.
QA Notes
Setup
adb logcatfiltered on the app to read node start and account load linesJourneys
journeys/pubky-marketplace/approval-while-node-restarts.xml— route changed: an account approved while the node is down now loads throughWatchOnlyAccountsWorker; step 21 now expects only "Registered derived on-chain wallet account"Manual Tests
Building node…toLDK node setupno longer grows per account;Loaded Paykit Server accountslogs shortly afterNode startedAutomated Checks
WatchOnlyAccountsWorkerTest.ktLightningRepoTest.kt,LightningServiceTest.kt,WatchOnlyAccountLifecycleCoordinatorTest.kt,BackupRepoTest.kt./gradlew testDevDebugUnitTest detekt(the suites above)Evidence
Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Gemini 4 Neon(reasoning:high)