Merge pull request #8857 from MPins/issue-8793
Fixing the current state update when lncli debuglevel and lncli setmccfg are called
This commit is contained in:
4 files changed
+60
-5
No files matched your search
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
# Bug Fixes
|
# Bug Fixes
|
||||||
|
|
||||||
|
* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/8857) to correctly
|
||||||
|
propagate mission control and debug level config values to the main LND config
|
||||||
|
struct so that the GetDebugInfo response is accurate.
|
||||||
|
|
||||||
# New Features
|
# New Features
|
||||||
## Functional Enhancements
|
## Functional Enhancements
|
||||||
## RPC Additions
|
## RPC Additions
|
||||||
@@ -53,4 +57,5 @@
|
|||||||
|
|
||||||
# Contributors (Alphabetical Order)
|
# Contributors (Alphabetical Order)
|
||||||
|
|
||||||
|
* Pins
|
||||||
* Ziggie
|
* Ziggie
|
||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/kvdb"
|
"github.com/lightningnetwork/lnd/kvdb"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
@@ -110,6 +111,10 @@ type MissionControl struct {
|
|||||||
// results that mission control collects.
|
// results that mission control collects.
|
||||||
estimator Estimator
|
estimator Estimator
|
||||||
|
|
||||||
|
// onConfigUpdate is a function that is called whenever the
|
||||||
|
// mission control state is updated.
|
||||||
|
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
// TODO(roasbeef): further counters, if vertex continually unavailable,
|
||||||
@@ -124,6 +129,10 @@ type MissionControlConfig struct {
|
|||||||
// Estimator gives probability estimates for node pairs.
|
// Estimator gives probability estimates for node pairs.
|
||||||
Estimator Estimator
|
Estimator Estimator
|
||||||
|
|
||||||
|
// OnConfigUpdate is function that is called whenever the
|
||||||
|
// mission control state is updated.
|
||||||
|
OnConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
|
||||||
|
|
||||||
// MaxMcHistory defines the maximum number of payment results that are
|
// MaxMcHistory defines the maximum number of payment results that are
|
||||||
// held on disk.
|
// held on disk.
|
||||||
MaxMcHistory int
|
MaxMcHistory int
|
||||||
@@ -224,11 +233,14 @@ func NewMissionControl(db kvdb.Backend, self route.Vertex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mc := &MissionControl{
|
mc := &MissionControl{
|
||||||
state: newMissionControlState(cfg.MinFailureRelaxInterval),
|
state: newMissionControlState(
|
||||||
now: time.Now,
|
cfg.MinFailureRelaxInterval,
|
||||||
selfNode: self,
|
),
|
||||||
store: store,
|
now: time.Now,
|
||||||
estimator: cfg.Estimator,
|
selfNode: self,
|
||||||
|
store: store,
|
||||||
|
estimator: cfg.Estimator,
|
||||||
|
onConfigUpdate: cfg.OnConfigUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mc.init(); err != nil {
|
if err := mc.init(); err != nil {
|
||||||
@@ -308,6 +320,11 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
|
|||||||
m.state.minFailureRelaxInterval = cfg.MinFailureRelaxInterval
|
m.state.minFailureRelaxInterval = cfg.MinFailureRelaxInterval
|
||||||
m.estimator = cfg.Estimator
|
m.estimator = cfg.Estimator
|
||||||
|
|
||||||
|
// Execute the callback function if it is set.
|
||||||
|
m.onConfigUpdate.WhenSome(func(f func(cfg *MissionControlConfig)) {
|
||||||
|
f(cfg)
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7061,6 +7061,9 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Propagate the new config level to the main config struct.
|
||||||
|
r.cfg.DebugLevel = req.LevelSpec
|
||||||
|
|
||||||
return &lnrpc.DebugLevelResponse{}, nil
|
return &lnrpc.DebugLevelResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -928,6 +928,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mcCfg := &routing.MissionControlConfig{
|
mcCfg := &routing.MissionControlConfig{
|
||||||
|
OnConfigUpdate: fn.Some(s.UpdateRoutingConfig),
|
||||||
Estimator: estimator,
|
Estimator: estimator,
|
||||||
MaxMcHistory: routingConfig.MaxMcHistory,
|
MaxMcHistory: routingConfig.MaxMcHistory,
|
||||||
McFlushInterval: routingConfig.McFlushInterval,
|
McFlushInterval: routingConfig.McFlushInterval,
|
||||||
@@ -1699,6 +1700,35 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateRoutingConfig is a callback function to update the routing config
|
||||||
|
// values in the main cfg.
|
||||||
|
func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
|
||||||
|
routerCfg := s.cfg.SubRPCServers.RouterRPC
|
||||||
|
|
||||||
|
switch c := cfg.Estimator.Config().(type) {
|
||||||
|
case routing.AprioriConfig:
|
||||||
|
routerCfg.ProbabilityEstimatorType =
|
||||||
|
routing.AprioriEstimatorName
|
||||||
|
|
||||||
|
targetCfg := routerCfg.AprioriConfig
|
||||||
|
targetCfg.PenaltyHalfLife = c.PenaltyHalfLife
|
||||||
|
targetCfg.Weight = c.AprioriWeight
|
||||||
|
targetCfg.CapacityFraction = c.CapacityFraction
|
||||||
|
targetCfg.HopProbability = c.AprioriHopProbability
|
||||||
|
|
||||||
|
case routing.BimodalConfig:
|
||||||
|
routerCfg.ProbabilityEstimatorType =
|
||||||
|
routing.BimodalEstimatorName
|
||||||
|
|
||||||
|
targetCfg := routerCfg.BimodalConfig
|
||||||
|
targetCfg.Scale = int64(c.BimodalScaleMsat)
|
||||||
|
targetCfg.NodeWeight = c.BimodalNodeWeight
|
||||||
|
targetCfg.DecayTime = c.BimodalDecayTime
|
||||||
|
}
|
||||||
|
|
||||||
|
routerCfg.MaxMcHistory = cfg.MaxMcHistory
|
||||||
|
}
|
||||||
|
|
||||||
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
|
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
|
||||||
// used for option_scid_alias channels where the ChannelUpdate to be sent back
|
// used for option_scid_alias channels where the ChannelUpdate to be sent back
|
||||||
// may differ from what is on disk.
|
// may differ from what is on disk.
|
||||||
|
|||||||
Reference in new issue
Block a user