Skip to content

Commit 0aced5c

Browse files
authored
Merge pull request #8857 from MPins/issue-8793
Fixing the current state update when lncli debuglevel and lncli setmccfg are called
2 parents 77c7f77 + 4dda2e2 commit 0aced5c

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

docs/release-notes/release-notes-0.19.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
# Bug Fixes
2121

22+
* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/8857) to correctly
23+
propagate mission control and debug level config values to the main LND config
24+
struct so that the GetDebugInfo response is accurate.
25+
2226
# New Features
2327
## Functional Enhancements
2428
## RPC Additions
@@ -53,4 +57,5 @@
5357

5458
# Contributors (Alphabetical Order)
5559

60+
* Pins
5661
* Ziggie

routing/missioncontrol.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/btcsuite/btcd/btcutil"
1010
"github.com/lightningnetwork/lnd/channeldb"
11+
"github.com/lightningnetwork/lnd/fn"
1112
"github.com/lightningnetwork/lnd/kvdb"
1213
"github.com/lightningnetwork/lnd/lnwire"
1314
"github.com/lightningnetwork/lnd/routing/route"
@@ -110,6 +111,10 @@ type MissionControl struct {
110111
// results that mission control collects.
111112
estimator Estimator
112113

114+
// onConfigUpdate is a function that is called whenever the
115+
// mission control state is updated.
116+
onConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
117+
113118
sync.Mutex
114119

115120
// TODO(roasbeef): further counters, if vertex continually unavailable,
@@ -124,6 +129,10 @@ type MissionControlConfig struct {
124129
// Estimator gives probability estimates for node pairs.
125130
Estimator Estimator
126131

132+
// OnConfigUpdate is function that is called whenever the
133+
// mission control state is updated.
134+
OnConfigUpdate fn.Option[func(cfg *MissionControlConfig)]
135+
127136
// MaxMcHistory defines the maximum number of payment results that are
128137
// held on disk.
129138
MaxMcHistory int
@@ -224,11 +233,14 @@ func NewMissionControl(db kvdb.Backend, self route.Vertex,
224233
}
225234

226235
mc := &MissionControl{
227-
state: newMissionControlState(cfg.MinFailureRelaxInterval),
228-
now: time.Now,
229-
selfNode: self,
230-
store: store,
231-
estimator: cfg.Estimator,
236+
state: newMissionControlState(
237+
cfg.MinFailureRelaxInterval,
238+
),
239+
now: time.Now,
240+
selfNode: self,
241+
store: store,
242+
estimator: cfg.Estimator,
243+
onConfigUpdate: cfg.OnConfigUpdate,
232244
}
233245

234246
if err := mc.init(); err != nil {
@@ -308,6 +320,11 @@ func (m *MissionControl) SetConfig(cfg *MissionControlConfig) error {
308320
m.state.minFailureRelaxInterval = cfg.MinFailureRelaxInterval
309321
m.estimator = cfg.Estimator
310322

323+
// Execute the callback function if it is set.
324+
m.onConfigUpdate.WhenSome(func(f func(cfg *MissionControlConfig)) {
325+
f(cfg)
326+
})
327+
311328
return nil
312329
}
313330

rpcserver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7061,6 +7061,9 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
70617061
return nil, err
70627062
}
70637063

7064+
// Propagate the new config level to the main config struct.
7065+
r.cfg.DebugLevel = req.LevelSpec
7066+
70647067
return &lnrpc.DebugLevelResponse{}, nil
70657068
}
70667069

server.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
928928
}
929929

930930
mcCfg := &routing.MissionControlConfig{
931+
OnConfigUpdate: fn.Some(s.UpdateRoutingConfig),
931932
Estimator: estimator,
932933
MaxMcHistory: routingConfig.MaxMcHistory,
933934
McFlushInterval: routingConfig.McFlushInterval,
@@ -1699,6 +1700,35 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
16991700
return s, nil
17001701
}
17011702

1703+
// UpdateRoutingConfig is a callback function to update the routing config
1704+
// values in the main cfg.
1705+
func (s *server) UpdateRoutingConfig(cfg *routing.MissionControlConfig) {
1706+
routerCfg := s.cfg.SubRPCServers.RouterRPC
1707+
1708+
switch c := cfg.Estimator.Config().(type) {
1709+
case routing.AprioriConfig:
1710+
routerCfg.ProbabilityEstimatorType =
1711+
routing.AprioriEstimatorName
1712+
1713+
targetCfg := routerCfg.AprioriConfig
1714+
targetCfg.PenaltyHalfLife = c.PenaltyHalfLife
1715+
targetCfg.Weight = c.AprioriWeight
1716+
targetCfg.CapacityFraction = c.CapacityFraction
1717+
targetCfg.HopProbability = c.AprioriHopProbability
1718+
1719+
case routing.BimodalConfig:
1720+
routerCfg.ProbabilityEstimatorType =
1721+
routing.BimodalEstimatorName
1722+
1723+
targetCfg := routerCfg.BimodalConfig
1724+
targetCfg.Scale = int64(c.BimodalScaleMsat)
1725+
targetCfg.NodeWeight = c.BimodalNodeWeight
1726+
targetCfg.DecayTime = c.BimodalDecayTime
1727+
}
1728+
1729+
routerCfg.MaxMcHistory = cfg.MaxMcHistory
1730+
}
1731+
17021732
// signAliasUpdate takes a ChannelUpdate and returns the signature. This is
17031733
// used for option_scid_alias channels where the ChannelUpdate to be sent back
17041734
// may differ from what is on disk.

0 commit comments

Comments
 (0)