rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Default to padding blinded paths

Open TheBlueMatt opened this issue 1 month ago • 5 comments

After much discussion in #3246 we mostly decided to allow
downstream developers to override whatever decisions the
`DefaultMessageRouter` makes regarding blinded path selection by
providing easy overrides for the selected `OnionMessageRouter`. We
did not, however, actually select good defaults for
`DefaultMessageRouter`.

Here we add those defaults, taking advantage of the
`MessageContext` we're given to detect why we're building a blinded
path and selecting blinding and compaction parameters based on it.

Specifically, if the blinded path is not being built for an offers
context, we always use a non-compact blinded path and always pad it
to four hops (including the recipient).

However, if the blinded path is being built for an `Offers` context
which implies it might need to fit in a QR code (or, worse, a
payment onion), we reduce our padding and try to build a compact
blinded path if possible.

We retain the `NodeIdMessageRouter` to disable compact blinded path
creation but use the same path-padding heuristic as for
`DefaultMessageRouter`.

TheBlueMatt avatar Nov 10 '25 15:11 TheBlueMatt

👋 Thanks for assigning @jkczyz 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.

ldk-reviews-bot avatar Nov 10 '25 15:11 ldk-reviews-bot

Codecov Report

:x: Patch coverage is 96.58537% with 7 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 89.35%. Comparing base (e42e74e) to head (f7620fe). :warning: Report is 145 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/offers_tests.rs 94.11% 2 Missing :warning:
lightning/src/offers/invoice.rs 87.50% 2 Missing :warning:
lightning-dns-resolver/src/lib.rs 0.00% 1 Missing :warning:
lightning/src/blinded_path/message.rs 97.50% 1 Missing :warning:
lightning/src/offers/flow.rs 92.30% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4213      +/-   ##
==========================================
+ Coverage   89.33%   89.35%   +0.02%     
==========================================
  Files         180      180              
  Lines      138055   139861    +1806     
  Branches   138055   139861    +1806     
==========================================
+ Hits       123326   124972    +1646     
- Misses      12122    12298     +176     
+ Partials     2607     2591      -16     
Flag Coverage Δ
fuzzing 35.17% <2.29%> (+1.60%) :arrow_up:
tests 88.69% <96.58%> (-0.04%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Nov 10 '25 18:11 codecov[bot]

🔔 1st Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 12 '25 15:11 ldk-reviews-bot

🔔 2nd Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 15 '25 00:11 ldk-reviews-bot

🔔 3rd Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 17 '25 00:11 ldk-reviews-bot

🔔 4th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 19 '25 00:11 ldk-reviews-bot

🔔 5th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 22 '25 00:11 ldk-reviews-bot

🔔 6th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 24 '25 00:11 ldk-reviews-bot

🔔 7th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 26 '25 00:11 ldk-reviews-bot

🔔 8th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Nov 29 '25 00:11 ldk-reviews-bot

🔔 9th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Dec 01 '25 00:12 ldk-reviews-bot

🔔 10th Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Dec 03 '25 00:12 ldk-reviews-bot

👋 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.

ldk-reviews-bot avatar Dec 03 '25 01:12 ldk-reviews-bot

🔔 1st Reminder

Hey @valentinewallace! 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.

ldk-reviews-bot avatar Dec 08 '25 22:12 ldk-reviews-bot

Squashed and updated a few docs/comments:

$ git diff-tree -U2 649ba3478 8efb3e171
diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs
index ffdb2f6403..75e2aaf3c5 100644
--- a/lightning/src/onion_message/functional_tests.rs
+++ b/lightning/src/onion_message/functional_tests.rs
@@ -696,5 +696,6 @@ fn test_blinded_path_padding_for_full_length_path() {
 #[test]
 fn test_blinded_path_compact_padding() {
-	// Check that for a blinded path with compact padding, no extra padding is applied.
+	// Check that for a blinded path with non-SCID intermediate hops with compact padding, no extra
+	// padding is applied.
 	let nodes = create_nodes(4);

@@ -729,5 +730,6 @@ fn test_blinded_path_compact_padding() {
 #[test]
 fn test_compact_blinded_path_compact_padding() {
-	// Check that for a blinded path with compact padding, no extra padding is applied.
+	// Check that for a blinded path with SCID intermediate hops with compact padding, no extra
+	// padding is applied.
 	let nodes = create_nodes(4);

diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs
index d6d4314196..03fc8dd4f7 100644
--- a/lightning/src/onion_message/messenger.rs
+++ b/lightning/src/onion_message/messenger.rs
@@ -773,4 +773,7 @@ where
 /// paths.
 ///
+/// This may be useful in cases where you want a long-lived blinded path and anticipate channel(s)
+/// may close, but connections to specific peers will remain stable.
+///
 /// This message router can only route to a directly connected [`Destination`].
 ///

TheBlueMatt avatar Dec 09 '25 21:12 TheBlueMatt

✅ Added second reviewer: @wpaulino

ldk-reviews-bot avatar Dec 09 '25 21:12 ldk-reviews-bot