discovery: add missing error channel sends in processNetworkAnnouncement
Without the error channel sends, we would block the gossip message stream upon receiving a premature channel announcement.
This commit is contained in:
parent
b1309277b9
commit
e713205eea
@ -1612,8 +1612,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the advertised inclusionary block is beyond our knowledge
|
// If the advertised inclusionary block is beyond our knowledge
|
||||||
// of the chain tip, then we'll put the announcement in limbo
|
// of the chain tip, then we'll ignore for it now.
|
||||||
// to be fully verified once we advance forward in the chain.
|
|
||||||
d.Lock()
|
d.Lock()
|
||||||
if nMsg.isRemote && isPremature(msg.ShortChannelID, 0) {
|
if nMsg.isRemote && isPremature(msg.ShortChannelID, 0) {
|
||||||
log.Infof("Announcement for chan_id=(%v), is "+
|
log.Infof("Announcement for chan_id=(%v), is "+
|
||||||
@ -1623,6 +1622,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
msg.ShortChannelID.BlockHeight,
|
msg.ShortChannelID.BlockHeight,
|
||||||
d.bestHeight)
|
d.bestHeight)
|
||||||
d.Unlock()
|
d.Unlock()
|
||||||
|
nMsg.err <- nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
d.Unlock()
|
d.Unlock()
|
||||||
@ -2132,16 +2132,14 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
|
|||||||
// By the specification, channel announcement proofs should be
|
// By the specification, channel announcement proofs should be
|
||||||
// sent after some number of confirmations after channel was
|
// sent after some number of confirmations after channel was
|
||||||
// registered in bitcoin blockchain. Therefore, we check if the
|
// registered in bitcoin blockchain. Therefore, we check if the
|
||||||
// proof is premature. If so we'll halt processing until the
|
// proof is premature.
|
||||||
// expected announcement height. This allows us to be tolerant
|
|
||||||
// to other clients if this constraint was changed.
|
|
||||||
d.Lock()
|
d.Lock()
|
||||||
if isPremature(msg.ShortChannelID, d.cfg.ProofMatureDelta) {
|
if isPremature(msg.ShortChannelID, d.cfg.ProofMatureDelta) {
|
||||||
log.Infof("Premature proof announcement, "+
|
log.Infof("Premature proof announcement, current "+
|
||||||
"current block height lower than needed: %v <"+
|
"block height lower than needed: %v < %v",
|
||||||
" %v, add announcement to reprocessing batch",
|
|
||||||
d.bestHeight, needBlockHeight)
|
d.bestHeight, needBlockHeight)
|
||||||
d.Unlock()
|
d.Unlock()
|
||||||
|
nMsg.err <- nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
d.Unlock()
|
d.Unlock()
|
||||||
|
@ -897,9 +897,8 @@ func TestProcessAnnouncement(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPrematureAnnouncement checks that premature announcements are
|
// TestPrematureAnnouncement checks that premature announcements are not
|
||||||
// not propagated to the router subsystem until block with according
|
// propagated to the router subsystem.
|
||||||
// block height received.
|
|
||||||
func TestPrematureAnnouncement(t *testing.T) {
|
func TestPrematureAnnouncement(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -920,8 +919,8 @@ func TestPrematureAnnouncement(t *testing.T) {
|
|||||||
|
|
||||||
// Pretending that we receive the valid channel announcement from
|
// Pretending that we receive the valid channel announcement from
|
||||||
// remote side, but block height of this announcement is greater than
|
// remote side, but block height of this announcement is greater than
|
||||||
// highest know to us, for that reason it should be added to the
|
// highest know to us, for that reason it should be ignored and not
|
||||||
// repeat/premature batch.
|
// added to the router.
|
||||||
ca, err := createRemoteChannelAnnouncement(1)
|
ca, err := createRemoteChannelAnnouncement(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't create channel announcement: %v", err)
|
t.Fatalf("can't create channel announcement: %v", err)
|
||||||
@ -929,31 +928,13 @@ func TestPrematureAnnouncement(t *testing.T) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.gossiper.ProcessRemoteAnnouncement(ca, nodePeer):
|
case <-ctx.gossiper.ProcessRemoteAnnouncement(ca, nodePeer):
|
||||||
t.Fatal("announcement was proceeded")
|
case <-time.After(time.Second):
|
||||||
case <-time.After(100 * time.Millisecond):
|
t.Fatal("announcement was not processed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ctx.router.infos) != 0 {
|
if len(ctx.router.infos) != 0 {
|
||||||
t.Fatal("edge was added to router")
|
t.Fatal("edge was added to router")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pretending that we receive the valid channel update announcement from
|
|
||||||
// remote side, but block height of this announcement is greater than
|
|
||||||
// highest known to us, so it should be rejected.
|
|
||||||
ua, err := createUpdateAnnouncement(1, 0, remoteKeyPriv1, timestamp)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("can't create update announcement: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-ctx.gossiper.ProcessRemoteAnnouncement(ua, nodePeer):
|
|
||||||
t.Fatal("announcement was proceeded")
|
|
||||||
case <-time.After(100 * time.Millisecond):
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ctx.router.edges) != 0 {
|
|
||||||
t.Fatal("edge update was added to router")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestSignatureAnnouncementLocalFirst ensures that the AuthenticatedGossiper
|
// TestSignatureAnnouncementLocalFirst ensures that the AuthenticatedGossiper
|
||||||
|
Loading…
Reference in New Issue
Block a user