rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

LSPS2 service event handling isn't idempotent

Open TheBlueMatt opened this issue 1 month ago • 4 comments

Event handlers in LDK are expected to always be idempotent, but LSPS2 service doesn't appear to be. eg once we get to PaymentQueue::add_htlc we debug_assert that an HTLC with the same intercept id isn't already present, but it definitely could be. There's probably other instances.

TheBlueMatt avatar Nov 05 '25 23:11 TheBlueMatt

Hmm, yeah, event replaying can be tricky. To handle this we probably need to error out when we detect a duplicate intercept SCID there, but to communicate this to the user we first need #4074.

tnull avatar Nov 06 '25 08:11 tnull

A duplicate event isn't an error, though, its an expected condition. An error there might imply that the dev should return an error in the event handler, which will result in an infinite loop. IMO we should return success on a replayed event.

TheBlueMatt avatar Nov 06 '25 12:11 TheBlueMatt

A duplicate event isn't an error, though, its an expected condition. An error there might imply that the dev should return an error in the event handler, which will result in an infinite loop. IMO we should return success on a replayed event.

Well, we just diverged from this model of 'just continue if expected' error handling with https://github.com/lightningdevkit/rust-lightning/pull/4160 . So now arguably you might expect a Duplicate error if there already is a corresponding entry.

tnull avatar Nov 06 '25 12:11 tnull

Oh, right, I forgot about that PR. Ugh, yea, maybe indeed.

TheBlueMatt avatar Nov 06 '25 12:11 TheBlueMatt