Skip to content
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

renepay: bugfix assertion htlc_total<=known_max #7574

Merged

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Aug 14, 2024

Make knowledge update and removal of pending HTLCs atomic to avoid race conditions.
A quick and dirty solution: comment the assertion making sure the rest of the code in linearize_channel can handle the
offending cases (for which known_max<htlc_total).

Fixes #7535.

@Lagrang3 Lagrang3 added this to the v24.08 milestone Aug 14, 2024
@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch from d07117d to 5d13c82 Compare August 14, 2024 20:12
@Lagrang3 Lagrang3 marked this pull request as ready for review August 14, 2024 20:22
@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch from 7aa263b to 77684a1 Compare August 15, 2024 06:56
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 77684a1

@Lagrang3
Copy link
Collaborator Author

Tests have just discovered a bug:

plugin-cln-renepay: Payment failed: minflow couldn't find a feasible flow: flowset_probability failed on MaxFlow phase: in-flight (1008080540msat) exceeds known_max (978718000msat)

@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch 2 times, most recently from b87b113 to 9c968d8 Compare August 16, 2024 09:03
@Lagrang3
Copy link
Collaborator Author

Lagrang3 commented Aug 16, 2024

Fixed some failed checks. It is confusing, even for me, the fact that we have sometimes flows with fees and some other times flows without fees (because MCF have flow conservation, fees cannot be transported). After the release I think a good approach
could be to use a different type for flows without fees, eg. struct flow and flows with fees struct route; and ensure
consistency everywhere.

Rebased on top of v24.08rc2 to fix conflicts.

@Lagrang3 Lagrang3 mentioned this pull request Aug 16, 2024
@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch from 4161c2e to 88dcfc9 Compare August 19, 2024 12:18
In theory we should not have htlc_total<=known_max.
But for some strange race condition we do sometimes.
Until we find a solution to ensure the correct state
of the uncertainty network we remove the assertion.
Thanks to signed arithmetic and MIN guards, the rest
of the code in linearize_channel can handle the
weird cases with known_max<htlc_total.

Signed-off-by: Lagrang3 <[email protected]>
- add more checks
- add more error messages
- compute probabilities without fees during MCF
- compute probabilities with fees during get_routes

Signed-off-by: Lagrang3 <[email protected]>
Reserved HTLCs were underestimated by floor (mathematical function)
use ceil instead.

Signed-off-by: Lagrang3 <[email protected]>
Refresh gossmap once before we read the routehints.
Make sure that if channels in the routehints are public,
we retrieve their capacities from gossip.

Signed-off-by: Lagrang3 <[email protected]>
Add a little bit of uncertainty to the local channels to avoid
consuming precisely all spendable_msat on our side, which leads to
temporary channel failure if the spendable_msat changes during the
course of the payment.

Signed-off-by: Lagrang3 <[email protected]>
Channel filter must apply to the modified gossmap+localmods,
otherwise we disable local channels with htlcmax=0.

Signed-off-by: Lagrang3 <[email protected]>
@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch from 88dcfc9 to bc38f2d Compare August 19, 2024 12:37
@Lagrang3
Copy link
Collaborator Author

Rebased

@Lagrang3 Lagrang3 force-pushed the renepay-bugfix-htlctotal branch from bc38f2d to b5f9734 Compare August 19, 2024 13:27
@ShahanaFarooqui
Copy link
Collaborator

ACK b5f9734

@ShahanaFarooqui ShahanaFarooqui merged commit 62a86cc into ElementsProject:master Aug 19, 2024
37 checks passed
@ShahanaFarooqui ShahanaFarooqui linked an issue Aug 19, 2024 that may be closed by this pull request
@Lagrang3 Lagrang3 deleted the renepay-bugfix-htlctotal branch August 19, 2024 20:32
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.

renepay crash on linearize_channel
3 participants