⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
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.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Oops sorry I missed this. The comments/description is wrong (there's definitely still fragmentation!) but it seems reasonable to accept it in first-hop cases to ensure we can send our full balance.

I wonder, however, if we shouldn't only do this in cases where we need it - cases where there is no channel to a peer above the amount we're sending.

// Verify the liquidity offered by this channel complies to the minimal contribution.
let contributes_sufficient_value = value_contribution_msat >= minimal_value_contribution_msat;
// For first hops, we allow skipping this if their aggregate capacity meets the
// threshold (they converge immediately, so no real fragmentation occurs).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't true, though. HTLCs aren't merged and there's still fragmentation across separate paths.

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.

3 participants