Skip to content

Prefactor for Trampoline MPP accumulation#4510

Open
carlaKC wants to merge 12 commits intolightningdevkit:mainfrom
carlaKC:2299-mpp-prefactor
Open

Prefactor for Trampoline MPP accumulation#4510
carlaKC wants to merge 12 commits intolightningdevkit:mainfrom
carlaKC:2299-mpp-prefactor

Conversation

@carlaKC
Copy link
Copy Markdown
Contributor

@carlaKC carlaKC commented Mar 24, 2026

This PR contains a set of refactors pulled out of #4493:

  • Extract common timeout / MPP logic into separate functions
  • Allow construction of blinded trampoline paths
  • Misc constructors + validation

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Mar 24, 2026

👋 I see @valentinewallace was un-assigned.
If you'd like another reviewer assignment, please click here.

@carlaKC carlaKC force-pushed the 2299-mpp-prefactor branch from 40f75a4 to f15271e Compare March 24, 2026 17:19
@ldk-claude-review-bot
Copy link
Copy Markdown
Collaborator

ldk-claude-review-bot commented Mar 24, 2026

I've completed a thorough review of every file and hunk in this PR diff, including reading source code for context around all major changes. I examined:

  1. blinded_path/payment.rs: ForwardTlvsInfo trait, ForwardNode<F> generics, new_for_trampoline constructor, generic blinded_hops and compute_payinfo functions. All trait accessor methods correctly delegate to the corresponding struct fields.

  2. blinded_payment_tests.rs: Replacement of create_blinded_tail with create_trampoline_forward_blinded_tail (verified the new function exists in functional_test_utils.rs with matching parameters).

  3. channelmanager.rs (bulk of the PR):

    • MppPart extraction and HasMppPart trait: Field mapping from ClaimableHTLC to MppPart is correct throughout.
    • check_mpp_timeout: Completion condition (total_intended_recvd_value >= total_mpp_value) correctly mirrors check_claimable_incoming_htlc. Minor difference in timer tick increment order vs old any() short-circuiting, but has no observable effect since timed-out HTLCs are all drained.
    • check_claimable_incoming_htlc: Logic matches old check_total_value! macro.
    • handle_claimable_htlc: committed_to_claimable tracking preserved through Err(bool) return.
    • fail_htlc! macro refactor: htlc_source is correctly pre-constructed before claimable_htlc is moved; all field mappings verified against old macro.
    • claim_funds_from_hop signature change (HTLCPreviousHopData&HTLCPreviousHopData): Method only reads fields (all Copy), never moves the struct. Both call sites already pass references.
    • check_incoming_htlc_cltv: MIN_CLTV_EXPIRY_DELTA parameter correctly passed at both call sites; was previously hardcoded inside the function.
    • previous_hop_data() method: Uses core::slice::from_ref correctly.
    • Serialization: TLV tags unchanged (0, 1, 2, 3, 4, 5, 6, 8, 10). Read/write functions correctly map through mpp_part. Backwards compatibility maintained.
    • PendingHTLCRouting::TrampolineForward: Field rename incoming_shared_secrettrampoline_shared_secret with TLV tag 0 unchanged. trampoline_shared_secret() accessor updated to handle this variant.

No issues found.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 91.08527% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.19%. Comparing base (ab31f99) to head (f15271e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 94.36% 12 Missing ⚠️
lightning/src/blinded_path/payment.rs 75.60% 9 Missing and 1 partial ⚠️
lightning/src/ln/onion_payment.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4510    +/-   ##
========================================
  Coverage   86.19%   86.19%            
========================================
  Files         160      160            
  Lines      107537   107713   +176     
  Branches   107537   107713   +176     
========================================
+ Hits        92693    92848   +155     
- Misses      12220    12238    +18     
- Partials     2624     2627     +3     
Flag Coverage Δ
tests 86.19% <91.08%> (+<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.

@valentinewallace valentinewallace requested review from valentinewallace and removed request for wpaulino March 25, 2026 15:57
@ldk-reviews-bot
Copy link
Copy Markdown

🔔 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
Copy link
Copy Markdown

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

@carlaKC
Copy link
Copy Markdown
Contributor Author

carlaKC commented Mar 30, 2026

Some discussion in the dependent PR, taking @valentinewallace off as a reviewer for now to save some bot-spam.

@carlaKC carlaKC removed the request for review from valentinewallace March 30, 2026 12:30
carlaKC added 12 commits March 30, 2026 16:23
Pull out all fields that are common to incoming claimable and trampoline
MPP HTLCs. This will be used in future commits to accumulate MPP HTLCs
that are part of trampoline forwards - we can't claim these, but need
to accumulate them in the same way as receives before forwarding onwards.
We'll use this shared logic when we need to timeout trampoline HTLCs.

Note that there's a slight behavior change in this commit. Previously,
we'd do a first pass to check out total received value and return
early if we'd reached it without applying a MPP tick to any HTLC.
Now, we'll apply the MPP tick as we accumulate our total value received.

This does not make any difference, because we never MPP-timeout fully
accumulated MPP payments so it doesn't matter if we've applied the
tick when we've reached our full amount.
We'll re-use this to check trampoline MPP timeout in future commits.
In the commit that follows we're going to need to take ownership
of our htlc before this macro is used, so we pull out the information
we need in advance.
We're going to use the same logic for trampoline and for incoming MPP
payments, so we pull this out into a separate function.
To allow re-use with trampoline payments which won't use the
ClaimablePayment type, make handling generic for anything with MPP
parts.
For trampoline payments, we don't want to enforce a minimum cltv delta
between our incoming and outer onion outgoing CLTV because we'll
calculate our delta from the inner trampoline onion's value. However,
we still want to check that we get at least the CLTV that the sending
node intended for us and we still want to validate our incoming value.
Refactor to allow setting a zero delta, for use for trampoline payments.
To use helper functions for either trampoline or regular paths.
To create trampoline forwarding and single hop receiving tails.
@carlaKC carlaKC force-pushed the 2299-mpp-prefactor branch from f15271e to 6aae0dd Compare April 1, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants