-
Notifications
You must be signed in to change notification settings - Fork 345
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
Add config option to set maximum total routing fee #2417
Add config option to set maximum total routing fee #2417
Conversation
Drafting for now as I'm not super happy that we only filter on a per-path basis and then fail entirely if the aggregate route surpasses the routing fee limit. So far experimented with the approach we took for the I think it's not super bad currently as we already pre-sort and filter routes by their This also currently doesn't account for retries. We might need to track the 'used' fees in a structure similar to |
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2417 +/- ##
==========================================
+ Coverage 88.83% 89.68% +0.85%
==========================================
Files 113 113
Lines 84489 89980 +5491
Branches 84489 89980 +5491
==========================================
+ Hits 75052 80696 +5644
+ Misses 7205 7055 -150
+ Partials 2232 2229 -3
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, I think. I agree we should clean it up later to more aggressively find paths even though our first choice was fee-limited out, but this is certainly better than not having fee limiting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as a first step, given where we're at with the release!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
ed0ade8
to
da559d3
Compare
c34a4a9
to
be27e7f
Compare
eaa9435
to
63ed69b
Compare
63ed69b
to
804abe6
Compare
LGTM after squash |
804abe6
to
97f07fb
Compare
Squashed fixups without further changes. |
97f07fb
to
90ef352
Compare
Rebased on main to get rid of the CI failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should land this to get the API in place for a second alpha, but we should get some of these comments fixed (at least the total-fee final check one) for 0.0.117.
// subtracting the used fee from the total fee budget. | ||
route_params.max_total_routing_fee_msat = route_params | ||
.max_total_routing_fee_msat.map(|m| m.saturating_sub(total_ok_fees_msat)); | ||
route_params.final_value_msat = pending_amt_unsent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a regression, but this is wrong - this includes any overpayment amount, ensuring we overpay again when we go to retry, rather than just recalculating the amount sent against the intended amount. Lets definitely fix this ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nevermind my previous reply): Tacked a corresponding commit onto #2575.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, thinking about this once more, I think my previous comment was kinda correct: if we find a route and need to overpay for some of the paths, we may reduce the value of the others to meet the final value, i.e., the route's split is essentially determined at this time. If now some of the overpaid paths fail and we start to only retry the net. value (excluding overpaid amounts), the sum of all paths might not meet the expected final value. I suspect this is no issue if we have infinite auto-retries as we'd retry until the expected value is met, but if we're limited we probably will run out of retry attempts sooner than expected/necessary. Not sure how we'd want to resolve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point here is we don't need to think about paths in this specific case - we tried to send a payment for route.route_params.final_value_msat
and we now have route.get_total_amount() - pending_amt_unsent
pending. We should retry pending_amt_unsent - (route.get_total_amount() - route.route_params.final_value_msat)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point here is we don't need to think about paths in this specific case - we tried to send a payment for
route.route_params.final_value_msat
and we now haveroute.get_total_amount() - pending_amt_unsent
pending. We should retrypending_amt_unsent - (route.get_total_amount() - route.route_params.final_value_msat)
.
Right, then we seem to be on the same page that per-path accounting doesn't make sense, but only to account for the overpayment for the whole route.
I think what you propose unfortunately doesn't work as is though as for the immediate/legacy retry case we'd recursively reduce final_value_msat
while we don't do this in the newer auto-retry case where we'd leave final_value_msat
static, but account for for the pending amounts differently. In d7ab0ef I solved this by taking the min
, but this seems to be pretty hacky.
@@ -159,6 +166,142 @@ fn mpp_retry() { | |||
claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_preimage); | |||
} | |||
|
|||
#[test] | |||
fn mpp_retry_overpay() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is nice but isn't what I was mostly interested about. I'm really curious to test overpaying the final recipient and ensuring the route_params' final_value_msat
is correct, not just the remaining fees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, had understood above request slightly differently. IIUC, this might now more or less be covered by the new test introduced in #2604?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test tests the router end of it, but I'm really worried about the outbound_payment part overpaying.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
Various router fixes and #2417 follow-ups
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
.. as a follow-up from lightningdevkit#2417.
In lightningdevkit#2417 support for setting a max fee was added but it is not exposed when using the `pay_invoice` utility functions. This makes it so the user can pass in that parameter. One downside is that this removes the defualt value form before.
Fixes #2339.
Closes #2596.
Based on #2555.Currently, users have no means to upper-bound the total fees accruing when finding a route. Here, we add a corresponding field to
PaymentParameters
which is used to limit the candidate set during path finding.To this end, we exclude any candidate hops if we find that using them would let the aggregated path routing fees exceed
max_total_routeing_fee_msat
. Moreover, we return an error if the aggregated fees over all paths of the selected route would surpassmax_total_routeing_fee_msat
.