Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Testing a Flare-like routing implementation on 2500 AWS nodes

5 messages, Sep 18 to 22, 2016. Started by Pierre.

Pierre (2), Fabrice Drouin, Olaoluwa Osuntokun, Gary Mulder

Permalink First message in the Wayback Machine

Pierre permalink original

TLDR: It kind of works (there is a 80+% chance of finding a route to any other node in ~500ms).

Hello guys,

Flare[1] is a routing protocol for the Lightning Network which combines local neighborhood maps and paths to remote beacons. It is really interesting and the simulations are promising, so we wanted to give it a try and actually implement it in Eclair. We ended up with a close variant [2], and tested it on 2500 nodes on AWS.

The main difference between our implementation and the original paper is in the way nodes communicate with each other. In the paper, an assumption is made that "there exists a way for any two nodes in LN to communicate with each other, perhaps with some prior setup (such as a distributed hashtable overlay maintained among LN nodes that would store mapping of node identifiers to their current IP addresses)". In our implementation there is no DHT: inter-nodes communication only occurs on existing open channels, and all routing-related messages are onion-encrypted and routed themselves, just like htlc messages. So a node can't talk directly to a node it doesn't already have a route to. This certainly has a cost but it should also improves privacy, and overall we think that using a DHT isn't necessary. Also, making the assumption that a node is reachable from the outside is rather strong, particularly for mobile/light wallets. Whereas by communicating over channels, a node can actively participate to the global routing as soon as it has more than two channels.

The neighbor discovery/beacons selection is pretty similar to what's in the paper, but a little bit simplified : - nodes don't ack table update messages (it is probably not needed since it occurs between adjacent nodes and any disconnection will be noticed) - nodes don't tell other nodes that they have been chosen as beacon (there is no beacon_set message). A given node knows it is a candidate because it received a beacon_req message, but it won't know if it was eventually selected.

We only focused on static ranking (finding a route formed of open channels between two given nodes), so it is very possible (probable?) that a route is not actually usable because the channels are not balanced. Basically we made the assumption that the network graph is undirected, which is not true and is a pretty strong assumption.

The route selection has also been simplified. Whereas Flare proposed a 3 steps process: (a) sender uses its own routing table (b) sender requests receiver's table and uses a combination of the two tables (c) sender iterates over nodes it knows that are close to the receiver, and request their tables in our test we only did (b), which is a strong tradeoff. It means that the time allowed to find a route is short and predictable, but it is very suboptimal in terms of probability of finding a route.

Below are the results of a few tests we ran on AWS. The procedure was as follows: 1) start a certain number of m1.medium instances with standard linux AMI 2) after startup the instances run an init script that d/l oracle jdk and our jar, then run the jar 3) from a control server, we link nodes to each other following a given graph using json-rpc commands 4) wait a few minutes for the gossip to calm down (it can be pretty intense with radius=3 [3] and our implementation is not optimized) 5) pick 1000 random routes (random sender, random receiver), and for each route using json-rpc we (a) asks the receiver for a "payment request" (H + routing_table) and then (b) asks the sender to find a route for this payment request (without actually making a payment). 6) collect stats

