htlcswitch: add new LinkFailureDisconnect action

In this commit, we add a new LinkFailureDisconnect action that'll be
used if we detect that the remote party hasn't sent a revoke and ack
when it actually should.

Before this commit, we would log our action, tear down the link, but
then not actually force a connection recycle, as we assumed that if the
TCP connection was actually stale, then the read/write timeout would
expire.

In practice this doesn't always seem to be the case, so we make a strong
action here to actually force a disconnection in hopes that either side
will reconnect and keep the good times rollin' 🕺.
This commit is contained in:
Olaoluwa Osuntokun committed 2023-05-23 12:25:11 -07:00
1 parent cb5fc71659
commit 4d633f04e3
5 files changed
+40 -12

No files matched your search

+8 -6
View File
@@ -5457,7 +5457,8 @@ func TestChannelLinkFail(t *testing.T) {
// If we expect the link to force close the channel in this
// case, check that it happens. If not, make sure it does not
// happen.
isForceCloseErr := (linkErr.FailureAction == LinkFailureForceClose)
isForceCloseErr := (linkErr.FailureAction ==
LinkFailureForceClose)
require.True(
t, test.shouldForceClose == isForceCloseErr, test.name,
)
@@ -6343,11 +6344,12 @@ func TestPendingCommitTicker(t *testing.T) {
// Assert that we get the expected link failure from Alice.
select {
case linkErr := <-linkErrs:
if linkErr.code != ErrRemoteUnresponsive {
t.Fatalf("error code mismatch, "+
"want: ErrRemoteUnresponsive, got: %v",
linkErr.code)
}
require.Equal(
t, linkErr.code, ErrRemoteUnresponsive,
fmt.Sprintf("error code mismatch, want: "+
"ErrRemoteUnresponsive, got: %v", linkErr.code),
)
require.Equal(t, linkErr.FailureAction, LinkFailureDisconnect)
case <-time.After(time.Second):
t.Fatalf("did not receive failure")