Lightning & Raiden: How Blockchains will scale to serve millions
- Dissecting Blockchain transactions
- Payment channels
- The Lightning network
- The Raiden network
There is one fundamental issue affecting all miners, traders, and end-users of popular cryptocurrencies such as Ethereum and Bitcoin. While both communities have their fair share of disagreements, they have been unanimously forced to acknowledge a common limitation shared by all Blockchain technologies. This limitation is known as scalability. In recent months, as both cryptocurrencies have seen their usage explode in terms of demand and public adoption, this issue has emerged as a dominant talking point for developers and investors alike. For Bitcoin, this issue has even manifested itself in the form of several very large backlogs of transactions that have triggered volatile price fluctuations. Quite simply, with exponential growth comes exponential headaches for Blockchain technologies.
Recently though, the issue of Blockchain scalability has seen its fair share of good news too. Developers for both Bitcoin and Ethereum have made vast improvements towards overall scalability. For Bitcoin, this was evident with the recently activated Segwit update, which has alleviated much of the problem for now. For Ethereum, the most recent Byzantium hard fork has also introduced several key improvements towards their daily transactional capacity. However, both of these cryptocurrency giants face a looming reality. Blockchain, in its pure form, can only scale so far.
The core concept behind a Blockchain is that all users, known as nodes, store a full copy of the ledger on their device. This concept has proven to be revolutionary for decentralization but fails to account for the obvious. There inherently will come a time for every cryptocurrency when the number of transactions on the ledger becomes too large for the average user to store. It would be unreasonable to expect every mobile device or laptop on the network to hold a terabyte-sized ledger. Similarly, it would be unreasonable to expect such devices to process thousands of transactions per second with current network configurations. Too much usage paired with rapidly increasing user adoption could potentially gridlock the entire system.
To solve this issue, both communities are planning to implement several unconventional features known as “off-chain scaling solutions.” These solutions will hopefully solve scalability for good but come at the cost of vast contention among community members. Many argue that these so-called “off-chain” solutions sacrifice the integrity of Blockchain’s inherent decentralization, as well as its overall transparency. The argument that these members hold is that off-chain solutions come at too steep of a cost. However, others argue that these features can be implemented responsibly and that they are necessary for survival. This article will be focusing on one such popular off-chain solution, known as a “Payment channel.”
Before we understand what they are though, let’s see why they are necessary.
Dissecting Blockchain transactions
The problem with transaction scalability is that decentralization inherently requires a delicate balance between users and validators. Since there are no central mediators (conventionally known as banks) to validate user transactions, decentralized Blockchains rely on a community of trusted validators known as “miners.” For these miners, the system must ensure that it remains profitable for them to tell the truth. In the case of Ethereum and Bitcoin, this trust is ensured through the use of complicated cryptographic puzzles. Users understand that if a miner mines a block (solves a cryptographic puzzle) truthfully, they will receive a large payout. In fact, the payout is large enough that it remains vastly more profitable to tell the truth than to lie about a transaction’s contents. Therefore, we can collectively trust that these validators will act honestly without knowing them personally.
As such, decentralization is a balancing act where truthfulness in the system must remain profitable and achievable. Each and every transaction placed on Bitcoin or Ethereum gets approved because of this key philosophy. Inevitably though, the miners become the bottleneck to this transaction process. This whole system was maintainable when Blockchains were first starting out, but it is no longer very practical.
Above is a chart showing the total number of daily transactions on Ethereum from October of 2015 to February of 2018. You’ll notice that evidently, daily transactions have exploded in the last few years. This requires a huge amount of computational power to verify each transaction in a timely fashion, which oftentimes miners simply cannot provide. When miners cannot meet such demand, the waiting period for each transaction skyrockets. This is not to say that things are bad every day, but there have been numerous times, usually following significant events such as a highly anticipated ICO, where transactions can be backlogged for hours if not days. Understandably, a solution is desperately needed to this problem. So what’s the leading prospect? Payment channels.
A payment channel is a sort of two-way connection between users which enables them to conduct transactions outside of the Blockchain. This greatly reduces waste on the Blockchain and cuts back the total number of transactions that miners will have to validate. Miners still exist and do most of the work, but off-chain solutions give them room to breathe and grow. Additionally, it reduces the fees that users will have to pay over time.
But how does an off-chain transaction work?
For the sake of avoiding confusion, I’ll keep this explanation very brief. Every Bitcoin/Ethereum address has a unique private and public key. If two parties know that they’ll be sending each other frequent transactions, perhaps in the form of micro-payments even, they can use this sense of identity to their advantage.
The participants of an off-chain transaction interact by signing transactions among themselves without submitting anything to the Blockchain. Two users, Bob and Alice, agree on a payment structure of 0.1 Eth/hour. Each hour Bob will sign a transaction of 0.1 Eth and give it to Alice. When Alice has completed her work, the transactions will be combined and submitted to the Blockchain as one full transaction.
This would be a great solution, if not for the fact that people often disagree with one another on the contents of transactions. What happens if Bob pays someone else while Alice is working, and no longer has the proper funds to pay her when she submits her signed transaction? How does one prove that they indeed have funds to send in the first place?
Because of these issues, Bitcoin and Ethereum have been developing forms of payment channels that exist offline while still interacting with the Blockchain for additional security and verification. Both teams have developed unique solutions, and both solutions offer different advantages as well as disadvantages.
Bitcoin’s approach: the lightning network
The lightning network is Bitcoin’s answer to off-chain transactions. The system is designed to replace most common on-chain transactions, and developers of the lightning protocol argue that most users will actually want to use lightning over on-chain transactions for day-to-day payments. This, because they’ll be both faster and cheaper to conduct. If the protocol works as designed, it would mostly solve Bitcoin’s scalability issues in terms of transactional capacity for years to come. Conceptualized by Joseph Poon and Tadge Dryja, this network presents several interesting concepts for solving off-chain agreement issues.
Imagine Alice wants to send 0.1 BTC to John. Using the lightning network this can be done with an intermediator who we’ll call Bob.
The transaction begins with both Alice and John opening independent payment channels among Bob. This establishes Bob as the trusted intermediator for their transaction and provides a buffer between Alice and John. Once this link has been formed between the three parties, John can generate an invoice of 0.1 BTC which he’ll send to Alice. This invoice contains a cryptographic hash of his Bitcoin address, which acts as a digital signature. In return, Alice signs her payment for this invoice using her own cryptographic hash, or signature, and passes it to Bob. The result is that the transaction has been signed by both parties, and given to Bob for processing.
At this point, there are two key conditions that bob is held to:
1.) Bob only gets the 0.1 BTC if he can prove that he has a channel open with John.
2.) There is a period of 2 days wherein, if Bob does not send John the money, Alice gets a refund of 0.1 BTC.
Bob then shows the transaction to John, proving that he has interacted with Alice, and triggers two more conditions that must be met:
1.) John must accept or reject this transaction, based upon it being the agreed upon amount.
2.) John must prove that he can produce the original signature embedded in the transaction.
Using this system of signatures, Alice and John can conduct as many transactions as they’d like with Bob as their intermediator. Once they have completed their business, they submit the end result to the Blockchain to make it permanent. This system comes with several key advantages and disadvantages. The lightning network allows for instantaneous payments, does not require miners, works great for micropayments, reduces bloat on the blockchain, and helps promote blockchain scalability. However, it does require a third-party intermediator.
Ethereum’s approach: The Raiden Network
Ethereum’s version of the lightning network is called “Raiden” and was developed with Ethereum’s unique features in mind. Ethereum transactions work differently than Bitcoin transactions, largely due to a feature called “Gas.” On Ethereum, transaction fees are dynamic and respond to network congestion. This allows for fees to increase during high-traffic periods, thus incentivizing more miners to join Ethereum, while also de-incentivizes users from submitting less important transactions during this crunch period.
At any time, users can also pay higher transaction fees to incentivize their transactions. Miners surely tend to prefer transactions with higher payouts, and thus the result is a system where important transactions can be expedited. However, this also creates a pay-to-play system during congested hours which works against the common user.
As for on-chain transactions, Ethereum can currently process around 15 transactions per second, with an average transaction taking 20 seconds. These figures are excellent when compared to Bitcoin’s mere 7 transactions per second capacity, but the increase only makes for a small dent in dealing with the average demand both networks are now receiving. In order to make these transactions faster, and to prevent Blockchain bloat, the Raiden network was introduced.
How does Raiden improve upon Ethereum’s total transaction capacity?
Just like the Lightning network, Raiden processes transactions without pushing them to the Ethereum Blockchain initially. However, Raiden does not need a third party to handle transactions. This is possible because Raiden takes advantage of so-called “smart contracts” that exist on the Ethereum network. These smart contracts can be thought of as vending machines which run predetermined instructions. Therefore, there is no need for an intermediator, such as with Bitcoin, as the process is delegated to an autonomous machine that lives on the Ethereum network.
So, how does Raiden work?
Suppose Alice wants to pay Bob 1 Eth using Raiden. Alice and Bob open an off-chain payment channel by deploying a smart contract to the network and depositing a base amount of Eth into it. This initial deposit can be for any amount and can be increased at any time. When Alice wants to send 1 Eth to Bob, she simply signs the message “1” and sends it to Bob outside of Ethereum by using the Raiden network. Bob now has cryptographic proof of Alice sending him 1 Eth, and can verify that there is a sufficient balance left on the smart contract to redeem.
Should Alice then want to send Bob another transaction on Raiden, She just needs to update the state of the message to reflect whatever end-value she desires, sign it, and send it to Bob over the Raiden network again. The moment Bob wants to redeem the funds he has received, Bob simply tells the smart contract to close out the channel. The channel will sort out the final balance, return any unused deposits, and save the final state onto the Blockchain permanently. The result is an off-chain scaling system for Ethereum which enables for fast and simple transfer of money while simultaneously decreasing the total load on the Ethereum Blockchain.
As Blockchain-based cryptocurrencies continue to gain mass-adoption from countless industries, the need for alternative scaling solutions remains imperative. While on-chain transaction validations such as mining and staking will continue to serve as the primary line of defense for decentralized network health, off-chain transactions will ultimately serve to alleviate pressure on the network. The result will be a more balanced and scalable ecosystem which improves network quality for miners, investors, and end-users alike.