Repository navigation
Conversation
a147ba4 to
562c34d
Compare
cdecker
left a comment
There was a problem hiding this comment.
This could be much simpler, as in the desired user value just gets assigned to the maxparts on the payment, we try with that, and if it fails we report a failure, no need to triple the MCF calls to try with a limit the user has never asked for.
| payment->maxparts = 0; | ||
| /* If we were restricting the number of parts, we relax it up to the | ||
| * user's provided maxparts (if any) and try again. */ | ||
| if (payment->maxparts && (payment->user_maxparts == 0 || |
There was a problem hiding this comment.
Why not go with user_maxparts right away? I think setting payment->maxparts = payment->user_maxpart and then relaxing if it does not work out is likely simpler, and more in line with what users want. It doesn't make much sense to me to try with a smaller maxparts first adn then try with user_maxparts and then unconstrained when we could implement the user's desired limit right away.
There was a problem hiding this comment.
We had issues with Phoenix not accepting more than 6 parts.
The user sets maxparts = 10 could lead to failed payment, while maxparts = 5 a success.
But this is counter intuitive because the first case is less restrictive.
maxparts should be interpreted as: "whatever you do, I don't care as long as the number of parts does not exceed my user set maxparts".
Therefore, if the user sets maxparts = 10, the solver will try do its best to find a solution that satisfies that constraint.
We know that Phoenix wallet will not like more than 6, so we first try with 6, when 6 is less than 10, we are honoring the user's request.
nGoline
left a comment
There was a problem hiding this comment.
A few things before it can go in:
- if the user sets
maxparts, that should be the limit; - passing
1as the user limit means keysend can no longer fall back to multiple parts when no single path exists; disable_mppsetsmaxparts = 1but leavesuser_maxpartsalone, so after a getroutes failure we widen to the user's value and send a multi-part payment to a node that didn't advertisebasic_mpp;- The ASan and Valgrind failures aren't flakes. On all three attempts the runner is killed for running out of memory while
test_xpay_maxparts_receiver_limitis running; - nit: the comment at
tests/test_xpay.py:1953says xpay drops the restriction and retries, but the test (correctly) expects it to fail.
| payment = new_payment(cmd, cmd, | ||
| *retryfor, | ||
| *maxdelay, | ||
| /* maxparts = */ 1, |
There was a problem hiding this comment.
xkeysend now passes maxparts = 1 as the user limit. On master keysend starts at maxparts = 1 (line 3472) but getroutes_done_err relaxes it to 0 if no single path works. With user_maxparts = 1 the relax condition at 1910 is false, so any keysend that needs more than one path now fails outright.
This is an undocumented behaviour change for an existing command. Pass 0 here (keeping the internal payment->maxparts = 1 start), or make it a deliberate, changelogged change.
There was a problem hiding this comment.
I am not sure we can allow xkeysend to use MPP. I'll check.
| payment->maxparts = payment->user_maxparts; | ||
| node_id_from_pubkey(&dstid, &payment->destination); | ||
| if (!gossmap_find_node(gossmap, &dstid)) | ||
| payment->maxparts = 6; | ||
| else | ||
| payment->maxparts = 0; | ||
| if (!gossmap_find_node(gossmap, &dstid)) { | ||
| if (payment->maxparts == 0 || payment->maxparts > 6) | ||
| payment->maxparts = 6; | ||
| payment_log( | ||
| payment, LOG_INFORM, | ||
| "The destination is unannounced, limiting maxparts to 6"); | ||
| } |
There was a problem hiding this comment.
When the user gives maxparts, it should be the limit, full stop: skip the unannounced-destination 6-part heuristic and do not relax on failure. Apply the heuristic (and the relax-to-unconstrained fallback) only when user_maxparts == 0. That also fixes the misleading log line (Andezion), and makes the test case "a larger maxparts does not override that" (tests/test_xpay.py:1977-1983) go away: with maxparts=10 the user asked for 10.
| payment->maxparts = payment->user_maxparts; | |
| node_id_from_pubkey(&dstid, &payment->destination); | |
| if (!gossmap_find_node(gossmap, &dstid)) | |
| payment->maxparts = 6; | |
| else | |
| payment->maxparts = 0; | |
| if (!gossmap_find_node(gossmap, &dstid)) { | |
| if (payment->maxparts == 0 || payment->maxparts > 6) | |
| payment->maxparts = 6; | |
| payment_log( | |
| payment, LOG_INFORM, | |
| "The destination is unannounced, limiting maxparts to 6"); | |
| } | |
| payment->maxparts = payment->user_maxparts; | |
| node_id_from_pubkey(&dstid, &payment->destination); | |
| if (!payment->maxparts && !gossmap_find_node(gossmap, &dstid)) { | |
| payment_log(payment, LOG_INFORM, | |
| "The destination is unannounced, limiting maxparts to 6"); | |
| payment->maxparts = 6; | |
| } |
There was a problem hiding this comment.
I can't agree.
maxfee means: find a route but the fees cannot be higher than this,
maxparts is the same: find a route but the number of parts cannot be higher than this.
If the user sets maxparts=10 and the routing algorithm determines that the best solution has 3 parts, we are ok, because 3 < 10.
We have a heuristic condition, that if the destination is unannounced (phoenix for example) we have better chances of delivering the payment
if we do not make more than 6 parts. If the user wants maxparts=10, the fact that internally we call askrene with maxparts=6 is:
- ok with the given user constraint (6 <= 10),
- to our knowledge, the best we can do to guarantee that payment to be completed.
| if (payment->maxparts && (payment->user_maxparts == 0 || | ||
| payment->user_maxparts > payment->maxparts)) { |
There was a problem hiding this comment.
To make user's maxparts final this could be:
| if (payment->maxparts && (payment->user_maxparts == 0 || | |
| payment->user_maxparts > payment->maxparts)) { | |
| if (payment->maxparts && !payment->user_maxparts) { |
562c34d to
fcda32a
Compare
|
I have changed this a little bit to avoid some the issues raised in the comments:
|
fcda32a to
067ac0a
Compare
067ac0a to
f4df707
Compare
I need to investigate this further. |
1d62551 to
53b6fae
Compare
Changelog-Added: xpay: option maxparts to limit the number of payment parts in Multi-Path-Payments Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
53b6fae to
38d0e1f
Compare
Adds
maxpartsoption toxpayand some tests.It is straightforward now that we have
maxpartsingetroutes.Fixes issue #9691