Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Peer Selection

7 messages, Dec 13 to 15, 2017. Started by ZmnSCPxj.

Stan Kladko (3), ZmnSCPxj (2), Christian Decker (2)

Permalink First message in the Wayback Machine

ZmnSCPxj permalink original

Good morning,

Quoted text (11 lines)
>>If you have a reason to open a channel to an arbitrary node, then other nodes have a reason to open a channel to an arbitrary node, which might be you. Even if the
>network grows large, that > also means there are more participants who might decide, via whatever heuristic, to channel to your node.
>
>If I am connected to some nodes, but no one connected to me, then all
>of my deposit is used by me only, and is not used by other nodes.
>If I am routing nodes through my node, then it can potentially
>negatively affect availability of my deposit for my own transactions.
>So it seems to me that the best strategy is to connect but accept no
>incoming connections.
>
>How much real is this problem?

You would also have to make your outgoing channels private (not sent by node gossip) so that others will not route through you. You will not be able to receive money on-Lightning (since your channels are private, people who are trying to send money to you on-Lightning will not be able to find a route to you). You will not earn any money from routing fees (since you are not willing to have others use your channels for routing).

It has the advantage that you can actually lose Internet connectivity indefinitely with no possibility of loss of funds, simply because in this mode of operation, channels are effectively unidirectional only from you to the rest of the network.

However, I think in the long run, you would prefer to receive funds by Lightning also, and so cannot use this kind of operation. Consider that in the future, you may get paid your salary or dividends in bitcoin over Lightning: your business/employer receives money from its customer over Lightning, it sends part of that money to sub-contractors and suppliers, and some to you (employee or shareholder). You then spend the money you receive as salary/dividends for food and services and other vices you might have, which are provided by other businesses which have their own shareholders, employees, sub-contractors, and suppliers.

In such a world, you would have to make your channels public and accept incoming channels, and at minimum accept incoming money (even if you reject routing attempts). Since routing can earn you some amount of money as fees, you probably want to accept at least a few routing attempts at a time to earn some fees (and offset the fees on your own transactions). This also leads to a more mesh-like network; the "unidirectional mode" where you keep all your channels private and only outgoing effectively makes you a second-class member of the network (and has higher onchain fees: if you have depleted a channel, there is an incentive to keep it open only if you are willing to accept routing attempts through you (every open channel is an opportunity to route, and a channel depleted on your end is full on the opposite end and you can still at least accept transactions toward you), otherwise, you are better off closing channels (and incurring fees) so you can recover the channel reserve).

Regards, ZmnSCPxj

Stan Kladko in reply to ZmnSCPxj permalink original

Thank you - this is lots of information !)

Quoted text (1 line)
> You would also have to make your outgoing channels private  (not sent by node gossip) so that others will not route through you.

If I would have only a single outgoing channel I would not have to make it private ? Correct? There is no way to route through a node that has one channel.

Another interesting question is what happens if I have lots of channels, but in my software block all routing through my node?

Is there a way for me to block all routing through my node by modifying node software but still enjoy all benefits of receiving and sending deposits?

As you said, blocking all routing has lots of benefit since money is safe if the network is down :-)

Sorry for playing devils advocate - I am just trying to understand it )

