← Portfolio

Payment Channel Networks

Can PCNs solve the scalability problem of Blockchains?

Tags:
During a traineeship at CSIRO in Sydney under the supervision of Dr. Ingo Weber, I extensively studied blockchain technologies, such as the Ethereum Platform and Payment Channel Networks (PCNs). To test the reliability of payment routing in PCNs, I developed a tool for running experiments.
PCN Simulator: Specify network properties and simulate payments

Ubiquitous Cryptocurrencies

One fundamental goal that motivates much of the research that is going on in cryptocurrencies and blockchain technologies is making these technologies fit for every-day transactions, such as buying coffee at the local coffee shop. However, some circumstances complicate the matter:

Transaction Fees in Bitcoin and Ethereum

On December 22nd 2017, right before Christmas, the average fee for a Bitcoin transaction hit a high of 55.16 USD. On the very same day, the average transaction value was 70,000 USD. It is obvious that these numbers are orders of magnitude away from a currency that is fit for every-day use. To be fair, fees in Ethereum do look better: In January, the average transaction cost was 1.18 USD. However, fees in Ethereum also rose quite fast, starting from a couple of cents only a few months ago. This is due to its rising popularity in the development community.

Bitcoin transaction fees in December 20171

If you are familiar with the concept of Proof of Work, you will find these developments very unsurprising. Block size in Bitcoin is limited — a scarce resource — and fees are the result of supply and demand. This means that fees do not stand in any proportion to the transacted value and are themselves highly volatile. As a result, a transaction of 100k USD may be as expensive as buying a coffee for 4 USD. Of course, this is unacceptable for everyday payments.

Now, there might be a solution to these problems.

Brief Introduction to Payment Channel Networks

Payment Channel Networks, such as the Lightning Network, allow arbitrary peers to make transactions via what are called "payment channels". For this to be possible, two nodes need to open a channel and commit funds to it. The opening of a channel is then confirmed on the blockchain as a regular transaction and incurs the normal transaction fee. But now the peers can exchange as many payments as they like for free, as long as they stay within their funding bounds, because every transaction just happens between the two parties — secured by the funding — with no transaction written to the blockchain. Finally, when the peers want to redeem their funds, they close the channel with the current balances, which is another transaction on the blockchain. Since fees only apply for opening and closing channels, they potentially save lots of transaction costs. In addition, the confirmation time is down from somewhere around a couple of minutes to seconds.

Alice pays Bob 0.1 BTC via a channel that is funded with 1.0 BTC

Payment Routing: Flare

Now comes the cool stuff: In addition to paying via a direct channel, peers can also use channes from other peers to forward their payments, which means that nodes and their channels form a payment channel network. These forwarded payments require routing, which is a mechanism that finds payment routes and selects a path of channels to carry out the transaction between sender and receiver. One major contribution to routing in PCNs is the source routing protocol Flare2. The authors describe Flare as a routing algorithm for the Lightning Network that uses a hybrid model of routing. The main idea behind the approach is based on the fact that some network information changes more frequently than other. Flare uses this difference to collect and maintain a view of slowly changing network information in advance and request volatile information (i.e. liquidity and fees) on-demand. Note that at the time of writing Flare is a proposal, but there are no clients that implement the protocol. In general, how routing is done is not prescribed by PCN protocols, such as the Lightning Network Specification3.

Fees in the Lightning Network

Since miners choose which transactions they include in a block, the transaction fee for blockchains such as Bitcoin or Ethereum is determined by congestion. This implies that fees are not linked to the transaction value, so sending 1 USD may cost the same as sending 100,000 USD. In PCNs, fees are subject to a fundamentally different dynamic. Instead of mining, peers earn fees by forwarding payments to other peers. Because of this fact, their interest — and hence, the fee — increases in proportion to the amount they forward.

Therefore, the fee for a relayed transaction in the Lightning Network is a linear function of the relayed amount $a$ and consists of a base fee $f_b$ provided in Millisatoshi (msat) (= 10−11 Bitcoin), as well as a variable rate $f_{v/m}$, in proportional millionths of Millisatoshi.

$$f_b + a \cdot \frac{f_{v/m}}{1000000}$$ Choosing values from the current Lightning Network Mainnet $f_b \approx 1000$ and $f_{v/m} \approx 10$, forwarding 1 USD over one channel would result in a transaction fee of 0.01%. Assuming the payment is forwarded ten times until it reaches its receiver, the overall fee would be 0.1%. In short: fees are extremely competitive.

How Reliable are Payment Channel Networks?

So far, large PCNs have not been explored thorougly. In a 2017 paper by Roos et al.4, the authors tested the success ratio of different PCN routing algorithms in a network derived from the Ripple Credit Network. At that time, the Lightning Network had not yet launched on Bitcoin Mainnet and nobody knew, how the topology of PCNs would evolve. Of course, the topology of a network has large impacts on the success ratio of routing algorithms, which is why we proposed user behavior models to be added to simulations. These models try to find likely topologies, based on the behavior of PCN users.

User Behavior: A Rational Model

Users don't act randomly, when it comes to their money. They open channels that are useful for them and fund channels with money they can afford. Based on this hypothesis, certain topologies develop, which can be either good or bad for the overall reliability of the PCN. At least, that was our idea. We wanted to test this hypothesis in the simulation tool that I developed. First, we needed a routine, that mimicked the behavior of users. We came up with a simple, rational behavior model that aims to minimize the cost for own transactions and maximizes the return of fees. If you are familiar with behavioral economics, you know that this routine does not precisely model the behavior of us humans, which has been shown to deviate from rational behavior with systematic errors, known as biases5. We still try to justify our decision, because PCNs have also been proposed as a machine-to-machine payment mechanism, where human users are not involved in payment processes.

First Experiments and Results

So far, larger experiments with user behavior are still work in progress. There is a thesis at TU Wien written about that topic, which uses the simulation tool to explore the reliability of routing with user behavior in larger networks. Nonetheless, I was curious to see at least some results. So, for a small but realistic network, we mined the Lightning Network on Bitcoin Mainnet (≈1000 nodes) for data and fitted probability distributions to the number of channels per node, as well as the amount of funding per channel. The two graphs below show the fitted curves.

Approximating the number of channels from LN on Bitcoin Mainnet with a $\chi^2_{k=2}$-Distribution
Approximating channel funding from LN on Bitcoin Mainnet with a $\beta$-Distribution

Next, we measured the reliability of routing using Flare (the best-described source routing alternative at the moment) with four metrics, the main one being the success ratio — the number of successful payments versus failed payments. First, we tested two static settings without user behavior. In the first setting, nodes were initialized with an average of two channels per node, following the distribution we fitted from the Lightning Network data. After 10,000 payments, the success ratio settled at 92%. For the second setting, we doubled the number of channels per node to four, resulting in a success ratio of 98%. Observation: The success ratio of payment routing increases with the number of channels per node. On average, routes also became 5.5% shorter. Now we wanted to compare, if user behavior had an influence on the scores. We started with the same initial settings as before, but this time nodes were allowed to open and close channels, based on their objective to minimize fees and maximize profits. To incentivise high activity, we assumed a very low blockchain transaction cost, where one blockchain transaction was as expensive as 33 channel transactions. What we found was that in both cases the success ratio climbed to 99% and the amount of channels reduced by 61-63%, meaning less money was locked in channels. Therefore, at least for our small setting it was true that, if everyone acted in his/her own best interest, everyone was better off.

Summary

Fast transaction confirmations and particularly low fees make PCNs a promising alternative on top of Proof of Work blockchains. But, we do not yet know, whether they will scale good enough and how reliable payment routing would be for large networks. We asked the question: How would the topology of a PCN evolve, if every peer in the network acted in his/her own best interest and is everyone better off in terms of reliability? Compared to static settings, the preliminary answer to our question is yes. However, this was just the beginning. There is still a lot of work required to test our hypothesis with larger networks.

Notes and References

  1. Historical chart of Bitcoin transaction fees (Link)
  2. Flare: An Approach to Routing in Lightning Network, published in 2016 (Link to Publication)
  3. The Lightning Network Specifications, hosted on GitHub (Link to Repository)
  4. Roos, S., Moreno-Sanchez, P., Kate, A., & Goldberg, I. (2017). Settling Payments Fast and Private: Efficient Decentralized Routing for Path-Based Transactions. arXiv preprint arXiv:1709.05748.
  5. De Martino, B., Kumaran, D., Seymour, B., & Dolan, R. J. (2006). Frames, biases, and rational decision-making in the human brain. Science, 313(5787), 684-687.