Skip to content

Askrene single path solver #8299

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented May 19, 2025

With this PR I want to include an internal API to askrene to compute optimally reliable
single path payments. It uses the same costs functions as the minimum cost flow solver
but with the additional constraint that only a single path solution will be considered.
In practice this is solved with the execution of Dijkstra best path algorithm therefore it is likely
to produce orders of magnitude (~x100?) faster run times.

This option can be activated by calling getroutes with the layer auto.no_mpp_support
or with the developer flag --dev_algorithm=single-path.

We used to compute single path routes by first doing a MCF computation and then
discarding all but one path which is computationally expensive and not even optimal.

We may use this single path computation with small payment amounts or situations for which MPP
is not supported or if time to solution is a concern.

Depends on #8163 and #7932.

TODO:

  • documentation
  • tests
  • benchmarks

Add log information about the runtime of getroutes.

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

Signed-off-by: Lagrang3 <[email protected]>
@Lagrang3 Lagrang3 force-pushed the askrene-single-path-solver branch from 0d0c36d to 444524a Compare May 28, 2025 07:54
@Lagrang3 Lagrang3 requested a review from renepickhardt May 28, 2025 08:05
@Lagrang3 Lagrang3 force-pushed the askrene-single-path-solver branch 4 times, most recently from f84f5ec to 6bc2ba4 Compare June 2, 2025 07:40
@Lagrang3
Copy link
Collaborator Author

Lagrang3 commented Jun 2, 2025

I benchmarked the single path solver in comparison to the MPP default solver
on the compressed gossmap "./tests/data/gossip-store-2024-09-22.compressed"
by simulating a payment from node 3301 to the first ordered 500* nodes,
the amount is 1M sat and maximum fee set to 1k sat.

The success rate for MPP is 82% while single path is 77%.

bench

I wanted to test the routing to the first 1000 nodes but askrene crashed while trying to reach node 785, this bug can also be reproduced in the master branch. I am digging into it.
The bug is a bad memory access due to miss interpretation of operator precedence: *flow[i] vs (*flow)[i].
It is fixed in the preceding PR #8163 where the bug was introduced.

@Lagrang3 Lagrang3 changed the title [WIP] Askrene single path solver Askrene single path solver Jun 2, 2025
@Lagrang3 Lagrang3 requested a review from rustyrussell June 2, 2025 10:26
@Lagrang3 Lagrang3 marked this pull request as ready for review June 2, 2025 10:26
@Lagrang3 Lagrang3 requested a review from cdecker as a code owner June 2, 2025 10:26
Lagrang3 added 8 commits June 3, 2025 10:37
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]>
Prefer the following programming pattern:

do_getroutes(){
        do_something1();
        do_something2();
        do_something3();
}

rather than

get_routes(){
        do_something1();
        do_something2();
}

do_getroutes(){
        get_routes();
        do_something3();
}

Changelog-None

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

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

1 participant