-
Notifications
You must be signed in to change notification settings - Fork 411
Disable MPP routing when the payee does not support it #827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable MPP routing when the payee does not support it #827
Conversation
8a18913
to
fc7227b
Compare
Codecov Report
@@ Coverage Diff @@
## main #827 +/- ##
==========================================
+ Coverage 90.97% 90.99% +0.01%
==========================================
Files 48 48
Lines 26538 26583 +45
==========================================
+ Hits 24144 24189 +45
Misses 2394 2394
Continue to review full report at Codecov.
|
Ah, I think this needs to add |
fc7227b
to
babda7b
Compare
Oops! Indeed, pushed an update to include |
I don't know much about how we pass features over the codebase, but integration with ACK babda7b |
babda7b
to
ed824a5
Compare
ed824a5
to
9811e81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this fails to build on 1.30.0 and 1.34.2. I guess because of #821? Not sure why that wasn't caught there. :(
lightning/src/routing/router.rs
Outdated
/// Without this, any knowledge we have of the payee's features may be used if they are available | ||
/// in the network graph, however MPP routing will be disabled and routing is more likely to fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a bit clearer as:
s/features may be used if they are available in the network graph/features may be used in the network graph if they are available
Or set off "if they are available" as "(if available)".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote it a bunch more.
lightning/src/routing/router.rs
Outdated
/// Without this, any knowledge we have of the payee's features may be used if they are available | ||
/// in the network graph, however MPP routing will be disabled and routing is more likely to fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar nit: "however" is not a coordinating conjunction
Either replace it with "but" or use a semi-colon or start a new sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part of the sentence was stale anyway :)
|
||
#[bench] | ||
fn generate_mpp_routes(bench: &mut Bencher) { | ||
let mut d = File::open("net_graph-2021-02-12.bin").expect("Please fetch https://bitcoin.ninja/ldk-net_graph-879e309c128-2020-02-12.bin and place it at lightning/net_graph-2021-02-12.bin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that generate_routes
has been failing on continuous integration. Does this need to be setup there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I was braindead when MPP got merged - a last-minute change caused the benchmark to fail due to a bug. It should be fixed in #815, but I'm still working on finishing it. I'm gonna move bindings out of the main repo today so that we get PRs to be all-green normally, making it harder to miss a red X.
In the past we skipped doing this since invoice parsing occurs in a different crate. However, we need to accept InvoiceFeatures in routing now that we support MPP route collection, to detect if we can select multiple paths or not. Further, we should probably take rust-lightning-invoice as either a module or a subcrate in this repo.
9811e81
to
a43905c
Compare
Oops, yea, rebased and fixed the build. |
@@ -328,7 +328,7 @@ fn compute_fees(amount_msat: u64, channel_fees: RoutingFees) -> Option<u64> { | |||
/// The fees on channels from us to next-hops are ignored (as they are assumed to all be | |||
/// equal), however the enabled/disabled bit on such channels as well as the | |||
/// htlc_minimum_msat/htlc_maximum_msat *are* checked as they may change based on the receiving node. | |||
pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, payee: &PublicKey, first_hops: Option<&[&ChannelDetails]>, | |||
pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, payee: &PublicKey, payee_features: Option<InvoiceFeatures>, first_hops: Option<&[&ChannelDetails]>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level question on how this should be used:
Rather than passing in None
in a ton of places, would it be preferable for the caller to modify the returned route? Or maybe instead provide some sort of wrapper that given an InvoiceFeatures
calls get_route
and updates the returned value as necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I strongly think its not preferable to have the user modify the Route
object. While its all visible, it really shouldn't fall to the user to figure out how to tweak it properly. If you're worried about the number of arguments, we could pull them out into an args struct, but the types/argument names are all pretty clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was leaning more to the second option of adding something like get_route_using_features
which delegates to get_route
and then updates the result before returning. Then get_route
doesn't need an extra parameter and all those call sites taking None
, which isn't very readable (what is None
for?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case the None-or-not also impacts how we build the route (MPP or not), so we can't just drop it and copy it into the route at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow. Isn't lines 969-974 doing just that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but lines 402-411 is also checking the features object provided to decide if we can use MPP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's what I get for looking at just one commit. :P I still wonder if we could come up with a better API, which would probably easier to do if get_route
was refactor into smaller functions. I feel like passing None
in places is similar to passing a bool
. Just makes reading code difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to hold up on this, BTW. We could take a more wholistic look at the APIs later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, generally agree, it definitely makes some tests harder. That said, in "real" applications it'd be somewhat "wrong" to pass None in any of the fields - the last-hop hints and invoice features should be at least be passed if they're present.
We currently only use it to override the graph-specific features returned in the route, though we should also use it to enable or disable MPP. Note that tests which relied on MPP behavior have had all of their get_route calls upgraded to provide the MPP flag.
a43905c
to
b9fef85
Compare
Squashed. Lets follow up on further API improvements in followup PRs if it looks bad in eg the sample node or in Overtorment's work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⭐ I've been using this in the sample for a while as well.
We really need to provide a features object to show the router if the payee supports MPP, which we do through a new
InvoiceFeatures
object.