Repository navigation
fix: keep a stopped node's late writes off its rebuilt node - #1521
Conversation
Retries the recovery start while the build fails on a VSS store still busy with the stopped node's writes, and skips it once a stop was requested. Verified: unit suite (CI selection) on an iPhone 17 Pro simulator, iOS 26.5, with bitkit-ios#1519 applied locally; simulator run of node start, two restarts and a failed Electrum change recovering.
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. |
QATested 416f572, a dev (regtest) debug build on an iPhone 17 Pro simulator, iOS 26.5, against staging VSS and Electrum, with a new wallet. The build resolved
node-run2x.mp4Not covered: a VSS write still in flight past the 60 s wait cannot be triggered on demand in the app, so the busy-store retry is covered by the unit tests only. |
Verified: swiftformat --lint on both files (0 require formatting)
|
Renamed to match its twin synonymdev/bitkit-android#2004; the ldk-node 0.7.0-rc.82 bump stays as described in the body. |
[High impact] The PR appears safe to merge; no actionable issues were established. SummaryUpdates
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Config change fails] --> B[Stop failed node]
B --> C{Stop requested?}
C -->|Yes| D[Skip recovery start]
C -->|No| E[Build and start previous config]
E -->|Success| F[Recovery complete]
E -->|Store busy and attempts remain| C
E -->|Other error or final attempt| G[Log recovery failure]
D --> H[Return original config error]
F --> H
G --> H
Reviews (1) · Last reviewed commit: "chore: bump ldk-node to 0.7.0-rc.82" · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Bumps LDKNode to 0.7.0-rc.82 (the VSS store fence of synonymdev/ldk-node#140) and makes the Electrum/RGS recovery start retry up to 5 times while the build fails with KvStoreSetupFailed, stopping as soon as a caller asks for a stop. Reviewed 443d622c6, full tier, static: iOS does not build on Linux, so nothing was compiled or run here.
What I checked, and 4 candidates I ruled out
Read in full: LightningService.swift lifecycle section (setup, restart, recovery, start, stop, stopNode), ServiceQueue.background, AppError(error:), NodeRestarter, SettingsViewModel+Electrum, WalletViewModel.stopNodeLocked / stopForWipe, AppReset server-settings wipe, ldk-node src/io/vss_store.rs and src/builder.rs at the rc.82 tag.
Call sites traced: every caller of stop(clearEventCallback:) (only WalletViewModel through NodeLifecycleService) and of restart(...) (Electrum, RGS, LDK debug screen). restartNode and restartWithPreviousConfig now use stopNode, so the restart's own stops do not count as requested stops; external stops still go through stop and bump requestedStops.
Error matching: setup builds inside ServiceQueue.background(.ldk), which wraps the thrown BuildError in AppError with underlyingError set (Errors.swift), so isKvStoreSetupFailure sees BuildError.KvStoreSetupFailed on the real path, as in the tests.
Binary: the bindings/swift sources are identical between rc.81 and rc.82, and the sha256 of the published LDKNodeFFI.xcframework.zip for v0.7.0-rc.82 matches the checksum in its Package.swift (abb06ea3...). Package.resolved pins the tag commit 1dd2f42e.
CI: SwiftFormat, validate and detect-changes green; Run Tests, Run Integration Tests and build-local still pending when this was posted.
Ruled out
- Retry also matches an unreachable VSS server:
KVStoreSetupFailedis also what the schema-version read returns after its retries, so offline each attempt can take minutes and the loop stretches recovery. Bounded at 5 attempts, and retrying while offline can bring the node back once the network returns, so this is a trade-off rather than a defect. - A stop during one attempt's
setup:stopfinds no node yet, and that attempt'sstartstill runs. The same window existed for the single recovery start before this change; the new check only narrows it. - Native stop failed and the old node is still live: each build then waits the full 60 s fence and fails, so recovery gives up after about 5 minutes, bounded.
- Lock leak between attempts: a failed
setupreleases the lightning lock in itsdeferand leavesconfiguredNodenil, so the next attempt's guard passes.
Merge confidence: 4/5, the unit and integration jobs had not finished, and the busy-store path is covered only by closure-level unit tests, not by a real fence timeout.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer does not carry an effort setting)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 443d622.
1 actionable finding — resolve or provide an evidence-backed rebuttal.
The ldk-node rc.82 bump adds a VSS store fence: every build now waits up to 60 s for a node still live on the same store, and for its in-flight writes, then fails with KvStoreSetupFailed. The PR only retries that failure in restartWithPreviousConfig. The first attempt of an Electrum or RGS change is not retried. When the store is busy, a valid server is rejected and the node falls back to the previous server (see the finding). The rest of the change holds up in source analysis:
stop()andstopNode()are split correctly, so the restart's own stops don't count as requested stops.BuildError.KvStoreSetupFailedreachesisKvStoreSetupFailurethroughServiceQueue.backgroundandAppError(error:).- A failed
setupreleases the lightning lock and leavesconfiguredNodenil between attempts. - The Swift binding's
BuildErrorcases are unchanged between rc.81 and rc.82.
Dependency source inspected: synonymdev/ldk-node rc.81 366d56ef3c735406146ed12a34aba291776d29f6 against rc.82 1dd2f42e44561ee4005f109c0d2cb61e1de99123 (src/builder.rs, src/io/vss_store.rs, src/lib.rs).
Parity: compared with the twin bitkit-android#2004 at 35873ab4. Android uses the same 5-attempt recovery-only retry and the same stop-wins check (pendingStopJob). Its first restart attempt also goes straight to recovery on KvStoreSetupFailed, so the finding's mechanism looks the same there. That was not reviewed in full.
Other notes, not findings:
- A restart can now block for several minutes: up to 60 s for the first attempt, plus up to 5 recovery builds of up to 60 s each, all on the serial
.ldkqueue. Meanwhile the Electrum/RGS screen stays loading. - A wallet wipe started during that window waits on in-flight server switches with a 30 s bound (
AppReset.swift:60,SettingsViewModel.swift:363-371), so it fails with a timeout and must be retried. KvStoreSetupFailedalso covers an unreachable VSS server during the schema-version read, so recovery retries that case too.
Validation: I compiled and ran nothing; iOS can't build in this environment. The new LightningServiceTests cases only exercise startRetryingBusyStore with closures. No test covers the first restart attempt hitting a busy store. At review time, CI SwiftFormat passed; Run Tests and Run Integration Tests were still running. The author reports a passing unit suite and manual cases 1 and 2 at 416f5720. A busy store past the 60 s wait was not exercised at runtime.
Device testing: not performed in this review.
Suggested additional test cases:
- iOS unit: stub
setupso it throwsAppError(error: BuildError.KvStoreSetupFailed)for the requested Electrum URL and succeeds when called again. Callrestart(electrumServerUrl:). Expected: the requested server is retried and kept instead of falling back to the previous config. - iOS manual (needs a way to block VSS writes, e.g. a proxy that holds VSS PUTs for more than 60 s): change the Electrum server to a valid host while VSS writes are held. Expected: no server-change error caused only by the busy store, and the screen doesn't stay loading for minutes.
Findings
- [MEDIUM] Retry a busy-store build failure on the requested Electrum/RGS restart, not only in recovery — inline at
Bitkit/Services/LightningService.swift:461.
Reviewer model: claude-opus-5-5
Reasoning effort: high
An Electrum or RGS change whose build fails because the stopped node's VSS writes are still in flight now retries its own start before falling back to the previous config. Verified: unit suite (CI selection) on an iPhone 17 Pro simulator, iOS 26.5; swiftformat --lint on both files.
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 443d622c6, including affected code paths and unit tests, at 3ca894644. Baseline: previous review (inheriting the unchanged ldk-node 0.7.0-rc.82 dependency bump and VSS fence contract, stop()/stopNode() accounting, and changelog.d/next/1520.fixed.md).
No new actionable code findings.
LightningService.applyConfigChange retries the config change's own setup + start up to busyStoreStartAttempts (5) on BuildError.KvStoreSetupFailed, yields to requested stops via stopRequested, falls back to restartWithPreviousConfig (which also releases any node built during a non-busy failure before skipping restart if a stop was requested), and rethrows the original error. BitkitTests/LightningServiceTests.swift adds focused coverage for retrying on a busy store without falling back and falling back on non-busy failures.
Parity comparison against synonymdev/bitkit-android#2004 at 35873ab4e: iOS at 3ca894644 now retries KvStoreSetupFailed on the config change's own start as well as during recovery, whereas the Android twin at 35873ab4e currently retries KvStoreSetupFailed only in restartWithPreviousConfig() (restartWithElectrumServer and restartWithRgsServer still call start(shouldRetry = false, ...) directly).
Validation and limitations: CI SwiftFormat passed at 3ca894644, while CI Run Tests, Run Integration Tests, and e2e-tests (build-local) were still in progress during this review. Xcode compilation and unit tests could not be executed locally on this Linux host (the author reports 4686 unit tests passing locally at 3ca894644).
Recommended before device testing
- Wait for CI Run Tests and Run Integration Tests at 3ca894644 to complete green.
Device testing: not performed in this review. The author's manual cases 1 and 2 were reported passing at 416f5720e; the busy-store retry path itself is covered by unit tests (LightningServiceTests) rather than live device reproduction.
Earlier findings reconciled at this revision: 1 verified fixed.
Reviewer model: gemini-4-neon
Reasoning effort: high
|
Merged: approved by @piotr-iohk at 3ca8946, checks green, every thread resolved. |
Closes #1520
Twin:
Refs: synonymdev/ldk-node#140
Updates
LDKNodeto 0.7.0-rc.82, which carries synonymdev/ldk-node#140, so both apps ship the same ldk-node in 3.2.0.Description
KvStoreSetupFailedand replaces nothing.project.pbxprojandPackage.resolved. The Swift API is unchanged between rc.81 and rc.82.Out of Scope
Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
Dev (regtest) debug build on an iPhone 17 Pro simulator, iOS 26.5, against staging VSS and Electrum, with a new wallet.
Journeys
N/A — no user-visible behaviour change.
Manual Tests
Node stopped,LDK node setup,Node startedandNode restarted successfully.1→ Connect To Host → the change fails, the log showsFailed ldk-node config change, attempting recovery…, then the node starts with the previous config.Automated Checks
LightningServiceTestscases: a start retries while the store is busy, gives up after 5 attempts, does not retry other failures, and does not start or retry once a stop was requested; a config change retries its own start on a busy store without falling back, and falls back after another failure.RUSTFLAGS="--cfg vss_test" cargo test io::vss_storein ldk-node at the rc.82 tag against a local VSS server (see chore: release 0.7.0-rc.82 ldk-node#142).Evidence
LDKNodeFFI.xcframeworkof 0.7.0-rc.82 at 3ca8946: 4686 tests, 0 failures (5 skipped).ifbodies for SwiftFormat and 3ca8946 retries a config change's own start on a busy store; neither path is reached in 1 or 2 without a busy store.Gaps