On Wed, Dec 13, 2017 at 3:13 PM, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (56 lines)
> Good morning,
>
>>>If you have a reason to open a channel to an arbitrary node, then other
>>> nodes have a reason to open a channel to an arbitrary node, which might be
>>> you. Even if the
>>network grows large, that > also means there are more participants who
>> might decide, via whatever heuristic, to channel to your node.
>>
>>If I am connected to some nodes, but no one connected to me, then all
>>of my deposit is used by me only, and is not used by other nodes.
>>If I am routing nodes through my node, then it can potentially
>>negatively affect availability of my deposit for my own transactions.
>>So it seems to me that the best strategy is to connect but accept no
>>incoming connections.
>>
>>How much real is this problem?
>
> You would also have to make your outgoing channels private (not sent by node
> gossip) so that others will not route through you.  You will not be able to
> receive money on-Lightning (since your channels are private, people who are
> trying to send money to you on-Lightning will not be able to find a route to
> you).  You will not earn any money from routing fees (since you are not
> willing to have others use your channels for routing).
>
> It has the advantage that you can actually lose Internet connectivity
> indefinitely with no possibility of loss of funds, simply because in this
> mode of operation, channels are effectively unidirectional only from you to
> the rest of the network.
>
> However, I think in the long run, you would prefer to receive funds by
> Lightning also, and so cannot use this kind of operation.  Consider that in
> the future, you may get paid your salary or dividends in bitcoin over
> Lightning: your business/employer receives money from its customer over
> Lightning, it sends part of that money to sub-contractors and suppliers, and
> some to you (employee or shareholder).  You then spend the money you receive
> as salary/dividends for food and services and other vices you might have,
> which are provided by other businesses which have their own shareholders,
> employees, sub-contractors, and suppliers.
>
> In such a world, you would have to make your channels public and accept
> incoming channels, and at minimum accept incoming money (even if you reject
> routing attempts).  Since routing can earn you some amount of money as fees,
> you probably want to accept at least a few routing attempts at a time to
> earn some fees (and offset the fees on your own transactions).  This also
> leads to a more mesh-like network; the "unidirectional mode" where you keep
> all your channels private and only outgoing effectively makes you a
> second-class member of the network (and has higher onchain fees: if you have
> depleted a channel, there is an incentive to keep it open only if you are
> willing to accept routing attempts through you (every open channel is an
> opportunity to route, and a channel depleted on your end is full on the
> opposite end and you can still at least accept transactions toward you),
> otherwise, you are better off closing channels (and incurring fees) so you
> can recover the channel reserve).
>
> Regards,
> ZmnSCPxj
ZmnSCPxj in reply to Stan Kladko permalink original

Good morning Stan,

Money is safe when network is down only if you only pay out of your node. Once you receive, it is possible for your counterparty to transmit an invalid old state where it owns more money than you do. Then you need to monitor the blockchain for invalid closings of channel state, meaning you cannot be offline for more than a few days (this timeout is settable in your node).

Basically, consider the below situation:

You make a channel to me and load it with 3mBTC. You force the channel to be unidirectional, because you might be offline for months.

Stan: 3mBTC, ZmnSCPxj: 0mBTC Initial state Stan: 2mBTC, ZmnSCPxj: 1mBTC after you pay me 1 mBTC Stan: 1mBTC, ZmnSCPxj: 2mBTC after you pay me 1 mBTC

Now suppose you decide to accept money via this channel. So the channel history now becomes:

Stan: 2mBTC, ZmnSCPxj: 1mBTC after I pay you 1 mBTC Stan: 3mBTC, ZmnSCPxj: 0mBTC after I pay you 1 mBTC

At this point, I can take back my 2mBTC by replaying the old "Stan: 1mBTC, ZmnSCPxj: 2mBTC" state. Normally, this is a bad move on my part, since old state is revoked and you can present evidence of fraud on the blockchain layer to take the entire channel value as yours, as damages. However, you only have a few days where you can present this evidence. If those few days pass, then the payment is finalized and I get back the 2 mBTC I paid to you.

The upshot is that if you receive money for any reason (whether for routing, or because you are the final payee) you can only be offline for at most a few days. Otherwise, you force yourself into unidirectional mode only (you can only pay, never receive): unidirectional mode also is bad for you since you cannot offset the fees you pay for spending using fees you receive for routing.

If you are going to receive money anyway, you might as well enable routing also, because that lets you earn some fees (to offset the fees you would pay to spend your money). The added risk is low: most routes will either successfully reach the destination, or fail outright, within a few seconds, freeing the funds back to you again.

The protocol has two settings "max_htlc_value_in_flight_msat" and "max_accepted_htlcs" to limit your exposure to routing risk. These limit how much of your channel funds can be spent on routing (max_htlc_value_in_flight_msat) and the number of routes at a time that should be used on that channel (max_accepted_htlcs). If those limits would be violated by a route attempting to go to you, the route simply fails and the payer will have to find another route.

