Repository navigation
fix: spark send and exit follow-ups - #1898
Conversation
A Redo hold whose build the held funding paid drops the fee ask. A second overlapping Spark send of one invoice is refused at admission. A failed operator status no longer locks out a pre-restore invoice.
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. |
[Critical impact] The PR appears safe to merge, with no actionable issues found. SummaryThis PR fixes three Spark send and exit follow-ups:
No actionable issues were found. The added tests cover the changed decisions. No tests were run during this review. Reviews (1) · Last reviewed commit: "fix: spark send and exit follow-ups" · Reviewed by Greptile |
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Closes the three Spark follow-ups: a Redo hold that the held funding built goes back to Running with no fee ask, a second Spark send of one invoice is refused at admission, and an operator FAILED status lets a pre-restore invoice retry. Reviewed 8ee7828, full tier, static: per this repo's rule for auto reviews the branch was not built here, so this rests on the code and CI.
What I checked, and 5 candidates I ruled out
Read: the full diff, plus LightningRepo.payInvoice / payInvoiceWithLdk / admitSend / releaseSend, SparkRepo.payInvoice / lightningSend / refuseUnverifiedRestoredInvoice / isUnsentPerOperators / hasRecordedSendSince, SparkExitDriver.tick / buildOnceFunded / build / holdingRedo / askForFunding, and SparkExitRecord.fundingShortfallSats.
Upstream checked: fetch_lightning_send_status in breez/spark-sdk at 0.28.3 (the version libs.versions.toml pins) returns Failed only when the preimage requests are non-empty, none has a preimage or PreimageShared, none is WaitingForPreimage, and none is Unknown (that one is an error, which isUnsentPerOperators treats as "can't be asked"). So FAILED really does mean every attempt at the hash was Returned, which is what the new KDoc says.
CI: build-and-test, build-local, lint and Greptile green; the e2e-tests-local shards and compose-ui were still running when I posted.
Ruled out
- Spark refusal leaves the rail record wrong: the throw happens inside
authorizeSendwithisRefused = trueandisAdmitted = false, soonFailureleavessendRailsalone and thefinallydoes not release a hold it never took. - A sequential retry after a failed Spark send is now refused:
sparkRecordsBeforeis read at the start of the retry, after the first attempt was recorded, sohasRecordedSendSincestays false; only a send recorded after the checks refuses it. - Overlap already covered by
sendsInFlight: that guard closes only whilesparkService.sendruns. A second send whose checks passed before the first was recorded and whose submission comes after the first returned slips past it; the newhasRecordedSendSinceterm in the Spark admission closes that window, and the held-by-Spark term closes the window beforeputIfAbsent. - Held Redo build stuck in Running:
isRebuildingstays true andlastBuildAtis set, so the next tick takes theRunning if record.isRebuildingbranch and rebuilds atREBUILD_INTERVAL; a later build that comes up short goes throughaskForFundingand shows NeedsFunding again. - FAILED opening a Spark-address invoice: with
prefersSparkon, an invoice carrying the Spark address hint is still refused after FAILED, since a direct transfer is invisible to the operators. That is narrower than the description's wording, but it is the safe side.
Merge confidence: 4/5, no findings and each fix has a test, but the e2e shards were still running and the branch was reviewed without a local build.
Reviewer model: claude-opus-5-5
Reasoning effort: 15 (runtime setting of this run)
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews, nothing blocking a merge.
worth doing, does not block
- Funding notification outlives a Redo hold that turns Running on a later tick (app/src/main/java/to/bitkit/repositories/SparkExitWorker.kt:397-399). The PR drops the fee ask on screen and in App Status, but on some paths the posted
SparkExitAlert.Fundingnotification stays up after the exit moves to Running. The notification is only withdrawn inSparkExitRepo.updateAlerts, throughSparkExitAlerts.isFundingAskWithdrawn(SparkExitWorker.kt:397-399). That check needsprevious.isUnverifiedAsk.driveWhileFundingclearsisUnverifiedAskon the Redo tick (SparkExitDriver.kt:551), so the withdrawal fires only when the held build runs in that same tick (buildOnceFundedreachesbuildwhenisRebuildDue). The newisBuilthold can instead move the exit to Running on a later tick. That happens in three cases: - the Redo tick finds the rebuild not due, withinREBUILD_INTERVALof the last build; - the Redo tick's prepare is empty, so the hold keepsNeedsFunding; - the Redo tick's first build comes up short. Thenprevious.isUnverifiedAskis already false, and a notification asking for the top-up stays in the shade while the screen shows Running. This predates the branch: the old hold-end adoption made the sameNeedsFundingto Running move. The PR improves the common same-tick case. I found this by reading the code; I did not reproduce it in a test. A small fix would treatprevious.phase is NeedsFunding && previous.isRedoRebuild && record.phase == Runningwith no new funding as a withdrawn ask. Another would keep a flag for the ask through the Redo. - Settled competing sends can leave the refused caller pending (app/src/main/java/to/bitkit/repositories/LightningRepo.kt:1538-1543)
nits
- New redo-hold test never passes held funding to recover (app/src/test/java/to/bitkit/repositories/SparkExitDriverTest.kt:1906-1925)
|
Merging: CI is green, @coreyphillips approved this head and every thread is answered. His non-blocking points go in a follow-up PR: #1899 (the funding notification after a Redo turns Running, plus the hold tests) and #1900 (a refused overlapping send stays pending). |
Description
Fixes three Spark points deferred from #1892 and #1893:
seedRestoredSendHashesKDoc and the new log line are updated to match.No changelog fragment: these change Spark behaviour that hasn't shipped in a release yet.
QA Notes
SparkExitDriverTest: a redo hold built from the held funding drops the fee ask the top-up was forLightningRepoTest: of two overlapping spark sends of one invoice only one reaches spark; a spark send of an invoice spark recorded since its checks is refused at submissionSparkRepoTest: a pre-restore invoice retries on both rails after its spark send failed (replaces the test that expected a refusal)