@@ -517,6 +517,9 @@ type AuthenticatedGossiper struct {
517
517
// AuthenticatedGossiper lock.
518
518
chanUpdateRateLimiter map [uint64 ][2 ]* rate.Limiter
519
519
520
+ // vb is used to enforce job dependency ordering of gossip messages.
521
+ vb * ValidationBarrier
522
+
520
523
sync.Mutex
521
524
}
522
525
@@ -542,6 +545,8 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
542
545
banman : newBanman (),
543
546
}
544
547
548
+ gossiper .vb = NewValidationBarrier (1000 , gossiper .quit )
549
+
545
550
gossiper .syncMgr = newSyncManager (& SyncManagerCfg {
546
551
ChainHash : cfg .ChainHash ,
547
552
ChanSeries : cfg .ChanSeries ,
@@ -1409,10 +1414,6 @@ func (d *AuthenticatedGossiper) networkHandler() {
1409
1414
log .Errorf ("Unable to rebroadcast stale announcements: %v" , err )
1410
1415
}
1411
1416
1412
- // We'll use this validation to ensure that we process jobs in their
1413
- // dependency order during parallel validation.
1414
- validationBarrier := graph .NewValidationBarrier (1000 , d .quit )
1415
-
1416
1417
for {
1417
1418
select {
1418
1419
// A new policy update has arrived. We'll commit it to the
@@ -1481,11 +1482,17 @@ func (d *AuthenticatedGossiper) networkHandler() {
1481
1482
// We'll set up any dependent, and wait until a free
1482
1483
// slot for this job opens up, this allow us to not
1483
1484
// have thousands of goroutines active.
1484
- validationBarrier .InitJobDependencies (announcement .msg )
1485
+ annJobID , err := d .vb .InitJobDependencies (
1486
+ announcement .msg ,
1487
+ )
1488
+ if err != nil {
1489
+ announcement .err <- err
1490
+ continue
1491
+ }
1485
1492
1486
1493
d .wg .Add (1 )
1487
1494
go d .handleNetworkMessages (
1488
- announcement , & announcements , validationBarrier ,
1495
+ announcement , & announcements , annJobID ,
1489
1496
)
1490
1497
1491
1498
// The trickle timer has ticked, which indicates we should
@@ -1536,28 +1543,23 @@ func (d *AuthenticatedGossiper) networkHandler() {
1536
1543
//
1537
1544
// NOTE: must be run as a goroutine.
1538
1545
func (d * AuthenticatedGossiper ) handleNetworkMessages (nMsg * networkMsg ,
1539
- deDuped * deDupedAnnouncements , vb * graph. ValidationBarrier ) {
1546
+ deDuped * deDupedAnnouncements , jobID JobID ) {
1540
1547
1541
1548
defer d .wg .Done ()
1542
- defer vb .CompleteJob ()
1549
+ defer d . vb .CompleteJob ()
1543
1550
1544
1551
// We should only broadcast this message forward if it originated from
1545
1552
// us or it wasn't received as part of our initial historical sync.
1546
1553
shouldBroadcast := ! nMsg .isRemote || d .syncMgr .IsGraphSynced ()
1547
1554
1548
1555
// If this message has an existing dependency, then we'll wait until
1549
1556
// that has been fully validated before we proceed.
1550
- err := vb .WaitForDependants ( nMsg .msg )
1557
+ err := d . vb .WaitForParents ( jobID , nMsg .msg )
1551
1558
if err != nil {
1552
1559
log .Debugf ("Validating network message %s got err: %v" ,
1553
1560
nMsg .msg .MsgType (), err )
1554
1561
1555
- if ! graph .IsError (
1556
- err ,
1557
- graph .ErrVBarrierShuttingDown ,
1558
- graph .ErrParentValidationFailed ,
1559
- ) {
1560
-
1562
+ if errors .Is (err , ErrVBarrierShuttingDown ) {
1561
1563
log .Warnf ("unexpected error during validation " +
1562
1564
"barrier shutdown: %v" , err )
1563
1565
}
@@ -1577,7 +1579,16 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
1577
1579
1578
1580
// If this message had any dependencies, then we can now signal them to
1579
1581
// continue.
1580
- vb .SignalDependants (nMsg .msg , allow )
1582
+ err = d .vb .SignalDependents (nMsg .msg , jobID )
1583
+ if err != nil {
1584
+ // Something is wrong if SignalDependents returns an error.
1585
+ log .Errorf ("SignalDependents returned error for msg=%v with " +
1586
+ "JobID=%v" , spew .Sdump (nMsg .msg ), jobID )
1587
+
1588
+ nMsg .err <- err
1589
+
1590
+ return
1591
+ }
1581
1592
1582
1593
// If the announcement was accepted, then add the emitted announcements
1583
1594
// to our announce batch to be broadcast once the trickle timer ticks
@@ -2407,7 +2418,6 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,
2407
2418
err ,
2408
2419
graph .ErrOutdated ,
2409
2420
graph .ErrIgnored ,
2410
- graph .ErrVBarrierShuttingDown ,
2411
2421
) {
2412
2422
2413
2423
log .Error (err )
@@ -3148,7 +3158,6 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3148
3158
if graph .IsError (
3149
3159
err , graph .ErrOutdated ,
3150
3160
graph .ErrIgnored ,
3151
- graph .ErrVBarrierShuttingDown ,
3152
3161
) {
3153
3162
3154
3163
log .Debugf ("Update edge for short_chan_id(%v) got: %v" ,
0 commit comments