Skip to content

Allow blinded path diversification by expanding create_blinded_paths - #3087

Merged
TheBlueMatt merged 3 commits into
lightningdevkit:mainfrom
shaavan:reply_path_diversity
Jul 16, 2024
Merged

Allow blinded path diversification by expanding create_blinded_paths#3087
TheBlueMatt merged 3 commits into
lightningdevkit:mainfrom
shaavan:reply_path_diversity

Conversation

@shaavan

Copy link
Copy Markdown
Member
  • The current usage of blinded_paths is limited because create_blinded_path only returns a single BlindedPath.
  • This PR expands the functionality of create_blinded_path by allowing it to return multiple BlindedPaths, as determined by the new count parameter.
  • Additionally, this PR integrates this new capability throughout the codebase by:
    • Allowing multiple paths in offers and refund builders.
    • Sending Offers Response messages, such as InvoiceRequest (in pay_for_offer) and Invoice (in request_refund_payment), using multiple reply paths.
  • As a proof-of-concept, this PR increases the maximum count of create_blinded_paths to 10, enabling the generation of more reply paths. It also increases the number of blinded_paths used in offer and refund builders and responders to 5, demonstrating the usage of multiple reply paths.

@jkczyz
jkczyz self-requested a review May 31, 2024 19:56
@codecov-commenter

codecov-commenter commented May 31, 2024

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.78%. Comparing base (78c0eaa) to head (957b337).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@ Coverage Diff @@## main #3087 +/- ##
==========================================
- Coverage 89.80% 89.78% -0.02% 
==========================================
Files 121 121 Lines 100045 100207 +162 Branches 100045 100207 +162 ==========================================
+ Hits 89845 89975 +130 - Misses 7533 7558 +25 - Partials 2667 2674 +7 

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

Comment threadlightning/src/onion_message/messenger.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/offers/offer.rs Outdated
Comment threadlightning/src/offers/refund.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.01 to pr3087.02 (diff):
Addressed @jkczyz comment

Changes:

  1. Remove the redundant MAX_PATHS constant and the associated debug_assert!
  2. Reduce the number of paths created in offers, and refund builder to 1, and introduce a TODO comment.
  3. Refactor the path functions
  4. Update pay_for_offer to allow setting REQUEST_LIMIT to the number of messages created, instead of the number of the path used. Also updated the comment accordingly.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from f0c2e7d to f32a93aCompareJune 3, 2024 18:48
Comment threadlightning/src/ln/channelmanager.rs
Comment threadlightning/src/ln/channelmanager.rs
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs
@shaavan
shaavanforce-pushed the reply_path_diversity branch from f32a93a to c8e7993CompareJune 6, 2024 14:24
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.02 to pr3087.03 (diff):
Changes:

  1. Rebase on main.

Comment threadlightning/src/onion_message/messenger.rs Outdated
@shaavan
shaavanforce-pushed the reply_path_diversity branch from c8e7993 to 4032289CompareJune 6, 2024 14:36
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.03 to pr3087.04 (diff):
Addressed @jkczyz comments

Changes:

  1. Move the and_then call to the call, and revert the Offer and Refund Builder path functions to the original. The function again adds only a single path to offer/refund paths.
  2. Refactored the pay_for_offer code to remove redundant clonings.
  3. Updated request_refund_payment to use similar REQUEST_LIMIT as pay_for_offer.
  4. Introduce a constant MAX_REPLY_PATHS to pay_for_offer and request_refund_payment.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from 4032289 to 56013beCompareJune 10, 2024 14:04
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.04 to pr3087.05 (diff):
Addressed @TheBlueMatt and @jkczyz

Updates:

  1. Reverted changes to MessageRouter's create_blinded_paths.
  2. Update the create_blinded_path function to return the entire vector returned by create_blinded_paths, and hence remove the count parameter.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from 56013be to b6e38c2CompareJune 10, 2024 14:17
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.05 to pr3087.06 (diff):

Changes:

  1. Rebase on main.
  2. Also update create_blinded_path_using_absolute_expiry and create_compact_blinded_path to return Vec<BlindedPath>

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/onion_message/messenger.rs Outdated
@shaavan
shaavanforce-pushed the reply_path_diversity branch from b6e38c2 to 4461115CompareJune 12, 2024 07:46
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.06 to pr3087.07 (diff):
Addressed @jkczyz comment

Changes:

  1. Reverted the changes in onion_messenger.rs as they were not affecting the behavior.
  2. Updated function names and docs to better suit their roles.
  3. Remove the TODO comment as the exact interface is to be decided.

Comment threadlightning/src/ln/channelmanager.rs
TheBlueMatt
TheBlueMatt previously approved these changes Jun 13, 2024
Comment threadlightning/src/ln/channelmanager.rs Outdated

@jbesraajbesraa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good
Is it worth adding a test to cover the new code?

@jkczyz

Copy link
Copy Markdown
Contributor

Looks good Is it worth adding a test to cover the new code?

Chatted with @shaavan earlier today about how to go about testing this.

@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.07 to pr3087.08 (diff):
Addressed @TheBlueMatt, @jbesraa comment

Changes:

  1. Pulled REQUEST_LIMIT into a global const, and renamed it to OFFERS_MESSAGE_REQUEST_LIMIT.
  2. Introduce a test to check the new behavior.

Thanks, @jkczyz, for the pointers and inspirations for the testing.

TheBlueMatt
TheBlueMatt previously approved these changes Jun 28, 2024
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs
@shaavan
shaavanforce-pushed the reply_path_diversity branch from f541586 to 94354f3CompareJune 29, 2024 13:17
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.09 to pr3087.10 (diff):
Addressed @jbesraa comments