Regards, ZmnSCPxj

Sent with ProtonMail Secure Email.

-------- Original Message -------- Subject: Re: [Lightning-dev] Peer Selection Local Time: December 14, 2017 12:10 AM UTC Time: December 13, 2017 4:10 PM From: stan.kladko at galacticexchange.io To: ZmnSCPxj <ZmnSCPxj at protonmail.com> lightning-dev at lists.linuxfoundation.org <lightning-dev at lists.linuxfoundation.org>

Thank you - this is lots of information !) You would also have to make your outgoing channels private (not sent by node gossip) so that others will not route through you.

If I would have only a single outgoing channel I would not have to make it private ? Correct? There is no way to route through a node that has one channel.

Another interesting question is what happens if I have lots of channels, but in my software block all routing through my node?

Is there a way for me to block all routing through my node by modifying node software but still enjoy all benefits of receiving and sending deposits?

As you said, blocking all routing has lots of benefit since money is safe if the network is down :-)

Sorry for playing devils advocate - I am just trying to understand it )

On Wed, Dec 13, 2017 at 3:13 PM, ZmnSCPxj ZmnSCPxj at protonmail.com wrote: Good morning, If you have a reason to open a channel to an arbitrary node, then other nodes have a reason to open a channel to an arbitrary node, which might be you. Even if the network grows large, that > also means there are more participants who might decide, via whatever heuristic, to channel to your node. If I am connected to some nodes, but no one connected to me, then all of my deposit is used by me only, and is not used by other nodes. If I am routing nodes through my node, then it can potentially negatively affect availability of my deposit for my own transactions. So it seems to me that the best strategy is to connect but accept no incoming connections. How much real is this problem? You would also have to make your outgoing channels private (not sent by node gossip) so that others will not route through you. You will not be able to receive money on-Lightning (since your channels are private, people who are trying to send money to you on-Lightning will not be able to find a route to you). You will not earn any money from routing fees (since you are not willing to have others use your channels for routing). It has the advantage that you can actually lose Internet connectivity indefinitely with no possibility of loss of funds, simply because in this mode of operation, channels are effectively unidirectional only from you to the rest of the network. However, I think in the long run, you would prefer to receive funds by Lightning also, and so cannot use this kind of operation. Consider that in the future, you may get paid your salary or dividends in bitcoin over Lightning: your business/employer receives money from its customer over Lightning, it sends part of that money to sub-contractors and suppliers, and some to you (employee or shareholder). You then spend the money you receive as salary/dividends for food and services and other vices you might have, which are provided by other businesses which have their own shareholders, employees, sub-contractors, and suppliers. In such a world, you would have to make your channels public and accept incoming channels, and at minimum accept incoming money (even if you reject routing attempts). Since routing can earn you some amount of money as fees, you probably want to accept at least a few routing attempts at a time to earn some fees (and offset the fees on your own transactions). This also leads to a more mesh-like network; the "unidirectional mode" where you keep all your channels private and only outgoing effectively makes you a second-class member of the network (and has higher onchain fees: if you have depleted a channel, there is an incentive to keep it open only if you are willing to accept routing attempts through you (every open channel is an opportunity to route, and a channel depleted on your end is full on the opposite end and you can still at least accept transactions toward you), otherwise, you are better off closing channels (and incurring fees) so you can recover the channel reserve). Regards, ZmnSCPxj

Stan Kladko in reply to ZmnSCPxj permalink original

I see, thank you for the explanation.

Now I understand, so if my node is down and I received payments, I may lose some of my received payments. But if I route and someone routed large amounts of money through me, and then my node is down, then may lose these payments too.

Basically, if I am routing, then if my node crashes, I may be liable for some of the routed funds, in addition losing some of the funds I received .

So from the safety perspective there are three stages of risk

a) send only b) send and receive c) send and receive and route

