-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Probing for more reliable route fee estimation #8136
Conversation
e90bf4a
to
a0e1522
Compare
There is currently a problem with prepayment probing in combination with some lightning service providers. Basically prepayment probes are not compatible with the current LSP protocols. Since nodes behind a LSP can be a significant portion of destinations, I think it's good to keep the following considerations in mind. In below context, assume the payee is a lightning node behind a LSP. In the current state I generally recommend against sending prepayment probes when a LSP is involved. Or if you do really want to probe, probe up to the LSP node, and manually add the fees for the ultimate hop. These fees can be taken from the route hint in the invoice. I guess the question is: how do you determine whether a LSP is involved? Let's outline the protocols and their caveats. Present: Breez LSP
Soon: LSPS2Very soon Breez and multiple other LSPs will implement the LSPS2 protocol. This is a protocol for just-in-time channels. This initial version of the protocol is incompatible with prepayment probes. There are no payment hash tricks here. These nodes should have feature bit 729 ( Medium term: LSPS4The LSP spec group is currently in the process of designing a LSP protocol LSPS4 for just-in-time channels. When LSPS4 is fully implemented, prepayment probes won't be much of an issue. This is not going to be implemented soon, however. Other thoughtsPrepayment probes don't work together with MPP very well. At least there is no indication whether you were able to deliver the full amount for the specified fee, even if all payment parts return with |
lnrpc/routerrpc/router.proto
Outdated
An invoice of the target node that the route fee request is intended for. | ||
Its parameters are input to probe payments that estimate routing fees. | ||
*/ | ||
string invoice = 3; |
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.
normally these are called payment_request
when it's a bolt 11 payreq input
a0e1522
to
e8ce139
Compare
Thanks for the detailed rundown on LSP mechanics @JssDWt. The primary focus of this PR is to improve the currently active graph based method of estimating routing fees. It is unreliable because the gossip announcements might not accurately reflect the network topology or fees at the time when a payment occurs. So in this first step the desired outcome is to improve the fee estimation for payments to publicly known nodes. Follow-up PRs will focus on MPP/AMP as noted in the linked issue #7916. This seems to have gotten possible since the release of AMP by invalidating the last shard of a AMP, see #4219 (comment). I think LSP specific probing protocols will also land with a separate PR. |
e8ce139
to
adc76f8
Compare
adc76f8
to
1cf5900
Compare
assigned @bitromortac for approach ack |
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, I think the api looks good, except that we could return an lnrpc.PaymentFailureReason
to find out more about why a probe failed. Also added a suggestion for how to handle the streaming responses differently.
Another important point is backwards compatibility, I think we need to support the old ux for some time, as the new api now has a time component. So I'd suggest to keep the old code with the pubkey/amount input and only use the new estimation if an invoice is provided. This can then be removed after some time when the rpc fields are removed.
AMP solves that. You can send the N-1 shards, then make the Nth shared fail by giving it an invalid secret share. |
How will that work if a probing hash is used, and also only a single shard is sent that may be below the actual payment amount? The LSP just decides on a value to use for channel opening? What if the sender doesn't retry again, the LSP just eats the chain fees cost? What about if the user already has a channel open? |
Assuming you're asking about probing all the way to the destination node, and not up until the LSP. Let me answer these one by one.
In that case the single shard is failed back by the LSP after a timeperiod similar to the MPP timeout. The recipient's invoice amount is the threshold for letting htlcs through and trigger channel open.
The recipient communicates the intended amount to receive to the LSP before creating the invoice. The invoice then contains a route hint with a scid specifically for this payment/channel order.
In that case there are no issues. The destination works like any other lightning node. Only if the recipient ordered a cchannel for that payment will this LSPS2 spec be used. |
1cf5900
to
715f90a
Compare
@hieblmi is this ready to leave draft? |
cae529d
to
0e85acb
Compare
0e85acb
to
7806868
Compare
6b9fe34
to
5923576
Compare
Once again thanks for the thorough review @ProofOfKeags + @bitromortac, I've addressed all your comments. This PR is ready for another review round. |
5923576
to
6d0617a
Compare
func maxLspFee(routeHints [][]zpay32.HopHint, amt lnwire.MilliSatoshi) (uint32, | ||
uint32) { | ||
|
||
var maxFeePpm uint32 |
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.
nit: put in var
block
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.
I have some more nits and the itests needs an update to test real probing to the receiver which needs to take the bits of the destination node into account (read from the invoice as discussed).
6d0617a
to
9d4ea1c
Compare
51eb85d
to
5b133ee
Compare
3d953cd
to
49284e4
Compare
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.
LGTM 🎉. There's only one remark left concerning the api docs.
lnrpc/routerrpc/router.proto
Outdated
take, denoted in seconds. Although the probing function is aborted if the | ||
timeout is reached, the underlying payment attempt is not cancelled. This | ||
might leave the node with pending outgoing htlcs that wait for resolution. |
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.
nit: we should be more accurate here, suggestion:
The probing payment loop is aborted if this timeout is reached. Note that the probing process itself can take longer than the timeout if the HTLC becomes delayed or stuck. Canceling the context of this call will not cancel the payment loop, the duration is only controlled by the timeout parameter.
49284e4
to
fba6fda
Compare
conf: fee estimation timeout in sample config
In this commit the mission control based fee estimation is supplemented with a payment probe estimation which can lead to more accurate estimation results. The probing utilizes a hop-hint heurisic to detect routes through LSPs in order to manually estimate fees to destinations behind an LSP that would otherwise block the payment probe.
Once again thank you @bitromortac for this thorough review journey. The handling of route hints by |
This PR implements #7916
Overview
In this PR we extend the implementation of the graph based
EstimateRouteFee
RPC with a payment probe based approach to obtain a more reliable routing fee estimate.Notes on implementation
lncli
adds support to use the graph-based and probe-based fee estimation:graph-based:
probe-based: