Repository navigation
chore: bump ldk-node to 0.7.0-rc.84 - #1550
Conversation
rc.84 unwinds on a panic instead of aborting: the node stops itself and cannot start again. A start, a return to the foreground and a returning network replace such a node, and the event loop stops instead of redelivering an event the node can no longer mark handled. Verified: WalletViewModelWipeTests, LightningServiceTests, NodeStartRetryTests, WalletWipeAfterFailedStartIntegrationTests, swiftformat --lint on the changed files
A node the app is stopping is no longer taken for one that stopped itself. Verified: swiftformat lint, xcodebuild tests WalletViewModelWipeTests, LightningServiceTests, NodeStartRetryTests, WalletWipeAfterFailedStartIntegrationTests
No start or stop runs between the mark and the node status, and a pending restart never counts as a stopped node. Verified: swiftformat, xcodebuild tests WalletViewModelWipeTests, LightningServiceTests, NodeStartRetryTests, WalletWipeAfterFailedStartIntegrationTests
A stop or restart can begin while the status is read. Verified: swiftformat, xcodebuild tests WalletViewModelWipeTests, LightningServiceTests, NodeStartRetryTests, WalletWipeAfterFailedStartIntegrationTests
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. |
Verified: none (file rename only)
[Medium impact] The changes affect recovery and event handling for the wallet’s Lightning node. The PR appears safe to merge, with a non-blocking test cleanup issue. Findings
SummaryUpdates
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Start, foreground, or network return] --> B{Started node stopped itself?}
B -->|No| C[Keep current lifecycle]
B -->|Yes| D[Mark wallet node stopped]
D --> E[Request wallet start when online]
E --> F[Release stopped node]
F --> G[Build and start replacement]
Reviews (1) · Last reviewed commit: "fix: re-read the stopped node mark after..." · Reviewed by Greptile |
Verified: swiftformat lint, xcodebuild tests WalletViewModelWipeTests
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P2). Bumps ldk-node to 0.7.0-rc.84 and discards a node that stopped itself before the next setup, on start, foreground return and network return. Reviewed 1f69f49b1d561511659c9591f59895c4462e4382, full tier, static: iOS does not build on Linux, so this is reasoned from the code, the ldk-node rc.84 source and CI, and nothing was run.
What I checked, and 4 candidates I ruled out
Read in full: the diff; LightningService.restart, stopNode(only:), releaseAfterFailedStop, stoppedNode, discardStoppedNode, listenForEvents; WalletViewModel.startNode, markNodeStoppedIfItStoppedItself; the AppScene foreground and network handlers; NodeRestarter; ldk-node rc.84 Node::start, event_handled, the panic guard.
CI: SwiftFormat, validate and Run Tests still running at this head; the previous head's SwiftFormat and validate passed. 1f69f49 only adds snapshotAppDefaultsDomain() to the new test, which answers Greptile's P2.
Ruled out
- A restart's node discarded mid-restart:
stoppedNoderecheckspendingRestarts == 0and the configured node after the queue read. - An app stop read as a self-stop:
startTriedNodeis cleared on the LDK queue beforenode.stop()and restored only on a failed stop. - Foreground marks a node stopped while starting:
hasStoppedNodeWhileUpre-reads the state after each await, covered bytestOnlyANodeThatStoppedItselfIsMarkedStopped. - Network return double-restarts:
NodeRestarter.restartgoes throughwallet.start, whose state switch refuses.starting.
Merge confidence: 4/5, one P2 on a narrow trigger, and CI has not finished at this head.
Reviewer model: Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: Not exposed (the runtime does not report it to the reviewer)
A failed write removes the event, so an equal next event no longer ends the loop while the node runs. Verified: swiftformat lint, xcodebuild tests WalletViewModelWipeTests, LightningServiceTests
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 1f69f49.
1 actionable finding — resolve or provide an evidence-backed rebuttal.
A failed event-queue write can stop the Lightning listener while the node is still running, so later payment and channel events are not delivered until the app process starts again. The same mechanism is already described in the open thread. A VSS put retries for 30 seconds per attempt and up to 180 seconds in total, which overlaps this app's 10-second on-chain sync, so a second identical SyncCompleted is queued while the failed write is in flight. The panic path still refuses event_handled before removing the event and clears is_running; foreground, network, and start recovery still apply to a node that has actually stopped.
Compared bitkit-android#2197 at 54893685 for the shared listener-stop and self-stop restart contracts only, not a full review. That listener uses the same equality check. iOS restarts a self-stopped node when the scene becomes active, when the network returns, and on the next wallet start. An app left open does not poll, which this PR states.
The preferences snapshot requested on the test thread is present in testAStartReplacesANodeThatStoppedItself at this head. No matching issue was found for this listener stop. No unit tests or device run were executed in this review. The author reports manual case 1 passed on 49303a3d3; the two later commits rename the changelog fragment and snapshot test preferences.
Device testing: not performed in this review.
Suggested additional test cases
- iOS, regtest wallet online. Queue two identical on-chain
SyncCompletedevents and fail the event-queue write whilestatus().isRunningstays true. Expected: the log does not show "Event loop stopping", and a later payment or channel event still updates the app. - iOS, same debug hook as manual case 1. Stop the native node, disconnect the network, then reconnect. Expected: the wallet start is retried once, the node runs in the same process, and it does not restart again.
Limitation: 1 earlier attempt left no retained output, so its findings could not be reconciled.
Findings
- [MEDIUM] Keep the event loop running after a failed event write — inline at
Bitkit/Services/LightningService.swift:3096.
Reviewer model: grok-4.7
Reasoning effort: xhigh
A node whose start has not returned is not running either. Verified: swiftformat lint, xcodebuild tests WalletViewModelWipeTests, LightningServiceTests
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 1f69f49, including the event-loop stop path, at 063426f. Baseline: review on 1f69f49. Inherited from that baseline: the ldk-node pin bump to 0.7.0-rc.84, self-stopped node detection and discard, WalletViewModel start, foreground and network restart triggers, WalletViewModelWipeTests, and changelog fragment 1550.fixed.md.
1 actionable finding — resolve or provide an evidence-backed rebuttal.
The follow-up stops the event loop after a failed eventHandled() when that event is still first, startTriedNode is this node, and status().isRunning is false. In ldk-node v0.7.0-rc.84, a recorded panic makes event_handled return before the event is removed, and a failed queue write removes the event first, so an equal event can follow. startTriedNode is set in the defer after node.start() returns, which keeps a start that has not returned off the stop path. This is source analysis; this review did not run the unit tests.
The event-listener stop was compared with bitkit-android#2197 at 54893685. Android stops when the next event compares equal. Only that contract was checked, not a full review of the Android pull request.
Device testing: not performed in this review.
Suggested additional test cases:
- iOS: cover the updated stop decision. When
eventHandled()fails and the next event compares equal, stop before delivery when start was tried on that node and it is not running. A running node, and a node whosestart()has not returned, keep the loop and deliver the following event.
Earlier findings reconciled at this revision: 1 still present, 1 verified fixed.
Findings
- [LOW] Snapshot host preferences in the successful start test — inline at
BitkitTests/WalletViewModelWipeTests.swift:315. Still present from an earlier unpublished review.
Reviewer model: grok-4.7
Reasoning effort: xhigh
piotr-iohk
left a comment
There was a problem hiding this comment.
iOS regtest device QA — PASS on 063426f40eb5e23e51654e97d3c6af556c58097a with LDK 0.7.0-rc.84 (iPhone 17 simulator, iOS 27.2).
- Stopped the native Lightning node while Bitkit was online using the PR’s regtest-only debug hook. Sent Bitkit to the background, then reopened it. The app retried wallet startup, started a different native node in the same process, and completed Lightning wallet sync.
- The same replacement node was still running 67 seconds later and the logs showed no additional startup.
The run covered stopped-node foreground recovery. A real panic, a native PersistenceFailed event refusal, and a simulator network-return trigger remain unverified on device.
|
Merged: approved by @piotr-iohk, checks green, all review threads answered. |
Source: self, synonymdev/ldk-node#145
This PR bumps ldk-node to 0.7.0-rc.84 and restarts a Lightning node that stops itself after an internal panic.
Description
Package.resolvedto 0.7.0-rc.84, so that a panic inside the node returns an error and stops the node instead of ending the appOut of Scope
WalletViewModelWipeTests.swift: start refreshes that can write preferences after a test restores them — test: wallet start tests leave app preferences changed #1553, raised in chore: bump ldk-node to 0.7.0-rc.84 #1550 (comment).Design
N/A — no UI changes.
Preview
N/A — no user-visible changes.
QA Notes
Setup
A regtest dev build with a wallet. A panic cannot be triggered from the app, so the manual cases need an uncommitted debug hook that calls the native node's
stop()behind the app's back.Journeys
N/A — not drivable; see Manual Tests.
Manual Tests
Automated Checks
WalletViewModelWipeTests.swift— a start replaces a node that stopped itself, and only such a node is marked stoppedWalletWipeAfterFailedStartIntegrationTests.swift— a wipe after a failed start still completesEvidence
49303a3d3on a simulator, regtest debug build plus the debug hook:Gaps
PersistenceFailedwas not exercised on a deviceLightningServicehave no unit test, as both need a real node49303a3d3and was not re-run on a deviceModels used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)Gemini 4 Neon(reasoning:high)