Research/Bitcoin Dev Archive / lightning-dev list
Pinging a route for capacity
8 messages, Mar 1 to 4, 2018. Started by Jim Posen.
Jim Posen (2), René Pickhardt (2), gb, ZmnSCPxj, Rusty Russell, Christian Decker
My understanding is that the best strategy for choosing a route to send funds over is to determine all possible routes, rank them by estimated fees based on channel announcements and number of hops, then try them successively until one works.
It seems inefficient to me to actually do a full HTLC commitment handshake on each hop just to find out that the last hop in the route didn't have sufficient remaining capacity in the first place. Depending on how many people are using the network, I could also forsee situations where this creates more payment failures because bandwidth is locked up in HTLCs that are about to fail anyway.
One idea that would likely help is the ability to send a ping over an onion route asking "does every hop have capacity to send X msat?" Every hop would forward the onion request if the answer is yes, or immediately send the response back up the circuit if the answer is no. This should reveal no additional information about the channel capacities that the sender couldn't determine by sending a test payment to themself (assuming they could find a loop). Additionally, the hops could respond with the latest fee rate in case channel updates are slow to propagate.
The main benefit is that this should make it quicker to send a successful payment because latency is lower than sending an actual payment and the sender could ping all possible routes in parallel, whereas they can't send multiple payments in parallel. The main downside I can think of is that, by the same token, it is faster and cheaper for someone to extract information about channel capacities on the network with a binary search.
-jimpo
Hey everyone,
disclaimer I am new here and have not a full understanding of the complete specs yet - however since I decided to participate in lighting dev I will just be brave and try to add my ideas on the problem jimpo posed. So even in case by ideas are complete bs please just tell me in a friendly way and I know I need to read more code and specs in order to participate.
Reading about the described problem techniques like IP-Fragmentation ( https://en.wikipedia.org/wiki/IP_fragmentation ) come to my mind. The setting is a little bit different but in from my current understanding it should still be applicable and also be the favorable solution in comparison to the proposed ping:
1.) IP setting: In IP-Fragmentation one would obviously just split the IP-package in order to utilize a link layer protocol that doesn't have enough bandwidth for a bigger size package. 2.) Lightning case: When the capacity of a channel during routing is not high enough - which means that the channel balance on that side is somewhere between 0 and the size of the payment - one would have to to send the second part of the fragmented package on a different route. This is obvious since the insufficient channel balance cannot come out of thin air (as in IP-Routing).
My first intuition was that this would become a problem for onion routing since the router in question does not know the final destination but only knows the next hop which can't be utilized as the channel doesn't have enough funds. However I imagine one could just encapsulate the second part of the fragmented payment in a new onion routed package that goes on a detour (using different payment channels) to the original "next" hop und progresses from there as it was originally thought of.
Not sure however how the impacts to the HTLC would be and if it would actually be possible to fragment a payment that is encapsulated within the onion routing.
If possible the advantage in comparison to your proposed ping method is that fragmentation would be highly dynamic and still work if a channel runs out of funds while routing payment. In your ping scenario it could very well happen that you do a ping for a designated rout, everything looks great, you send a payment but while it is on its way a channel on that way could run dry.
best Rene
On Thu, Mar 1, 2018 at 3:45 PM, Jim Posen <jim.posen at gmail.com> wrote:
Quoted text (36 lines)
> My understanding is that the best strategy for choosing a route to send > funds over is to determine all possible routes, rank them by estimated fees > based on channel announcements and number of hops, then try them > successively until one works. > > It seems inefficient to me to actually do a full HTLC commitment handshake > on each hop just to find out that the last hop in the route didn't have > sufficient remaining capacity in the first place. Depending on how many > people are using the network, I could also forsee situations where this > creates more payment failures because bandwidth is locked up in HTLCs that > are about to fail anyway. > > One idea that would likely help is the ability to send a ping over an > onion route asking "does every hop have capacity to send X msat?" Every hop > would forward the onion request if the answer is yes, or immediately send > the response back up the circuit if the answer is no. This should reveal no > additional information about the channel capacities that the sender > couldn't determine by sending a test payment to themself (assuming they > could find a loop). Additionally, the hops could respond with the latest > fee rate in case channel updates are slow to propagate. > > The main benefit is that this should make it quicker to send a successful > payment because latency is lower than sending an actual payment and the > sender could ping all possible routes in parallel, whereas they can't send > multiple payments in parallel. The main downside I can think of is that, > by the same token, it is faster and cheaper for someone to extract > information about channel capacities on the network with a binary search. > > -jimpo > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev > >
Hey everyone,
disclaimer I am new here and have not a full understanding of the complete specs yet - however since I decided to participate in lighting dev I will just be brave and try to add my ideas on the problem jimpo posed. So even in case by ideas are complete bs please just tell me in a friendly way and I know I need to read more code and specs in order to participate.
Reading about the described problem techniques like IP-Fragmentation ( https://en.wikipedia.org/wiki/IP_fragmentation ) come to my mind. The setting is a little bit different but in from my current understanding it should still be applicable and also be the favorable solution in comparison to the proposed ping:
1.) IP setting: In IP-Fragmentation one would obviously just split the IP-package in order to utilize a link layer protocol that doesn't have enough bandwidth for a bigger size package. 2.) Lightning case: When the capacity of a channel during routing is not high enough - which means that the channel balance on that side is somewhere between 0 and the size of the payment - one would have to to send the second part of the fragmented package on a different route. This is obvious since the insufficient channel balance cannot come out of thin air (as in IP-Routing).
My first intuition was that this would become a problem for onion routing since the router in question does not know the final destination but only knows the next hop which can't be utilized as the channel doesn't have enough funds. However I imagine one could just encapsulate the second part of the fragmented payment in a new onion routed package that goes on a detour (using different payment channels) to the original "next" hop und progresses from there as it was originally thought of.
Not sure however how the impacts to the HTLC would be and if it would actually be possible to fragment a payment that is encapsulated within the onion routing.
If possible the advantage in comparison to your proposed ping method is that fragmentation would be highly dynamic and still work if a channel runs out of funds while routing payment. In your ping scenario it could very well happen that you do a ping for a designated rout, everything looks great, you send a payment but while it is on its way a channel on that way could run dry.
best Rene
On Thu, Mar 1, 2018 at 3:45 PM, Jim Posen <jim.posen at gmail.com> wrote:
Quoted text (36 lines)
> My understanding is that the best strategy for choosing a route to send > funds over is to determine all possible routes, rank them by estimated fees > based on channel announcements and number of hops, then try them > successively until one works. > > It seems inefficient to me to actually do a full HTLC commitment handshake > on each hop just to find out that the last hop in the route didn't have > sufficient remaining capacity in the first place. Depending on how many > people are using the network, I could also forsee situations where this > creates more payment failures because bandwidth is locked up in HTLCs that > are about to fail anyway. > > One idea that would likely help is the ability to send a ping over an > onion route asking "does every hop have capacity to send X msat?" Every hop > would forward the onion request if the answer is yes, or immediately send > the response back up the circuit if the answer is no. This should reveal no > additional information about the channel capacities that the sender > couldn't determine by sending a test payment to themself (assuming they > could find a loop). Additionally, the hops could respond with the latest > fee rate in case channel updates are slow to propagate. > > The main benefit is that this should make it quicker to send a successful > payment because latency is lower than sending an actual payment and the > sender could ping all possible routes in parallel, whereas they can't send > multiple payments in parallel. The main downside I can think of is that, > by the same token, it is faster and cheaper for someone to extract > information about channel capacities on the network with a binary search. > > -jimpo > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev > >
.... and any thoughts on protections against flood pinging?
On Thu, 2018-03-01 at 09:45 -0500, Jim Posen wrote:
Quoted text (14 lines)
> The main benefit is that this should make it quicker to send a > successful payment because latency is lower than sending an actual > payment and the sender could ping all possible routes in parallel, > whereas they can't send multiple payments in parallel. The main > downside I can think of is that, by the same token, it is faster and > cheaper for someone to extract information about channel capacities on > the network with a binary search. > > > -jimpo > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
Good morning Rene,
Please consider the recent discussion about AMP, atomic multi-path. https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/amp-atomic-multi-path-payments-over-lightning#m-6757b7a5
Note that only the source (payer) can split the payment into multiple smaller payments; we cannot safely let intermediaries split the payment as the intermediaries may very well decide to send it to a ridiculously high-fee channel. So the payer will make multiple payments that can only be merged at the destination, each sub-payment has a single route and itself cannot be split unless the payer decides to split.
Quoted text (1 line)
> Not sure however how the impacts to the HTLC would be and if it would actually be possible to fragment a payment that is encapsulated within the onion routing.
The timeouts in particular would be impossible to handle. At any point the payment should reach the payee within some N blocks and each hop reduces that margin by a small amount (14 blocks for c-lightning if I remember correctly). It is likely that there will not be enough time if it goes through a detour, unless the detour has equal or smaller reduction (delay) than the original hop with insufficient monetary capacity.
Regards, ZmnSCPxj
Sent with [ProtonMail](https://protonmail.com) Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On March 1, 2018 11:26 PM, René Pickhardt via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (36 lines)
> Hey everyone, > > disclaimer I am new here and have not a full understanding of the complete specs yet - however since I decided to participate in lighting dev I will just be brave and try to add my ideas on the problem jimpo posed. So even in case by ideas are complete bs please just tell me in a friendly way and I know I need to read more code and specs in order to participate. > > Reading about the described problem techniques like IP-Fragmentation ( https://en.wikipedia.org/wiki/IP_fragmentation ) come to my mind. The setting is a little bit different but in from my current understanding it should still be applicable and also be the favorable solution in comparison to the proposed ping: > > 1.) IP setting: In IP-Fragmentation one would obviously just split the IP-package in order to utilize a link layer protocol that doesn't have enough bandwidth for a bigger size package. > 2.) Lightning case: When the capacity of a channel during routing is not high enough - which means that the channel balance on that side is somewhere between 0 and the size of the payment - one would have to to send the second part of the fragmented package on a different route. This is obvious since the insufficient channel balance cannot come out of thin air (as in IP-Routing). > > My first intuition was that this would become a problem for onion routing since the router in question does not know the final destination but only knows the next hop which can't be utilized as the channel doesn't have enough funds. However I imagine one could just encapsulate the second part of the fragmented payment in a new onion routed package that goes on a detour (using different payment channels) to the original "next" hop und progresses from there as it was originally thought of. > > Not sure however how the impacts to the HTLC would be and if it would actually be possible to fragment a payment that is encapsulated within the onion routing. > > If possible the advantage in comparison to your proposed ping method is that fragmentation would be highly dynamic and still work if a channel runs out of funds while routing payment. In your ping scenario it could very well happen that you do a ping for a designated rout, everything looks great, you send a payment but while it is on its way a channel on that way could run dry. > > best Rene > > On Thu, Mar 1, 2018 at 3:45 PM, Jim Posen <jim.posen at gmail.com> wrote: > >> My understanding is that the best strategy for choosing a route to send funds over is to determine all possible routes, rank them by estimated fees based on channel announcements and number of hops, then try them successively until one works. >> >> It seems inefficient to me to actually do a full HTLC commitment handshake on each hop just to find out that the last hop in the route didn't have sufficient remaining capacity in the first place. Depending on how many people are using the network, I could also forsee situations where this creates more payment failures because bandwidth is locked up in HTLCs that are about to fail anyway. >> >> One idea that would likely help is the ability to send a ping over an onion route asking "does every hop have capacity to send X msat?" Every hop would forward the onion request if the answer is yes, or immediately send the response back up the circuit if the answer is no. This should reveal no additional information about the channel capacities that the sender couldn't determine by sending a test payment to themself (assuming they could find a loop). Additionally, the hops could respond with the latest fee rate in case channel updates are slow to propagate. >> >> The main benefit is that this should make it quicker to send a successful payment because latency is lower than sending an actual payment and the sender could ping all possible routes in parallel, whereas they can't send multiple payments in parallel. The main downside I can think of is that, by the same token, it is faster and cheaper for someone to extract information about channel capacities on the network with a binary search. >> >> -jimpo >> >> _______________________________________________ >> Lightning-dev mailing list >> Lightning-dev at lists.linuxfoundation.org >> https://www.learnbitcoin.com/archive/lists/lightning-dev > > -- > Skype: rene.pickhardt
Regarding ping flooding, if it is problematic, the best solution is probably including a small proof-of-work with the ping, similar to BIP 154. However, the whole purpose of the ping in the first place is to be a cheaper way to collect routing information than attempting to send a payment, so I think adding a PoW starts to become counterproductive. Note that the sender needs to expend a certain amount of computation just creating the onion packet up front (on the order of a few ms, I believe), so perhaps that is sufficient.
Also, if someone wanted to DoS the network, there are much better ways than using this proposed ping mechanism. For example, someone can send payments along any circuit with a randomly generated payment hash (for which the preimage is unknown), and force a payment failure at the end of the route. That is basically a way to ping that works now, but is more expensive for everyone.
On Thu, Mar 1, 2018 at 4:16 PM, gb <kiwigb at yahoo.com> wrote:
Quoted text (22 lines)
> .... and any thoughts on protections against flood pinging? > > On Thu, 2018-03-01 at 09:45 -0500, Jim Posen wrote: > > > > The main benefit is that this should make it quicker to send a > > successful payment because latency is lower than sending an actual > > payment and the sender could ping all possible routes in parallel, > > whereas they can't send multiple payments in parallel. The main > > downside I can think of is that, by the same token, it is faster and > > cheaper for someone to extract information about channel capacities on > > the network with a binary search. > > > > > > -jimpo > > _______________________________________________ > > Lightning-dev mailing list > > Lightning-dev at lists.linuxfoundation.org > > https://www.learnbitcoin.com/archive/lists/lightning-dev > > >
Jim Posen <jim.posen at gmail.com> writes:
Quoted text (11 lines)
> My understanding is that the best strategy for choosing a route to send > funds over is to determine all possible routes, rank them by estimated fees > based on channel announcements and number of hops, then try them > successively until one works. > > It seems inefficient to me to actually do a full HTLC commitment handshake > on each hop just to find out that the last hop in the route didn't have > sufficient remaining capacity in the first place. Depending on how many > people are using the network, I could also forsee situations where this > creates more payment failures because bandwidth is locked up in HTLCs that > are about to fail anyway.
If failure is common this would be true, but I think it's too early to design for it.
This kind of signalling is what fees are for: when capacity gets low you increase fees, and when it gets high, you reduce them. But that may still prove insufficient.
Two things come to mind:
1. `temporary_channel_failure` returns a `channel_update`. The implication is that this has the disabled flag, but we should probably make that true iff the request asks for < 2% of the channel capacity or some "minimal bar". If you can't even service this, you should disable the channel.
2. We can implement fast failure to reduce latency: https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming
Note that there needs to be more analysis on reliable ways to mask the active capacity of a channel: using a static random threshold still leaks information that *something* has happened, so it may need to be more sophisticated.
Cheers, Rusty.
Rusty Russell <rusty at rustcorp.com.au> writes:
Quoted text (23 lines)
> Jim Posen <jim.posen at gmail.com> writes: > If failure is common this would be true, but I think it's too early to > design for it. > > This kind of signalling is what fees are for: when capacity gets low you > increase fees, and when it gets high, you reduce them. But that may > still prove insufficient. > > Two things come to mind: > > 1. `temporary_channel_failure` returns a `channel_update`. The > implication is that this has the disabled flag, but we should > probably make that true iff the request asks for < 2% of the channel > capacity or some "minimal bar". If you can't even service this, you > should disable the channel. > > 2. We can implement fast failure to reduce latency: > https://github.com/lightningnetwork/lightning-rfc/wiki/Brainstorming > > Note that there needs to be more analysis on reliable ways to mask the > active capacity of a channel: using a static random threshold still > leaks information that *something* has happened, so it may need to be > more sophisticated.
I have to agree with Rusty here, pinging a channel for capacity sounds a lot like premature optimization. In addition it could lead to a rather large privacy leak, both for the sender as well as the individual channels.
Giving any information about the current balance of a channel, could lead to tracing payments through the network. And users pinging channels before making a payment could result also in traced payments.
The feedback mechanism we have by adding channel_updates in the failure message should allow senders to learn about changes in the channels that caused the failure, and it should be injected into the gossip so peers learn about it as well. Once we have exhausted what we can do with the simple gossip mechanism, only then should we be looking at other solutions.
Cheers, Christian