Skip to content

Conversation

@martinsaposnic
Copy link
Contributor

The routing fragmentation mitigation heuristic requires each channel to contribute at least payment_amount / max_path_count to avoid excessive path splitting. This makes sense for network paths where each additional path incurs base fees and increases failure probability.

However, for first hops this is overly restrictive. Multiple channels to the same peer converge immediately at the first hop - there's no actual network-level fragmentation. A 2M sat channel and a 48M sat channel to the same peer should be usable together for a 50M sat payment, but currently the small channel gets rejected (threshold would be 5M sat with default max_path_count=10), leaving only 48M available.

This change checks the aggregate capacity across all first-hop channels to a peer. If the aggregate meets the contribution threshold, individual channels are allowed regardless of their size.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 21, 2026

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

The routing fragmentation mitigation heuristic requires each channel to
contribute at least `payment_amount / max_path_count` to avoid excessive
path splitting. This makes sense for network paths where each additional
path incurs base fees and increases failure probability.

However, for first hops this is overly restrictive. Multiple channels to
the same peer converge immediately at the first hop - there's no actual
network-level fragmentation. A 2M sat channel and a 48M sat channel to
the same peer should be usable together for a 50M sat payment, but
currently the small channel gets rejected (threshold would be 5M sat
with default max_path_count=10), leaving only 48M available.

This change checks the aggregate capacity across all first-hop channels
to a peer. If the aggregate meets the contribution threshold, individual
channels are allowed regardless of their size.
@martinsaposnic martinsaposnic force-pushed the first-hop-aggregate-fragmentation-check branch from 0aa525f to 6c8ab68 Compare January 21, 2026 22:34
@martinsaposnic martinsaposnic marked this pull request as draft January 21, 2026 22:37
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 94.64286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.84%. Comparing base (7785360) to head (6c8ab68).

Files with missing lines Patch % Lines
lightning/src/routing/router.rs 94.64% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4331      +/-   ##
==========================================
- Coverage   86.53%   85.84%   -0.70%     
==========================================
  Files         158      156       -2     
  Lines      103188   102869     -319     
  Branches   103188   102869     -319     
==========================================
- Hits        89292    88303     -989     
- Misses      11471    12000     +529     
- Partials     2425     2566     +141     
Flag Coverage Δ
fuzzing ?
tests 85.84% <94.64%> (+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.

Sign up for free to 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.

2 participants