Stay up to date with my latest tweets here: @BoudjemaaAdam
Nowadays, it is widely believed that bitcoin was an experimental technology pushed forward by Satoshi Nakamoto as a way to introduce the new decentralized governance system to the world — the kind of system that runs independently, driven purely by the market and doesn’t rely on any central authority whatsoever. Now the question arises, what makes people think that it was purely an experimental technology?
The answer (to them) is pretty obvious! The bitcoin network can only handle up to 7 transactions per second and a single transaction takes anywhere from 15 minutes to even one hour in some cases. Billions of transactions happen every day and in many forms, but if bitcoin was meant to be the ‘new currency’ of the world, why is it technically so limited and constrained? If Satoshi Nakamoto knew that bitcoin would take over the world, then why did he make the architecture in such a way that the entire network can only handle up to 7 transactions per second with 1MB block size and an average 15 minutes to one hour block confirmation time?
The Protocol vs The Infrastructure
These questions are valid, but if you are the one thinking on these terms too, then you are probably wrong. Bitcoin, by its design, isn't technically limited or constrained, but it lacks the 'scalability factor' which can be solved. When the internet came along in the early 90s, the infrastructure wasn't scalable at that time. It couldn't support videos, photos, any kind of multi-media, etc. and a simple message could take hours or even days to propagate through the network.
The 'internet infrastructure' lacked proper scalability, but the 'underlying protocol' wasn't restricted, and it was later used to improve both the architecture and the infrastructure! When you're watching a 4K YouTube video today, do remember that it is the same TCP/IP and HTTP protocol at the backend, which was used in the late 90s when you couldn't even send an email effectively. That's the difference between the protocol and the infrastructure. Bitcoin is essentially a protocol that supports its infrastructure. The infrastructure is currently limited. However, the protocol is very flexible and has all the necessary ingredients built-in for the scalability.
The Scalability Trilemma
Before discussing the lightning network, lets first discuss an important concept called the 'Scalability Trilemma'. This term was first coined by Vitalik Buterin, the founding father of Ethereum Blockchain and The Ethereum Foundation. Scalability Trilemma states that any blockchain can only have two of the following three properties:
If any blockchain protocol is very scalable and highly secure, then they would have to compromise on decentralization (e.g., EOS, Cardano). If a blockchain protocol is very secure and highly decentralized, then it would be scalable (e.g., Bitcoin, Ethereum). The reason why bitcoin has given more importance to security and decentralization is that it is dealing with a very critical concept — The Currency!
Without any central authority, the bitcoin protocol should be very secure in the first place because you're talking about the money here. Security was given so much importance that it became the first priority after decentralization, and we can see this from the fact that since the emergence of Bitcoin in January 2009, not even a single person can hack the network and steal all the Bitcoins!
But now the question arises, if bitcoin protocol is highly decentralized and extremely secure, how would it tackle billions of transactions if it's not scalable beyond 7 transactions per second? Let's discuss this question in our next section before jumping into the Lightning Network.
The Scalability Approach and the Lightning Network
To solve this fundamental scalability problem, many people coming from diverse backgrounds proposed different solutions. One solution was to simply increase the block size so that more transactions can be accumulated into a single block, thus increasing the number of transactions per second. However, this approach wasn't accepted by the community, and it resulted in a hard fork, creating Bitcoin Cash (BCH) and Bitcoin SV (BSV) later on.
It was also counterintuitive because to match the transaction capacity of a leading payment network like Visa or MasterCard, you have to increase the block size from 1MB to several hundred MBs, which are very difficult to propagate across the network just because the available bandwidth won't be able to support such huge blocks. This would significantly slow down the bitcoin network, and the network would be chocked quite often. This is why the hard forks of bitcoin that emerged as a result of this thought process failed miserably.
Another scalability approach was 'optimization'. It should be noted that the transaction signatures takes a lot of space in a bitcoin block. These signatures can be reduced or compressed using a variety of techniques to save the space to have more transactions. This was achieved using SegWit. With the introduction of the Schnorr Signature scheme, the block size would be optimized even further. However, these optimizations are at the protocol level. They won't result in a significant increase in the average TPS(transaction per second) of the bitcoin network. The only solution to massively increase the TPS of the bitcoin etwork, ensuring mass adoption and scalability, is the 'Layer-2 Networks'.
Lightning Network, the best Layer-2 Network solution ?
Layer-2 Networks are the independent protocols that run on top of the primary protocols. To simply understand this concept, you can think of a Layer-2 Network as a software that runs on top of the Operation System (which would be a primary Layer-1 Network). The only difference is that in this case, the Layer-2 Network doesn't rely on the primary portal (Layer-1 Network) and can run independently.
Lightning Network (often denoted as LN Network) is a kind of a Layer-2 Network that is primarily built for micropayments. The LN Network runs on top of the bitcoin network, utilizing its multi-sig scheme using payment channels. The famous question that the LN prospects often throw away is, 'Can you buy a cup of coffee with bitcoin?' The obvious answer is 'No' because, to buy a $2 coffee, you would have to give away the equivalent amount of transaction fees and have to wait for like an hour for the transaction settlement. However, with the LN Network on top of bitcoin, you can instantly make this transaction (within milliseconds) without the fees and an extra hassle! ☕️
Lightning Network achieves this using what's called 'micropayment channels' (sometimes they're just called payment channels). You can think of these payment channels as a collection of unconfirmed transactions that aren't yet broadcasted to the bitcoin network. One important thing to note here is that these payment channels work completely off-chain before the final settlement. At the heart of these payment channels, is bitcoin's multi-sig (m of n) scheme. Multi-sig allows multiple parties to sign the transaction before it's broadcasted on the network. For the transaction to be successful, all the parties taking part in the multi-sig transaction scheme should sign the transaction.
How Lightning Network Works ⚡️?
Imagine Alice running a coffee shop, and Bob walks in to buy a cup of coffee worth $2. Alice would open up a payment channel and sign it with an initial transaction that would generate a multi-sig address. Bob would send the funds to this address, and he would sign the transaction. Since its a multi-sig scheme, Alice would get the transaction but won't sign it or broadcast it. Many people would walk into the coffee shop, and they would send the transactions to this address. After the end of the day, Alice would sign all the transactions and would broadcast them to the bitcoin network for final settlement.
Using Lightning Network, people can make micro-transactions without worrying about the fees, transaction settlement, and block confirmation times. They can just send an off-chain transaction to the micro-payment channel and enjoy their coffee! The owner or the creator of the micro-payment channel can leave it open as long as he wants. Once he wishes to receive all the transactions of the day, he can just sign all the transactions in the micro-payment channel and broadcast them to the bitcoin network for final settlement and collection.
Payment Routing Mechanism and the LN channels
Another important thing to note here is that the opening and closing of a payment channel isn't required for every transaction. In Lightning Network, every user is treated as a node, and every node is connected to other nodes on the network. If you want to send a lightning transaction to someone but you don't have an active payment channel with them, you can just use other nodes as a 'hop' to find an already opened channel and make the transaction instantly. Let's imagine there are three separate payment channels.
- First payment channel is between Alice and Bob
- Second payment channel is between Bob and Carol
- Third payment channel is between Carol and Dave
Imagine if Bob wants to pay Dave, but he doesn't have an active payment channel with Carol. In that case, Bob can use Carol as a 'hop' to send the LN transaction to Dave since they already have an active payment channel. This would reduce network congestion since Bob won't have to open up another payment channel with Dave, and instead, he can use a simple hop.
On the Lightning Network, users find the required payment channels using hops across the network of nodes and find the nearest hop for the transaction, and the network handles the rest.
How Lightning Network handles fraudulent transactions?
If someone makes an off-chain transaction into the payment channel, which is broadcasted by the owner of the channel later, how is it ensured that the previous off-chain transaction was valid and that no party would try to cheat? Well, there is a very simple solution to that. When you are sending the LN transaction, the channel ensures that you have sufficient funds into your wallet.
When the transaction is broadcasted, all the individual transactions are verified first, and they are matched with the transaction history to avoid broadcasting fake or incorrect transactions. In the LN Network, there is also a penalty imposed on fraudulent transactions where if the network detects a bad actor in the system, they are immediately charged with a penalty (which you can think of as a variation of higher transaction fees). This way, the entire network ensures credibility and consistency while discouraging bad behaviour.
Overall, the lighting network would make micro-payments a breeze instead of chocking the bitcoin blockchain with millions of small transactions. LN network enables the settlement of one large transaction onto the bitcoin blockchain which is a combination of hundreds of small transactions (think of it as a closing balance sheet for the end of the day).
Some of the core features of the Lightning network include:
- Quick and instant transactions
- Perfect for micro-payments
- Less on-chain network congestion
- Extremely low (sub-satoshi) transaction fees
With these Layer-2 Networks, bitcoin would be able to scale much faster to ensure global adoption handling billions of daily transactions. Layer-2 solutions like Lightning Network aren't just limited to bitcoin, they can be applied to any blockchain protocol provided that they have the recipe built-in (multi-sign scheme). A lot of experiments are happening for the LN networks on other blockchain platforms like Ethereum, Cardano, or EOS.
All the major wallets also support LN network, and once they are applied everywhere, we would surely be able to see a decentralized finance revolution where scalability won't be an issue, and it would be a thing of the past, just like we don't discuss the scalability of the internet these days!
Lightning networks and other similar Layer-2 Network solutions bring us one step closer to a vision of 'Decentralized global currency'.
Stay up to date with my latest tweets here: @BoudjemaaAdam
Follow me on Linkedin here: @AdamBoudjemaa