From a1b1b06b9ea7627b0a7d733c16b59a3518abb4bd Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Mon, 27 Aug 2018 14:40:47 -0700 Subject: [PATCH] discovery/gossiper: remove optimistic channel announcement request In this commit, we aim to resolve an issue with nodes requesting for channel announcements when receiving a channel update for a channel they're not aware of. This can happen if a node is not caught up with the chain or if they receive updates for zombie channels. This would lead to a spam issue, as if a node is not caught up with the chain, every new update they receive is premature, causing them to manually request the backing channel announcement. Ideally, we should be able to detect this as a potential DoS vector and ban the node responsible, but for now we'll simply remove this functionality. --- discovery/gossiper.go | 47 ------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index a698d60d3..5f3b89273 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1983,23 +1983,6 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement( "saving for reprocessing later", shortChanID) - // If the node supports it, we may try to - // request the chan ann from it. - d.wg.Add(1) - go func() { - defer d.wg.Done() - - reqErr := d.maybeRequestChanAnn( - msg.ShortChannelID, - ) - if reqErr != nil { - log.Errorf("unable to request "+ - "ann for chan_id=%v: "+ - "%v", shortChanID, - reqErr) - } - }() - // NOTE: We don't return anything on the error // channel for this message, as we expect that // will be done when this ChannelUpdate is @@ -2598,33 +2581,3 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo, return chanAnn, chanUpdate, err } - -// maybeRequestChanAnn will attempt to request the full channel announcement -// for a particular short chan ID. We do this in the case that we get a channel -// update, yet don't already have a channel announcement for it. -func (d *AuthenticatedGossiper) maybeRequestChanAnn( - cid lnwire.ShortChannelID) error { - - d.syncerMtx.Lock() - defer d.syncerMtx.Unlock() - - for nodeID, syncer := range d.peerSyncers { - // If this syncer is already at the terminal state, then we'll - // chose it to request the fully channel update. - if syncer.SyncState() == chansSynced { - log.Debugf("attempting to request chan ann for "+ - "chan_id=%v from node=%x", cid, nodeID[:]) - - return syncer.cfg.sendToPeer(&lnwire.QueryShortChanIDs{ - ChainHash: d.cfg.ChainHash, - EncodingType: lnwire.EncodingSortedPlain, - ShortChanIDs: []lnwire.ShortChannelID{cid}, - }) - } - } - - log.Debugf("unable to find peer to request chan ann for chan_id=%v "+ - "from", cid) - - return nil -}