routing: allow runtime updates to mission control config#4909
Conversation
bhandras
left a comment
There was a problem hiding this comment.
Pretty straightforward changes and nice refactoring along the way.
My only real comment is that since we can change the mission control config during route calculation (since locking is per point) we may create an unwanted path as a result. It's very unlikely as a single user but may be likely as service provider. I'd consider fixing that too, although it's probably not a huge deal.
There was a problem hiding this comment.
I'm a bit unsure about using integer percents for the probability. Maybe better to use floats since it results in simpler code and also less confusing? Also for weight?
|
Just from a high level look, I'm wondering if we can do this without introducing race conditions? Even though we get/set the config behind a mutex, |
I thought I'd checked all of these, but looks like |
|
@carlaKC I was thinking about places like this: https://github.com/lightningnetwork/lnd/blob/d7ecde2972bfb949c6df717d53ebfbb3283de90b/routing/probability_estimator.go#L82 One alternative to swapping out the mission control config, is to create a new MissionControl with the new config and swap that out instead. |
daac715 to
7318702
Compare
We are going to use the config struct to allow getting and setting of the mission control config in the commits that follow. Self node is not something we want to change, so we move it out for better separation.
All of the other mission control exported functions acquire their locks immediately, and do not lock in the subsequent unexported functions. This commit moves the lock up for the report payment functions so that mission control's config values are covered by this lock, in preparation for allowing config to be updated at runtime. Moving this lock means that we will hold the lock for the additional time it takes to store a single result, AddResult, to the store.
In preparation for allowing live update of mc config, we extract our probability estimator cfg for easy update and add validation.
| control more willing to try hops that we have no information about, lower | ||
| values will discourage trying these hops. | ||
| */ | ||
| float hop_probability = 2; |
|
Perhaps it is worth documenting in the proto that the runtime settings will only be in effect until the next restart. An alternative would be to hot-reload the config file, either automatically or via a cli command (similar to |
|
I think just adding to the doc that it won't be persisted is good enough for now? |
Indeed, will add some comments on the rpc making a note of it.
I think this would be a nice feature to have, but likely a larger project since not everybody runs lnd with a config file. Although it's kicking the can down the road a bit, I'd like to go ahead with adding this rpc because mission control is a pretty underused feature IMO, and surfacing it will help people experiment with it. If we find ourselves exposing other config rpcs, then it's time to talk hot reload. |
I don't think that there's a clean way to do this, without restructuring the way payment sessions use mission control quite significantly, which I'm not sure is worth the effort.
If we do run into problems here, I think there could be an option to provide specific MC params for an individual payment, so that you can specify exactly what you want for that route. WDYT? |
| "rely on historical results, expressed as " + | ||
| "value in [0;1]", | ||
| }, cli.UintFlag{ | ||
| Name: "pmtnr", |
If the value is just the number of seconds, why is it described as a unix timestamp? |
Shouldn't be, fix in #5078. |
…ssion control config
…rical-sync * commit 'b444ae37125d32eaab1d68e73c4b1b12bf6451bc': backport lightningnetwork#5061 - routing: add mission control import rpc backport lightningnetwork#4909 - routing: allow runtime updates to mission control config
This PR adds the ability to get and set mission control's config via rpc, allowing for experimentation with these values without a restart.
Since we already have locking in mission control, we can just acquire the lock and update the cfg.