Caveats: - nodes are connected all at once (step 3) above), and don't periodically reconcile their own routing table with that of their neighbors (neighbor_reset in the paper). This leads to nodes not knowing all the nodes in their radius, and probably has a significant negative impact on results; we figured this out afterwards :-s - there is no "proof of channels" (nodes are not lying to each other about existing channels) - onion messages are not actually encrypted (although channel communications are) - it is a "LAN" setup so things wouldn't be that smooth in reality (although we are testing static routes so it doesn't actually matter that much) - smallworld graphs may seem a little bit optimistic in terms of actual network topology - ...

Parameters and results (probability of finding a route to any given node):
test nodes   r    beacon_count     graph      result  t_avg
  A  1000    2    10            sw1000_6_02     87%
  B  2000    2    10            sw2000_6_02     76%    305ms
  C  2500    2    10            sw2500_4_01    ~20%
  D  2500    3    10            sw2500_4_01     43%    377ms
  E  2500    3    10            sw2500_6_02     83%    532ms
Note: a swX_Y_0Z graph is a smallworld graph generated using the Watts and
Strogatz model with n=X, k=Y and beta=0.Z
Network size (known nodes):
test adjacent  all
  A
  B    6.8    62.3
  C
  D    4.0    58.8
  E    6.0    97.0
Note: expected values for column 'all' should be D=4^3=64+ and E=6^3=216+,
see caveat above. The good thing is that a radius=2 might actually be
enough, just like the paper says!
Beacons:
test dist_avg dist_max dist_var
  A
  B    7.4      39      29.4
  C
  D    9.2      96      79.5
  E    8.1      45      36.0
Route lengths:
test  len_avg len_max len_var
  A     5.4    26.0     3.3
  B     6.2    30.0     6.2
  C
  D    17.9    74.0   109.5
  E     7.3    28.0     5.6
Response time (this includes sender requesting the receiver's routing table
and running a dijkstra):
test  t_avg   t_max
  A
  B   305ms   5158ms
  C
  D   377ms   7809ms
  E   532ms   5128ms
Note: High max times are probably related to the use of poor-performance
instances that sometimes behave erratically (unfortunately we don't have
the variance).

In conclusion, we show that our modified version of Flare actually works on a decent size network. Because of the bug mentioned in the caveats, the value of the radius parameter should be taken with caution. One of the main concerns for us is the fact that the graph is in fact directed and that at creation channels are actually one-way. This might make finding route very difficult at bootstrapping.

Cheers,

Pierre

[1] http://bitfury.com/content/5-white-papers-research/bitfury_whitepaper_shared_send_untangling_in_bitcoin_8_24_2016.pdf [2] https://github.com/ACINQ/eclair/blob/wip-flare/eclair-node/src/main/scala/fr/acinq/eclair/router/FlareRouter.scala [3] https://s3-eu-west-1.amazonaws.com/acinq/public/network_out.PNG

Fabrice Drouin in reply to Pierre permalink original

Edit: our link to the Flare white paper should be [1] http://bitfury.com/content/5-white-papers-research/whitepaper_flare_an_approach_to_routing_in_lightning_network_7_7_2016.pdf

Fabrice

On 18 September 2016 at 14:58, Pierre <pm+lists at acinq.fr> wrote:

Quoted text (157 lines)
> TLDR: It kind of works (there is a 80+% chance of finding a route to any
> other node in ~500ms).
>
> Hello guys,
>
> Flare[1] is a routing protocol for the Lightning Network which combines
> local neighborhood maps and paths to remote beacons. It is really
> interesting and the simulations are promising, so we wanted to give it a try
> and actually implement it in Eclair. We ended up with a close variant [2],
> and tested it on 2500 nodes on AWS.
>
> The main difference between our implementation and the original paper is in
> the way nodes communicate with each other. In the paper, an assumption is
> made that "there exists a way for any two nodes in LN to communicate with
> each other, perhaps with some prior setup (such as a distributed hashtable
> overlay maintained among LN nodes that would store mapping of node
> identifiers to their current IP addresses)". In our implementation there is
> no DHT: inter-nodes communication only occurs on existing open channels, and
> all routing-related messages are onion-encrypted and routed themselves, just
> like htlc messages. So a node can't talk directly to a node it doesn't
> already have a route to. This certainly has a cost but it should also
> improves privacy, and overall we think that using a DHT isn't necessary.
> Also, making the assumption that a node is reachable from the outside is
> rather strong, particularly for mobile/light wallets. Whereas by
> communicating over channels, a node can actively participate to the global
> routing as soon as it has more than two channels.
>
> The neighbor discovery/beacons selection is pretty similar to what's in the
> paper, but a little bit simplified :
> - nodes don't ack table update messages (it is probably not needed since it
> occurs between adjacent nodes and any disconnection will be noticed)
> - nodes don't tell other nodes that they have been chosen as beacon (there
> is no beacon_set message). A given node knows it is a candidate because it
> received a beacon_req message, but it won't know if it was eventually
> selected.
>
> We only focused on static ranking (finding a route formed of open channels
> between two given nodes), so it is very possible (probable?) that a route is
> not actually usable because the channels are not balanced. Basically we made
> the assumption that the network graph is undirected, which is not true and
> is a pretty strong assumption.
>
> The route selection has also been simplified. Whereas Flare proposed a 3
> steps process:
> (a) sender uses its own routing table
> (b) sender requests receiver's table and uses a combination of the two
> tables
> (c) sender iterates over nodes it knows that are close to the receiver, and
> request their tables
> in our test we only did (b), which is a strong tradeoff. It means that the
> time allowed to find a route is short and predictable, but it is very
> suboptimal in terms of probability of finding a route.
>
> Below are the results of a few tests we ran on AWS. The procedure was as
> follows:
> 1) start a certain number of m1.medium instances with standard linux AMI
> 2) after startup the instances run an init script that d/l oracle jdk and
> our jar, then run the jar
> 3) from a control server, we link nodes to each other following a given
> graph using json-rpc commands
> 4) wait a few minutes for the gossip to calm down (it can be pretty intense
> with radius=3 [3] and our implementation is not optimized)
> 5) pick 1000 random routes (random sender, random receiver), and for each
> route using json-rpc we (a) asks the receiver for a "payment request" (H +
> routing_table) and then (b) asks the sender to find a route for this payment
> request (without actually making a payment).
> 6) collect stats
>
> Caveats:
> - nodes are connected all at once (step 3) above), and don't periodically
> reconcile their own routing table with that of their neighbors
> (neighbor_reset in the paper). This leads to nodes not knowing all the nodes
> in their radius, and probably has a significant negative impact on results;
> we figured this out afterwards :-s
> - there is no "proof of channels" (nodes are not lying to each other about
> existing channels)
> - onion messages are not actually encrypted (although channel communications
> are)
> - it is a "LAN" setup so things wouldn't be that smooth in reality (although
> we are testing static routes so it doesn't actually matter that much)
> - smallworld graphs may seem a little bit optimistic in terms of actual
> network topology
> - ...
>
> Parameters and results (probability of finding a route to any given node):
> test nodes   r    beacon_count     graph      result  t_avg
>   A  1000    2    10            sw1000_6_02     87%
>   B  2000    2    10            sw2000_6_02     76%    305ms
>   C  2500    2    10            sw2500_4_01    ~20%
>   D  2500    3    10            sw2500_4_01     43%    377ms
>   E  2500    3    10            sw2500_6_02     83%    532ms
> Note: a swX_Y_0Z graph is a smallworld graph generated using the Watts and
> Strogatz model with n=X, k=Y and beta=0.Z
>
> Network size (known nodes):
> test adjacent  all
>   A
>   B    6.8    62.3
>   C
>   D    4.0    58.8
>   E    6.0    97.0
> Note: expected values for column 'all' should be D=4^3=64+ and E=6^3=216+,
> see caveat above. The good thing is that a radius=2 might actually be
> enough, just like the paper says!
>
> Beacons:
> test dist_avg dist_max dist_var
>   A
>   B    7.4      39      29.4
>   C
>   D    9.2      96      79.5
>   E    8.1      45      36.0
>
> Route lengths:
> test  len_avg len_max len_var
>   A     5.4    26.0     3.3
>   B     6.2    30.0     6.2
>   C
>   D    17.9    74.0   109.5
>   E     7.3    28.0     5.6
>
> Response time (this includes sender requesting the receiver's routing table
> and running a dijkstra):
> test  t_avg   t_max
>   A
>   B   305ms   5158ms
>   C
>   D   377ms   7809ms
>   E   532ms   5128ms
> Note: High max times are probably related to the use of poor-performance
> instances that sometimes behave erratically (unfortunately we don't have the
> variance).
>
> In conclusion, we show that our modified version of Flare actually works on
> a decent size network. Because of the bug mentioned in the caveats, the
> value of the radius parameter should be taken with caution. One of the main
> concerns for us is the fact that the graph is in fact directed and that at
> creation channels are actually one-way. This might make finding route very
> difficult at bootstrapping.
>
>
> Cheers,
>
> Pierre
>
>
> [1]
> http://bitfury.com/content/5-white-papers-research/bitfury_whitepaper_shared_send_untangling_in_bitcoin_8_24_2016.pdf
> [2]
> https://github.com/ACINQ/eclair/blob/wip-flare/eclair-node/src/main/scala/fr/acinq/eclair/router/FlareRouter.scala
> [3] https://s3-eu-west-1.amazonaws.com/acinq/public/network_out.PNG
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
Olaoluwa Osuntokun in reply to Fabrice Drouin permalink original