On Thu, Dec 14, 2017 at 5:11 AM, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (138 lines)
> Good morning Stan,
>
> Money is safe when network is down only if you only pay out of your node.
> Once you receive, it is possible for your counterparty to transmit an
> invalid old state where it owns more money than you do.  Then you need to
> monitor the blockchain for invalid closings of channel state, meaning you
> cannot be offline for more than a few days (this timeout is settable in your
> node).
>
> Basically, consider the below situation:
>
> You make a channel to me and load it with 3mBTC.  You force the channel to
> be unidirectional, because you might be offline for months.
>
> Stan: 3mBTC, ZmnSCPxj: 0mBTC Initial state
> Stan: 2mBTC, ZmnSCPxj: 1mBTC after you pay me 1 mBTC
> Stan: 1mBTC, ZmnSCPxj: 2mBTC after you pay me 1 mBTC
>
> Now suppose you decide to accept money via this channel.  So the channel
> history now becomes:
>
> Stan: 2mBTC, ZmnSCPxj: 1mBTC after I pay you 1 mBTC
> Stan: 3mBTC, ZmnSCPxj: 0mBTC after I pay you 1 mBTC
>
> At this point, I can take back my 2mBTC by replaying the old "Stan: 1mBTC,
> ZmnSCPxj: 2mBTC" state.  Normally, this is a bad move on my part, since old
> state is revoked and you can present evidence of fraud on the blockchain
> layer to take the entire channel value as yours, as damages.  However, you
> only have a few days where you can present this evidence.  If those few days
> pass, then the payment is finalized and I get back the 2 mBTC I paid to you.
>
> The upshot is that if you receive money for any reason (whether for routing,
> or because you are the final payee) you can only be offline for at most a
> few days.  Otherwise, you force yourself into unidirectional mode only (you
> can only pay, never receive): unidirectional mode also is bad for you since
> you cannot offset the fees you pay for spending using fees you receive for
> routing.
>
> If you are going to receive money anyway, you might as well enable routing
> also, because that lets you earn some fees (to offset the fees you would pay
> to spend your money).  The added risk is low: most routes will either
> successfully reach the destination, or fail outright, within a few seconds,
> freeing the funds back to you again.
>
> The protocol has two settings "max_htlc_value_in_flight_msat" and
> "max_accepted_htlcs" to limit your exposure to routing risk.  These limit
> how much of your channel funds can be spent on routing
> (max_htlc_value_in_flight_msat) and the number of routes at a time that
> should be used on that channel (max_accepted_htlcs).  If those limits would
> be violated by a route attempting to go to you, the route simply fails and
> the payer will have to find another route.
>
> Regards,
> ZmnSCPxj
>
>
> Sent with ProtonMail Secure Email.
>
> -------- Original Message --------
> Subject: Re: [Lightning-dev] Peer Selection
> Local Time: December 14, 2017 12:10 AM
> UTC Time: December 13, 2017 4:10 PM
> From: stan.kladko at galacticexchange.io
> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>
> lightning-dev at lists.linuxfoundation.org
> <lightning-dev at lists.linuxfoundation.org>
>
> Thank you - this is lots of information !)
> You would also have to make your outgoing channels private (not sent by node
> gossip) so that others will not route through you.
>
> If I would have only a single outgoing channel I would not have to
> make it private ? Correct? There is no way to route through a node
> that has one channel.
>
> Another interesting question is what happens if I have lots of
> channels, but in my software block all routing through my node?
>
> Is there a way for me to block all routing through my node by
> modifying node software but still enjoy all benefits of receiving and
> sending deposits?
>
> As you said, blocking all routing has lots of benefit since money is
> safe if the network is down :-)
>
> Sorry for playing devils advocate - I am just trying to understand it )
>
>
>
> On Wed, Dec 13, 2017 at 3:13 PM, ZmnSCPxj ZmnSCPxj at protonmail.com wrote:
> Good morning,
> If you have a reason to open a channel to an arbitrary node, then other
> nodes have a reason to open a channel to an arbitrary node, which might be
> you. Even if the
> network grows large, that > also means there are more participants who
> might decide, via whatever heuristic, to channel to your node.
> If I am connected to some nodes, but no one connected to me, then all
> of my deposit is used by me only, and is not used by other nodes.
> If I am routing nodes through my node, then it can potentially
> negatively affect availability of my deposit for my own transactions.
> So it seems to me that the best strategy is to connect but accept no
> incoming connections.
> How much real is this problem?
> You would also have to make your outgoing channels private (not sent by node
> gossip) so that others will not route through you. You will not be able to
> receive money on-Lightning (since your channels are private, people who are
> trying to send money to you on-Lightning will not be able to find a route to
> you). You will not earn any money from routing fees (since you are not
> willing to have others use your channels for routing).
> It has the advantage that you can actually lose Internet connectivity
> indefinitely with no possibility of loss of funds, simply because in this
> mode of operation, channels are effectively unidirectional only from you to
> the rest of the network.
> However, I think in the long run, you would prefer to receive funds by
> Lightning also, and so cannot use this kind of operation. Consider that in
> the future, you may get paid your salary or dividends in bitcoin over
> Lightning: your business/employer receives money from its customer over
> Lightning, it sends part of that money to sub-contractors and suppliers, and
> some to you (employee or shareholder). You then spend the money you receive
> as salary/dividends for food and services and other vices you might have,
> which are provided by other businesses which have their own shareholders,
> employees, sub-contractors, and suppliers.
> In such a world, you would have to make your channels public and accept
> incoming channels, and at minimum accept incoming money (even if you reject
> routing attempts). Since routing can earn you some amount of money as fees,
> you probably want to accept at least a few routing attempts at a time to
> earn some fees (and offset the fees on your own transactions). This also
> leads to a more mesh-like network; the "unidirectional mode" where you keep
> all your channels private and only outgoing effectively makes you a
> second-class member of the network (and has higher onchain fees: if you have
> depleted a channel, there is an incentive to keep it open only if you are
> willing to accept routing attempts through you (every open channel is an
> opportunity to route, and a channel depleted on your end is full on the
> opposite end and you can still at least accept transactions toward you),
> otherwise, you are better off closing channels (and incurring fees) so you
> can recover the channel reserve).
> Regards,
> ZmnSCPxj
Christian Decker in reply to Stan Kladko permalink original

