-
Notifications
You must be signed in to change notification settings - Fork 952
Askrene: fix constraints #8358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rustyrussell
merged 8 commits into
ElementsProject:master
from
Lagrang3:askrene-fix-constraints
Aug 8, 2025
Merged
Askrene: fix constraints #8358
rustyrussell
merged 8 commits into
ElementsProject:master
from
Lagrang3:askrene-fix-constraints
Aug 8, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
425e9cb
to
a471749
Compare
57b4471
to
be9cde6
Compare
1d475e5
to
73fd757
Compare
73fd757
to
d570cff
Compare
Lagrang3
commented
Jul 17, 2025
d570cff
to
3c2d662
Compare
Try a new way to refine flows, ie. reduce excess due to MCF accuracy and HTLC max constraints after hop amounts are computed with fees included. Changelog-None. Signed-off-by: Lagrang3 <[email protected]>
Changelog-None Signed-off-by: Lagrang3 <[email protected]>
Disable channels with HTLC min violations so that we don't hit them twice when computing routes. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
that can be useful for us in the mcf.c main loop. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
1288efe
to
9fea795
Compare
010a89e
to
1d4e372
Compare
by a small amount if the deliver amount is less than the requested amount by X. This step saves runtime by avoiding calling an extra MCF and it helps us solve a small percentage of cases where the only available routes have HTLCmin that is bigger than X. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
16a7cb1
to
42aa01e
Compare
We use a wrapper around the MCF solver that takes care of finding the best linearization parameters and fixing the flow values to meet the htlc_min and htlc_max constraints. We have reworked the current implementation and made it a bit more similar to renepay's version. Out of 50000 simulated payment situations distributed accross payment amounts of 1e2, 1e3, 1e4, 1e5 and 1e6 sats, we find that 133 failed cases in the master branch turn to success with the current changes, while only 3 success cases in the master are not solved by the changes. master +-------+------+ | S | F | +---+-------+------+ | S | 46329 | 133 | changes +---+-------+------+ | F | 3 | 3535 | +---+-------+------+ Out of the 133 cases that flipped from failure to success the failed reasons were: 122 -> "Could not find route without excessive cost" 5 -> "We couldn't quite afford it" 5 -> "Amount *msat below minimum" 1 -> tripped an HTLC min check Changelog-None. Signed-off-by: Lagrang3 <[email protected]>
and remove unused helper functions. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
that new flows respect the HTLC min/max constraints. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
42aa01e
to
f31c093
Compare
rustyrussell
approved these changes
Aug 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack f31c093
Great work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In this PR I am refactoring the wrapper of the MCF solver and the
refine
procedure in askreneto fix some issues we have seen when building routes in some common corner cases.
It addresses issues: #8339 and #7960.
Results
We have tested (with this tool https://github.com/Lagrang3/askrene-benchmarks/blob/master/test_askrene_bench.py)
the performance of askrene before and after the changes introduced in this PR.
We have found that in a test set of 50000 payment attempts
(random pairs of nodes and amounts from the set
{1e2, 1e3, 1e4, 1e5, 1e6}
) that 133 failed cases using the master branchflip to success in with the changes in this PR, while only 3 cases that were successes in the master become failures
with this PR.
Out of the 133 cases that flipped from failure to success the failed message was attributed to the following:
For completeness we also show the failure cases that remained failure after the changes in this PR:
That means that we are able to fix 5 out of 6 cases of "We couldn't quite afford it".
There is also a significant decrease in runtime for payments around 1000sats (~3x) and significant



less fees for payments around 100sats (~3x):
Tasks
Follow up
In a following PR I will address other issues related to
refine
andmcf
:This is part of a sequence of refactorings and improvements, last one is #8332.