Hi, y'all

Excellent work!!

As you noted our, Flare paper as currently written only includes a series of simulations of various topologies/parameters which are then extrapolated to larger network sizes. The logical next step would be to deploy a proto-implementation within a live testbed with real latencies, preferential attachment, etc. I'm thrilled that y'all went ahead getting your hands dirty to gauge the real-word feasibility of our scheme.

Quoted text (4 lines)
> In the paper, an assumption is made that "there exists a way for any two
> nodes in LN to communicate with each other, perhaps with some prior setup
> (such as a distributed hashtable overlay maintained among LN nodes that
> would store mapping of node identifiers to their current IP addresses)".

In reality we envisioned that a DHT would acts as a substitute for a pure broadcast network, rather than to allow individual nodes to communicate with each other. At the time of the writing of the paper, we envisioned that information such as the current onion key for each node, identity keys, channel proofs, etc would potentially be stored within a DHT.

For communications, we referenced that something akin to HORNET could be used to allow nodes to communicate with each other without necessarily knowing the IP address of each node or a node's selected beacons. As y'all noted, in this scenario, nodes would only be able to directly communicate with nodes that they have a direct path to.

HORNET was especially attractive as as after its setup phase, there exists a bi-directional communication link between two nodes. This link could either be used in a request/response manner to notify a node that it's a selected beacon and/or to fetch routing tables, or in a more streaming manner between the sender/receiver to negotiate the details of further payments (additional R-Hashes, etc) once the link was established. As a substitute for the first use-case (request/response) the latest design of our Sphinx construction could be used, with the requesting node providing the backwards path within the e2e payload. It's worth noting that this substitute reveals the entire path to the responding node, while construction based on HORNET still obfuscates the backwards route from the target node. Additionally with HORNET, the backwards route can be distinct from the forwards route.

