From 7ff4a8b157498f9246efc7038faa0b2c687e02ed Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 13 Nov 2023 12:21:30 +0200 Subject: [PATCH] discovery: use correct channel ID for MarkEdgeLive In processZombieUpdate, the SCID passed to MarkEdgeLive should _not_ be derived from the ChannelEdgeInfo ChannelID field since this field will not be populated when GetChannelByID returns a ChannelEdgeInfo along with an ErrZombieEdge error. So this commit ensures that a usable SCID is provided to processZombieUpdate. --- discovery/gossiper.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index ce8eacdeb..17ef933e0 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -2022,8 +2022,12 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement( // processZombieUpdate determines whether the provided channel update should // resurrect a given zombie edge. +// +// NOTE: only the NodeKey1Bytes and NodeKey2Bytes members of the ChannelEdgeInfo +// should be inspected. func (d *AuthenticatedGossiper) processZombieUpdate( - chanInfo *models.ChannelEdgeInfo, msg *lnwire.ChannelUpdate) error { + chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID, + msg *lnwire.ChannelUpdate) error { // The least-significant bit in the flag on the channel update tells us // which edge is being updated. @@ -2031,7 +2035,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate( // Since we've deemed the update as not stale above, before marking it // live, we'll make sure it has been signed by the correct party. If we - // have both pubkeys, either party can resurect the channel. If we've + // have both pubkeys, either party can resurrect the channel. If we've // already marked this with the stricter, single-sided resurrection we // will only have the pubkey of the node with the oldest timestamp. var pubKey *btcec.PublicKey @@ -2055,8 +2059,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate( // With the signature valid, we'll proceed to mark the // edge as live and wait for the channel announcement to // come through again. - baseScid := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID) - err = d.cfg.Router.MarkEdgeLive(baseScid) + err = d.cfg.Router.MarkEdgeLive(scid) switch { case errors.Is(err, channeldb.ErrZombieEdgeNotFound): log.Errorf("edge with chan_id=%v was not found in the "+ @@ -2740,7 +2743,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg, break case channeldb.ErrZombieEdge: - err = d.processZombieUpdate(chanInfo, upd) + err = d.processZombieUpdate(chanInfo, graphScid, upd) if err != nil { log.Debug(err) nMsg.err <- err