Skip to content

Trampoline forwarding - #3976

Closed
a-mpch wants to merge 4 commits into
lightningdevkit:mainfrom
a-mpch:2025-07-trampoline-forwarding
Closed

Trampoline forwarding#3976
a-mpch wants to merge 4 commits into
lightningdevkit:mainfrom
a-mpch:2025-07-trampoline-forwarding

Conversation

@a-mpch

@a-mpcha-mpch commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

Supersedes #3711
Rebase and fixes to a sooner main branch.

Some changes from the previous branch:

  • Changes how we handle the unblinded receiving without hardcoded values
  • Takes into account refactor changes of errors names and attributable errors.
  • Moves logic to outbound_payment.rs and actually trampolines retry if some error appears and we take care of not sending payment events.
  • Fixes tests for unblinded and blinded scenarios

What's missing:

  • Keep trampoline routing disabled (accept suggestions)

@ldk-reviews-bot

ldk-reviews-bot commented Jul 30, 2025

Copy link
Copy Markdown

👋 Hi! This PR is now in draft status.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

Comment threadlightning/src/ln/channelmanager.rs Outdated

#[cfg(not(any(test, feature = "_test_utils")))]
let retry_strategy = Retry::Attempts(3);
#[cfg(any(test, feature = "_test_utils"))]

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Not really a fan on this one, I'd accept any idea

@a-mpch

Copy link
Copy Markdown
ContributorAuthor

drafting while rebasing again and fixing minor issues of CI

@a-mpch
a-mpch marked this pull request as draft July 30, 2025 23:16
a-mpchand others added 3 commits July 31, 2025 10:26
Ensure that the Trampolin onion's amount and CLTV values does not exceed
the limitations imposed by the outer onion.
Co-authored-by: Arik Sosman <git@arik.io>
To process errors returned from downstream nodes when forwarding between
Trampoline nodes, we need to store information beyond what's available
in `HTLCPreviousHopData`, suc as the used hops as the newly generated
outer onion's session_priv.
To that end, we add a new variant to `HTLCSource` in this commit, which
futre-proofs mapping an outbound forward to an incoming MPP.
Co-authored-by: Arik Sosman <git@arik.io>
The previously existing `HTLCDestination` do not map nicely to the
failure vent of a Trampoline forward, so we introduce a new variant to
fill the gap.
Co-authored-by: Arik Sosman <git@arik.io>
{
// We use Unkonwn Failure code instead of TemporaryTrampolineFailure because errors uses u16 bolt04 codes.
let payment_failed_conditions = PaymentFailedConditions::new()
.expected_htlc_error_data(LocalHTLCFailureReason::UnknownFailureCode { code: 16409 }, &[0; 0]);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Not really sure on testing like this or just add the TemporaryTrampolineFailure

@a-mpch
a-mpchforce-pushed the 2025-07-trampoline-forwarding branch 2 times, most recently from 4a72640 to ef09262CompareAugust 1, 2025 14:44
@codecov

codecovBot commented Aug 1, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.20710% with 225 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.91%. Comparing base (664511b) to head (3d2fe8d).
⚠️ Report is 1138 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/channelmanager.rs83.05%80 Missing and 10 partials ⚠️
lightning/src/ln/outbound_payment.rs71.56%56 Missing and 4 partials ⚠️
lightning/src/ln/onion_payment.rs52.43%38 Missing and 1 partial ⚠️
lightning/src/ln/onion_utils.rs67.46%26 Missing and 1 partial ⚠️
lightning/src/ln/blinded_payment_tests.rs98.85%5 Missing and 2 partials ⚠️
lightning/src/chain/channelmonitor.rs50.00%2 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #3976 +/- ##
=========================================
Coverage 88.91% 88.91% =========================================
Files 174 174 Lines 124232 125526 +1294 Branches 124232 125526 +1294 =========================================
+ Hits 110455 111610 +1155 - Misses 11301 11419 +118 - Partials 2476 2497 +21 
FlagCoverage Δ
fuzzing22.43% <12.77%> (-0.18%)⬇️
tests88.74% <85.20%> (+<0.01%)⬆️

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

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

In this commit, we expand our forwarding logic to do ad-hoc pathfinding
to subsequent Trampoline nodes, covering both blinded and unblinded scenarios.
We set a constant for retrying payments in Trampoline nodes up to 3 failures.
We further modify our error propagation logic to handle Trampoline forward
HTLC failures.
Co-authored-by: Arik Sosman <git@arik.io>
@carlaKC

Copy link
Copy Markdown
Contributor

Replaced with #4414.

@carlaKCcarlaKC closed this Feb 12, 2026
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.

3 participants

@a-mpch@ldk-reviews-bot@carlaKC