Repository navigation
Forward channel closures and failed opens to the LSPS2 service - #1233
Conversation
|
👋 Thanks for assigning @jkczyz as a reviewer! |
049f1a4 to
3a3dafb
Compare
| ); | ||
| } | ||
|
|
||
| if let Err(e) = lsps2_service_handler.channel_closed(channel_id).await { |
There was a problem hiding this comment.
🤖 lightning-liquidity's channel_closed only prunes JIT channels in PaymentForwarded. A JIT channel that closes after channel_ready but before the payment is forwarded (PendingPaymentForward / PendingPayment) is still never pruned, and channel_open_failed rejects it too. Is that intended, or a follow-up upstream?
There was a problem hiding this comment.
We have related PRs open:
- LSPS2: fail back held HTLCs when JIT channel state is dropped or can't complete:
https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/5441 - Time out withheld LSPS2 JIT channels and discard their funding: https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/5582
- Add APIs to prune completed state for LSPS1/LSPS2/LSPS5: https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/4526
|
🤖 Two interactions with #999 (same merge base) worth coordinating:
A related nuance: the retry these tests demonstrate is BOLT11-only. A BOLT12 payer can't re-send a JIT invoice — the failure is recorded against the invoice's single blinded path, and a new send requests a new invoice — so with #999 the reset SCID is orphaned and keeps counting toward |
That just says we need to rebase and resolve conflicts after either PR lands, no? |
73461fa to
a9629d3
Compare
There won't be a merge conflict if #999 lands first, but there will be a compilation error since it removes an argument from |
de6e3dd to
23ef5c7
Compare
Rebased and addressed silent merge conflicts after #999 landed. Also took the liberty of squashing fixups. |
|
Needs another rebase. |
|
🤖 This now conflicts with #1204. The conflict itself is just the
Both should fail the open like the existing insufficient-funds check does. Otherwise the HTLCs are held again on those paths. |
|
Field data point from our mainnet LSP (LSPS2 service on ldk-node e0b01fa plus a few local patches, none on this path): on 2026-11-15 a 110,000-sat JIT payment was intercepted at 20:52:00Z and the open failed 56 ms later with "peer not being not connected"; the receiving phone had created the invoice about 3 min earlier and was no longer connected. With no |
`lightning-liquidity` requires `Event::ChannelClosed` to be forwarded to the LSPS2 service handler, which we never did. The service hence kept the state of every JIT channel that ever got paid for, and with it the persisted state of the respective client, forever. That state also counts towards the service's global peer limit. We now hand closed channels to the LSPS2 service, allowing it to prune the state of JIT channels that are gone. Co-Authored-By: HAL 9000
When we couldn't open a JIT channel as an LSPS2 service, or when the channel closed before becoming ready, we never told `lightning-liquidity` about it. The intercepted HTLCs were therefore held until they timed out, and as the JIT channel state stayed stuck waiting for the channel, no later payment to the same invoice could trigger another attempt. We now report failed channel opens to the LSPS2 service, which fails the held HTLCs back right away and lets the payer retry. Co-Authored-By: HAL 9000
The log message for a failed JIT channel open to a disconnected peer read "not being not connected". Reword it to say that the peer is not connected. Co-Authored-By: HAL 9000
23ef5c7 to
d0897a3
Compare
Rebased, addressed conflicts. |
lightning-liquidityexpects LSPS2 services to forwardEvent::ChannelClosedand to report failed JIT channel opens. We did neither:
the state of every client that ever paid for a channel. That state also
counts towards the service's global peer limit.
timed out, and the JIT state stayed stuck waiting for the channel, so
retrying the same invoice could never trigger another open.
This PR fixes both, one commit each:
ChannelClosedtoLSPS2ServiceHandler::channel_closed.LSPS2ServiceHandler::channel_open_failedwhen we can't open thechannel (peer not connected, insufficient on-chain funds,
create_channelfailing) and when the channel closes before becoming ready. The held HTLCs
are failed back right away and the payer can retry.