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

wtclient: handle un-acked updates for exhausted sessions #8233

Merged
merged 4 commits into from
Jan 12, 2024

Conversation

ellemouton
Copy link
Collaborator

This PR addresses an edge case that could lead to the "tower has un-acked updates" error
when a user tries to remove a tower. See the issue here.

The Issue:

Currently, if you call "remove tower", then only sessions from that tower that are loaded into memory on
startup are terminated correctly. And we only load in sessions where session.SeqNum < session.policy.MaxUpdates.
So the issue occurs when the session is technically exhausted but there is still an un-acked update on disk.
This means that we would not terminate such a session properly on tower removal and so would run into "tower has un-acked updates".

The Solution:

So with this PR, we make sure to load a session into memory if there are still un-acked updates that it needs to deal with.

Flow of the PR:

  1. First, the bug is demonstrated through a test.
  2. Then, we extend the session fetching filter function to also count the number of un-acked updates so that we can decide to load the session if there are un-acked updates.
  3. The test is then adjusted to show that the bug has been fixed

Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, super clean and readable change! Very very nice! ✨

watchtower/wtclient/client_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find and fix 🚀. I only have a question regarding the CountCommittedUpdates bool

watchtower/wtdb/client_db.go Outdated Show resolved Hide resolved
This commit adds a test to demonstrate an edge case that can result in
the "tower has un-acked updates" error being thrown when a user is
attempting to remove a tower. This will be fixed in an upcoming commit.
@ellemouton
Copy link
Collaborator Author

@bhandras - gonna re-request since i've updated as per @bitromortac's comment about not needing the boolean option 🙏

@ellemouton ellemouton requested a review from bhandras January 11, 2024 13:24
Copy link
Collaborator

@bitromortac bitromortac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ⚡, very nice!

watchtower/wtdb/client_db.go Outdated Show resolved Hide resolved
watchtower/wtclient/client_test.go Show resolved Hide resolved
Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR after minor cleanup still LGTM 🌊

In this commit, we adjust the PostEvaluateFilterFn to also take in a
count representing the number of committed updates (ie, persisted
un-acked updates) that the session has. This will be made use of in an
upcoming commit.
In this commit, we use the newly added session listing options to ensure
that we only see a session as exhausted if it does not have any un-acked
updates on disk. This fixes the bug previously demonstrated.
@ellemouton ellemouton merged commit 2824fe2 into lightningnetwork:master Jan 12, 2024
24 of 25 checks passed
@ellemouton ellemouton deleted the unackedUpdatesBug branch January 12, 2024 07:49
@saubyk saubyk added this to the v0.18.0 milestone Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants