Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronously clean up obsolete HTLC info from DB #2705

Merged
merged 5 commits into from
Feb 14, 2024

Commits on Jan 18, 2024

  1. Asynchronously clean up obsolete HTLC info from DB

    When a channel is closed, we can forget the data from historical HTLCs
    sent and received through that channel (which is otherwise required to
    punish cheating attempts by our peer).
    
    We previously synchronously removed that data from the DB when the closing
    transaction confirmed. However, this could create performance issues as
    the `htlc_infos` table can be very large for busy nodes and many concurrent
    writes may be happening at the same time.
    
    We don't need to get rid of this data immediately: we only want to remove
    it to avoid degrading the performance of active channels that read and
    write to the `htlc_infos` table. We now mark channels as closed in a
    dedicated table, and run a background actor that deletes batches of
    obsolete htlc data at regular intervals. This ensures that the table is
    eventually cleaned up, without impacting the performance of active
    channels.
    
    Fixes #2610 and #2702
    t-bast committed Jan 18, 2024
    Configuration menu
    Copy the full SHA
    01be7b4 View commit details
    Browse the repository at this point in the history
  2. Asynchronously clean up obsolete HTLC info after splice

    When a splice transaction confirms, all the revoked commitment transactions
    that only applied to the previous funding transaction cannot be published
    anymore, because the previous funding output has already been spent.
    
    We can thus forget all the historical HTLCs that were included in those
    commitments, because we will never need to generate the corresponding
    penalty transactions.
    
    This ensures that the growth of our DB is bounded, and will shrink every
    time a splice transaction is confirmed.
    
    Fixes #2740
    t-bast committed Jan 18, 2024
    Configuration menu
    Copy the full SHA
    ed12d7b View commit details
    Browse the repository at this point in the history
  3. Fix PR comments

    - use `forgetHtlcInfo` to avoid code duplication
    - test exact number of DB entries cleaned up
    - use commitment index mismatch in splice test
    t-bast committed Jan 18, 2024
    Configuration menu
    Copy the full SHA
    d5f4e5d View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2024

  1. Move firstRemoteCommitIndex to Commitment

    While it requires more duplication in the codecs, because we didn't
    version the commitments codec, it is cleaner to have this filed in
    the commitment instead of having it in the funding status.
    t-bast committed Feb 14, 2024
    Configuration menu
    Copy the full SHA
    bc07548 View commit details
    Browse the repository at this point in the history
  2. Small refactoring

    t-bast committed Feb 14, 2024
    Configuration menu
    Copy the full SHA
    ce50751 View commit details
    Browse the repository at this point in the history