watchtower: account for rogue updates

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.
This commit is contained in:
Elle Mouton
2023-09-13 13:11:00 +02:00
parent c33cd0ea38
commit 2a9339805e
3 changed files with 271 additions and 26 deletions

View File

@@ -2417,14 +2417,10 @@ var clientTests = []clientTest{
},
},
{
// This test demonstrates a bug that will be addressed in a
// follow-up commit. It shows that if a channel is closed while
// an update for that channel still exists in an in-memory queue
// somewhere then it is possible that all the data for that
// channel gets deleted from the tower client DB. This results
// in an error being thrown in the DB AckUpdate method since it
// will try to find the associated channel data but will not
// find it.
// This test shows that if a channel is closed while an update
// for that channel still exists in an in-memory queue
// somewhere then it is handled correctly by treating it as a
// rogue update.
name: "channel closed while update is un-acked",
cfg: harnessCfg{
localBalance: localBalance,
@@ -2532,7 +2528,7 @@ var clientTests = []clientTest{
require.NoError(h.t, err)
// Show that the committed update for the closed channel
// remains in the client's DB.
// is cleared from the DB.
err = wait.Predicate(func() bool {
sessions, err := h.clientDB.ListClientSessions(
nil,
@@ -2545,11 +2541,11 @@ var clientTests = []clientTest{
require.NoError(h.t, err)
if len(updates) != 0 {
return true
return false
}
}
return false
return true
}, waitTime)
require.NoError(h.t, err)
},