Skip to content

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

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Jun 17, 2025

In this PR I am refactoring the wrapper of the MCF solver to fix some issues
we have seen when building routes in some common corner cases.
It addresses issues: #8339 and #7960.

We also take the opportunity to add a couple of features:

If reviewers are fine with it I can include those features in this PR, otherwise I could
create a separate PR for each them.

This is part of a sequence of refactorings and improvements, last one is #8332.

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

@Lagrang3 Lagrang3 force-pushed the askrene-fix-constraints branch from 425e9cb to a471749 Compare June 23, 2025 11:56
@Lagrang3 Lagrang3 force-pushed the askrene-fix-constraints branch from 57b4471 to be9cde6 Compare July 1, 2025 07:46
Lagrang3 and others added 24 commits July 8, 2025 13:02
Add log information about the runtime of getroutes.

Changelog-None: askrene: add runtime of getroutes to the logs

Signed-off-by: Lagrang3 <[email protected]>
Move the feature tuning algorithm to mcf.c, ie. the loops for searching
a good mu and delay_feefactor to satisfy the problem constraints.

We are looking to set the stage for an execution logic that allows for
multiple choices of routing algorithms, mainly for experimenting without
breaking the default working code.

Changelog-None

Signed-off-by: Lagrang3 <[email protected]>
Simple refactoring.

Stolen entirely from Eduardo.
Signed-off-by: Rusty Russell <[email protected]>
It was originally a wrapper for JSON param() results, but now it's a more
generic struct.  So make it clear that the fields are not optional.  This
means a manual assignment in the initial population of this struct, but
all the users are now far clearer.

Signed-off-by: Rusty Russell <[email protected]>
Refactor MCF solver: remove structs linear_network and residual_network.
Prefer passing raw data to the helper functions.

Changelog-None

Signed-off-by: Lagrang3 <[email protected]>
The single path solver uses the same probability cost and fee cost
estimation of minflow. Single path routes computed this way are
suboptimal with respect to the MCF solution but still are optimal among
any other single path. Computationally is way faster than MCF, therefore
for some trivial payments it should be prefered.

Changelog-None.

Signed-off-by: Lagrang3 <[email protected]>
Changelog-Added: askrene: an optimal single-path solver has been added, it can be called using the developer option --dev_algorithm=single-path or by adding the layer "auto.no_mpp_support"

Signed-off-by: Lagrang3 <[email protected]>
Constraint the number of flow units to 1000 and prune arcs that are
provably not used in the MCF computation.

Changelog-None.

Signed-off-by: Lagrang3 <[email protected]>
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]>
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]>
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.

Changelog-None.

Signed-off-by: Lagrang3 <[email protected]>
and remove unused helper functions.

Changelog-None

Signed-off-by: Lagrang3 <[email protected]>
mcf computation graph

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]>
Take into account htlc overhead in reservations.

Changelog-None

Signed-off-by: Lagrang3 <[email protected]>
@Lagrang3 Lagrang3 force-pushed the askrene-fix-constraints branch from 19ae57b to ab22991 Compare July 9, 2025 20:23
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