Repository navigation
Conversation
`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
|
👋 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? |
Failing the payment back when the client isn't connected was only covered for the insufficient-funds case, leaving the disconnected-peer path untested. Add an integration test that pays a JIT invoice while the client is offline, expects the payment to fail, and checks that a retry succeeds once the client is back. Co-Authored-By: HAL 9000
We told the LSPS2 service about a closed channel before queueing the `ChannelClosed` event. If queueing failed, the event was replayed and the failed channel open reported a second time, which would fail the HTLCs of a payment the payer retried in the meantime. Tell the LSPS2 service only once the event was queued, so that it hears of each closure once. 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
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 |
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.