lnd+routerrpc: configure server with new estimator
We add new lnd.conf configuration options for both probability estimators. Note that this is a breaking change for the existing apriori parameters.
This commit is contained in:
5 files changed
+160
-58
No files matched your search
+33
-16
@@ -42,14 +42,23 @@ type Config struct {
|
|||||||
// DefaultConfig defines the config defaults.
|
// DefaultConfig defines the config defaults.
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
defaultRoutingConfig := RoutingConfig{
|
defaultRoutingConfig := RoutingConfig{
|
||||||
AprioriHopProbability: routing.DefaultAprioriHopProbability,
|
ProbabilityEstimatorType: routing.DefaultEstimator,
|
||||||
AprioriWeight: routing.DefaultAprioriWeight,
|
MinRouteProbability: routing.DefaultMinRouteProbability,
|
||||||
MinRouteProbability: routing.DefaultMinRouteProbability,
|
|
||||||
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
AttemptCost: routing.DefaultAttemptCost.ToSatoshis(),
|
||||||
AttemptCost: routing.DefaultAttemptCost.ToSatoshis(),
|
AttemptCostPPM: routing.DefaultAttemptCostPPM,
|
||||||
AttemptCostPPM: routing.DefaultAttemptCostPPM,
|
MaxMcHistory: routing.DefaultMaxMcHistory,
|
||||||
MaxMcHistory: routing.DefaultMaxMcHistory,
|
McFlushInterval: routing.DefaultMcFlushInterval,
|
||||||
McFlushInterval: routing.DefaultMcFlushInterval,
|
AprioriConfig: &AprioriConfig{
|
||||||
|
HopProbability: routing.DefaultAprioriHopProbability,
|
||||||
|
Weight: routing.DefaultAprioriWeight,
|
||||||
|
PenaltyHalfLife: routing.DefaultPenaltyHalfLife,
|
||||||
|
},
|
||||||
|
BimodalConfig: &BimodalConfig{
|
||||||
|
Scale: int64(routing.DefaultBimodalScaleMsat),
|
||||||
|
NodeWeight: routing.DefaultBimodalNodeWeight,
|
||||||
|
DecayTime: routing.DefaultBimodalDecayTime,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Config{
|
return &Config{
|
||||||
@@ -60,13 +69,21 @@ func DefaultConfig() *Config {
|
|||||||
// GetRoutingConfig returns the routing config based on this sub server config.
|
// GetRoutingConfig returns the routing config based on this sub server config.
|
||||||
func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
func GetRoutingConfig(cfg *Config) *RoutingConfig {
|
||||||
return &RoutingConfig{
|
return &RoutingConfig{
|
||||||
AprioriHopProbability: cfg.AprioriHopProbability,
|
ProbabilityEstimatorType: cfg.ProbabilityEstimatorType,
|
||||||
AprioriWeight: cfg.AprioriWeight,
|
MinRouteProbability: cfg.MinRouteProbability,
|
||||||
MinRouteProbability: cfg.MinRouteProbability,
|
AttemptCost: cfg.AttemptCost,
|
||||||
AttemptCost: cfg.AttemptCost,
|
AttemptCostPPM: cfg.AttemptCostPPM,
|
||||||
AttemptCostPPM: cfg.AttemptCostPPM,
|
MaxMcHistory: cfg.MaxMcHistory,
|
||||||
PenaltyHalfLife: cfg.PenaltyHalfLife,
|
McFlushInterval: cfg.McFlushInterval,
|
||||||
MaxMcHistory: cfg.MaxMcHistory,
|
AprioriConfig: &AprioriConfig{
|
||||||
McFlushInterval: cfg.McFlushInterval,
|
HopProbability: cfg.AprioriConfig.HopProbability,
|
||||||
|
Weight: cfg.AprioriConfig.Weight,
|
||||||
|
PenaltyHalfLife: cfg.AprioriConfig.PenaltyHalfLife,
|
||||||
|
},
|
||||||
|
BimodalConfig: &BimodalConfig{
|
||||||
|
Scale: cfg.BimodalConfig.Scale,
|
||||||
|
NodeWeight: cfg.BimodalConfig.NodeWeight,
|
||||||
|
DecayTime: cfg.BimodalConfig.DecayTime,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,28 +7,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RoutingConfig contains the configurable parameters that control routing.
|
// RoutingConfig contains the configurable parameters that control routing.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
type RoutingConfig struct {
|
type RoutingConfig struct {
|
||||||
|
// ProbabilityEstimatorType sets the estimator to use.
|
||||||
|
ProbabilityEstimatorType string `long:"estimator" choice:"apriori" choice:"bimodal" description:"Probability estimator used for pathfinding." `
|
||||||
|
|
||||||
// MinRouteProbability is the minimum required route success probability
|
// MinRouteProbability is the minimum required route success probability
|
||||||
// to attempt the payment.
|
// to attempt the payment.
|
||||||
MinRouteProbability float64 `long:"minrtprob" description:"Minimum required route success probability to attempt the payment"`
|
MinRouteProbability float64 `long:"minrtprob" description:"Minimum required route success probability to attempt the payment"`
|
||||||
|
|
||||||
// AprioriHopProbability is the assumed success probability of a hop in
|
|
||||||
// a route when no other information is available.
|
|
||||||
AprioriHopProbability float64 `long:"apriorihopprob" description:"Assumed success probability of a hop in a route when no other information is available."`
|
|
||||||
|
|
||||||
// AprioriWeight is a value in the range [0, 1] that defines to what
|
|
||||||
// extent historical results should be extrapolated to untried
|
|
||||||
// connections. Setting it to one will completely ignore historical
|
|
||||||
// results and always assume the configured a priori probability for
|
|
||||||
// untried connections. A value of zero will ignore the a priori
|
|
||||||
// probability completely and only base the probability on historical
|
|
||||||
// results, unless there are none available.
|
|
||||||
AprioriWeight float64 `long:"aprioriweight" description:"Weight of the a priori probability in success probability estimation. Valid values are in [0, 1]."`
|
|
||||||
|
|
||||||
// PenaltyHalfLife defines after how much time a penalized node or
|
|
||||||
// channel is back at 50% probability.
|
|
||||||
PenaltyHalfLife time.Duration `long:"penaltyhalflife" description:"Defines the duration after which a penalized node or channel is back at 50% probability"`
|
|
||||||
|
|
||||||
// AttemptCost is the fixed virtual cost in path finding of a failed
|
// AttemptCost is the fixed virtual cost in path finding of a failed
|
||||||
// payment attempt. It is used to trade off potentially better routes
|
// payment attempt. It is used to trade off potentially better routes
|
||||||
// against their probability of succeeding.
|
// against their probability of succeeding.
|
||||||
@@ -47,4 +35,51 @@ type RoutingConfig struct {
|
|||||||
// McFlushInterval defines the timer interval to use to flush mission
|
// McFlushInterval defines the timer interval to use to flush mission
|
||||||
// control state to the DB.
|
// control state to the DB.
|
||||||
McFlushInterval time.Duration `long:"mcflushinterval" description:"the timer interval to use to flush mission control state to the DB"`
|
McFlushInterval time.Duration `long:"mcflushinterval" description:"the timer interval to use to flush mission control state to the DB"`
|
||||||
|
|
||||||
|
// AprioriConfig defines parameters for the apriori probability.
|
||||||
|
AprioriConfig *AprioriConfig `group:"apriori" namespace:"apriori" description:"configuration for the apriori pathfinding probability estimator"`
|
||||||
|
|
||||||
|
// BimodalConfig defines parameters for the bimodal probability.
|
||||||
|
BimodalConfig *BimodalConfig `group:"bimodal" namespace:"bimodal" description:"configuration for the bimodal pathfinding probability estimator"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AprioriConfig defines parameters for the apriori probability.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
|
type AprioriConfig struct {
|
||||||
|
// HopProbability is the assumed success probability of a hop in a route
|
||||||
|
// when no other information is available.
|
||||||
|
HopProbability float64 `long:"hopprob" description:"Assumed success probability of a hop in a route when no other information is available."`
|
||||||
|
|
||||||
|
// Weight is a value in the range [0, 1] that defines to what extent
|
||||||
|
// historical results should be extrapolated to untried connections.
|
||||||
|
// Setting it to one will completely ignore historical results and
|
||||||
|
// always assume the configured a priori probability for untried
|
||||||
|
// connections. A value of zero will ignore the a priori probability
|
||||||
|
// completely and only base the probability on historical results,
|
||||||
|
// unless there are none available.
|
||||||
|
Weight float64 `long:"weight" description:"Weight of the a priori probability in success probability estimation. Valid values are in [0, 1]."`
|
||||||
|
|
||||||
|
// PenaltyHalfLife defines after how much time a penalized node or
|
||||||
|
// channel is back at 50% probability.
|
||||||
|
PenaltyHalfLife time.Duration `long:"penaltyhalflife" description:"Defines the duration after which a penalized node or channel is back at 50% probability"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BimodalConfig defines parameters for the bimodal probability.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
|
type BimodalConfig struct {
|
||||||
|
// Scale describes the scale over which channels still have some
|
||||||
|
// liquidity left on both channel ends. A value of 0 means that we
|
||||||
|
// assume perfectly unbalanced channels, a very high value means
|
||||||
|
// randomly balanced channels.
|
||||||
|
Scale int64 `long:"scale" description:"Defines the unbalancedness assumed for the network, the amount defined in msat."`
|
||||||
|
|
||||||
|
// NodeWeight defines how strongly non-routed channels should be taken
|
||||||
|
// into account for probability estimation. Valid values are in [0,1].
|
||||||
|
NodeWeight float64 `long:"nodeweight" description:"Defines how strongly non-routed channels should be taken into account for probability estimation. Valid values are in [0, 1]."`
|
||||||
|
|
||||||
|
// DecayTime is the scale for the exponential information decay over
|
||||||
|
// time for previous successes or failures.
|
||||||
|
DecayTime time.Duration `long:"decaytime" description:"Describes the information decay of knowledge about previous successes and failures in channels."`
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,10 @@ type pathFinder = func(g *graphParams, r *RestrictParams,
|
|||||||
[]*channeldb.CachedEdgePolicy, float64, error)
|
[]*channeldb.CachedEdgePolicy, float64, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// DefaultEstimator is the default estimator used for computing
|
||||||
|
// probabilities in pathfinding.
|
||||||
|
DefaultEstimator = AprioriEstimatorName
|
||||||
|
|
||||||
// DefaultAttemptCost is the default fixed virtual cost in path finding
|
// DefaultAttemptCost is the default fixed virtual cost in path finding
|
||||||
// of a failed payment attempt. It is used to trade off potentially
|
// of a failed payment attempt. It is used to trade off potentially
|
||||||
// better routes against their probability of succeeding.
|
// better routes against their probability of succeeding.
|
||||||
|
|||||||
+35
-16
@@ -1105,21 +1105,23 @@ litecoin.node=ltcd
|
|||||||
|
|
||||||
[routerrpc]
|
[routerrpc]
|
||||||
|
|
||||||
|
; Probability estimator used for pathfinding. (default: apriori)
|
||||||
|
; routerrpc.estimator=[apriori|bimodal]
|
||||||
|
|
||||||
; Minimum required route success probability to attempt the payment (default:
|
; Minimum required route success probability to attempt the payment (default:
|
||||||
; 0.01)
|
; 0.01)
|
||||||
; routerrpc.minrtprob=1
|
; routerrpc.minrtprob=1
|
||||||
|
|
||||||
; Assumed success probability of a hop in a route when no other information is
|
; The maximum number of payment results that are held on disk by mission control
|
||||||
; available. (default: 0.6)
|
; (default: 1000)
|
||||||
; routerrpc.apriorihopprob=0.2
|
; routerrpc.maxmchistory=900
|
||||||
|
|
||||||
; Weight of the a priori probability in success probability estimation. Valid
|
; The time interval with which the MC store state is flushed to the database
|
||||||
; values are in [0, 1]. (default: 0.5)
|
; (default: 1s)
|
||||||
; routerrpc.aprioriweight=0.3
|
; routerrpc.mcflushinterval=1m
|
||||||
|
|
||||||
; Defines the duration after which a penalized node or channel is back at 50%
|
; Path to the router macaroon
|
||||||
; probability (default: 1h0m0s)
|
; routerrpc.routermacaroonpath=~/.lnd/data/chain/bitcoin/simnet/router.macaroon
|
||||||
; routerrpc.penaltyhalflife=2h
|
|
||||||
|
|
||||||
; The (virtual) fixed cost in sats of a failed payment attempt (default: 100)
|
; The (virtual) fixed cost in sats of a failed payment attempt (default: 100)
|
||||||
; routerrpc.attemptcost=90
|
; routerrpc.attemptcost=90
|
||||||
@@ -1128,15 +1130,32 @@ litecoin.node=ltcd
|
|||||||
; attempt (default: 1000)
|
; attempt (default: 1000)
|
||||||
; routerrpc.attemptcostppm=900
|
; routerrpc.attemptcostppm=900
|
||||||
|
|
||||||
; The maximum number of payment results that are held on disk by mission control
|
; Assumed success probability of a hop in a route when no other information is
|
||||||
; (default: 1000)
|
; available. (default: 0.6)
|
||||||
; routerrpc.maxmchistory=900
|
; routerrpc.apriori.hopprob=0.2
|
||||||
|
|
||||||
; The time interval with which the MC store state is flushed to the DB.
|
; Weight of the a priori probability in success probability estimation. Valid
|
||||||
; routerrpc.mcflushinterval=1m
|
; values are in [0, 1]. (default: 0.5)
|
||||||
|
; routerrpc.apriori.weight=0.3
|
||||||
|
|
||||||
; Path to the router macaroon
|
; Defines the duration after which a penalized node or channel is back at 50%
|
||||||
; routerrpc.routermacaroonpath=~/.lnd/data/chain/bitcoin/simnet/router.macaroon
|
; probability (default: 1h0m0s)
|
||||||
|
; routerrpc.apriori.penaltyhalflife=2h
|
||||||
|
|
||||||
|
; Describes the scale over which channels still have some liquidity left on
|
||||||
|
; both channel ends. A very low value (compared to typical channel capacities)
|
||||||
|
; means that we assume unbalanced channels, a very high value means randomly
|
||||||
|
; balanced channels. Value in msat. (default: 300000000)
|
||||||
|
; routerrpc.bimodal.scale=1000000000
|
||||||
|
|
||||||
|
; Defines how strongly non-routed channels of forwarders should be taken into
|
||||||
|
; account for probability estimation. A weight of zero disables this feature.
|
||||||
|
; Valid values are in [0, 1]. (default: 0.2)
|
||||||
|
; routerrpc.bimodal.nodeweight=0.3
|
||||||
|
|
||||||
|
; Defines the information decay of knowledge about previous successes and
|
||||||
|
; failures in channels. (default: 168h0m0s)
|
||||||
|
; routerrpc.bimodal.decaytime=72h
|
||||||
|
|
||||||
|
|
||||||
[workers]
|
[workers]
|
||||||
|
|||||||
@@ -873,15 +873,42 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
if cfg.Estimator != nil {
|
if cfg.Estimator != nil {
|
||||||
estimator = cfg.Estimator
|
estimator = cfg.Estimator
|
||||||
} else {
|
} else {
|
||||||
aCfg := routing.AprioriConfig{
|
switch routingConfig.ProbabilityEstimatorType {
|
||||||
AprioriHopProbability: routingConfig.
|
case routing.AprioriEstimatorName:
|
||||||
AprioriHopProbability,
|
aCfg := routingConfig.AprioriConfig
|
||||||
PenaltyHalfLife: routingConfig.PenaltyHalfLife,
|
aprioriConfig := routing.AprioriConfig{
|
||||||
AprioriWeight: routingConfig.AprioriWeight,
|
AprioriHopProbability: aCfg.HopProbability,
|
||||||
}
|
PenaltyHalfLife: aCfg.PenaltyHalfLife,
|
||||||
estimator, err = routing.NewAprioriEstimator(aCfg)
|
AprioriWeight: aCfg.Weight,
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
|
||||||
|
estimator, err = routing.NewAprioriEstimator(
|
||||||
|
aprioriConfig,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case routing.BimodalEstimatorName:
|
||||||
|
bCfg := routingConfig.BimodalConfig
|
||||||
|
bimodalConfig := routing.BimodalConfig{
|
||||||
|
BimodalNodeWeight: bCfg.NodeWeight,
|
||||||
|
BimodalScaleMsat: lnwire.MilliSatoshi(
|
||||||
|
bCfg.Scale,
|
||||||
|
),
|
||||||
|
BimodalDecayTime: bCfg.DecayTime,
|
||||||
|
}
|
||||||
|
|
||||||
|
estimator, err = routing.NewBimodalEstimator(
|
||||||
|
bimodalConfig,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown estimator type %v",
|
||||||
|
routingConfig.ProbabilityEstimatorType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user