Changes:

  1. Referenced the PaymentId in the const's documentation.

Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
Comment threadlightning/src/ln/channelmanager.rs Outdated
@shaavan
shaavanforce-pushed the reply_path_diversity branch from 94354f3 to 0354d8dCompareJuly 2, 2024 09:12
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.10 to pr3087.11 (diff):
Addressed @jkczyz comments

Changes:

  1. Replace invoices -> requests to match the context the word is used.
  2. Remove the reference for PaymentId since it's already used in the file.

Comment threadlightning/src/ln/offers_tests.rs Outdated
@shaavan
shaavanforce-pushed the reply_path_diversity branch from 0354d8d to 43e821cCompareJuly 5, 2024 13:02
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.11 to pr3087.12 (diff):
Addressed @jkczyz comment

Changes:

  1. Update extract_invoice() to also return the corresponding reply_path.
  2. Introduce reply_path_diversification test for refund case.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from 43e821c to 893f62dCompareJuly 5, 2024 13:16
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.12 to pr3087.13 (diff):

Changes:

  1. Rebase on main.
  2. Change the return type of extract_invoice() from (Bolt12Invoice, BlindedPath) -> (Bolt12Invoice, Option<BlindedPath>), to avoid some test failures.

Comment threadlightning/src/ln/offers_tests.rs
Comment threadlightning/src/ln/offers_tests.rs
Comment threadlightning/src/ln/offers_tests.rs Outdated
fn extract_invoice<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessage) -> (Bolt12Invoice, Option<BlindedPath>) {
match node.onion_messenger.peel_onion_message(message) {
Ok(PeeledOnion::Receive(message, _, _)) => match message {
Ok(PeeledOnion::Receive(message, _, reply_path)) => match message {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As a follow-up PR, could you start including a reply path with invoices for offers? We should have the capability now, but we just haven't updated ChannelManager's implementation of OffersMessageHandler yet.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sure! Added it to the task list! 🚀

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Comment threadlightning/src/ln/channelmanager.rs Outdated
@shaavan
shaavanforce-pushed the reply_path_diversity branch from 893f62d to 212ade4CompareJuly 9, 2024 13:08
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.13 to pr3087.14 (diff):
Addressed @jkczyz comments

Updates:

  1. Rename added test, to be more explicit.
  2. Update added const comment to be more clear.

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change looks good. I went through the tests and noted where we should remove checks that aren't relevant to the new behavior. There may be tests where we are asserting more than necessary, but might as well avoid doing that in newer tests.

Comment threadlightning/src/ln/offers_tests.rs Outdated
Comment threadlightning/src/ln/offers_tests.rs Outdated
Comment threadlightning/src/ln/offers_tests.rs Outdated
Comment threadlightning/src/ln/offers_tests.rs Outdated
Comment threadlightning/src/ln/offers_tests.rs Outdated
Comment threadlightning/src/ln/offers_tests.rs Outdated
…ication
- Previously, the `create_blinded_path` function was limited to
returning a single `BlindedPath`, which restricted the usage of
`blinded_paths`.
- This commit extends the `create_blinded_path` function to return
the entire blinded path vector generated by the `MessageRouter`'s
`create_blinded_paths`.
- The updated functionality is integrated across the codebase, enabling
the sending of Offers Response messages, such as `InvoiceRequest`
(in `pay_for_offer`) and `Invoice` (in `request_refund_payment`),
utilizing multiple reply paths.
- This will be utilised in the following commit for a test.
@shaavan
shaavanforce-pushed the reply_path_diversity branch from 212ade4 to f5aa883CompareJuly 11, 2024 13:48
@shaavan

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.14 to pr3087.15 (diff):

Updates:

  1. Rebase on main to resolve merge conflicts.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from 0e16cdb to e6bb965CompareJuly 11, 2024 14:02

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Please squash the fixup.

@shaavan
shaavanforce-pushed the reply_path_diversity branch from e6bb965 to a643112CompareJuly 12, 2024 14:13
@shaavan
shaavanforce-pushed the reply_path_diversity branch from a643112 to 957b337CompareJuly 12, 2024 14:16
@shaavan

shaavan commented Jul 12, 2024

Copy link
Copy Markdown
MemberAuthor

Updated from pr3087.16 to pr3087.17 (diff):
Addressed @jkczyz comment

  1. Squashed the f: commits together.
  2. Fixed one failing test by reintroducing an important line of code.

@TheBlueMattTheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Diff since @jkczyz's "LGTM" is trivial, so landing:

$ git diff-tree -U2 e6bb965bcd3fede82b956c5abb17d6e501c8d9af 957b33712ad3d5a7aed624e4f565887817fd9944
diff --git a/lightning/src/ln/offers_tests.rs b/lightning/src/ln/offers_tests.rs
index 2eddb1991..cdd78d02c 100644
--- a/lightning/src/ln/offers_tests.rs+++ b/lightning/src/ln/offers_tests.rs@@ -1019,4 +1019,6 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
expect_recent_payment!(alice, RecentPaymentDetails::AwaitingInvoice, payment_id);
+	let _expected_invoice = david.node.request_refund_payment(&refund).unwrap();+
connect_peers(david, bob);
$ 

@TheBlueMatt
TheBlueMatt merged commit 6ed398d into lightningdevkit:mainJul 16, 2024
@shaavan
shaavan deleted the reply_path_diversity branch July 17, 2024 10:44
Sign up for freeto 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.

5 participants

@shaavan@codecov-commenter@jkczyz@TheBlueMatt@jbesraa