Deep Dive: The Lightning Network
How does it work, why do we need it and what does it enable?
One of the most common criticisms of Bitcoin is the idea that it does not scale - that it has insufficient transactions-per-second or that transaction fees will become prohibitive and price ordinary users off the network. Here we explore the most popular and fully-developed Bitcoin scaling technology the Lightning Network - how it works and what it enables.
In this issue:
Why blockchains are hard to scale
Blockspace is a precious resource
What is the Lightning Network?
What does the Lightning Network let us do?
It is very hard to scale a blockchain
Cryptocurrencies are (at least in theory) supposed to be decentralized. Decentralization is not easy to define and it has many different meanings, but one part of what it means is that none of the nodes on the network should be special. Every node should be an equal peer to every other node - none of them can be closer or further from the center because there is no center. Hence: decentralized.
Network equality isn’t enough though - Amazon has many peer nodes running on data centers throughout the world but that doesn’t make them decentralized because you and I have no ability to join the network. There are lots of nodes on AWS and they are all peers with each other but none of them will ever belong to us.So it needs to be possible for anyone to join the network and become a peer, too.
In fact ideally it should be more than just possible to join the network - it should be cheap and easy. If you can run a node on Raspberry Pi over home wifi lots of people will run nodes and the network will be relatively decentralized. If you need constant high-speed broadband and state of the art server hardware to run a node fewer people will be able to run one for themselves and more will have to rely on a trusted third party. The network will become more centralized.
So networks that place a high premium on true decentralization (like Bitcoin) work very hard to keep the cost of starting and running a node on the network down. There are a lot of subtle costs to running a node but the largest and most important one is the cost of downloading and storing the blockchain itself. The Bitcoin blockchain is currently ~353GB and grows ~1.4MB every ~ten minutes when a new block appears.
That means you only need to download ~1.4MB every ~ten minutes to keep up with the network, which makes running a node cheap and keeps the network decentralized. But it also means there is only ~1.4MB worth of space every ~ten minutes for new transactions to be confirmed with. That’s why transaction fees rise when the network is congested - miners auction the limited blockspace off to the highest bidding transactions waiting in the mempool.
You could imagine increasing the size of the blocks to make room for more transactions at a cheaper price (that’s basically what Bitcoin Cash is) but as nodes become more difficult and expensive to run fewer people will run them and your network will start to centralize.
That trade off is at the heart of every blockchain: if it is cheap to transact on a network it will be expensive to run a network node and if it is cheap to run a network node it will be expensive to transact. Decentralization is expensive.
Blockspace is a precious resource
One of the reasons that people worry about the scalability of Bitcoin is because they misunderstand what it is for - Bitcoin is not a competitor to VISA or Paypal, it is a settlement network. But another reason is because they mistakenly assume the only way to scale Bitcoin is by changing it - rather than by changing how we use it.
Blockspace is like a precious new resource we have only just discovered. Our current use of the blockchain is as crude and inefficient as our first attempts to harness the power of petroleum or electricity. Electricity and oil did not need to be upgraded for our technology to make better use of them - neither will Bitcoin. Projecting future scalability by taking today’s usage and multiplying it is as naive as looking at a kerosene lamp and concluding that jet fuel is impossible.
The Bitcoin protocol operates as a foundation known as Layer 1 or L1. Protocols that build on top of the base layer to extend its functionality and/or make more efficient use of it are traditionally known as Layer 2 or L2 technologies. The most famous and widely adopted Layer 2 technology is the Lightning Network.
What is the Lightning Network?
A good way to conceptualize the Lightning Network is to compare it to opening a tab when buying drinks at a bar. Credit card networks are convenient, so bartenders want to accept them. Credit card networks are also very expensive though, so bartenders want to use them as efficiently as possible. Opening a tab is a way to fit multiple separate drink purchases into a single expensive credit card transaction.
Giving the bartender your credit card gives them permission to charge you but also permission to wait. The bartender doesn’t need to trust you because they can submit your charges to the credit card network anytime they like. You don’t need to trust the bartender because if they submit charges you didn’t agree to you can dispute those charges with the credit card company and they won’t be paid.
That’s loosely how the Lightning Network works - you open up a tab (called a "payment channel") with someone you want to transact with by depositing money into a multi-signature wallet - a special kind of Bitcoin address where multiple parties agree to a set of rules about how the Bitcoin inside can be spent.
Once the payment channel is established you and the merchant can make an unlimited number of payments back and forth locally without needing to submit anything to the network until it is time to close the tab and settle up. Transactions that open or close a payment channel consume the same blockspace and cost the same transaction fees as raw Bitcoin transactions - but transactions within a payment channel never actually appear on the blockchain and cost nothing.
Here is a slightly dated but pretty approachable explanation of how it works:
Infinite free payments between two parties is neat but when you start to link different payment channels together the network starts to become really powerful. If I have a payment channel open with you and you have a payment channel open with the merchant I want to send bitcoin to, I don’t even need to open a channel with them. I can send a payment to you and you can send a payment to them, allowing trust free payments without needing to go back to the expensive L1 blockchain at all.
Here is the Lightning Network as it stands today:
At the moment there are about ~10.5k Lightning nodes operating ~47.5k known payment channels, although there is no particular requirement that payment channels be disclosed to the network so there could be many more private payment channels. Because updates are only made to the network when channels are open and closed and because payments 'hop' across multiple channels Lightning Network payments aren’t just cheaper but are also fundamentally more private.
Issuing a raw transaction on the base layer of Bitcoin means paying exorbitant rates to advertise our private transactions to every node on the network forever. Our children will laugh at us.
What does the Lightning Network let us do?
The first and most obvious thing that Lightning enables is cheaper payments. The Lightning network (via the Strike app) is the tool El Salvador is using for its new legal tender law. You can actually use Strike to send remittances around the world across different currencies and it will use the Lightning Network on the back end without the user ever needing to be aware of it.
Payments on the Lightning Network are so cheap that it opens up other use cases, like micropayments for achievements within a video game (Zebedee.io) or pay-per-use APIs for backend services. You can even use the Lightning network to send payments across different cryptocurrencies, since 'hopping' between channels doesn’t require that channels be in the same currency. So you can use Lightning to trustlessly transfer between any two currencies that both support the Lightning network.
You can use the Lightning Network for other kinds of trusted communication as well. Sphinx.Chat for example is a network that blends payments and chat, or Impervious.AI is a decentralized VPN that leverages the Lightning Network to establish a cryptographically secure and private connection over an untrusted network. The applications that build on top of the Lightning Network like this are collectively known as Layer 3 or L3 technology.
Layer 3 technologies are still consuming the precious blockspace of the L1 blockchain but much, much more efficiently than raw transactions - the same way modern cars make much, much more efficient use of petroleum than early motor vehicles did. It turns out blockspace is an incredibly scarce resource, but also an incredibly powerful one. A little goes a long way.
What are the drawbacks?
The Lightning Network is powerful but it does not instantly solve all of Bitcoin’s problems. Payment channels on the Lightning Network still need to be opened and closed by expensive L1 bitcoin transactions. The network can process ~2000 transactions/block and produces ~144 blocks/day, meaning that opening up a payment channel for everyone on earth would take ~72 years, assuming that no one died or had children during that time. More scaling will still be needed.
The Lightning Network also allows different trade-offs than the base layer but that also means it has different requirements. Bitcoin nodes can go offline and come back on again without any particular risks, but Lightning Network nodes need to be "always online" (or almost always online) so they can watch the network for any attempts by other parties in their payment channels to cheat - roughly similar to how you need to read your credit card bills to make sure no dishonest merchants are trying to take advantage of you.
Managing the Lightning Network is also a lot more complicated than a typical communication network because payment channels have limited capacity and are not necessarily symmetrical. I am much more likely to spend money at a local business than they are to send me money back, so any payment channel between us will eventually be exhausted unless someone else is sending me money back along that same channel. The lightning network is kind of like a giant web of interlocking abacuses - if all the beads end up pushed to one side it is less useful.
That also makes finding a route for your payment to go through the Lightning Network non-trivial. The route may require many hops to reach its destination. Any leg of that route may find the payment channel has been exhausted or is suddenly a dead end. By the time you notice and go back to recalculate your route channels may have opened and closed and the network may have changed. Payments can be quite difficult to route and can sometimes fail entirely.
Just like Bitcoin itself the Lightning Network needs time to mature and grow.
Further reading …
If you’re interested in learning more about the current state and future trajectory of the Lightning Network Michael Levin of Lightning Labs has a great two-part essay on the subject on Medium:
Unless Jeff Bezos is a reader. If you are reading this Mr. Bezos I have a very reasonable team subscription rate that I think would make a wonderful employee perk.
Strictly speaking of course you don’t need your own payment channel in order to take advantage of the Lightning Network. Just as you can 'use' Bitcoin by buying and holding it through centralized exchanges you can also use the Lightning Network through custodial services like banks. This is almost certainly how most people will use the Lightning Network most of the time. From the perspective of the network itself however the only users are the ones who actually run nodes/channels for themselves.