Skip to content

Conversation

@TheBlueMatt
Copy link
Collaborator

When we have many channels to the same first-hop, many of which do
not have sufficient balance to make the requested payment, but when
some do, instead of simply using the available channel balance we
may switch to MPP, potentially with many, many paths.

Instead, we should seek to use the smallest channel which can
easily handle the requested payment, which we do here by sorting
the first_hops in our router before beginning the graph search.

Note that the "real" fix for this should be to instead decide which
channel to use at HTLC-send time, as most other nodes do during
relay, but this provides a minimal fix without needing to do the
rather-large work of refactoring our HTLC send+relay pipelines.

Issues with overly-aggressive MPP on many channels were reported by
Cash App.

@TheBlueMatt TheBlueMatt added this to the 0.0.106 milestone Mar 18, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2022

Codecov Report

Merging #1370 (3bf47ad) into main (5ed2985) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 3bf47ad differs from pull request most recent head 81ecd4d. Consider uploading reports for the commit 81ecd4d to get more accurate results

@@            Coverage Diff             @@
##             main    #1370      +/-   ##
==========================================
- Coverage   90.75%   90.75%   -0.01%     
==========================================
  Files          73       73              
  Lines       40884    40906      +22     
  Branches    40884    40906      +22     
==========================================
+ Hits        37106    37123      +17     
- Misses       3778     3783       +5     
Impacted Files Coverage Δ
lightning/src/routing/router.rs 92.43% <100.00%> (+0.06%) ⬆️
lightning-invoice/src/de.rs 81.06% <0.00%> (-0.21%) ⬇️
lightning/src/ln/functional_tests.rs 97.09% <0.00%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ed2985...81ecd4d. Read the comment docs.

@jkczyz jkczyz self-requested a review March 19, 2022 03:53
Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Makes sense. Tried some random capacities above and below payment amount, seems to work as advertised

Comment on lines +818 to +825
// First, if channels are below `recommended_value_msat`, sort them in descending order,
// preferring larger channels to avoid splitting the payment into more MPP parts than is
// required.
//
// Second, because simply always sorting in descending order would always use our largest
// available outbound capacity, needlessly fragmenting our available channel capacities,
// sort channels above `recommended_value_msat` in ascending order, preferring channels
// which have enough, but not too much, capacity for the payment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the order of these two paragraphs should be swapped given the conditions are in the opposite order below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found it more readable this way, I'll just swap the conditional.

jkczyz
jkczyz previously approved these changes Mar 23, 2022
When we have many channels to the same first-hop, many of which do
not have sufficient balance to make the requested payment, but when
some do, instead of simply using the available channel balance we
may switch to MPP, potentially with many, many paths.

Instead, we should seek to use the smallest channel which can
easily handle the requested payment, which we do here by sorting
the first_hops in our router before beginning the graph search.

Note that the "real" fix for this should be to instead decide which
channel to use at HTLC-send time, as most other nodes do during
relay, but this provides a minimal fix without needing to do the
rather-large work of refactoring our HTLC send+relay pipelines.

Issues with overly-aggressive MPP on many channels were reported by
Cash App.
@TheBlueMatt TheBlueMatt dismissed stale reviews from jkczyz and valentinewallace via b1bc078 March 23, 2022 21:01
@TheBlueMatt TheBlueMatt force-pushed the 2022-03-pref-first-hop-chans branch from 81ecd4d to b1bc078 Compare March 23, 2022 21:01
@TheBlueMatt
Copy link
Collaborator Author

Squashed without changes.

@TheBlueMatt TheBlueMatt merged commit f6fa8e9 into lightningdevkit:main Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants