Skip to content

Commit 001e559

Browse files
committed
multi: add debug logs for edge policy flow
This commit adds more logs around the ChannelUpdate->edge policy process flow.
1 parent e0a920a commit 001e559

File tree

8 files changed

+43
-10
lines changed

8 files changed

+43
-10
lines changed

discovery/gossiper.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ func (d *AuthenticatedGossiper) stop() {
808808
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
809809
peer lnpeer.Peer) chan error {
810810

811+
log.Debugf("Processing remote msg %T from peer=%x", msg, peer.PubKey())
812+
811813
errChan := make(chan error, 1)
812814

813815
// For messages in the known set of channel series queries, we'll
@@ -2371,7 +2373,8 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,
23712373
timestamp := time.Unix(int64(nodeAnn.Timestamp), 0)
23722374

23732375
log.Debugf("Processing NodeAnnouncement: peer=%v, timestamp=%v, "+
2374-
"node=%x", nMsg.peer, timestamp, nodeAnn.NodeID)
2376+
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
2377+
nMsg.source.SerializeCompressed())
23752378

23762379
// We'll quickly ask the router if it already has a newer update for
23772380
// this node so we can skip validating signatures if not required.
@@ -2430,7 +2433,8 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,
24302433
// TODO(roasbeef): get rid of the above
24312434

24322435
log.Debugf("Processed NodeAnnouncement: peer=%v, timestamp=%v, "+
2433-
"node=%x", nMsg.peer, timestamp, nodeAnn.NodeID)
2436+
"node=%x, source=%x", nMsg.peer, timestamp, nodeAnn.NodeID,
2437+
nMsg.source.SerializeCompressed())
24342438

24352439
return announcements, true
24362440
}
@@ -3034,9 +3038,9 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
30343038
edgeToUpdate = e2
30353039
}
30363040

3037-
log.Debugf("Validating ChannelUpdate: channel=%v, from node=%x, has "+
3038-
"edge=%v", chanInfo.ChannelID, pubKey.SerializeCompressed(),
3039-
edgeToUpdate != nil)
3041+
log.Debugf("Validating ChannelUpdate: channel=%v, for node=%x, has "+
3042+
"edge policy=%v", chanInfo.ChannelID,
3043+
pubKey.SerializeCompressed(), edgeToUpdate != nil)
30403044

30413045
// Validate the channel announcement with the expected public key and
30423046
// channel capacity. In the case of an invalid channel update, we'll

discovery/sync_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ func (m *SyncManager) createGossipSyncer(peer lnpeer.Peer) *GossipSyncer {
529529
s.setSyncState(chansSynced)
530530
s.setSyncType(PassiveSync)
531531

532-
log.Debugf("Created new GossipSyncer[state=%s type=%s] for peer=%v",
533-
s.syncState(), s.SyncType(), peer)
532+
log.Debugf("Created new GossipSyncer[state=%s type=%s] for peer=%x",
533+
s.syncState(), s.SyncType(), peer.PubKey())
534534

535535
return s
536536
}

discovery/syncer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,9 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
13421342
return err
13431343
}
13441344

1345-
log.Infof("GossipSyncer(%x): applying new update horizon: start=%v, "+
1346-
"end=%v, backlog_size=%v", g.cfg.peerPub[:], startTime, endTime,
1347-
len(newUpdatestoSend))
1345+
log.Infof("GossipSyncer(%x): applying new remote update horizon: "+
1346+
"start=%v, end=%v, backlog_size=%v", g.cfg.peerPub[:],
1347+
startTime, endTime, len(newUpdatestoSend))
13481348

13491349
// If we don't have any to send, then we can return early.
13501350
if len(newUpdatestoSend) == 0 {

graph/builder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,9 @@ func (b *Builder) processUpdate(msg interface{},
14001400
msg.ChannelID)
14011401
}
14021402

1403+
log.Debugf("Found edge1Timestamp=%v, edge2Timestamp=%v",
1404+
edge1Timestamp, edge2Timestamp)
1405+
14031406
// As edges are directional edge node has a unique policy for
14041407
// the direction of the edge they control. Therefore, we first
14051408
// check if we already have the most up-to-date information for

graph/db/graph.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,10 @@ func (c *ChannelGraph) UpdateEdgePolicy(edge *models.ChannelEdgePolicy,
27972797
tx, edge, c.graphCache,
27982798
)
27992799

2800+
if err != nil {
2801+
log.Errorf("UpdateEdgePolicy faild: %v", err)
2802+
}
2803+
28002804
// Silence ErrEdgeNotFound so that the batch can
28012805
// succeed, but propagate the error via local state.
28022806
if errors.Is(err, ErrEdgeNotFound) {

graph/db/graph_cache.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ func (c *GraphCache) UpdatePolicy(policy *models.ChannelEdgePolicy, fromNode,
228228
var inboundFee lnwire.Fee
229229
_, err := policy.ExtraOpaqueData.ExtractRecords(&inboundFee)
230230
if err != nil {
231+
log.Errorf("Failed to extract records from edge policy %v: %v",
232+
policy.ChannelID, err)
233+
231234
return
232235
}
233236

@@ -236,11 +239,16 @@ func (c *GraphCache) UpdatePolicy(policy *models.ChannelEdgePolicy, fromNode,
236239

237240
updatePolicy := func(nodeKey route.Vertex) {
238241
if len(c.nodeChannels[nodeKey]) == 0 {
242+
log.Warnf("Node=%v not found in graph cache", nodeKey)
243+
239244
return
240245
}
241246

242247
channel, ok := c.nodeChannels[nodeKey][policy.ChannelID]
243248
if !ok {
249+
log.Warnf("Channel=%v not found in graph cache",
250+
policy.ChannelID)
251+
244252
return
245253
}
246254

graph/db/models/channel_edge_policy.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package models
22

33
import (
4+
"fmt"
45
"time"
56

67
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
@@ -113,3 +114,10 @@ func (c *ChannelEdgePolicy) ComputeFee(
113114

114115
return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
115116
}
117+
118+
// String returns a human-readable version of the channel edge policy.
119+
func (c *ChannelEdgePolicy) String() string {
120+
return fmt.Sprintf("ChannelID=%v, MessageFlags=%v, ChannelFlags=%v, "+
121+
"LastUpdate=%v", c.ChannelID, c.MessageFlags, c.ChannelFlags,
122+
c.LastUpdate)
123+
}

routing/unified_edges.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func (u *nodeEdgeUnifier) addPolicy(fromNode route.Vertex,
5959
// Skip channels if there is an outgoing channel restriction.
6060
if localChan && u.outChanRestr != nil {
6161
if _, ok := u.outChanRestr[edge.ChannelID]; !ok {
62+
log.Debugf("Skipped adding policy for restricted edge "+
63+
"%v", edge.ChannelID)
64+
6265
return
6366
}
6467
}
@@ -100,6 +103,9 @@ func (u *nodeEdgeUnifier) addGraphPolicies(g Graph) error {
100103
// Note that we are searching backwards so this node would have
101104
// come prior to the pivot node in the route.
102105
if channel.InPolicy == nil {
106+
log.Debugf("Skipped adding edge %v due to nil policy",
107+
channel.ChannelID)
108+
103109
return nil
104110
}
105111

0 commit comments

Comments
 (0)