Skip to content

LSPS5 Follow ups #3944

Closed
Closed

Description

@martinsaposnic

PR #3662 got too big, so a few small fixes will come in follow up PRs once the base PR is merged

Fixes coming in a follow up:

With PR:

Activity

  1. TheBlueMatt commented on Jul 24, 2025

    @TheBlueMatt
    Collaborator

    Also a few more #3662 (review)

  2. martinsaposnic commented on Jul 29, 2025

    @martinsaposnic
    ContributorAuthor

    I found a tiny implementation bug

    From the spec: https://github.com/lightning/blips/pull/55/files#diff-0446c6230ffe4cf26243c752fedea2998f61da34f7e3230e3dcbc9da872423e6R618

    LSP: Rate-limiting Notifications By method

    An LSP implementation must avoid sending multiple LSPS5 notifications of the same method (other than
    lsps5.webhook_registered) close in time, as long as the client has not connected to it.
    For example, if a payment arrives and the LSP thus wants to send lsps5.payment_incoming notification to a registered webhook, and another payment arrives before the client comes online, the LSP must not send another lsps5.payment_incoming notification.
    If the client does not come online after some time that a particular method was sent via a webhook, then the LSP may raise it again. This timeout must be measurable in hours or days.
    The timeout should be reset once the client comes online and then goes offline.

    I misunderstood this and implemented a notification_cooldown_hours (with a 24 hours default) that prevents the service from sending the same notification method for 24 hours, which is completely ridiculous (sorry 🙃 ). Relevant code https://github.com/lightningdevkit/rust-lightning/blob/main/lightning-liquidity/src/lsps5/service.rs#L397

    That logic is completely wrong and needs to go, but for implementing the spec correctly, I think we would need to expose a new public function client_connected on the service so it can be notified that the app went back online so it can reset the timeout. do we have any other alternatives? what do you think @tnull ?

  3. tnull commented on Jul 30, 2025

    @tnull
    Contributor

    I found a tiny implementation bug

    From the spec: https://github.com/lightning/blips/pull/55/files#diff-0446c6230ffe4cf26243c752fedea2998f61da34f7e3230e3dcbc9da872423e6R618

    LSP: Rate-limiting Notifications By method

    An LSP implementation must avoid sending multiple LSPS5 notifications of the same method (other than
    lsps5.webhook_registered) close in time, as long as the client has not connected to it.
    For example, if a payment arrives and the LSP thus wants to send lsps5.payment_incoming notification to a registered webhook, and another payment arrives before the client comes online, the LSP must not send another lsps5.payment_incoming notification.
    If the client does not come online after some time that a particular method was sent via a webhook, then the LSP may raise it again. This timeout must be measurable in hours or days.
    The timeout should be reset once the client comes online and then goes offline.

    I misunderstood this and implemented a notification_cooldown_hours (with a 24 hours default) that prevents the service from sending the same notification method for 24 hours, which is completely ridiculous (sorry 🙃 ). Relevant code https://github.com/lightningdevkit/rust-lightning/blob/main/lightning-liquidity/src/lsps5/service.rs#L397

    That logic is completely wrong and needs to go, but for implementing the spec correctly,

    Huh, I don't think that logic is 'completely wrong', we just need to reset the cooldown once the client connects, right? Thanks for catching it though!

    I think we would need to expose a new public function client_connected on the service so it can be notified that the app went back online so it can reset the timeout. do we have any other alternatives? what do you think @tnull ?

    No, let's just have a pub(crate) fn peer_connected(..) on the LSPS5 service and have it called by LiquidityManager::peer_connected.

    FWIW, we could also consider reducing the cooldown to an hour or a few hours. I think it is only meant to ensure that the LSP doen't bombard the client with unnecessary notifications.

  4. TheBlueMatt commented on Aug 5, 2025

    @TheBlueMatt
    Collaborator
  5. tnull commented on Aug 7, 2025

    @tnull
    Contributor

    IMO a minute or five would be much more appropriate than an hour - https://github.com/lightningdevkit/rust-lightning/pull/3975/files#r2254509585

    Also https://github.com/lightningdevkit/rust-lightning/pull/3975/files#r2254524535

    Seem my responses there: for the former we might need to amend the spec. The latter I'll see to pickup as part of the persistence work, for which I'll probably introduce a per-peer state anyways (was just waiting so far for the conflicting LSPS5 PRs to land).

  6. tnull commented on Sep 4, 2025

    @tnull
    Contributor

    Seems all open points have been addressed, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions