Repository navigation
Conversation
a147ba4 to
562c34d
Compare
| } | ||
|
|
||
| if (disable_mpp) { | ||
| payment->maxparts = 1; |
There was a problem hiding this comment.
maybe payment->maxparts = payment->user_maxparts = 1; in that branch. That also covers sendamount, because includefees_msat already sets disable_mpp = true
There was a problem hiding this comment.
Why set user_maxparts = 1 here? Are you worried that I might fallback to a higher maxparts at
if (payment->maxparts && (payment->user_maxparts == 0 ||
payment->user_maxparts > payment->maxparts)) {
if (payment->user_maxparts)
payment_log(payment, LOG_INFORM,
"getroute failed with maxparts=%u, so "
"retrying with maxparts=%" PRIu32,
payment->maxparts, payment->user_maxparts);
else
payment_log(payment, LOG_INFORM,
"getroute failed with maxparts=%u, so "
"retrying without that restriction",
payment->maxparts);
payment->maxparts = payment->user_maxparts;
return getroutes_for(aux_cmd, payment, payment->amount_being_routed);
}?
| if (!gossmap_find_node(gossmap, &dstid)) { | ||
| if (payment->maxparts == 0 || payment->maxparts > 6) | ||
| payment->maxparts = 6; | ||
| payment_log( |
There was a problem hiding this comment.
maybe log the real value ("... limiting maxparts to %u"), or log only when the value is actually lowered to 6, because the test hint_small waits for this exact line while asserting num_flows() <= 3
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; | |
| } |
| 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) { |
There was a problem hiding this comment.
For an invoice without basic_mpp, payment->maxparts = 1 is set but user_maxparts is left as given. After a getroutes failure the new relax step widens the limit to the user's value (e.g. maxparts=5) and sends a multi-part payment to a node that did not advertise MPP. The unconstrained case was already like this on master, but the PR rewrote that condition and is the place to pin it: set payment->user_maxparts = 1 too (@Andezion suggestion). With finding 2's shape this also stops the relax-to-0 for non-MPP invoices.
| wait_xpay_done() | ||
|
|
||
| l3.rpc.askrene_age('xpay', int(time.time())) | ||
| # Impossible with only 2 parts: xpay drops the restriction and retries. |
There was a problem hiding this comment.
Comment says "xpay drops the restriction and retries" but the assertion (correctly) expects failure with the user's limit; fix the comment. Once finding 2 is applied, the three wait_for_log("The destination is unannounced, limiting maxparts to 6") calls at 1973/1982/1991 need adjusting (only the default case logs it).
| xparams->layers = layers; | ||
| xparams->retryfor = *retryfor; | ||
| xparams->maxdelay = *maxdelay; | ||
| xparams->maxparts = 1; |
There was a problem hiding this comment.
sendamount passing maxparts = 1 as the user limit also incidentally stops the relax-to-0 that could hit assert(attempt->payment->maxparts == 1) in attempt_mpp_amount() (xpay.c:418) for includefees payments, which is a good thing; worth a sentence in the commit message.
| xparams->layers = layers; | ||
| xparams->retryfor = *retryfor; | ||
| xparams->maxdelay = *maxdelay; | ||
| xparams->maxparts = 1; |
There was a problem hiding this comment.
Same here: sendamount passing maxparts = 1 as the user limit also incidentally stops the relax-to-0 that could hit assert(attempt->payment->maxparts == 1) in attempt_mpp_amount() (xpay.c:418) for includefees payments, which is a good thing; worth a sentence in the commit message.
| &invoice_msat, maxfee, layers, *retryfor, NULL, *maxdelay, | ||
| label, NULL, false, false, send_msat); | ||
| return xpay_core(cmd, invstring, &invoice_msat, maxfee, layers, | ||
| *retryfor, NULL, *maxdelay, /* maxparts = */ 1, label, |
There was a problem hiding this comment.
Same here: sendamount passing maxparts = 1 as the user limit also incidentally stops the relax-to-0 that could hit assert(attempt->payment->maxparts == 1) in attempt_mpp_amount() (xpay.c:418) for includefees payments, which is a good thing; worth a sentence in the commit message.
Changelog-Added: xpay: option maxparts to limit the number of concurrent payment parts in Multi-Path-Payments Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
562c34d to
fcda32a
Compare
|
I have changed this a little bit to avoid some the issues raised in the comments:
|
Adds
maxpartsoption toxpayand some tests.It is straightforward now that we have
maxpartsingetroutes.Fixes issue #9691