Merge pull request #5193 from wpaulino/neutrino-assume-valid

Use routing.assumechanvalid=true by default in Neutrino mode
This commit is contained in:
Olaoluwa Osuntokun 2021-04-13 15:37:51 -07:00 committed by GitHub
commit 25dfbc4106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 8 deletions

@ -14,4 +14,5 @@ type Neutrino struct {
AssertFilterHeader string `long:"assertfilterheader" description:"Optional filter header in height:hash format to assert the state of neutrino's filter header chain on startup. If the assertion does not hold, then the filter header chain will be re-synced from the genesis block."`
UserAgentName string `long:"useragentname" description:"Used to help identify ourselves to other bitcoin peers"`
UserAgentVersion string `long:"useragentversion" description:"Used to help identify ourselves to other bitcoin peers"`
ValidateChannels bool `long:"validatechannels" description:"Validate every channel in the graph during sync by downloading the containing block. This is the inverse of routing.assumechanvalid, meaning that for Neutrino the validation is turned off by default for massively increased graph sync performance. This speedup comes at the risk of using an unvalidated view of the network for routing. Overwrites the value of routing.assumechanvalid if Neutrino is used. (default: false)"`
}

@ -2,5 +2,5 @@ package lncfg
// Routing holds the configuration options for routing.
type Routing struct {
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)"`
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)"`
}

11
lnd.go

@ -1553,6 +1553,17 @@ func initializeDatabases(ctx context.Context,
func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService,
func(), error) {
// Both channel validation flags are false by default but their meaning
// is the inverse of each other. Therefore both cannot be true. For
// every other case, the neutrino.validatechannels overwrites the
// routing.assumechanvalid value.
if cfg.NeutrinoMode.ValidateChannels && cfg.Routing.AssumeChannelValid {
return nil, nil, fmt.Errorf("can't set both " +
"neutrino.validatechannels and routing." +
"assumechanvalid to true at the same time")
}
cfg.Routing.AssumeChannelValid = !cfg.NeutrinoMode.ValidateChannels
// First we'll open the database file for neutrino, creating the
// database if needed. We append the normalized network name here to
// match the behavior of btcwallet.

@ -24,6 +24,9 @@ func (b NeutrinoBackendConfig) GenArgs() []string {
var args []string
args = append(args, "--bitcoin.node=neutrino")
args = append(args, "--neutrino.connect="+b.minerAddr)
// We enable validating channels so that we can obtain the outpoint for
// channels within the graph and make certain assertions based on them.
args = append(args, "--neutrino.validatechannels")
return args
}

@ -476,13 +476,17 @@ bitcoin.node=btcd
; Used to help identify ourselves to other bitcoin peers (default: 0.11.0-beta).
; neutrino.useragentversion=0.11.0-beta
; Skip checking channel spentness and existence during graph validation for
; neutrino. Enabling this option means that neutrino nodes will not need to
; perform long rescans which block initial usage of the daemon, but comes at
; the cost of not validating channels in your routing graph. Skipping this
; validation means that your node may have an incorrect view of the network
; if it receives updates for closed or non-existent channels. This could affect
; routing, but funds are safu.
; Validate every channel in the graph during sync by downloading the containing
; block. This is the inverse of routing.assumechanvalid, meaning that for
; Neutrino the validation is turned off by default for massively increased graph
; sync performance. This speedup comes at the risk of using an unvalidated view
; of the network for routing. Overwrites the value of routing.assumechanvalid if
; Neutrino is used. (default: false)
; neutrino.validatechannels=false
; 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!
; --routing.assumechanvalid=true
[Btcd]