Skip to content

Commit fc00572

Browse files
committed
discovery+graph: track job set dependencies in ValidationBarrier
Prior to this commit, it was rare, but possible that proper validation order was not adhered to when using the ValidationBarrier. This commit does two things that fix this: - removes the concept of allow / deny. Having this in place was a minor optimization and removing it makes the solution simpler. - changes the job dependency tracking to track sets of parent jobs rather than individual parent jobs. As a note, the purpose of the ValidationBarrier is that it allows us to launch gossip validation jobs in goroutines while still ensuring that the validation order of these goroutines is adhered to when it comes to validating ChannelAnnouncement _before_ ChannelUpdate and _before_ NodeAnnouncement.
1 parent b163b70 commit fc00572

File tree

2 files changed

+292
-120
lines changed

2 files changed

+292
-120
lines changed

discovery/gossiper.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,11 +1470,14 @@ func (d *AuthenticatedGossiper) networkHandler() {
14701470
// We'll set up any dependent, and wait until a free
14711471
// slot for this job opens up, this allow us to not
14721472
// have thousands of goroutines active.
1473-
validationBarrier.InitJobDependencies(announcement.msg)
1473+
annJobID := validationBarrier.InitJobDependencies(
1474+
announcement.msg,
1475+
)
14741476

14751477
d.wg.Add(1)
14761478
go d.handleNetworkMessages(
1477-
announcement, &announcements, validationBarrier,
1479+
announcement, &announcements,
1480+
validationBarrier, annJobID,
14781481
)
14791482

14801483
// The trickle timer has ticked, which indicates we should
@@ -1525,7 +1528,8 @@ func (d *AuthenticatedGossiper) networkHandler() {
15251528
//
15261529
// NOTE: must be run as a goroutine.
15271530
func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
1528-
deDuped *deDupedAnnouncements, vb *graph.ValidationBarrier) {
1531+
deDuped *deDupedAnnouncements, vb *graph.ValidationBarrier,
1532+
jobID graph.JobID) {
15291533

15301534
defer d.wg.Done()
15311535
defer vb.CompleteJob()
@@ -1536,7 +1540,7 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
15361540

15371541
// If this message has an existing dependency, then we'll wait until
15381542
// that has been fully validated before we proceed.
1539-
err := vb.WaitForDependants(nMsg.msg)
1543+
err := vb.WaitForParents(jobID, nMsg.msg)
15401544
if err != nil {
15411545
log.Debugf("Validating network message %s got err: %v",
15421546
nMsg.msg.MsgType(), err)
@@ -1566,7 +1570,7 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
15661570

15671571
// If this message had any dependencies, then we can now signal them to
15681572
// continue.
1569-
vb.SignalDependants(nMsg.msg, allow)
1573+
vb.SignalDependents(nMsg.msg, jobID)
15701574

15711575
// If the announcement was accepted, then add the emitted announcements
15721576
// to our announce batch to be broadcast once the trickle timer ticks

0 commit comments

Comments
 (0)