Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

network topology and routing

5 messages, Sep 15 to 22, 2015. Started by Pierre.

Pierre (3), Anthony Towns, Rusty Russell

Permalink First message in the Wayback Machine

Pierre permalink original

Hello,

I know there hasn't been much work on routing yet (not that I am aware of at least), but it seems there is a consensus around the fact that the target network topology would look like this : https://s3-eu-west-1.amazonaws.com/acinq/public/lightning_network_1.svg

implying that : - there would exist multiple paths to a target user - reaching a target user would require several hops - some nodes might even be connected only to nodes

This puzzles me because the network topology I expected would look more like this : https://s3-eu-west-1.amazonaws.com/acinq/public/lightning_network_2.svg

I am not saying each node should be aware of every other node, but that : - nodes connected only to nodes shouldn't exist - when user A sends a payment to user B, it goes through at most 2 nodes, or just 1 if A and B are connected to the same node

The reason for that is there is an incentive for reducing the number of hops right ? Because it is faster (each hop adds latency) and cheaper (each hop adds a fee).

With that in mind, why would routing be more complicated than just <user-id>@<node> ? Then we just agree on a standard port and that's it ! Isn't it how the internet works already ? Why do we need an application-level routing on top of the IP routing ?

Now that I made a fool of myself, please correct me :-)

Cheers

Pierre

Anthony Towns in reply to Pierre permalink original

On Tue, Sep 15, 2015 at 02:10:18PM +0200, Pierre wrote:

Quoted text (1 line)
> Now that I made a fool of myself, please correct me :-)

None of what you said seems foolish to me; routing's an open problem...

Quoted text (5 lines)
> I know there hasn't been much work on routing yet (not that I am aware of
> at least), but it seems there is a consensus around the fact that the
> target network topology would look like this :
> [a] https://s3-eu-west-1.amazonaws.com/acinq/public/lightning_network_1.svg
> [b] https://s3-eu-west-1.amazonaws.com/acinq/public/lightning_network_2.svg

Both these indicate each wallet (end-user) is connected to just one node; I'd expect the usual case to be two or three so you can more easily deal with downtime by a node.

Quoted text (9 lines)
> [a] implying that :
> - there would exist multiple paths to a target user
> - reaching a target user would require several hops
> - some nodes might even be connected only to nodes
>
> This puzzles me because the network topology I expected would look more
> like [b]:
> I am not saying each node should be aware of every other node, but that :
> - nodes connected only to nodes shouldn't exist

If I'm an end-user with a wallet with two channels; and I switch my software to being a full lightning node with the same two channels, I'd end up in this state. Likewise if I was a new node trying to establish myself on the network.

Also, if there's a lot of traffic from node A to node B, their channel will become lopsided (B will own all the coins), if it turns out that C has channels with both A and B, a circular transaction A -> C -> B -> A would allow those channels to rebalance (and x->A->C->B->y would allow x and y to continue to transact despite A->B being full). If that happens a lot, it might be profitable for everyone concerned if "C" sets up a node that only does that, and doesn't deal with end-users directly.

Quoted text (2 lines)
> - when user A sends a payment to user B, it goes through at most 2 nodes,
> or just 1 if A and B are connected to the same node

That's optimal for efficiency, but probably pessimal for privacy. If lightning is fast and cheap enough, delaying things slightly for a significant increase in privacy would be worthwhile.

Quoted text (5 lines)
> The reason for that is there is an incentive for reducing the number of
> hops right ? Because it is faster (each hop adds latency) and cheaper (each
> hop adds a fee).
> With that in mind, why would routing be more complicated than just
> <user-id>@<node> ?

Setting up channels isn't free, though -- it costs a blockchain transaction, and locks up bitcoins for no value if the channel's idle -- so you also want to minimise the number of channels, not just the number of hops for a transaction.

I think this means you actually want to optimise a formula more like

   ALPHA * (d/2 * N^2) + BETA * log_d( N )

where N is number of nodes, and d is the average number of channels a node has open, and ALPHA and BETA are (roughly) the costs of having a channel, and adding a hop to the average transaction respectively.

