Skip to content

Xpay limit path length 26.06 - #9656

Open
Lagrang3 wants to merge 9 commits into
ElementsProject:release-26.06.9from
Lagrang3:xpay-limit-path-length-26.06
Open

Lagrang3 wants to merge 9 commits into
ElementsProject:release-26.06.9from
Lagrang3:xpay-limit-path-length-26.06

Conversation

@Lagrang3

@Lagrang3 Lagrang3 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Similar to #9627, but with a little hack to call maxhops on askrene without needing to modify the RPC.
It is rebased on top of v26.06.9

Add onion budget and payload constructors to the internal xpay API.
Onion budget computation can be used to know a realistic number of hops
that constraints our payment before calling askrene.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Changed: xpay: computes a budget for the number of hops in the payment depending on the final payload and blinded paths, it can fail early if the onion packet doesn't fit

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
@Lagrang3
Lagrang3 requested a review from cdecker as a code owner October 23, 2026 08:53
@Lagrang3
Lagrang3 force-pushed the xpay-limit-path-length-26.06 branch from bba4723 to 8598598 Compare October 23, 2026 10:30
@cdecker

cdecker commented Oct 23, 2026

Copy link
Copy Markdown
Member

I think you may have accidentally rebadged on top of some other branch that is not part of master yet, making the diff unreadable. Can you strip the PR to just your intended changes?

@Lagrang3
Lagrang3 changed the base branch from release-26.06.8 to release-26.06.9 October 26, 2026 08:35
@Lagrang3
Lagrang3 force-pushed the xpay-limit-path-length-26.06 branch from 8598598 to 3d04549 Compare October 26, 2026 08:36
@Lagrang3 Lagrang3 mentioned this pull request Oct 27, 2026
6 tasks done
Added an homogeneous and constant cost to every hop in the MCF solver.

test_real_data shows a slight decrease of paths lengths by looking at
the path length histograms

SLOW_MACHINE=0
histogram before {2: 1, 3: 8, 4: 34, 5: 77, 6: 45, 7: 23, 8: 4}
histogram after {2: 2, 3: 59, 4: 110, 5: 5, 6: 5}

SLOW_MACHINE=1
histograms before {2: 1, 3: 3, 4: 11, 5: 15, 6: 6, 7: 6, 8: 3}
histogram after {2: 2, 3: 16, 4: 18, 5: 1, 6: 5}

the most frequent path length moves from 5 to 4 and there aren't more
than 6 hops in any given path.

Another consequence of the additional per hop cost is a slight reduction
in the number paths (or payment parts) per route query.  Even though our linear
approximation gives equal cost to 3 paths of length 1 than to 1 path of
length 3.

in test_real_data this is shown by the expected_first_success (the
number of success computations in the first loop) and
expected_total_paths (the total number of parts for those successes,
also the sum of values in the histogram).

For SLOW_MACHINE=0 we get a mean parts per payment of
expected_total_paths / expected_first_success = 192 / 95 = 2.02
that becomes
expected_total_paths / expected_first_success = 181 / 95 = 1.90

For SLOW_MACHINE=1 we get a mean parts per payment of
expected_total_paths / expected_first_success = 45 / 24 = 1.87
that becomes
expected_total_paths / expected_first_success = 42 / 24 = 1.75

Changelog-Changed: askrene-getroutes: penalizes every extra hop in every route with an homogeneous and constant probability of failure of 1%, as a consequence askrene will slightly prefer smaller routes and fewer payment parts.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Treat all cost features as the same type of variable.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Use cost dials normalized to 1 to combine the cost of different
features.  This is a generalization of the mu factor combination with
medians ratio applied to more than 2 features: fees and delays.

Just like that fee constraining got slightly better.
Before mu (the corresponding fee dial) started at 1% and increased
linearly in chunks of 10%.  Now every dial is increased by a factor of 2
per iteration and it approximates 1 asymptotically as the dials are
renormalized at each iteration.  We have a cut-off at 1 - 1e-6, that
means 27 iterations until mu reaches the cut-off.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
No updates to the RPC, no need to run as developer.  We inject the
maxhops value through a layer name.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Fail early if we see detect a suggestion that a pair of cost dials are
racing each other.  We are not likely to find a solution and we would
just waste cycles.  This usually means that our method is not able to
find a solution that satisfies all given constraints.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Fixed: xpay: Clamp the length of the payment routes using askrene's maxhops option aiming at producing routes that fit the data limits in the onion packet.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
@Lagrang3
Lagrang3 force-pushed the xpay-limit-path-length-26.06 branch from 3d04549 to d5d2044 Compare October 27, 2026 18:07
@madelinevibes madelinevibes added this to the v26.12 milestone Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants