multi: link quit can interrupt commitment signing

In this commit, we make sig job handling when singing a next commitment
non-blocking by allowing the shutdown of a channel link to prevent
further waiting on sig jobs by the channel state machine. This addresses
possible cases where the aux signer may be shut down via a separate quit
signal, so the state machine could block indefinitely on receiving an
update on a sig job.
This commit is contained in:
Jonathan Harvey-Buschel
2024-10-17 13:38:34 +02:00
committed by Oliver Gugger
parent 6edd942c70
commit 77ae7afe78
9 changed files with 256 additions and 177 deletions

View File

@@ -2,6 +2,7 @@ package contractcourt
import (
"bytes"
"context"
"crypto/sha256"
"fmt"
"testing"
@@ -145,17 +146,15 @@ func TestChainWatcherRemoteUnilateralClosePendingCommit(t *testing.T) {
// With the HTLC added, we'll now manually initiate a state transition
// from Alice to Bob.
_, err = aliceChannel.SignNextCommitment()
if err != nil {
t.Fatal(err)
}
testQuit, testQuitFunc := context.WithCancel(context.Background())
t.Cleanup(testQuitFunc)
_, err = aliceChannel.SignNextCommitment(testQuit)
require.NoError(t, err)
// At this point, we'll now Bob broadcasting this new pending unrevoked
// commitment.
bobPendingCommit, err := aliceChannel.State().RemoteCommitChainTip()
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
// We'll craft a fake spend notification with Bob's actual commitment.
// The chain watcher should be able to detect that this is a pending