Quoted text (3 lines)
> Then we just agree on a standard port and that's it !
> Isn't it how the internet works already ? Why do we need an
> application-level routing on top of the IP routing ?

1) It'd be expensive to join the lightning network (if I wanted to be able to send up to $5 to anyone, and there were 100 nodes on the network, I'd need to commit $500 to lightning channels up front).

2) It'd be easy to block payments (USA bans anyone from setting up channels with anyone in Cuba; Cubans can't run nodes)

3) If there's a communications blockage, there's no ability to route around it.

That said, no routing might still result in a functional system when we're just trying things out and there's only a handful of people running nodes?

Cheers, aj

Pierre in reply to Anthony Towns permalink original
Quoted text (3 lines)
> Both these indicate each wallet (end-user) is connected to just one node;
> I'd expect the usual case to be two or three so you can more easily deal
> with downtime by a node.

Yes, I skipped that.

Quoted text (4 lines)
> If I'm an end-user with a wallet with two channels; and I switch my
> software to being a full lightning node with the same two channels, I'd
> end up in this state. Likewise if I was a new node trying to establish
> myself on the network.

I understand the idea and advantages of everybody running a node, to be honest I implicitely discarded this possibility in favor of a limited (10s ? 100s ?) number of specialized supernodes. I feel like having a lot of small nodes that constantly appear and disappear is somewhat incompatible with a reliable and low latency (<1s ?) payment network, but I admit I am probably too pessimistic !

Quoted text (7 lines)
> Also, if there's a lot of traffic from node A to node B, their channel
> will become lopsided (B will own all the coins), if it turns out that
> C has channels with both A and B, a circular transaction A -> C -> B ->
> A would allow those channels to rebalance (and x->A->C->B->y would allow
> x and y to continue to transact despite A->B being full). If that happens
> a lot, it might be profitable for everyone concerned if "C" sets up a
> node that only does that, and doesn't deal with end-users directly.

This makes sense, although if I am not mistaken it can only be done once, because then C will own all the coins in the channel A-C, and if A-B becomes lopsided again A will need to find yet another circular route. I would think in that case B would be more likely to cash out as mentioned here : https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2015/atomic-swap#m-93b0d90f. In fact, I think that members of the lightning network will be "strongly typed": overall they will either mainly send or mainly receive money.

Quoted text (3 lines)
> That's optimal for efficiency, but probably pessimal for privacy. If
> lightning is fast and cheap enough, delaying things slightly for a
> significant increase in privacy would be worthwhile.

Agreed.

Quoted text (4 lines)
> Setting up channels isn't free, though -- it costs a blockchain
> transaction, and locks up bitcoins for no value if the channel's idle --
> so you also want to minimise the number of channels, not just the number
> of hops for a transaction.

This actually leads me to the "supernode" conclusion. End user would only have a handful of channels set up with a few of those large, well-connected nodes. Just one remark on the fact that funds would be locked in a channel: if lightning is widely successful and becomes the primary way of doing payments, don't you think that this would change our perception of which funds (in a wallet or in an open channel) are actually more usable ?

Quoted text (7 lines)
>> Then we just agree on a standard port and that's it !
>> Isn't it how the internet works already ? Why do we need an
>> application-level routing on top of the IP routing ?
>
> 1) It'd be expensive to join the lightning network (if I wanted to be
> able to send up to $5 to anyone, and there were 100 nodes on the
> network, I'd need to commit $500 to lightning channels up front).

In my view you would just be connected to a few nodes which would handle the rest.

Quoted text (2 lines)
> 2) It'd be easy to block payments (USA bans anyone from setting up
> channels with anyone in Cuba; Cubans can't run nodes)

Good point...

Quoted text (2 lines)
> 3) If there's a communications blockage, there's no ability to route
> around it.

True, but this is mitigated by the fact that every participant of the network would be connected to a few nodes, so we can imagine that a merchant would require to be paid at id1 at node1 or id2 at node2 ?

Cheers,

Pierre

Rusty Russell in reply to Pierre permalink original