Let me add some more color to the discussion.

If you do not announce the existence of the channel to the wider network you can still receive incoming payments, by simply telling the payment sender about the channel. This is what is being done in the payment request by adding the `r` parameter to the request. You are selectively informing the sender about the channel, which can then use that information to construct the route (and onion packet) and initiate the payment.

Even though you have only one channel, and announce it, people might still want to route through you, by using the channel twice: once to route to you and then back out from you. While this may seem wasteful, it may be useful to hide the real origin/destination of the payment. Another scenario for which this is useful is that you are an auditor that witnesses the payment while it is being processed, for book keeping or similar cases. This would also work for unannounced channels.

So the decision whether to announce a channel is exactly what you're looking for. It allows you to do bidirectional payments, and does not allow random people to route through you. Implementations might eventually add an "endpoint mode" that rejects any HTLC for which the node is not the origin or the destination, which would further enforce this.

Cheers, Christian

Stan Kladko in reply to Christian Decker permalink original

Hi Cristian,

If there is such a great company, BlockStream. and Blockstream runs a fantastic high quality node, then as a user why should I connect to any node other than Blockstream? In this case I dont need to be online all the time and dont need to monitor the blockchain for anything. I will just believe that Blockstream will do no bad to me.

Why do I need to drink unnamed cola if there is Pepsi?)) People used to run emails servers, it is all Gmail now, much more secure and reliable!

On Fri, Dec 15, 2017 at 9:06 PM, Christian Decker <decker.christian at gmail.com> wrote:

Quoted text (27 lines)
> Let me add some more color to the discussion.
>
> If you do not announce the existence of the channel to the wider network
> you can still receive incoming payments, by simply telling the payment
> sender about the channel. This is what is being done in the payment
> request by adding the `r` parameter to the request. You are selectively
> informing the sender about the channel, which can then use that
> information to construct the route (and onion packet) and initiate the
> payment.
>
> Even though you have only one channel, and announce it, people might
> still want to route through you, by using the channel twice: once to
> route to you and then back out from you. While this may seem wasteful,
> it may be useful to hide the real origin/destination of the
> payment. Another scenario for which this is useful is that you are an
> auditor that witnesses the payment while it is being processed, for book
> keeping or similar cases. This would also work for unannounced channels.
>
> So the decision whether to announce a channel is exactly what you're
> looking for. It allows you to do bidirectional payments, and does not
> allow random people to route through you. Implementations might
> eventually add an "endpoint mode" that rejects any HTLC for which the
> node is not the origin or the destination, which would further enforce
> this.
>
> Cheers,
> Christian
Christian Decker in reply to Stan Kladko permalink original

For one thing having a single connection means that the peer you're connecting to can see all your payment amounts and their timings, and they can be sure that they are from you since you don't have any other channel. Opening more channels gives you plausible deniability. Also it'd make your single peer a single point of failure, meaning that if it goes down you're dead in the water.

And then on the other end, we have no interest in running a large hub in the first place. They're expensive to run, since we'd have to allocate enough funds to cover the sum of payments you might receive over time (which is already hard to know, so we'd have to over-provision). That'd also make the hub an attractive target for an attack, since it'd have a lot of funds sitting in hot wallets. Furthermore the utility the hub gets from the funds it allocates to the channels going to endpoints, such as your node, is very minimal, since it can only earn fees on payments that are either initiated by you or received by you, meaning the funds mostly sit idle. Compare that to a channel that is very active because it bridges two large clusters in the network. The low utilization of the funds in the channel also means that hubs will have to charge large fees for the few times the channels are actually used, which again is an incentive for you to create bypasses.

I think these arguments alone are probably sufficient to discourage the formation of large hubs, and should incentivize even end-users to create at least 2 channels. Remember that this is all taken care of in the background by the client, users don't actually have to think about opening/closing/maintaining channels, or how to allocate funds to the channels. Our goal in the end is to create clients that show a single balance, allow users to make both off-chain or on-chain payments from that balance, and not require people to ever think about the details in the background.

I appreciate your trust in Blockstream, but as our informal motto says "don't trust, verify!" :-)

Cheers, Christian

Stan Kladko <stan.kladko at galacticexchange.io> writes:

Quoted text (45 lines)
> Hi Cristian,
>
> If there is such a great company, BlockStream. and Blockstream runs a
> fantastic high quality node, then as a user why should I connect to
> any node other than Blockstream?
> In this case I dont need to be online all the time and dont need to
> monitor the blockchain for anything. I will just believe that
> Blockstream will do no bad to me.
>
> Why do I need to drink unnamed cola if there is Pepsi?))  People used
> to run emails servers, it is all Gmail now, much more secure and
> reliable!
>
>
>
>
> On Fri, Dec 15, 2017 at 9:06 PM, Christian Decker
> <decker.christian at gmail.com> wrote:
>> Let me add some more color to the discussion.
>>
>> If you do not announce the existence of the channel to the wider network
>> you can still receive incoming payments, by simply telling the payment
>> sender about the channel. This is what is being done in the payment
>> request by adding the `r` parameter to the request. You are selectively
>> informing the sender about the channel, which can then use that
>> information to construct the route (and onion packet) and initiate the
>> payment.
>>
>> Even though you have only one channel, and announce it, people might
>> still want to route through you, by using the channel twice: once to
>> route to you and then back out from you. While this may seem wasteful,
>> it may be useful to hide the real origin/destination of the
>> payment. Another scenario for which this is useful is that you are an
>> auditor that witnesses the payment while it is being processed, for book
>> keeping or similar cases. This would also work for unannounced channels.
>>
>> So the decision whether to announce a channel is exactly what you're
>> looking for. It allows you to do bidirectional payments, and does not
>> allow random people to route through you. Implementations might
>> eventually add an "endpoint mode" that rejects any HTLC for which the
>> node is not the origin or the destination, which would further enforce
>> this.
>>
>> Cheers,
>> Christian