LNTopology
A tool to analyze the topology of Bitcoin's Lightning Network
view repo
Bitcoin's Lightning Network (LN) is a scalability solution for Bitcoin allowing transactions to be issued with negligible fees and settled instantly at scale. In order to use LN, funds need to be locked in payment channels on the Bitcoin blockchain (Layer1) for subsequent use in LN (Layer2). LN is comprised of many payment channels forming a payment channel network. LN's promise is that relatively few payment channels already enable anyone to efficiently, securely and privately route payments across the whole network. In this paper, we quantify the structural properties of LN and argue that LN's current topological properties can be ameliorated in order to improve the security of LN, enabling it to reach its true potential.
READ FULL TEXT VIEW PDF
Payment channel networks are a highly discussed approach for improving
s...
read it
It is now a whole year since Lightning Network (LN) has been launched on...
read it
The Bitcoin Lightning network is a mechanism to enable fast and inexpens...
read it
Payment channel networks, and the Lightning Network in particular, seem ...
read it
Bitcoinotc is a peer to peer (overthecounter) marketplace for trading...
read it
We propose Parsec, a webscale State channel for the Internet of Value t...
read it
The Lightning Network is a socalled secondlayer technology built on to...
read it
A tool to analyze the topology of Bitcoin's Lightning Network
Recently the Bitcoin [nakamoto2008bitcoin] network celebrated its 10th anniversary. During these years Bitcoin gained a huge popularity due to its publicly verifiable, decentralized, permissionless and censorshipresistant nature. This tremendous popularity and increasing interest in Bitcoin pushed its network’s throughput to its limits. Without further advancements, the Bitcoin network can only settle transactions per second (tps), while mainstream centralized payment providers such as Visa and Mastercard can process approximately tps in peak hours. Moreover one might need to pay large transaction fees on the Bitcoin network, while also need to wait 6 new blocks to be published in order to be certain enough that the transaction is included in the blockchain.
To alleviate these scalability issues the Lightning Network (LN) was designed in 2016 [poon2016bitcoin], and launched in 2018, January. The main insight of LN is that transactions can be issued offblockchain in a trustminimized manner achieving instant transaction confirmation times with negligible fees, whilst retaining the security of the underlying blockchain.
Bidirectional payment channels can be formed onchain using a construction called Hashed Timelock Contracts (HTLC). Later several payments can take place in a payment channel. The main advantage of payment channels is that one can send and receive thousands of payments with essentially only 2 onchain transations: the opening and closing channel transactions.
Using these payment channels as building blocks one might establish a payment channel network, where it is not necessary to have direct payment channels between nodes to transact with each other, but they could simply route their payments through other nodes’ payment channels. Such a network can be built, because LN achieves payments to be made without any counterparty risk, however efficient and privacypreserving payment routing remains a challenging algorithmic task [roos2017settling].
Our contributions. We empirically measure^{1}^{1}1https://github.com/seresistvanandras/LNTopology and describe LN’s topology and show how robust it is against both random failures and targeted attacks. These findings suggest that LN’s topology can be ameliorated in order to achieve its true potential.
Number of nodes  

Number of payment channels  
Average degree  
Connected components  
Density  
Total BTC held in LN 
B