Quoted text (8 lines)
> We only focused on static ranking (finding a route formed of open channels
> between two given nodes), so it is very possible (probable?) that a route
is
> not actually usable because the channels are not balanced. Basically we
made
> the assumption that the network graph is undirected, which is not true
and is a
> pretty strong assumption.

Indeed, as channels themselves have fixed capacities, proper path finding stems beyond simply "shortest path", and begins to wonder into the realm of network flow theory[1]. Assuming nodes are aware of the available channel capacity and current fee advertised by the each node, then optimal path (cheapest) path can be discovered by solving the for the min-cost flow[2] within the node's subset of the network graph. Additionally, the cost function for each edge within the graph can also factor in the absolute HTLC time delay between each node.

On a related note, in the past Tadge has suggested that the available channel capacity that a nodes wants to advertise should be an input to a function which derives the advertised fee across the link. One potential strategy would be to have the advertised fee be inversely proportional to a metric which captures how balanced the channel is. So if a channel was mostly unbalanced to in one direction, then the advertised fee in that direction would be relatively "high", while in the opposite (balancing flow) direction the advertised fee would be proportionally lower. Fully depleted channels (which should only exist right after channel creation, with no committed state transitions) would then advertise a fee of "infinity" allowing nodes to update their path finding accordingly (something Rusty pointed out the other day). Following down this line of thinking further beings to invoke the concept of "negative fees" which have been discussed a bit informally in the past.

