Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found a few things than can be improved in the MPP retry behavior.
Those will be particularly helpful for Trampoline-MPP to a remote peer (take into account the fact that a Trampoline node will likely have many channels).
Improvement 1: sending to a direct peer should not retry
It doesn't make any sense to let the
PaymentLifecycle
retry when we're forcing the choice of the first hop and the recipient is on the other end of that channel.This is fixed by setting
maxAttempts=1
when sending child payments via direct channels to the recipient.Improvement 2: only use public channels for remote recipients
When the recipient isn't a direct peer, it's very unlikely that choosing a route prefix with an unannounced channel will succeed. Most unannounced channels Endurance/Horizon has are with mobile wallets. We ignore them when sending to remote nodes.
Improvement 3: handle RouteNotFound
We're choosing the first hop without looking at the graph. That means we may choose a first hop that can't yield a complete route to our recipient. When that happens, we should avoid retrying with that same hop.
If we have a lot of channels, it's likely that we'll often choose a bad first hop. Since we only retry 5 times, this will lead to many payment failures which is bad when we're relaying (Trampoline). So we add some randomness on whether to count a
LocalFailure
as a complete attempt or "refund" that attempt.Note that this hack won't be necessary once we move the MPP logic inside the router: when that happens we will only select first hops that are on a potentially valid route to the recipient.
Unrelated
I also fixed the random failure that was happening in one of the MPP IntegrationSpec test.
With the code that's running on master, the
PaymentInitiator
doesn't guarantee that it will send thePaymentId
before payment events.Now we guarantee that.