discovery: add panic recovery for serial announce signatures processing
In this commit, we extend the panic recovery mechanism to cover the serial processing path for AnnounceSignatures1 messages. Unlike other gossip messages which are processed in parallel goroutines, announcement signatures are processed serially in the main networkHandler loop. A panic during this serial processing would previously crash the entire gossiper. This change wraps the processing in an anonymous function with a deferred panic recovery, ensuring resilience without changing the serial processing semantics. Since AnnounceSignatures bypass the validation barrier, we pass nil for the jobID parameter.
This commit is contained in:
1 file changed
+26
-12
+26
-12
@@ -1521,19 +1521,33 @@ func (d *AuthenticatedGossiper) networkHandler(ctx context.Context) {
|
||||
// Channel announcement signatures are amongst the only
|
||||
// messages that we'll process serially.
|
||||
case *lnwire.AnnounceSignatures1:
|
||||
emittedAnnouncements, _ := d.processNetworkAnnouncement(
|
||||
ctx, announcement,
|
||||
)
|
||||
log.Debugf("Processed network message %s, "+
|
||||
"returned len(announcements)=%v",
|
||||
announcement.msg.MsgType(),
|
||||
len(emittedAnnouncements))
|
||||
|
||||
if emittedAnnouncements != nil {
|
||||
announcements.AddMsgs(
|
||||
emittedAnnouncements...,
|
||||
// Process in an anonymous function so we can
|
||||
// recover from any panics without crashing the
|
||||
// main networkHandler goroutine. We pass nil
|
||||
// for jobID since AnnounceSignatures bypass the
|
||||
// validation barrier.
|
||||
func() {
|
||||
defer d.finalizeGossipProcessing(
|
||||
ctx, "processing",
|
||||
announcement, nil,
|
||||
)
|
||||
}
|
||||
|
||||
//nolint:ll
|
||||
emittedAnnouncements, _ := d.processNetworkAnnouncement(
|
||||
ctx, announcement,
|
||||
)
|
||||
log.Debugf("Processed network "+
|
||||
"message %s, returned "+
|
||||
"len(announcements)=%v",
|
||||
announcement.msg.MsgType(),
|
||||
len(emittedAnnouncements))
|
||||
|
||||
if emittedAnnouncements != nil {
|
||||
announcements.AddMsgs(
|
||||
emittedAnnouncements...,
|
||||
)
|
||||
}
|
||||
}()
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user