smetric  
Maximal independent set  
Bridges  
Diameter  
Radius  
Mean shortest path  
Transitivity  
Average clustering coefficient  
Degree assortativity 
LN can be described as a weighted graph , where is the set of LN nodes and is the set of bidirectional payment channels between these nodes. We took a snapshot^{2}^{2}2https://graph.lndexplorer.com of LN’s topology on the 10th birthday of Bitcoin, 2019 January 3rd. In the following we are going to analyze this dataset. Although the number of nodes and payment channels are permanently changing in LN, we observed through several snapshots that the main topological characteristics (density, average degree, transitivity, nature of degree distribution) remained unchanged. We leave it for future work to analyze the dynamic properties of LN.
LN gradually increased adoption and attraction throughout 2018, which resulted in 3 independent client implementations (clightning^{3}^{3}3https://github.com/ElementsProject/lightning/, eclair^{4}^{4}4https://github.com/ACINQ/eclair and lnd^{5}^{5}5https://github.com/lightningnetwork/lnd) and nodes joining LN as of 2019, January 3rd. The density of a graph is defined as which is the ratio of present and potential edges. As it is shown in Figure 2. LN is quite a sparse graph. This is further justified by the fact that LN has bridges, edges which deletion increases the number of connected components. Although LN consists of components, the second component has only nodes. The low transitivity, fraction of present and possible triangles in the graph, highlights the sparseness of LN as well.
Negative degree assortativity of the graph indicates that on average low degree nodes tend to connect to high degree nodes rather than low degree nodes [newman2002assortative]. Such a dissortative property hints a hub and spoke network structure, which is also reflected in the degree distribution, see Figure 3.
Average shortest path length is , without taking into account capacities of edges, which signals that payments can easily be routed with a few hops throughout the whole network. Although this is far from being a straightforward task, since one also needs to take into consideration the capacity of individual payment channels along a candidate path.
When a new node joins LN, it needs to select which other nodes it is trying to connect to. In the lnd LN implementation key goals for a node is to optimize its centrality by connecting to central nodes. This phenomena sets up a preferential attachment pattern. Other LN implementations rely on their users to create channels manually, which also most likely leads to users connecting to highdegree nodes. Betweenness centrality of a node is given by the expression where is the total number of shortest paths between node and , whilst is the number of those paths, that pass through . Closeness centrality of a node is defined as where is the number of nodes in the graph and is the distance between node and . Closeness centrality measures how close a node is to all other nodes.
Smallworld architectures, like LN, exhibit high clustering with short path lenghts. The appropriate graph theoretic tool to asses clustering is the clustering coefficient [watts1998collective]. Local clustering coefficient measures how well a node’s neighbors are connected to each other, namely how close they are to being a clique. If a node has neighbors, then between these neighbors could be at maximum edges. If denotes the set of ’s neighbors, then the local clustering coefficient is defined as .
LN’s local clustering coefficient distribution suggestively captures that LN is essentially comprised of a small central clique and a loosely connected periphery.
LN might exhibit scalefree properties as the smetric suggests. Smetric was first introduced by Lun Li et al. in [li2005towards] and defined as . The closer to smetric of is, the more scalefree the network. Diameter and radius of LN suggests that LN is a small world. Somewhat scalefreeness is also exhibited in the degree distribution of LN. Majority of nodes have very few payment channels, although there are a few hubs who have significantly more connections as it can be seen in Figure 3.
The scalefreeness of LN is further justified also by applying the method introduced in [clauset2009power]. The maximumlikelihood fitting asserted that the best fit for the empirical degree distribution is a power law function with exponent . The goodnessoffit of the scalefree model was ascertained by the KolmogorovSmirnov statistic. We found that the value of the scalefree hypothesis is , which is accurate within . Therefore the scalefree hypothesis is plausible for the empirical degree distribution of LN.
It is a major question in network science how robust a given network is. LN, just like Bitcoin, is a permissionless network, where nodes can join and leave arbitrarily at any point in time. Nodes can also create new payment channels or close them any time. Furthermore as new payments are made, capacities of payment channels are changing steadily. Despite the dynamic nature of LN, its topology’s characteristics remain constant after all. In this section we investigate how resilient LN is, whether it can effectively withhold random node failures or deliberate attacks.
Measuring robustness means that one gradually removes nodes and/or edges from the graph, until the giant component is broken into several isolated components. The fraction of nodes that need to be removed from a network to break it into multiple isolated connected components is called the percolation threshold and is denoted as
. In real networks percolation threshold can be well estimated by the point where the giant component first drops below
of its original size [barabasi2016network].Network  

Internet  
WWW  
US Power Grid  
Mobil Phone Call  
Science collaboration  
E. Coli Metabolism  
Yeast Protein Interactions  
LN 
Random failures are a realistic attack vector for LN. If nodes happen to be offline due to bad connections or other reasons, they can not participate in routing payments anymore. Such a failure can be modeled as if a node and its edges are removed from the graph.
For scalefree networks with degree distribution , where the percolation threshold can be calculated by applying the MolloyReed criteria, ie. , where and denote the lowest and highest degree nodes respectively. This formula yields for LN in case of random failures. This value is indeed close to the percolation threshold measured by network simulation as shown in Figure 10, that is, LN provides an evidence of topological stability under random failures. In particular this is due to the fact that in LN a randomly selected node is unlikely to affect the network as a whole, since an average node is not significantly contributing to the network’s topological connectivity, see also degree distribution at Figure 3.
Targeted attacks on LN nodes are also a major concern as the short history of LN has already shown it. On 2018 March 21st ^{6}^{6}6https://www.trustnodes.com/2018/03/21/lightningnetworkddossends20nodes,
of nodes were down due to a Distributed Denial of Service (DDoS) attack against LN nodes. Denial of Service (DoS) attacks are also quite probable by flooding HTLCs. These attack vectors are extremely harmful, especially if they are coordinated well. One might expect that not only statesponsored attackers will have the resources to attack a small network like LN. In the first attack scenario we removed 30 highestdegree nodes one by one starting with the most wellconnected one and gradually withdraw the subsequent highdegree nodes. We recorded the number of connected components. As it is shown in Figure
8. even just removing the highestdegree node^{7}^{7}7http://rompert.com/ fragments the LN graph into 37 connected components! Altogether the removal of the largest hubs incurs LN to collapse into components, although most of these are isolated vertices. This symptom can be explained by the experienced dissortativity, namely hubs tend to be at the periphery.We reasserted the targeted attack scenario, but for the second time we only removed one of the largest hubs and recorded the number of connected components. As it can be seen in Figure 9 most of the hubs, 25, would leave behind several disconnected components.
Network  

Internet  
WWW  
Euroroad  
US Power Grid  
Mobil Phone Call  
Science collaboration  
E. Coli Metabolism  
Yeast Protein Interactions  
LN 
Such network fragmentations are unwanted in case of LN, because they would make payment routing substantially more challenging (one needs to split the payment over several routes) or even impossible (there would be no routes at all).
Furthermore we estimated the percolation threshold by simulating two attacking strategies. In the first scenario we removed high degree nodes one by one (high degree removal attack, HDR) and in the second we removed nodes with the highest betweenness centrality (high betweenness removal attack, HBR). Note that in both cases after each node removal we recalculated which node has the highest degree or betweenness centrality in order to have a more powerful attack. We found out that for removing high degree nodes, while for removing high betweenness centrality nodes , therefore choosing to remove high betweenness centrality nodes is a better strategy as it can also be seen in Figure 12.
Node outage not only affects robustness and connectivity properties, but also affects average shortest path lengths. Although the outage of random nodes does not significantly increase the average shortest path lengths in LN, targeted attacks against hubs increase distances between remaining nodes. The spillage of highdegree nodes not only decrease the amount of available liquidity but also rapidly increase the necessary hops along payment routes as Figure 11 suggests. This could cause increased ratio of failed payments due to larger payment routes.
Designing networks which are robust to random failures and targeted attacks appear to be a conflicting desire [barabasi2016network]. For instance a star graph, the simplest hub and spoke network, is resilient to random failures. The removal of any set of spokes does not hurt the connectedness of the main component. However it can not withstand a targeted attack against its central node, since it would leave behind isolated spokes. Furthermore when one attempts increasing robustness of a network, they do desire not to decrease the connectivity of nodes.
A similar optimization strategy of robustness and connectivity to that of [shargel2003optimization] could be applied to LN as well. We leave it for future work to empirically assess the robustness and connectivity gains if strategy of [shargel2003optimization] would be implemented in LN client implementations.
Nonetheless, we can still enhance the network’s attack tolerance by connecting its peripheral nodes [barabasi2016network]. This could be achieved by LN client implementations by implicitly mandating newcomers to connect to not only hubs, as current implementations do, but also to at least a few random nodes. This would largely increase robustness of LN even against targeted attacks.
In summary, a better understanding of the network topology is essential for improving the robustness of complex systems, like LN. Networks’ resilience depends on their topology. LN is well approximated by the scalefree model and also its attack tolerance properties are similar to those of scalefree networks; in particular, while LN is robust against random failures, it is quite vulnerable in the face of targeted attacks. Highlevel depictions of LN’s topology, like Figure 1, convey a false image of security and robustness. As we have demonstrated, LN is structurally weak against rational adversaries. Thus, to provide robust Layer2 solutions for blockchains, such as LN and Raiden, the community needs to aim at building resilient network topologies.
We are grateful for the insightful comments and discussions to Chris Buckland, Daniel Goldman, Olaoluwa Osuntokun and Alex Bosworth.
Comments
There are no comments yet.