Repository navigation
Initialisation of lightning-background-prober - #2397
007harshmahajan wants to merge 11 commits into
Conversation
|
If this is standalone module and this can be its own rust crate, I would recommend to have it in its own new repository still under the We have already the following modules (code accounting at
From a viewpoint of backward compatibility, inter-operability and security of an open-source project like LDK, where ultimately you have user funds safety involved for marginal mistake, a conservative approach would be to have all (non-critical and non-default) utilities crates to be moved in their own repository to have their own maintenance cycles (quite at the image of how the Linux kernel “cascade” development is organized). My thinking only, and my apologies if it’s a “cold shower” for a first contribution. Independently of this more organizational review feedback, a background prober for LDK is a good idea! |
Hmm, we don't have a policy in the org for this kinda thing. Historically for any other Rust crates which are run as a part of an LDK node in one form or another, we've mostly put them in the same repo (just as separate crates in the workspace). There are two real exceptions - (a) One really nice thing with pieces being in the same repo is it allows us to run CI across the whole set of "LDK crates", updating them in lock-step as APIs change. With multiple repos that isn't really practical and creates some burden on the release steps.
I strongly disagree with this. Keeping it all in one repo keeps everything visible to all contributors, and for a relatively small project where that's still tenable, I see no reason to change that.
Linux is one repository, with one build-system and one release cycle, across many modules and sub-modules. I wouldn't mind that :) |
Yeah for
Yes, I share the observation than having all the crates under the same repo means we can run everything on the same CI or fuzzing infrastructure, rather than every crates team re-doing the boring work here. And moving the API in lock-step yes reduce the silent breakage.
Keeping everything visible to all contributors is a good point, on the other hand it means we’ll have issues in term of review process scalability. A thing like a It sounds to me it’s more a question of maintenance and release cycles, in the sense of being able to have things like On the other hand, if we do so it’s better than maintainers start to be more “domain experts” a la Linux, as I wouldn’t be okay to have
Sure on the one build-system, what I like with Linux culture is the clear’s |
a32ae0e to
4a04b0c
Compare
|
Let us know what kind of feedback you're looking for here - mostly I'd recommend you not worry too much about building all the infrastructure up here and focus on the single method of "okay, its time to probe again, given a |
+1 if we think it’s breaking something of existent interface or bad interference with Lightning network, we’ll let it know during review. Would be very nice to have proving infra in LDK :) |
|
It seems that the problem stated "okay, its time to probe again, given a NetworkGraph and ProbabilisticScorer who do I choose to target with my probe", has some satisfactory solution with 2 specific method in last commit |
|
Hmm. Focusing on the nodes with the most channels isn't a bad idea, but I think just doing normal route-finding isn't super great. One thing we want to consider is having a custom |
|
So the thing is lightning network is big and dynamic, probing for all channel is neither feasible nor practical, because if we are about to know complete graph knowledge, it changes and doing sending node a payment at same time would overwhelm Also, complete probing has be its new repo (same as |
|
Right, I didn't mean to imply that we should week to gather knowledge about every single channel in the network, indeed that's not really practical, nor useful. However, if there are three "preferred" paths for us to get to node C, and we learn that the first path is good, probing that same path over and over and over again isn't all that interesting - we aren't learning anything new, and we're wasting network resources to do so. Rather, it'd be very nice to use our probing to also learn a bit about the other two paths that we think look good, that way when our first-choice paths fails we have some information about other choices, rather than flying completely blind. |
|
Yes, that would work great, I would try to implement that soon |
It might even be worth to take a look at some advanced graph algorithms to find some paths that provide optimal coverage of a set of picked edges or nodes with as little as possible overlap. In contrast to our usual on-device routing, it might be worth to optimize the background prober for probing capital efficiency rather than algorithmic runtime. |
|
Well, due to time constrains its was implemented with |
jkczyz
left a comment
There was a problem hiding this comment.
Discussed offline. Let's clean up value_selector and make sure it is thoroughly documented and all cases are unit tested.
| let vec_len = node_rating.probes.len(); | ||
|
|
||
| if vec_len == 0 { |
There was a problem hiding this comment.
Why do we need a Vec for probes? What's the significance of checking its length?
There was a problem hiding this comment.
It is used to know number of probes send till now, as first probe values depend on max_htlc_list and channel_capacity_list, I didnt found any good method, without any counter (It might not be updated correctly) or Vec.len()
There was a problem hiding this comment.
It is used to know number of probes send till now, as first probe values depend on
max_htlc_listandchannel_capacity_list,
Could you describe in detail how the Vec is used? I'm not entirely convinced it is necessary. Does the number of probes in the Vec ever decrease? We can't have a data structure that is constantly growing.
I didnt found any good method, without any counter (It might not be updated correctly) or
Vec.len()
I'm not sure what you mean by this.
There was a problem hiding this comment.
There has to be some counter to know "How many probes has been sent to target_node" and Vec keeps count of that alonge with various info like probe_value, as we discussed First probe, don't have any knowledge of path, hence it uses min(max_htlc_list[0].1, capacity_list[0].1.unwrap())
If Vec.len() == 0 hence no probe has been sent
else if Vec.len() == 1 hence 1 probe has been sent
And for every newly network graph graph, which is currently 24hrs, complete NodeRating (Local Probe persister) will be dropped and new instance will be created
There was a problem hiding this comment.
There has to be some counter to know "How many probes has been sent to
target_node" andVeckeeps count of that alonge with various info likeprobe_value, as we discussed First probe, don't have any knowledge of path, hence it usesmin(max_htlc_list[0].1, capacity_list[0].1.unwrap())If
Vec.len() == 0hence no probe has been sent else ifVec.len() == 1hence 1 probe has been sent
Why not an Option? When would we need to know about more than one probe?
And for every newly network graph graph, which is currently 24hrs, complete
NodeRating(Local Probe persister) will be dropped and new instance will be created
That's still needlessly using memory that isn't needed during the 24 hours, no?
There was a problem hiding this comment.
Got your point, it only need 2 probes persisted, one is 'last successful probe' and second is 'last probe', will make the required changes
| return val | ||
| } | ||
| ProbeStatus::Failure => { | ||
| let val = (0.5*((value) as f64)).floor() as u64; |
There was a problem hiding this comment.
Integer division should be sufficient.
| if let Some(last_probe) = node_rating.probes.last_mut() { | ||
| last_probe.update_path(path); | ||
| last_probe.update_value(val); | ||
| } |
There was a problem hiding this comment.
I don't quite follow the logic. What's the purpose of this?
| node_rating.probes.push(ProbePersister::new(nodeid)); | ||
| if let Some(last_probe) = node_rating.probes.last_mut() { | ||
| last_probe.update_path(path); | ||
| last_probe.update_value(val); | ||
| } |
There was a problem hiding this comment.
Seems like you can set these before inserting into the Vec?
| let val_mid = node_rating.probes.get(vec_len-2).unwrap().value.unwrap(); | ||
| let val = (0.5*((value + val_mid) as f64)).floor() as u64; |
There was a problem hiding this comment.
Other than these lines, it looks like the else block is entirely the same as the preceding else if block. Could you write this to avoid repeating yourself?
| //Value selector for probing (Uses binary search method) | ||
| async fn value_selector ( |
There was a problem hiding this comment.
Please add more thorough documentation.
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #2397 +/- ##
==========================================
- Coverage 90.58% 90.45% -0.14%
==========================================
Files 110 111 +1
Lines 57526 57922 +396
Branches 57526 57922 +396
==========================================
+ Hits 52112 52392 +280
- Misses 5414 5530 +116
☔ View full report in Codecov by Sentry. |
|
@TheBlueMatt and @jkczyz I would like to get some direction for this project going forward
|
Will discuss offline, but I don't believe there is much code here for us to use without substantial changes to work in LDK's event model and without a heavy amount of review cycles. |
| if let a = max_htlc_list.is_empty() { | ||
| // only if max_htlc_list is empty and last_probe == None | ||
| // DEFAULT_FINAL_VALUE_MSAT = 1000 | ||
| return DEFAULT_FINAL_VALUE_MSAT; | ||
| } |
There was a problem hiding this comment.
This pattern will always match, so the early return is hit and none of the code that follows would ever be executed.
If you remove #![allow(warnings)], the compiler will tell you:
warning: irrefutable `if let` pattern
--> lightning-background-prober/src/lib.rs:657:9
|
657 | if let a = max_htlc_list.is_empty() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this pattern will always match, so the `if let` is useless
= help: consider replacing the `if let` with a `let`
= note: `#[warn(irrefutable_let_patterns)]` on by default
You'll want:
if max_htlc_list.is_empty() {
return DEFAULT_FINAL_VALUE_MSAT;
}Likewise in a few other places below. So seems like you are missing some test coverage.
|
Gonna go ahead and close this as abandoned. While it was a valiant effort, I think biting off a bit less in any new attempt would be good - simply focus on a single public function that takes a NetworkGraph and returns a |
This library basically provides payment channel probing as standalone service