-
Notifications
You must be signed in to change notification settings - Fork 367
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
Support MPP Keysend #2156
Support MPP Keysend #2156
Conversation
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 #2156 +/- ##
==========================================
+ Coverage 90.87% 91.83% +0.96%
==========================================
Files 104 104
Lines 52789 68099 +15310
Branches 52789 68099 +15310
==========================================
+ Hits 47972 62540 +14568
- Misses 4817 5559 +742
☔ View full report in Codecov by Sentry. |
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, this also doesn't check that all parts have the same payment secret, I think. Its also going to conflict with passing the payment_metadata out through the receive pipeline. If its alright I'm gonna do some of the piping in there, we can merge that first, and that should simplify this sone.
Sure sounds good! |
And yea I initially thought we didn't need to validate the payment secret since the preimage is serving the same role here, but I realize even then people probably should still be sending all parts with at least the same secret + it'll be good to keep things consistent with normal MPPs. |
Okay, let me know what you think on #2127, that should simplify things here a bit. |
2127 landed, looks like this is good for rebase. |
Thanks for the heads up! Planning to get to this today or tomorrow |
3622a42
to
8e83b7a
Compare
8e83b7a
to
2cdc2e9
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.
Still going through an initial pass, but looks good :)
Not exactly related to the PR, but I think we can consolidate a good chunk of the logic in process_pending_htlc_forwards
by always calling check_total_value
for keysends now: https://pastebin.com/mTCLQxaS
79a249e
to
93f61e8
Compare
This DRY of |
@TheBlueMatt I have some questions on this.
Do these requested changes make sense, before I send alec on a wild goose chase? |
I disagree, while its true that we should generally not be sending a payment secret (or, in fact, payment metadata) for a keysend where we haven't communicated with the recipient or are doing MPP, we may have communicated with the recipient and still want to use keysend, in which case we'll want to be able to fill in the other fields. More generally, part of the point of
Right, I'm not sure what the exact right API is here, its kinda awkward to have the keysend methods also take the secret and then only actually work if you set the secret correctly corresponding to if you did multipath or not. Then again, lnd also will reject multipath keysends anyway, so its not like we're not always running that risk with such an API. Worse still, we separately take a Maybe we have a separate |
Or maybe we just have an |
Maybe lnd would be open to upstreaming this change? It looks like a few line change. Maybe a stopgap could be to support receiving MPP keysends but not sending? |
We'll also want to update |
I think we should support sending, just make very clear what's going on in the |
93f61e8
to
40d4bd0
Compare
For how to handle the Otherwise, is the problem here lnd-specific or that generally not all implementations support receiving MPP keysend + there’s not a good way to signal support for it (since keysend means no invoice to communicate features + other contexts' feature bits supporting MPP and keysend individually don’t necessarily signal support for MPP keysend, and MPP keysend doesn’t have its own feature bit)? If anyone knows off the top of their head about eclair and cln that’d be appreciated otherwise I can take a look soon.
I haven't looked at the routing code much, but if our payee doesn't support MPP keysend, will there be a chance that we end up using a multi-part route and getting the payment failed when we should've just used a single path route? Or if there's a single path route would that generally be preferred, in which case setting this feature by default would only really help us out if our payee does support it? Also added a to do list in the description to keep track of some of the things I still gotta get around to :) |
I'm tentatively with this idea, plus documentation that lnd doesn't accept mpp keysends. I'm not sure about an lnd-specific method, because I don't think wallets generally have logic to detect which lightning implementation they're sending to, so how usable would this bespoke api be? Also, worth noting that I don't think said api would decrease overall failures rates that much, we'd just fail at pathfinding instead of at the destination (which is preferable, ofc). |
I'd kinda prefer we not override what the user says. As long as the method names (and documentation) are super clear on That said, its not exactly super critical, ideally they'd use a custom TLV for that or the new metadata field, rather than the secret, which has a more specific purpose.
Indeed, its not really lnd specific because LDK also doesn't support it! As y'all both noted there's no way to detect it cause there's no invoice. Instead of blaming lnd in our API, we could instead go for keysend and mpp_keysend to differentiate them without focusing on an implementation, noting in the docs mpp_keysend isnt widely supported (just lnd now).
If we set mpp_supported in the payee info, it'll maybe get used, if we don't it'll only use a single-path route (or fail if it cant find one). |
Heh, sorry this went off the rails, do we have (rough) consensus on the way forward here? I'm vaguely happy with really any of the above options, even if I prefer one or another, its all a bit of a mess. |
Yea sorry for the delay, I'll be getting back to this soon, I should be good to push some changes within the next couple of days based on everything we've discussed |
40d4bd0
to
96c5941
Compare
Made a bunch of changes, annotating main things here:
|
db29939
to
a73104e
Compare
a73104e
to
67d45d1
Compare
CI is gonna fail until I squash since I made some changes to the tests (eventually fixed in 0b35ab8) Btw thanks a ton for all the review as always @TheBlueMatt @valentinewallace! |
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.
This looks good to me. Can you squash the fixup commits down into a clean git history?
To support receiving MPP keysends, we will add a new non-backward compatible field to `PendingHTLCRouting::ReceiveKeysend`, which will break deserialization of `ChannelManager` on downgrades, so we allow the user choose whether they want to do this. Note that this commit only adds the config flag, while full MPP support is added in later commits.
67d45d1
to
981d62f
Compare
Squashed! Also rewrote some of the commit messages/descriptions to make them a bit more intuitive, but the overall commits remained the same |
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 but the test looks borked.
db8d619
to
6aa9589
Compare
LGTM, feel free to squash and we can get another review pass from @valentinewallace |
6aa9589
to
16fced0
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.
Just some docs nits, LGTM! Sorry for the delay
When routing a keysend payment, the user may want to signal to the router whether to find multi-path routes in the `PaymentParameters::for_keysend` helper, without going through manual construction. Since some implementations do not support MPP keysend, we have the user make the choice here rather than making it the default. Some implementations will reject keysend payments with payment secrets, so this commit also adds docs to `RecipientOnionFields` to communicate this to the user.
This commit adds the field `payment_data: FinalOnionHopData` to `ReceiveKeysend` which will allow us to check for payment secrets and total amounts which is needed to support receiving MPP keysends. This field is non-backwards compatible since we wouldn't be able to handle an MPP keysend properly if we were to downgrade to a prior version. We also no longer reject keysends with payment secrets if we support MPP keysend.
This commit refactors a significant portion of the receive validation in `ChannelManager::process_pending_htlc_forwards` now that we repurpose previous MPP validation logic to accomodate keysends. This also removes a previous restriction on claiming, as well as tests sending and receiving MPP keysends.
The logic has been changed around duplicate keysend payments such that it's no longer explicitly clear that we reject duplicate keysend payments now that we handle receiving multi-part keysends. This test catches that. Note that this also tests that we reject MPP keysends when our config states we should, and that we reject MPP keysends without payemnt secrets when our config states we support MPP keysends.
9db962c
16fced0
to
9db962c
Compare
Thanks for all the review! |
Closes #1222. This implements everything needed to support sending and receiving MPP keysend.
Some implementations reject keysend payments with payment secrets (we do before this PR) so we try and communicate to the user in
RecipientOnionFields
that they should be aware of this. There's also no great way to signal/tell when a node supports this so we leave it up to the user to decide when they want to route/send MPP keysends.Since MPP keysend requires a payment secret which previously was not included in
PendingHTLCRouting::ReceiveKeysend
, downgrading can break deserialization, and so we also include a new flagUserConfig::accept_mpp_keysend
to allow the user to opt-in to receive support.