Skip to content

[RFC] move the bolt12 invoice inside HTLCSource::OutboundRoute #3719

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vincenzopalazzo
Copy link
Contributor

Matt noted during the last round of review the following:

Oof. Sorry I missed this until now. This is not, in fact, "only used for retries", we use it on claims only, in fact. If a user is relying on the event field for PoP, what this can mean is that we can initiate a send, restart with a stale ChannelManager, notice the payment is pending, then when it claims fail to provide the invoice (only the preimage) to the payer.
In practice, to fix this, we'll need to include the PaidBolt12Invoice in the HTLCSource::OutboundRoute, I believe.

This commit is trying to store the PaidBolt12Invoice inside the HTLCSource::OutboundRoute, but this is not enough because we have to store the invoice also inside the PendingOutboundPayment.

Fixes: #3714

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Apr 8, 2025

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@vincenzopalazzo vincenzopalazzo changed the title move the bolt12 invoice inside HTLCSource::OutboundRoute [RFC] move the bolt12 invoice inside HTLCSource::OutboundRoute Apr 8, 2025
@vincenzopalazzo vincenzopalazzo marked this pull request as ready for review April 14, 2025 17:16
@wpaulino wpaulino requested review from TheBlueMatt and removed request for wpaulino April 14, 2025 18:07
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this all makes sense I think. Sorry to make you undo some of the previous patch.

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@vincenzopalazzo vincenzopalazzo force-pushed the macros/pop-with-persistance branch 3 times, most recently from 637983d to 5c25caf Compare April 22, 2025 17:54
@vincenzopalazzo
Copy link
Contributor Author

Thanks Matt! I rebased on the main to fix the commit checks and addressed some of the review comments. We should be good for another round

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @wpaulino

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually looks good, but there's still quite a few FIXMEs left, do you want to address those?

@@ -705,7 +707,8 @@ impl core::hash::Hash for HTLCSource {
0u8.hash(hasher);
prev_hop_data.hash(hasher);
},
HTLCSource::OutboundRoute { path, session_priv, payment_id, first_hop_htlc_msat } => {
// FIXME(vincenzopalazzo): we can ignore the bolt12_invoice here?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't, no.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basic idea here is that with or without bolt12 the the struct hash should be unique anyway? due we will pay the invoice one time.

However, if we want to add also the bolt12, I think I need to make the bolt12 invoice hashable, which requires some derive macros along the 'hierarchy' of the struct

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @wpaulino! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@vincenzopalazzo
Copy link
Contributor Author

Jumping in finishing this tomorrow, sorry for the delay!

Matt noted during the last round of review the following:

>Oof. Sorry I missed this until now. This is not, in fact, "only used for retries", we use it on claims only, in fact. If a user is relying on the event field for PoP, what this can mean is that we can initiate a send, restart with a stale ChannelManager, notice the payment is pending, then when it claims fail to provide the invoice (only the preimage) to the payer.
>In practice, to fix this, we'll need to include the PaidBolt12Invoice in the HTLCSource::OutboundRoute, I believe.

This commit is trying to store the PaidBolt12Invoice inside the HTLCSource::OutboundRoute, but
this is not enough because we have to store the invoice also inside the PendingOutboundPayment.

Link: lightningdevkit#3714
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo vincenzopalazzo force-pushed the macros/pop-with-persistance branch from 94cadd5 to 19ba769 Compare April 26, 2025 12:32
@vincenzopalazzo vincenzopalazzo force-pushed the macros/pop-with-persistance branch from 19ba769 to 6af45f9 Compare April 26, 2025 12:49
Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Project coverage is 89.10%. Comparing base (c6921fa) to head (b7ea0de).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/offers/signer.rs 0.00% 4 Missing ⚠️
lightning/src/ln/outbound_payment.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3719      +/-   ##
==========================================
- Coverage   89.15%   89.10%   -0.06%     
==========================================
  Files         156      157       +1     
  Lines      123837   123868      +31     
  Branches   123837   123868      +31     
==========================================
- Hits       110408   110373      -35     
- Misses      10754    10806      +52     
- Partials     2675     2689      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo vincenzopalazzo force-pushed the macros/pop-with-persistance branch from 6af45f9 to b7ea0de Compare April 26, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix (or doc, for 0.2) missing Event::PaymentSent::bolt12_invoice on payments loaded from monitors
3 participants