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

watchtower: handle rogue updates #7981

Merged
merged 8 commits into from
Sep 18, 2023

Conversation

ellemouton
Copy link
Collaborator

With this PR, we take introduce the concept of a "Rogue Update". A rogue update is an update of a channel that has already been closed. With this PR, if we go to Ack an update and discover that it is rogue, we will just keep count of the number of rogue updates that the session has backed-up.

In the first few commits, the testing infrastructure of the tower client is changed to only use the bbolt implementation instead of a mock implementation of the DB. This is so that the DB code can be tested properly.

Fixes #7980

The watchtower client test framework currently uses a mock version of
the tower client DB. This can lead to bugs if the mock DB works slightly
differently to the actual bbolt DB. So this commit ensures that we only
use the bbolt db for the tower client tests. We also increment the
`waitTime` used in the tests a bit to account for the slightly longer DB
read and write times. Doing this switch resulted in one bug being
caught: we were not removing sessions from the in-memory set on deletion
of the session and so that is fixed here too.
Remove the use of the mock tower client DB and use the actual bbolt DB
everywhere instead.
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 nice PR ✨

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

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

Very clean PR! Mostly questions🙏

watchtower/wtclient/client_test.go Show resolved Hide resolved
watchtower/wtclient/client_test.go Outdated Show resolved Hide resolved
watchtower/wtclient/client_test.go Show resolved Hide resolved
watchtower/wtdb/client_db.go Outdated Show resolved Hide resolved
watchtower/wtdb/client_db.go Show resolved Hide resolved
watchtower/wtdb/client_db_test.go Show resolved Hide resolved
This commit adds a new test to the tower client to demonstrate a bug
that can happen if a channel is closed while an update for it has yet to
be acked by the tower server. This will be fixed in an upcomming commit.
A pure refactor commit that passes the required buckets to the
`getRangesWriteBucket` instead of re-fetching them.
In this commit, we introduce the concept of a rogue update. An update is
rogue if we need to ACK it but we have already deleted all the data for
the associated channel due to the channel being closed. In this case, we
now no longer error out and instead keep count of how many rogue updates
a session has backed-up.
Copy link
Collaborator Author

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Thanks @yyforyongyu !

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

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM🏖

@Roasbeef Roasbeef merged commit 9f4a883 into lightningnetwork:master Sep 18, 2023
24 of 25 checks passed
@saubyk saubyk modified the milestones: v0.17.1, v0.17.0 Sep 18, 2023
@ellemouton ellemouton deleted the handleRogueUpdates branch September 19, 2023 11:19
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.

[bug]: watchtowers: need to correctly handle acked updates for closed channels
5 participants