Skip to content

Xpay limit parts #8448

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
merged 3 commits into from
Aug 15, 2025
Merged

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Aug 13, 2025

This PR attempts to limit the number of payment routes in xpay and askrene.
The solution proposed should be considered only a patch, because the algorithm is far
from optimal.

Solves issue #8331

Important

25.09 FREEZE July 28TH: Non-bugfix PRs not ready by this date will wait for 25.12.

RC1 is scheduled on August 11th

The final release is scheduled for September 1st.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • 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.

"description": [
"Maximum number of pending routes at any given time."
],
"default": "6"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What could be a good default value for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should only restrict it if:

  1. We have more than 6, AND
  2. We get a rejection from the penultimate node.

A bit more complex (we must not ask for getroutes again if our maxparts has dropped), but avoids exposing this to users!

Copy link
Collaborator Author

@Lagrang3 Lagrang3 Aug 14, 2025

Choose a reason for hiding this comment

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

I see... Let me for the time being remove the option from the schema and flag maxparts as a developer option.

@Lagrang3 Lagrang3 marked this pull request as ready for review August 13, 2025 13:03
@Lagrang3 Lagrang3 requested a review from cdecker as a code owner August 13, 2025 13:03
@Lagrang3 Lagrang3 added this to the v25.09 milestone Aug 13, 2025
"description": [
"Maximum number of pending routes at any given time."
],
"default": "6"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should only restrict it if:

  1. We have more than 6, AND
  2. We get a rejection from the penultimate node.

A bit more complex (we must not ask for getroutes again if our maxparts has dropped), but avoids exposing this to users!

@Lagrang3 Lagrang3 force-pushed the xpay-limit-parts branch 2 times, most recently from 00ccf25 to 0c93959 Compare August 14, 2025 10:27
remove_flows is a helper function to remove flows from a set so that we
keep the number of flows limited.

Signed-off-by: Lagrang3 <[email protected]>
Changelog-Added: askrene: add a new parameter maxparts to getroutes that limits the number of routes in the solution.

Signed-off-by: Lagrang3 <[email protected]>
dev_maxparts limits the number of pending routes allowed at any given
time.

Changelog-None

Signed-off-by: Lagrang3 <[email protected]>
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack f953656

Since we're close to release, this is OK, but can we open an issue to autodetect this overcrowing problem and then reduce?

asort(*flows, tal_count(*flows), reverse_cmp_flows, NULL);
for (size_t count = tal_count(*flows); n > 0; n--, count--) {
assert(count > 0);
tal_arr_remove(flows, count - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

You didn't free the flow when you removed it? I think you'll want this helper later, so:

static void remove_and_free_flow(struct flow ***flows, size_t i)
{
tal_free((*flows)[i]);
tal_arr_remove(flows, i);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

But in this case it doesn't leak, so we can leave this neatning until later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Removal was handled in the first version but I forgot after the changes.
Will do.

@rustyrussell rustyrussell enabled auto-merge (rebase) August 15, 2025 06:03
@rustyrussell rustyrussell merged commit 1830c0e into ElementsProject:master Aug 15, 2025
74 of 78 checks passed
@Lagrang3 Lagrang3 deleted the xpay-limit-parts branch August 15, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants