Uh oh!
There was an error while loading. Please reload this page.
Introduce MessageContext and use it to allow abandon failed payments - #3085
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@## main #3085 +/- ##
==========================================
+ Coverage 89.80% 90.27% +0.47%
==========================================
Files 121 121 Lines 99532 102381 +2849 Branches 99532 102381 +2849 ==========================================
+ Hits 89382 92429 +3047 + Misses 7498 7305 -193 + Partials 2652 2647 -5 ☔ View full report in Codecov by Sentry. |
tnull
commented
May 29, 2024
Unfortunately this seems to need a rebase already. |
shaavan
commented
May 30, 2024
shaavan
commented
May 31, 2024
There’s another variation of this PR that might help us achieve our goal using enums. You can check it out here: link to branch (check out the top three commits). This approach will help keep the Let me know which of the two approaches seems better. |
jkczyz
commented
May 31, 2024
@valentinewallace@TheBlueMatt Would you mind checking out the two alternatives for including |
TheBlueMatt
commented
May 31, 2024
Hmm, yea, we need to figure out what we want to do with |
jkczyz
commented
Jun 3, 2024
Presumably, the other TLVs would be
No, I believe we don't set it at all. Last we spoke about it, the thought was to reserve it for internal use. |
TheBlueMatt
commented
Jun 3, 2024
Yea, the "user stuffed data" variant would presumably have this?
I wonder if we should bother? Like, there's nothing special about the TLV the spec says should be the path_id, we can ignore it and no one will ever know. That would simplify the types here a bit. |
jkczyz
commented
Jun 3, 2024
Probably fine to ignore it or just encode the |
jkczyz
commented
Jun 6, 2024
Checking my understanding regarding When a recipient creates a blinded path to itself:
The final recipient (payment or message not specified, but message is then implied):
But then in the rational, the spec uses a payment example:
Later on in the BOLT under the "Onion Messages" section, the writer of
And then the reader:
Then in the rational:
Note how that section talks about reply paths. In LDK, we don't use
IIUC, we shouldn't include a I think that (plus any additional handler checks) would be sufficient to prevent de-anonymization discussed in the quoted rationale sections. @TheBlueMatt@valentinewallace Does that seem to check out? If so, we could drop the |
TheBlueMatt
commented
Jun 10, 2024
Is the attack there basically that someone can take an offer we generated, then request the invoice_request from every node in the network and see who responds (or equivalent for payments)? |
jkczyz
commented
Jun 10, 2024
Really to any node within N hops of the introduction node in one of the offer paths. Though using the |
TheBlueMatt
commented
Jun 10, 2024
Hmm, okay, I think we're talking about different things, then. I think my above-described attack works though, right? Currently anyone can probe all public nodes and figure out if it is the node that issued an LDK offer, I think?
Right, though it seems like if you know the node's pubkey you could do it too? Seems like something we should fix in both cases. |
jkczyz
commented
Jun 10, 2024
Yeah, I was just saying you could limit the search.
Correct. IIUC, the fix would result in an increased offer QR code size. |
TheBlueMatt
commented
Jun 11, 2024
Yep, that's my understanding. Sadly we kinda have to cause this is a big issue :). |
TheBlueMatt
commented
Jun 11, 2024
In any case, as it relates to this PR, ISTM we don't care too much about users using |
jkczyz
commented
Jun 11, 2024
Not sure I understand the suggestion here. We want different variants for each LDK usage so we can tell if the path is used correctly. Having a single variant with a bunch of |
TheBlueMatt
commented
Jun 11, 2024
Right, we're on the same page, my only point is that it seems like we should have a single-level enum, whereas the previous suggestion was a two-level enum. |
jkczyz
commented
Jun 11, 2024
I think the previous suggestion was a struct ( |
TheBlueMatt
commented
Jun 12, 2024
Ah, right, I was thinking we'd just go to a single top-level enum.
Or we could go the other way - have a top-level enum where the LDK-hidden variants contain a struct, that way the user-visible API is simpler. |
jkczyz
commented
Jun 12, 2024
SGTM. Each variant will likely need to hold a struct in order have something to pass to each handler. But, yeah, those structs can be |
jkczyz
commented
Jun 14, 2024
@TheBlueMatt FWIW, it might be simpler in the serialization code if we keep rust-lightning/lightning/src/onion_message/messenger.rs Lines 1703 to 1707 in 07f3380 |
shaavan
commented
Jun 15, 2024
Updated from pr3085.03 to pr3085.04 (diff): Addressed comments from @TheBlueMatt and @jkczyz Changes:
|
64496c4 to
3be2801Compareshaavan
commented
Jul 5, 2024
jkczyz
left a comment
There was a problem hiding this comment.
Pretty much LGTM other than a few last comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| let abandon_if_payment = |context| { | ||
| match context { | ||
| OffersContext::OutboundPayment { payment_id } => self.abandon_payment(payment_id), |
There was a problem hiding this comment.
We have to verify in InvoiceError - users may set a payment_id containing public(ish) data, and we can't let some third party fail all our outbound payments by providing InvoiceErrors.
Uh oh!
There was an error while loading. Please reload this page.
Will be replaced by lightningdevkit#3085.
shaavan
commented
Jul 8, 2024
Updated from pr3085.16 to pr3085.17 (diff):
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
CI is sad because |
1. The path_id will be removed from the codebase in the following commits.
1. New Enum for Enhanced Data Handling: - Introduced the `MessageContext` enum, which allows the node to include additional context data along with the `reply_path` sent to the counterparty. - The node anticipates receiving this data back for further processing. 2. Variants in MessageContext: - The `MessageContext` enum includes two variants: "Offers" and "Context" - One of the variants, `Offers`, holds the `payment_id` of the associated Outbound BOLT12 Payment. 3. Future Usage: - This enum will be utilized in a subsequent commit to abandon outbound payments that have failed to complete for various reasons.
1. Handling Offers Data: - Updated `handle_message` to accept `OffersContext` data as an input field. - If it is present, it will be utilized by the handler to abandon outbound payments that have failed for any reason. 2. Consistency in Custom Message Handling: - Updated `handle_custom_message` to accept optional custom data. for consistency. - Note: `custom_data` will remain unused in this PR.
…t field - Enabled `create_blinded_paths` to accept `MessageContext` TLVs as an input field. - `MessageContext` is intended to be sent along with the `reply_path` to the counterparty. - Added `MessageContext` in the `create_blinded_paths` flow, optionally appending it within the `reply_path`. - Updated tests to verify the new feature.
shaavan
commented
Jul 9, 2024
Updated from pr3085.19 to pr3085.20 (diff):
|
jkczyz
left a comment
There was a problem hiding this comment.
Please update the PR title and summary to reflect name changes.
| /// This data is encrypted by the recipient and remains invisible to anyone else. | ||
| /// It is included in the [`BlindedPath`], making it accessible again to the recipient | ||
| /// whenever the [`BlindedPath`] is used. | ||
| /// The recipient can authenticate the message and utilize it for further processing |
There was a problem hiding this comment.
nit
| /// The recipient can authenticate the message and utilize it for further processing | |
| /// The recipient can use this data to authenticate the message or for further processing |
There was a problem hiding this comment.
I'll update this in #3139 since I'm touching this.
| let abandon_if_payment = |context| { | ||
| match context { | ||
| OffersContext::OutboundPayment { payment_id } => self.abandon_payment(payment_id), |
There was a problem hiding this comment.
I believe the intended spec would be that we have some ability to verify the blinded path itself, which implies maybe a MAC in the blinded path :(
| let abandon_if_payment = |context| { | ||
| match context { | ||
| OffersContext::OutboundPayment { payment_id } => self.abandon_payment(payment_id), |
There was a problem hiding this comment.
Seems weird that this will call through and use PaymentFailureReason::UserAbandoned. ISTM we could just call pending_outbound_payments.abandon_payment manually with a better failure reason. We can do that in a followup/#3139 though.
Resolves#2837
Resolves#3124
Summary
This PR introduces a new field,
MessageContext, in theReceiveTlvsstruct. The key changes are as follows:MessageContext:reply_path, which they expect to receive back from the counterparty along with their response.OffersContextinMessageContext:OffersContextenum introduces a variant containing the Outbound Payment'sPaymentIdfield that can be utilized byOffersMessage.create_blinded_pathflow:MessageContextinto thecreate_blinded_pathprocess.pay_for_offerandcreate_refund_builderfunctions to passPaymentIdalong with the generatedreply_pathand path respectively.These improvements aim to allow passing additional information with the create
reply_pathand managing outbound payment failures more robustly.Note:
This PR builds on #2996