@@ -1462,6 +1462,10 @@ func (d *AuthenticatedGossiper) networkHandler() {
1462
1462
sourceToPub (announcement .source ),
1463
1463
) {
1464
1464
1465
+ peer := sourceToPub (announcement .source )
1466
+ log .Debugf ("Throttling messages from peer=%v " +
1467
+ "(recently rejected)" , peer )
1468
+
1465
1469
announcement .err <- fmt .Errorf ("recently " +
1466
1470
"rejected" )
1467
1471
continue
@@ -1927,17 +1931,24 @@ func (d *AuthenticatedGossiper) processRejectedEdge(
1927
1931
msg : chanAnn ,
1928
1932
})
1929
1933
if e1Ann != nil {
1930
- announcements = append (announcements , networkMsg {
1931
- source : d .selfKey ,
1932
- msg : e1Ann ,
1933
- })
1934
+ // Only add the ChanUpdate to the gossiper if the
1935
+ // __dont_forward__ bit signals it.
1936
+ if ! e1Ann .MessageFlags .HasDontForward () {
1937
+ announcements = append (announcements , networkMsg {
1938
+ source : d .selfKey ,
1939
+ msg : e1Ann ,
1940
+ })
1941
+ }
1934
1942
}
1935
1943
if e2Ann != nil {
1936
- announcements = append (announcements , networkMsg {
1937
- source : d .selfKey ,
1938
- msg : e2Ann ,
1939
- })
1940
-
1944
+ // Only add the ChanUpdate to the gossiper if the
1945
+ // __dont_forward__ bit signals it.
1946
+ if ! e2Ann .MessageFlags .HasDontForward () {
1947
+ announcements = append (announcements , networkMsg {
1948
+ source : d .selfKey ,
1949
+ msg : e2Ann ,
1950
+ })
1951
+ }
1941
1952
}
1942
1953
1943
1954
return announcements , nil
@@ -2347,6 +2358,18 @@ func IsKeepAliveUpdate(update *lnwire.ChannelUpdate1,
2347
2358
if update .MessageFlags .HasMaxHtlc () && ! prev .MessageFlags .HasMaxHtlc () {
2348
2359
return false
2349
2360
}
2361
+
2362
+ // Every public channel starts with the dont_forward bit set before the
2363
+ // mandatory six confirmations are reached. We will see 2 different
2364
+ // ChanUpdates before a public channel is announced to the broader
2365
+ // network. We need to make sure we don't consider the second one as a
2366
+ // keepalive msg.
2367
+ if ! update .MessageFlags .HasDontForward () &&
2368
+ prev .MessageFlags .HasDontForward () {
2369
+
2370
+ return false
2371
+ }
2372
+
2350
2373
if update .HtlcMaximumMsat != prev .MaxHTLC {
2351
2374
return false
2352
2375
}
@@ -2459,6 +2482,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2459
2482
)
2460
2483
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2461
2484
2485
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2486
+ "peer=%x to RejectCache" , key .chanID ,
2487
+ key .pubkey )
2488
+
2462
2489
nMsg .err <- err
2463
2490
return nil , false
2464
2491
}
@@ -2476,6 +2503,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2476
2503
)
2477
2504
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2478
2505
2506
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2507
+ "peer=%x to RejectCache" , key .chanID ,
2508
+ key .pubkey )
2509
+
2479
2510
nMsg .err <- err
2480
2511
return nil , false
2481
2512
}
@@ -2560,6 +2591,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2560
2591
)
2561
2592
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2562
2593
2594
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2595
+ "peer=%x to RejectCache" , key .chanID ,
2596
+ key .pubkey )
2597
+
2563
2598
log .Error (err )
2564
2599
nMsg .err <- err
2565
2600
return nil , false
@@ -2673,6 +2708,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2673
2708
)
2674
2709
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2675
2710
2711
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2712
+ "peer=%x to RejectCache" , key .chanID ,
2713
+ key .pubkey )
2714
+
2676
2715
// Increment the peer's ban score. We check isRemote
2677
2716
// so we don't actually ban the peer in case of a local
2678
2717
// bug.
@@ -2687,6 +2726,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2687
2726
)
2688
2727
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2689
2728
2729
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2730
+ "peer=%x to RejectCache" , key .chanID ,
2731
+ key .pubkey )
2732
+
2690
2733
// Since this channel has already been closed, we'll
2691
2734
// add it to the graph's closed channel index such that
2692
2735
// we won't attempt to do expensive validation checks
@@ -2717,6 +2760,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
2717
2760
sourceToPub (nMsg .source ),
2718
2761
)
2719
2762
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2763
+
2764
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2765
+ "peer=%x to RejectCache" , key .chanID ,
2766
+ key .pubkey )
2720
2767
}
2721
2768
2722
2769
if ! nMsg .isRemote {
@@ -2847,6 +2894,10 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
2847
2894
)
2848
2895
_ , _ = d .recentRejects .Put (key , & cachedReject {})
2849
2896
2897
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
2898
+ "peer=%x to RejectCache" , key .chanID ,
2899
+ key .pubkey )
2900
+
2850
2901
nMsg .err <- err
2851
2902
return nil , false
2852
2903
}
@@ -2956,9 +3007,9 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
2956
3007
// If the edge corresponding to this ChannelUpdate was not
2957
3008
// found in the graph, this might be a channel in the process
2958
3009
// of being opened, and we haven't processed our own
2959
- // ChannelAnnouncement yet, hence it is not not found in the
2960
- // graph. This usually gets resolved after the channel proofs
2961
- // are exchanged and the channel is broadcasted to the rest of
3010
+ // ChannelAnnouncement yet, hence it is not found in the graph.
3011
+ // This usually gets resolved after the channel proofs are
3012
+ // exchanged and the channel is broadcasted to the rest of
2962
3013
// the network, but in case this is a private channel this
2963
3014
// won't ever happen. This can also happen in the case of a
2964
3015
// zombie channel with a fresh update for which we don't have a
@@ -3014,6 +3065,10 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3014
3065
)
3015
3066
_ , _ = d .recentRejects .Put (key , & cachedReject {})
3016
3067
3068
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
3069
+ "peer=%x to RejectCache" , key .chanID ,
3070
+ key .pubkey )
3071
+
3017
3072
return nil , false
3018
3073
}
3019
3074
@@ -3143,6 +3198,10 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3143
3198
)
3144
3199
_ , _ = d .recentRejects .Put (key , & cachedReject {})
3145
3200
3201
+ log .Debugf ("Adding msg short_chan_id(%v) from " +
3202
+ "peer=%x to RejectCache" , key .chanID ,
3203
+ key .pubkey )
3204
+
3146
3205
log .Errorf ("Update edge for short_chan_id(%v) got: %v" ,
3147
3206
shortChanID , err )
3148
3207
}
@@ -3151,6 +3210,11 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3151
3210
return nil , false
3152
3211
}
3153
3212
3213
+ // Get our peer's public key.
3214
+ remotePubKey := remotePubFromChanInfo (
3215
+ chanInfo , upd .ChannelFlags ,
3216
+ )
3217
+
3154
3218
// If this is a local ChannelUpdate without an AuthProof, it means it
3155
3219
// is an update to a channel that is not (yet) supposed to be announced
3156
3220
// to the greater network. However, our channel counter party will need
@@ -3186,11 +3250,6 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3186
3250
}
3187
3251
}
3188
3252
3189
- // Get our peer's public key.
3190
- remotePubKey := remotePubFromChanInfo (
3191
- chanInfo , upd .ChannelFlags ,
3192
- )
3193
-
3194
3253
log .Debugf ("The message %v has no AuthProof, sending the " +
3195
3254
"update to remote peer %x" , upd .MsgType (), remotePubKey )
3196
3255
@@ -3214,12 +3273,29 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
3214
3273
// contains an alias because the network would reject this.
3215
3274
var announcements []networkMsg
3216
3275
if chanInfo .AuthProof != nil && ! d .cfg .IsAlias (upd .ShortChannelID ) {
3217
- announcements = append (announcements , networkMsg {
3218
- peer : nMsg .peer ,
3219
- source : nMsg .source ,
3220
- isRemote : nMsg .isRemote ,
3221
- msg : upd ,
3222
- })
3276
+ // We log the case where the dont_forward bit is set although
3277
+ // the channel is already announced to the network because we
3278
+ // already have a AuthProof for it. In addition we do not add
3279
+ // this msg to the gossip msg queue to make sure we follow the
3280
+ // network rules.
3281
+ if upd .MessageFlags .HasDontForward () {
3282
+ log .Warnf ("Received %v with the dont_forward bit set " +
3283
+ "(msgflags=%s) for channel=%v from peer=%x " +
3284
+ "for an announced channel, not forwarding to " +
3285
+ "the broader network" ,
3286
+ upd .MsgType ().String (),
3287
+ upd .MessageFlags .String (),
3288
+ upd .ShortChannelID .ToUint64 (),
3289
+ remotePubKey ,
3290
+ )
3291
+ } else {
3292
+ announcements = append (announcements , networkMsg {
3293
+ peer : nMsg .peer ,
3294
+ source : nMsg .source ,
3295
+ isRemote : nMsg .isRemote ,
3296
+ msg : upd ,
3297
+ })
3298
+ }
3223
3299
}
3224
3300
3225
3301
nMsg .err <- nil
@@ -3495,18 +3571,26 @@ func (d *AuthenticatedGossiper) handleAnnSig(nMsg *networkMsg,
3495
3571
msg : chanAnn ,
3496
3572
})
3497
3573
if src , err := chanInfo .NodeKey1 (); err == nil && e1Ann != nil {
3498
- announcements = append (announcements , networkMsg {
3499
- peer : nMsg .peer ,
3500
- source : src ,
3501
- msg : e1Ann ,
3502
- })
3574
+ // Only add the ChanUpdate to the gossiper if the
3575
+ // __dont_forward__ bit signals it.
3576
+ if ! e1Ann .MessageFlags .HasDontForward () {
3577
+ announcements = append (announcements , networkMsg {
3578
+ peer : nMsg .peer ,
3579
+ source : src ,
3580
+ msg : e1Ann ,
3581
+ })
3582
+ }
3503
3583
}
3504
3584
if src , err := chanInfo .NodeKey2 (); err == nil && e2Ann != nil {
3505
- announcements = append (announcements , networkMsg {
3506
- peer : nMsg .peer ,
3507
- source : src ,
3508
- msg : e2Ann ,
3509
- })
3585
+ // Only add the ChanUpdate to the gossiper if the
3586
+ // __dont_forward__ bit signals it.
3587
+ if ! e2Ann .MessageFlags .HasDontForward () {
3588
+ announcements = append (announcements , networkMsg {
3589
+ peer : nMsg .peer ,
3590
+ source : src ,
3591
+ msg : e2Ann ,
3592
+ })
3593
+ }
3510
3594
}
3511
3595
3512
3596
// We'll also send along the node announcements for each channel
0 commit comments