peer: always send channel update on reconnect

We have existing logic to attempt to reliably send a channel update to
the remote peer. In the wild, we've seen this fail, as it's possible
right when we send the update the peer disconnects.

In this commit, we implement a simple fix which is just to send the chan
update each time we connect to the remote party.

Fixes https://github.com/lightningnetwork/lnd/issues/6870.
This commit is contained in:
Olaoluwa Osuntokun
2024-07-31 18:03:57 -07:00
parent a449a5d132
commit 9acad37f57
4 changed files with 131 additions and 2 deletions

View File

@@ -341,6 +341,7 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
notifier: notifier,
publishTx: publishTx,
mockSwitch: mockSwitch,
mockConn: params.mockConn,
}, nil
}
@@ -493,10 +494,14 @@ func (m *mockMessageConn) Flush() (int, error) {
// the bytes sent into the mock's writtenMessages channel.
func (m *mockMessageConn) WriteMessage(msg []byte) error {
m.writeRaceDetectingCounter++
msgCopy := make([]byte, len(msg))
copy(msgCopy, msg)
select {
case m.writtenMessages <- msg:
case m.writtenMessages <- msgCopy:
case <-time.After(timeout):
m.t.Fatalf("timeout sending message: %v", msg)
m.t.Fatalf("timeout sending message: %v", msgCopy)
}
return nil
@@ -713,6 +718,11 @@ func createTestPeer(t *testing.T) *peerTestCtx {
return nil
},
PongBuf: make([]byte, lnwire.MaxPongBytes),
FetchLastChanUpdate: func(chanID lnwire.ShortChannelID,
) (*lnwire.ChannelUpdate, error) {
return &lnwire.ChannelUpdate{}, nil
},
}
alicePeer := NewBrontide(*cfg)