-
Notifications
You must be signed in to change notification settings - Fork 906
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
pay: fix re-adding payment amount back to estimated capacity #7188
pay: fix re-adding payment amount back to estimated capacity #7188
Conversation
Very interesting, I don't have an explanation either, because afaik the evaluation order for boolean expressions is left-to-right and the function should only be called if |
This is brilliant! The old code:
So, unless the add overflowed, it immediately subtracted again! This whole function is problematic, but your fix is minimal. I'll build a cleanup PR on top... |
Oh, can you add a Changelog-Fixed line to the first commit message please? e.g. Changelog-Fixed: Plugins: |
Oh wow I can't believe I didn't see that! |
5f5696c
to
524ef81
Compare
Changelog-Fixed: Plugins: pay now correctly estimates channel capacity after payment failure, fixing some retry cases. The `estimated_capacity` was properly substracted from the channel hint, but adding the amount back did not work. The amount was added back and then immediately substracted again. This caused the `estimated_capacity` to ever decrease. This commit makes sure re-adding the amount to the `estimated_capacity` works as expected.
Tests whether we're able to route around a low-fee channel in the graph. We should be able to find the more expensive route if the cheaper route is depleted.
524ef81
to
8433c27
Compare
@rustyrussell added that text to the commit message and rebased |
Fixes #7177
Below lines of code failed to actually re-add the amount back to the channel hint's estimated capacity.
lightning/plugins/libplugin-pay.c
Lines 586 to 589 in 4b8d261
I'm not sure why tbh, it seems like a reasonable piece of code. However, it made the corresponding test (added in this PR) fail, because the channel hint's estimated capacity of the sender's own channel was below the amount he was trying to send. I tested this by logging the
channel_hints
before and after the operation in those lines. When substracting the amount (remove == false
) the estimated capacity of the sender's channel after the operation was smaller than before the operation. When adding the amount back (remove == true
) the estimated capacity of the sender's channel after the operation was equal to what it was before the operation.The consequence of this was that the estimated channel capacity in the sender's own channel was ever decreasing during the
pay
lifecycle.