From eb4413154d219766a8a7a4d94b60abe229c9d6bc Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 29 Apr 2021 15:45:06 -0700 Subject: [PATCH] routing: return err on validation failure of network update This ensures the waiting receiving channel always receives an error to prevent a deadlock when processing a network update that fails due to the validation barrier. On commit d5aedbcbd9db510c974c9f7be5ab177ad6546994: 1000 @ 0x43a285 0x44a38f 0xc42e86 0xc80fda 0xc8682d 0xc976c9 0x46fce1 github.com/lightningnetwork/lnd/routing.(*ChannelRouter).AddNode+0x245 github.com/lightningnetwork/lnd/routing/router.go:2218 github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).addNode+0x3b9 github.com/lightningnetwork/lnd/discovery/gossiper.go:1510 github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).processNetworkAnnouncement+0x574c github.com/lightningnetwork/lnd/discovery/gossiper.go:1554 github.com/lightningnetwork/lnd/discovery.(*AuthenticatedGossiper).networkHandler.func1+0x24github.com/lightningnetwork/lnd/discovery/gossiper.go:1043 --- routing/router.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/routing/router.go b/routing/router.go index 20f7ee0c..a609bff3 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1038,12 +1038,19 @@ func (r *ChannelRouter) networkHandler() { update.msg, ) if err != nil { - if err != ErrVBarrierShuttingDown && - err != ErrParentValidationFailed { + switch err { + case ErrVBarrierShuttingDown: + update.err <- err + case ErrParentValidationFailed: + update.err <- newErrf( + ErrIgnored, err.Error(), + ) + default: log.Warnf("unexpected error "+ "during validation "+ "barrier shutdown: %v", err) + update.err <- err } return }