Quoted text (2 lines)
> 3) from a control server, we link nodes to each other following a given
> graph using json-rpc commands

Was the capacity of the channels created uniform? Or were the channel values uniformly distributed? Or perhaps drawn from a particular distribution?

Quoted text (5 lines)
> 5) pick 1000 random routes (random sender, random receiver), and for each
> route using json-rpc we (a) asks the receiver for a "payment request" (H +
> routing_table) and then (b) asks the sender to find a route for this
payment
> request (without actually making a payment).

Similar to the question above, how were the satoshis requested within the "payment request" distributed?

-- Laolu

[1]: https://en.wikipedia.org/wiki/Flow_network [2]: https://en.wikipedia.org/wiki/Minimum-cost_flow_problem

Pierre in reply to Olaoluwa Osuntokun permalink original
Quoted text (1 line)
> Excellent work!!

Thanks!

Quoted text (5 lines)
> In reality we envisioned that a DHT would acts as a substitute for a pure
> broadcast network, rather than to allow individual nodes to communicate with
> each other. At the time of the writing of the paper, we envisioned that
> information such as the current onion key for each node, identity keys,
> channel proofs, etc would potentially be stored within a DHT.

Got it, that makes sense. The reference to ip adress was confusing I guess.

Quoted text (4 lines)
> For communications, we referenced that something akin to HORNET could be
> used to allow nodes to communicate with each other [...]
> HORNET was especially attractive as as after its setup phase, there exists a
> bi-directional communication link between two nodes.

Yes I remember you mentioned HORNET on this ml some time ago. I am not too familiar with it, but I think it operates at the network layer, right? I am curious how you envision the relation between this layer and the application layer: would an application-level link (LN channel) be *equal* to a network-level link (whatever link there is between two adjacent HORNET nodes if there is such a thing)? Or would that be completely orthogonal, meaning if A and B have a channel open an htlc going from A to B could have to be routed through other nodes? Does this question make sense?

Quoted text (2 lines)
> Additionally with
> HORNET, the backwards route can be distinct from the forwards route.

That is an amazing feature, kind of magical really!

Quoted text (5 lines)
> As a substitute for the first
> use-case (request/response) the latest design of our Sphinx construction
> could be used, with the requesting node providing the backwards path within
> the e2e payload. It's worth noting that this substitute reveals the entire
> path to the responding node

Yes, that's what we did, it does leak information but we are not sure how bad that really is.

Quoted text (4 lines)
> Was the capacity of the channels created uniform? Or were the channel values
> uniformly distributed? Or perhaps drawn from a particular distribution?
> Similar to the question above, how were the satoshis requested within the<
> "payment request" distributed?

Well it didn't matter in this particular test, because as you pointed out we didn't look at channel values (that's what we meant by 'static ranking' and 'undirected graph'). So it could have been anything. Channel capacities, current values and fees will be key parameters of a future 'dynamic ranking' test, but we didn't think too much about it yet. Maybe normal distributions? If you have already researched the subject or have any insights please let us know :-)

Cheers,

Pierre

Gary Mulder in reply to Olaoluwa Osuntokun permalink original

On 20 September 2016 at 19:47, Olaoluwa Osuntokun <laolu32 at gmail.com> wrote:

Quoted text (14 lines)
> Hi, y'all
>
> Excellent work!!
>
> As you noted our, Flare paper as currently written only includes a series
> of
> simulations of various topologies/parameters which are then extrapolated to
> larger network sizes. The logical next step would be to deploy a
> proto-implementation within a live testbed with real latencies,
> preferential
> attachment, etc. I'm thrilled that y'all went ahead getting your hands
> dirty
> to gauge the real-word feasibility of our scheme.
>

There's modules in Linux iptables that allows you to simulate packet loss and latencies. While any simulation by definition will not be as good as a real-world test, a lot of negative (i.e. failure) testing can be done in the cloud with much faster test / debug / fix cycle times than in a real-world deployment.

Happy to help with iptables config. if there is interest...

Regards, Gary