Repository navigation
fix: close spark retry hold gaps - #1406
Conversation
Node sends in flight are counted per payment hash, so one node send of an invoice returning no longer clears the flag a repeat node send of the same invoice still relies on, and a Spark attempt stays refused while any of them is live. A send refused before admission no longer ends another send's entry. Verified: ChannelFreeRailTests on an iOS 26 simulator (new test fails with master's LightningService, passes with the fix); swiftformat --lint on the changed files.
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. |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Counts node sends in flight per payment hash, so one node send of an invoice returning no longer clears a repeat node send still queued, and only an admitted node send ends its entry. Reviewed 8ad1e70, full tier, static review, the branch was not built.
What I checked, and 4 candidates I ruled out
Read in full: LightningService.send(bolt11:) both rails, admitSend, isSendLive, attemptMark, attemptsLive, beginLdkSend/endLdkSend, submitPayment, ServiceQueue.background
Call sites traced: every reader and writer of ldkSendsInFlight (all in this file; beginLdkSend is only called from tests), and the tests that pair beginLdkSend/endLdkSend
CI: SwiftFormat, validate and detect-changes green; Run Tests, Integration Tests and build-local still pending at review time
Ruled out
- Read of
isAdmittedracing the write on the ldk queue: the flag is set inside the queue block and read in thedeferafter the continuation resumes, so the resume orders the two; the Spark path already uses the same captured-flag pattern withisRefusedAtAdmission. - A throw after admission leaving the count up: after
isAdmitted = trueonlynoteAttemptandrecordLdkAttemptrun, neither throws, and any throw fromsend()still reaches thedefer. - A count reaching zero left as a key:
endLdkSendremoves the key at the last decrement, and every membership read (Set(keys),[hash] != nil) sees only live counts. - Under-count from an end with no begin:
endLdkSendreturns when the hash is absent, and the refused path no longer calls it.
Merge confidence: 4/5, the change is covered by testANodeSendEndingLeavesARepeatNodeSendOfTheInvoiceInFlight but the unit suite on CI had not finished when this was posted.
Reviewer model: Claude Opus 5.5
Reasoning effort: Not exposed (the review runner does not report it)
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 8ad1e70. Each admitted LDK send keeps its own in-flight entry until cleanup, and a send refused before admission leaves that entry alone.
Low: The overlap test at BitkitTests/ChannelFreeRailTests.swift:481 enters and leaves the count through test helpers. It would still pass if production admission stopped incrementing the count or a refused send decremented it. Extend the test through the LDK send path and check that both a completed send and a send refused before admission leave another same-invoice send holding Spark.
Pre-existing Low candidate: The history-based releases at Bitkit/Services/LightningService.swift:1538 and Bitkit/Services/LightningService.swift:1566 can remove a newer same-invoice attempt because they do not revalidate the listing's generation under the removal lock. If the newer send returns before the other rail's final admission, that admission can lose both the in-flight check and the recorded-attempt check. This requires a narrow overlap between payments of the same invoice on both rails. Whether both can settle remains unverified.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
A follow-up PR, opened once this one merges, admits both sends through
Confirmed. In the same follow-up, both releases skip a hash that is in flight or was recorded since the listing's mark, as |
|
The node release guard ( |
Closes #1405
Twin: synonymdev/bitkit-android#2014
Description
Out of Scope
LightningService: the Spark rail's in-flight sends stay a set, as a second Spark send of one invoice is already refused when it begins.Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
N/A — no device testing required: the race needs two concurrent node sends of one invoice and can't be driven from the UI.
Journeys
N/A — no user-visible behaviour change.
Manual Tests
N/A
Automated Checks
ChannelFreeRailTests.swift— a Spark attempt stays refused after one of two node sends of the invoice returnsEvidence
ChannelFreeRailTestsat 8ad1e70 on an iPhone 17 Pro simulator, iOS 26: all 116 tests pass. With master'sLightningService.swiftand this branch's tests, the new test fails (the Spark attempt goes out).swiftformat --lintpasses on the changed files.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium)Claude Sonnet 5.5(reasoning:high)