Hi Pierre,

        Sorry for the delay; Blockstream had a big meeting after the
Montreal Scaling Bitcoin workshop, so I've been distracted.

Pierre <pm+lists at acinq.fr> writes:

Quoted text (10 lines)
>> If I'm an end-user with a wallet with two channels; and I switch my
>> software to being a full lightning node with the same two channels, I'd
>> end up in this state. Likewise if I was a new node trying to establish
>> myself on the network.
> I understand the idea and advantages of everybody running a node, to
> be honest I implicitely discarded this possibility in favor of a
> limited (10s ? 100s ?) number of specialized supernodes. I feel like
> having a lot of small nodes that constantly appear and disappear is
> somewhat incompatible with a reliable and low latency (<1s ?) payment
> network, but I admit I am probably too pessimistic !

Me too. Initially I was thinking of hub and spokes like this. It's certainly far simpler to organize routing among a few thousand supernodes.

But the interests of robustness privacy, decentralization, and the tantalizing possibility of negative fees all point to a flatter design (though I expect some power law to emerge).

Quoted text (12 lines)
>> Setting up channels isn't free, though -- it costs a blockchain
>> transaction, and locks up bitcoins for no value if the channel's idle --
>> so you also want to minimise the number of channels, not just the number
>> of hops for a transaction.
> This actually leads me to the "supernode" conclusion. End user would
> only have a handful of channels set up with a few of those large,
> well-connected nodes.
> Just one remark on the fact that funds would be locked in a channel:
> if lightning is widely successful and becomes the primary way of doing
> payments, don't you think that this would change our perception of
> which funds (in a wallet or in an open channel) are actually more
> usable ?

Possibly. But if it's the primary method of payments, you won't think of them as "locked in a channel".

Quoted text (3 lines)
>>> Then we just agree on a standard port and that's it !
>>> Isn't it how the internet works already ? Why do we need an
>>> application-level routing on top of the IP routing ?

You still need non-IP routing, unfortunately. It's an overlay network of channels (probably across multiple networks, like TOR, UDP etc), and there's no logical grouping to make routing tables smaller than "every node".

Quoted text (5 lines)
>> 1) It'd be expensive to join the lightning network (if I wanted to be
>> able to send up to $5 to anyone, and there were 100 nodes on the
>> network, I'd need to commit $500 to lightning channels up front).
> In my view you would just be connected to a few nodes which would
> handle the rest.

Definitely.

Quoted text (9 lines)
>> 2) It'd be easy to block payments (USA bans anyone from setting up
>> channels with anyone in Cuba; Cubans can't run nodes)
> Good point...
>
>> 3) If there's a communications blockage, there's no ability to route
>> around it.
> True, but this is mitigated by the fact that every participant of the
> network would be connected to a few nodes, so we can imagine that a
> merchant would require to be paid at id1 at node1 or id2 at node2 ?

I started exactly where you are! I was forced to throw it away to try to make it as distributed-by-default as possible. That all nodes are equal to by design, and we try to be clever with routing.

I think I have a method, too. It won't scale infinitely, but might work for a few million nodes...

Cheers, Rusty.

Pierre in reply to Rusty Russell permalink original
Quoted text (2 lines)
>         Sorry for the delay; Blockstream had a big meeting after the
> Montreal Scaling Bitcoin workshop, so I've been distracted.

No problem! I think you met Fabrice there, he told me the whole thing was pretty interesting. I'll probably attend the Hong Kong event.

Quoted text (3 lines)
> I started exactly where you are!  I was forced to throw it away to try
> to make it as distributed-by-default as possible.  That all nodes are
> equal to by design, and we try to be clever with routing.

Well, if I had done my homework properly I would have stumbled upon this discussion https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2015/routing-on-the-lightning-network#m-ede6ac58 before... I still think the path we are taking is very ambitious, but what the hell! Let's do this!

Quoted text (2 lines)
> I think I have a method, too.  It won't scale infinitely, but might work
> for a few million nodes...

Looking forward to see that.

Cheers,

Pierre