lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.65k stars 2.07k forks source link

[bug]: `lncli getdebuginfo` not showing the current state of config #8793

Closed feelancer21 closed 1 month ago

feelancer21 commented 4 months ago

I used lncli debuglevel to change the debuglevel and lncli setmccfg to change the estimator. In both cases the config under lncli getdebuginfo has not changed. It seems that only the config at the start time is displayed there and not the current state.

guggero commented 4 months ago

Yeah, those two RPCs don't seem to bubble up their changes to the main cfg struct of the RPC server, which should be quite trivial to fix.

MPins commented 4 months ago

Hello ... I've just reproduced the bug ... Can I work on it?

MPins commented 3 months ago

Yeah, those two RPCs don't seem to bubble up their changes to the main cfg struct of the RPC server, which should be quite trivial to fix.

The DebugLevel on main cfg can be updated at the end of the function 'DebugLevel'

On the other hand it seems that I can not access cfg from the function [setCfg] (https://github.com/lightningnetwork/lnd/blob/8adec8692ad2b8e1d1a4023c56ccc6db8ddcce76/cmd/commands/cmd_mission_control.go#L118)

Any Tip? Am I missing something?

guggero commented 3 months ago

You're looking in the wrong place, what you linked to is the Command Line Interface. You'll want to take a look at the server implementation here: https://github.com/lightningnetwork/lnd/blob/789c6bac8ca4b75d15e9e40f8ded8e394df518bb/lnrpc/routerrpc/router_server.go#L948 That then seems to call into this: https://github.com/lightningnetwork/lnd/blob/24080c51f9e37f7230f48b67c72b5da5f1fa6139/routing/missioncontrol.go#L292

Both places don't have access to the main cfg, so it's probably a bit more involved to get things working here. My suggestion would be to pass in a callback into MissionControl that allows the root level config to be updated. That callback would then be set and implemented somewhere here: https://github.com/lightningnetwork/lnd/blob/eaa85920ea1dca750eaa31b6f23c161135df24b0/server.go#L927 where you have s.cfg available.

MPins commented 3 months ago

ssionControl that allows the root level config to be updated. That callback would then be set and implemented somewhere here:

DebugLevel was easy as expected ... done and tested but I'm struggling to understand how to implement, pass and call the callback function... it's a new concept to me ...

feelancer21 commented 3 months ago

DebugLevel was easy as expected ... done and tested but I'm struggling to understand how to implement, pass and call the callback function... it's a new concept to me ...

I think a good example is UpdateForwardingPolicies which is part of the switch. The channel manager updating the policies has only access to a function

https://github.com/lightningnetwork/lnd/blob/68494fd91d69ccdd3e72a5eaca593b6e42babe23/routing/localchans/manager.go#L21-L25

The function is passed here to the manager.

https://github.com/lightningnetwork/lnd/blob/68494fd91d69ccdd3e72a5eaca593b6e42babe23/server.go#L1045-L1050

MPins commented 3 months ago

DebugLevel was easy as expected ... done and tested but I'm struggling to understand how to implement, pass and call the callback function... it's a new concept to me ...

I think a good example is UpdateForwardingPolicies which is part of the switch. The channel manager updating the policies has only access to a function

https://github.com/lightningnetwork/lnd/blob/68494fd91d69ccdd3e72a5eaca593b6e42babe23/routing/localchans/manager.go#L21-L25

The function is passed here to the manager.

https://github.com/lightningnetwork/lnd/blob/68494fd91d69ccdd3e72a5eaca593b6e42babe23/server.go#L1045-L1050

Thank you ... I'll take a look!

MPins commented 3 months ago

Hello @guggero and @feelancer21 this PR fixes the debuglevel updating but the estimator updating (callback function) is not working. Might be something basic that I'm missing ... Any help would be welcome!