From 6c27de7d1116fb8b09c2d0576992f700346818f8 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 2 Apr 2021 15:02:08 -0700 Subject: [PATCH] routing: add strict pruning as new flag, default for neutrino In this commit we add a new flag that controls if lnd will do strict zombie pruning or not. If true, then this will cause lnd to maintain a tighter graph as it wants both edges to always be live. We enable this by default for neutrino as without this, it's possible that a node never sees both edges begin disabled, so those edges are never actually pruned from the graph. --- lncfg/routing.go | 4 +++- sample-lnd.conf | 6 ++++++ server.go | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lncfg/routing.go b/lncfg/routing.go index 8f62745f..3e6cabc7 100644 --- a/lncfg/routing.go +++ b/lncfg/routing.go @@ -2,5 +2,7 @@ package lncfg // Routing holds the configuration options for routing. type Routing struct { - AssumeChannelValid bool `long:"assumechanvalid" description:"DEPRECATED: This is now turned on by default for Neutrino (use neutrino.validatechannels=true to turn off) and shouldn't be used for any other backend! (default: false)"` + AssumeChannelValid bool `long:"assumechanvalid" description:"Skip checking channel spentness during graph validation. This speedup comes at the risk of using an unvalidated view of the network for routing. (default: false)"` + + StrictZombiePruning bool `long:"strictgraphpruning" description:"If true, then the graph will be pruned more aggressively for zombies. In practice this means that edges with a single stale edge will be considered a zombie."` } diff --git a/sample-lnd.conf b/sample-lnd.conf index 615c8563..4659c1ce 100644 --- a/sample-lnd.conf +++ b/sample-lnd.conf @@ -489,6 +489,12 @@ bitcoin.node=btcd ; other backend! ; --routing.assumechanvalid=true +; If set to true, then we'll prune a channel if only a single edge is seen as +; being stale. This results in a more compact channel graph, and also is helpful +; for neutrino nodes as it means they'll only maintain edges where both nodes are +; seen as being live from it's PoV. +; --routing.strictgraphpruning=true + [Btcd] ; The base directory that contains the node's data, logs, configuration file, diff --git a/server.go b/server.go index fbc70699..688b9cda 100644 --- a/server.go +++ b/server.go @@ -768,6 +768,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr, s.controlTower = routing.NewControlTower(paymentControl) + strictPruning := (cfg.Bitcoin.Node == "neutrino" || + cfg.Routing.StrictZombiePruning) s.chanRouter, err = routing.New(routing.Config{ Graph: chanGraph, Chain: cc.ChainIO, @@ -784,6 +786,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, NextPaymentID: sequencer.NextID, PathFindingConfig: pathFindingConfig, Clock: clock.NewDefaultClock(), + StrictZombiePruning: strictPruning, }) if err != nil { return nil, fmt.Errorf("can't create router: %v", err)