Open yyforyongyu opened 1 year ago
When updating an invoice state, we'd mark it as settled before the HTLC is locked in first, resulting in a possible edge case that although an invoice is marked as settled, the HTLC is timed out.
https://github.com/lightningnetwork/lnd/blob/d3211822207afd28a9340b015938371340ba2ec9/htlcswitch/link.go#L3285-L3307
NotifyExitHopHtlc
notifyExitHopHtlcLocked
return l.processHtlcResolution(event, htlc)
With the final settle signal introduced here this issue is mitigated with extra data, but this still needs a proper fix.
Remove the following sleep in testExternalFundingChanPoint and run the itest,
testExternalFundingChanPoint
https://github.com/lightningnetwork/lnd/blob/d3211822207afd28a9340b015938371340ba2ec9/itest/lnd_funding_test.go#L558-L569
When the invoice is reported as settled, the commitment dance should be finished.
PendingSettle
Settled
An alternative name for a new PendingSettle state could be SettleRequested.
SettleRequested
Background
When updating an invoice state, we'd mark it as settled before the HTLC is locked in first, resulting in a possible edge case that although an invoice is marked as settled, the HTLC is timed out.
https://github.com/lightningnetwork/lnd/blob/d3211822207afd28a9340b015938371340ba2ec9/htlcswitch/link.go#L3285-L3307
NotifyExitHopHtlc
, which callsnotifyExitHopHtlcLocked
.return l.processHtlcResolution(event, htlc)
.With the final settle signal introduced here this issue is mitigated with extra data, but this still needs a proper fix.
Steps to reproduce
Remove the following sleep in
testExternalFundingChanPoint
and run the itest,https://github.com/lightningnetwork/lnd/blob/d3211822207afd28a9340b015938371340ba2ec9/itest/lnd_funding_test.go#L558-L569
Expected behavior
When the invoice is reported as settled, the commitment dance should be finished.
Possible Solutions
PendingSettle
to the invoice and replace it with the currentSettled
state. Then we only mark it as settled AFTER the HTLC lock-in.