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.
This commit is contained in:
Wilmer Paulino 2018-08-27 14:40:47 -07:00
parent 73af09a06a
commit a1b1b06b9e
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -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
}