Blockchain scalability is arguably the holy grail and bottleneck of the cryptocurrency world and mainly refers to transaction speed. At the moment, the transaction time of crypto doesn’t compare to other payment methods. However, crypto communities are working within different theories on how best to overcome this hurdle, and in this piece, we dive deep into the promising developments that might finally get us to near-instant transaction speed.
But first let’s dive into the basics of what transaction speed is before we look into different scalability solutions to speed things up.
The Transaction Speed of Cryptocurrencies
You may have seen the infographic above which compares the transaction speed of cryptocurrencies to Visa and Paypal. While Visa can process up to 24,000 transactions per second (tps), Bitcoin can only process seven tps, and Ethereum can handle 20 tps. Cryptocurrencies must catch up with VISA’s capability to achieve mass adoption.
But why is scalability so difficult on blockchain? What are some directions that people in space are attempting? This article will cover some of these key questions.
The Bottlenecks: Throughput, Finality, and Confirmation Time
How is transaction per second related to processing speed? What exactly does it mean when people ask if cryptocurrency is scalable? To answer those, we need first to understand the concept of throughput, finality, and confirmation time.
Consider this story:
You are waiting for a bus at a bus station to go home. The bus arrives at a 10 minute interval, and it takes 60 minutes for the bus to arrive at your destination. The route is popular, and there is always a long queue of people waiting for the bus.
Two minutes have passed, and the bus has arrived, but there are too many people ahead of you in the queue and the bus is filled. You now need to wait for another 10 minutes before you can begin your journey home.
The journey can be summarised like this:
Using the concepts demonstrated above in the context of throughput, finality, and confirmation:
- Capacity of bus (7 person/minute) = throughput
- Travel time from the bus stop to home (60 min) = finality
- Waiting to get on the bus (10 min) = average first block waiting time
- Total travel time (70 min) = Confirmation time
It should be noted that:
- Measuring throughput (tps) is not enough – we must also consider confirmation time. Simply put, a protocol that can process up to 100,000 tps is great, but if it has a two day confirmation time, that is not sufficient for daily life usage.
- When there is network congestion, throughput won’t decrease (since the bus can still carry seven passengers per minute), but the confirmation time will deteriorate because of the longer average first block waiting time.
- Finality is a fixed waiting time. We need to wait for the “6 blocks confirmation” to ensure that the block is not reversible. The average first block waiting time varies depending on the situation.
The Blockchain Scalability Trilemma
The blockchain scalability trilemma is one of the greatest hurdles for cryptocurrencies. It states that you can only achieve two out of either decentralisation, scalability, or security simultaneously, but never all three. Therefore trade-offs are inevitable. The trilemma was originally coined by Vitalik Buterin, the founder of Ethereum (ETH), who invented the name regarding the scalability of blockchain technology.
However, we would like readers to remember that the scalability trilemma is only an observation instead of a formal mathematical proof. Despite how difficult it is, an algorithm may exist that can solve the trilemma unless someone has proven that it is impossible. We will cover some recent directions on how people in the space are attempting in later sections of this article series.
Decentralisation refers to the degree of diversification in ownership, influence and value on a blockchain. Cryptocurrencies are generally ‘decentralised since no single party can govern the whole network. However, decentralisation is a spectrum rather than a binary ‘yes or no’, as we see different levels of decentralisation in various projects like Bitcoin, Ethereum, Ripple, EOS, etc.
Security is the level of defensibility blockchain has against attacks from external sources and the resistance of the system to tampering. There are many attack vectors in a blockchain system, including double-spending, sybil, DDoS, and 51% attacks. In general, more freedom (i.e. free entrance/exit of the network) results in higher decentralisation but lower security since it is hard to verify the identity of the new participants where they can be owned by a single malicious entity or collude together to cause harm to the network.
Scalability determines the network’s capacity, including the number of nodes in the network, the number of transactions that the network can process, how fast the network can process and so on. The term scalability is sometimes confusing because Bitcoin’s blockchain is scalable upon new participants joining the network. The PoW system will automatically adjust the difficulty, and the network can tolerate any number of nodes that exist in the network.
The common saying that “Bitcoin is not scalable” is mainly focused on its throughput, i.e. it can only handle seven transactions per second (tps) which is not enough for real-life usage (when compared to VISA, which can reportedly reach 24,000 tps). The finality speed is also another issue as people won’t wait for 60 minutes to confirm that a purchase of a coffee is valid.
New Directions for Ramping up Blockchain Scalability
Scaling blockchain is a complicated topic, and there are numerous efforts both from the crypto industry and academia trying to solve the scalability trilemma. In general, we believe there are three directions for blockchain scalability:
- 1st Layer (on-chain)
- 2nd Layer (off-chain)
- Other consensus
Layer 1 (On-Chain) Solutions
First layer solutions require changing the codebase of the actual blockchain (hence, ‘on-chain’). An on-chain scalability solution represents structural or fundamental change onto a blockchain.
Here, we will discuss two on-chain scaling solutions: Segwit and Sharding
1. Segregated Witness (SEGWIT)
Segwit is a protocol upgrade for Bitcoin that changes the way and structure of how data is stored. The original intention of segwit was to solve the transaction malleability problem. The digital signature that verifies the ownership and availability of the sender’s funds takes up a lot of space in a transaction. Therefore, removing it would allow more transactions to be included in one block. Removing the signature data for each transaction releases more space and capacity for more transactions to be contained in Bitcoin’s 1MB-storage blocks. Segwit has already been implemented in Litecoin.
Though segwit increases the throughput and helps Bitcoin to process more transactions, It’s not a sustainable scaling solution for multiple reasons. First, Segwit is not a generic scaling solution. Second, it can be applied to the only bitcoin-based blockchain. Third, Segwit enables Bitcoin to process more transactions but does not reduce the confirmation time.
Sharding is a form of database partitioning, also known as horizontal partitioning. The process involves breaking up a vast database into smaller, more manageable segments, with the idea of improving performance and reducing the query response time.2
Blockchain can be seen as a distributed database. If we apply sharding to the blockchain, then the blockchain network will be divided into different segments, and each segment is governed by certain nodes that have been allocated to them. By doing so, the throughput of the system can be greatly improved since, arbitrarily, many node clusters can be running in parallel to process the transactions.
Layer 2 (Off-Chain) Solutions
Second layer scalability solutions or off-chain solutions add a second layer to the main blockchain network to facilitate faster transactions. The secondary protocols are built on top of the main blockchain, where transactions are ‘off-loaded’ from the main blockchain to save space and reduce network congestion.
Sidechain is simply a separate blockchain linked to the main blockchain (mainchain). The assets on the mainchain and sidechains (ref) can be traded at predetermined rates using a two-way peg. Sidechains can be used to offload from the mainchain by moving certain applications on the sidechain. Sidechain is one of the promising solutions to the scalability problem if inter-blockchain communication becomes more efficient.
Multiple sidechains can be attached to the mainchain, and each sidechain can have its own architecture. A network of sidechains with a mainchain can be created where the mainchain can act as a relay network, and the sidechains represent a blockchain network. Plasma (ethereum)3 and Parachain (polkadot)4 are popular scaling solutions using sidechain and relays.
2. Payment Channels
A payment channel is an off-chain network that runs parallel to the main blockchain. The idea is to establish a channel between two parties who want to make a transaction.
All transactions that take place within the channel are off-chain and global consensus is not required. As a result, these transactions execute quickly via a smart contract, with much lower fees and at lightning speed. A typical payment channel has three phases:
Phase one: establish a channel by signing and funding a channel
Phase two: peer to peer transactions on a payment channel
Phase three: close the channel and broadcast the final state to the main blockchain
There are several different designs of payment channels. The Lightning Network (Bitcoin) and Raiden Network (Ethereum) are popular payment channel implementations.
How to Agree: Different Types Consensus Mechanisms & Why They Matter for Transaction Speed
The difficulty of scaling blockchain is mainly due to its consensus since it requires all participants in the network to agree on which transactions are valid. While Bitcoin can scale to a large number of participants, it cannot scale to a large number of transactions. Some alternative consensus, therefore, emerged to attempt to solve the problem.
1. Nakamoto consensus
Satoshi Nakamoto’s proof-of-work (PoW) consensus has opened a new direction for solving the Byzantine Generals Problem in a permissionless setup. Following the development of the proof-of-work consensus, many new consensus algorithms have emerged, such as proof-of-stake (PoS), proof-of-authority (PoA), proof-of-reputation (PoR), and Proof-of-importance (PoI).
In general, we would categorise all these kinds of consensus as Nakamoto consensus.
2. Classical consensus
Classical consensus are the traditional algorithms that have been researched before the invention of Bitcoin. They focus on fixed peer-sets with multiple rounds of voting for reaching consensus within the whole network. Examples of classical consensus include Paxos, Raft, pBFT, and more. After the invention of Bitcoin, the classical consensus also evolved with new variations like Delegated BFT (dBFT), Federated BFT (fBFT), Tendermint, and more. They can be more adaptive to a permissionless environment.
3. Leaderless consensus
Both traditional consensus (BFT-like) and Nakamoto consensus (PoW-like) are leader-based. They require the whole network to elect a leader for block proposals (or transactions/ledger state, etc.), and then the rest of the network can vote to agree on the proposal or not. However, there is a new emerging direction using leaderless consensus where all participants in the network are allowed to propose recent transactions. Those transactions will spread like gossip across the whole network and eventually let the entire network come up with a consensus on which transactions to include or not.
Examples of projects include Avalanche, IOTA, and NKN. We will discuss more in later chapters. While leaderless seems to provide a path for solving the scalability trilemma, they are currently largely experimental.
For a more in-depth discussion on the underlying principles of consensus, read this: How to Agree: Different Types of Consensus for Blockchain
Bitcoin Scaling: The Lightning Network and Payment Channels
As we demonstrated above, Bitcoin has scaling problems. The scalability problem prevents Bitcoin from becoming a practical payment network. The lightning network, however, is the one tested method that might work in the Bitcoin network.
Lightning network was first described in a white paper by Joseph Poon and Thaddeus Dryja in 2015. There are currently three teams collectively carrying out most of the work on the development of the Lightning Network: Blockstream, Lightning Labs, and ACINQ, with input from other members of the Bitcoin community.5
The lightning network is a second-layer payment protocol that works on a blockchain-based system (like Bitcoin). It enables users to create payment channels between two parties on the second layer (Layer 2) by committing a fund transaction to the relevant base blockchain (Layer 1). These channels can exist for as long as required, and because they’re only set up between two parties, transactions are almost instant, and the fees are extremely low. Users can make any number of transactions on the payment channel without broadcasting it to the main blockchain. When the payment channel is closed, the final balance of the transactions will be broadcasted and written into the base blockchain. The following explains how the lightning network operates.
How lightning works: Bidirectional payment channels
The mechanism operates on a peer-to-peer (P2P) level, and its practice relies on the creation of bidirectional payment channels through which users can make seamless cryptocurrency transactions. An on-chain transaction is inevitable when setting up a new payment channel. However, all transactions within the channel are off-chain and global consensus is not required. As a result, these transactions are executed quickly via a smart contract, with much lower fees and a much higher transaction per second (tps) rate.
To establish a payment channel, the two participants need to set up a shared multi-signature wallet and add funds to it. Funds that are stored on multi-signature wallets can only be accessed when both parties’ private keys are provided. This means that one party cannot open the wallet without the consent of the other.6
For instance, imagine that Alice wants to transact bitcoins with Bob through the lightning network. First, they set up a payment channel using a multi-sig wallet. Alice and Bob can transact via the off-chain as much as they want during the lifetime of the payment channel.
After each transaction, Alice and Bob confirm and update the balance sheet of their copies, which records the number of coins each one possesses. When they complete the transactions, they close the payment channel and broadcast the final balance sheet of each to the base Bitcoin blockchain. The lightning network smart contract ensures that they receive their own bitcoins, agreeing with the last version of the balance sheet.
The involved participants only need to interact with the Bitcoin blockchain twice (open and close the payment channel). All other transactions that took place within the channel are not directly communicated with the main chain.
Network routing on lightning
The lightning network avoids opening new payment channels. When possible, it will use already established channels instead. Even if there isn’t a direct payment channel between two parties, they are still available to transact through interconnected payment channels. That means that Alice can pay Charlie without creating a new direct channel with him, as long as there is a network route between them and it contains enough bitcoin.
So, if Alice has a payment channel with Bob and Bob has a payment channel with Charlie, she can send the payment through Bob. The payment routing may include many lightning network nodes, but the smart contract will automatically search for the shortest reachable path.
Advantages and disadvantages of the lightning network
Advantages of the Lightning Network
- As an off-chain solution, it can reduce traffic on the main blockchain
- It enables almost instant payments without wait times for network confirmations
- Low fees as transactions proceed within the payment channels instead of on the base blockchain
- It it is able to process at least 1 million transactions per second
- Cross-chain atomic swaps: The lightning network provides a way to cross-blockchain transactions as the two blockchains share the same cryptographic hash function
- It’s suitable for micropayments, as it allows the transfer of small values. Automated micropayments may be implemented on the machine level between electronic devices
Disadvantages of the Lightning Network
- Unlike on-chain transactions, payments are impossible if the receiver is offline
- Users of the network may need to monitor payment channels frequently to keep their funds safe
- It’s not suitable for large payments yet. Because the network contains many multi-signature wallets (basically shared wallets), these wallets may not have sufficient balance to act as intermediaries for large payments
- It still involves on-chain transactions when opening and closing a payment channel, so manual work and higher transaction fees may be inevitable
In general, lightning network-like layer two solutions are called payment channels. Examples of payment channels include:
Processing Things Piece by Piece: What is Sharding?
Sharding is a form of database partitioning, also known as horizontal partitioning. The database is horizontally partitioned into pieces to provide high concurrency and short response times. In the case of blockchain sharding, the network is split into multiple pieces called shards.
Each shard holds a unique set of smart contracts. Transaction validation will happen on a shard instead of on the whole blockchain network. By adding shards on-demand and executing transactions parallelly, the blockchain can be scaled to infinity (theoretically). Though this is not possible practically due to tight coupling and other limitations on power distribution, sharding can be a sustainable long term solution for blockchain scalability issues.
The main drawback of sharding a blockchain is its complexity and security. Hackers can easily overtake a single shard in a segmented blockchain due to the reduced hash power required to control individual segments. Once a segment is hacked, malicious transactions can be broadcasted to the leading network, disrupting the whole system.9
Also, since different node clusters govern different blockchain segments, each shard will appear as a separate blockchain network. Intershard communication mechanisms are needed to allow users and applications of one subdomain to communicate with another subdomain. Improper implementation will result in easy double-spending, which substantially affects the security of the whole network.
Another challenge with sharding is its complexity. Implementing sharding on existing blockchain networks is very difficult since it involves network splits and reassigning of state.
One key property that sharding needs is tight coupling. Tight coupling is a property of sharding but not a property of side chains. A child chain block that specifies an invalid main chain block as a dependency is by definition invalid. More importantly, the main chain block that includes an invalid child chain block is invalid.10
Zilliqa is the first public blockchain platform to have implemented sharding. The Ethereum Foundation is also planning to use sharding in their next update, Ethereum 2.0. Other blockchain projects using sharding as a solution to scalability issues are Cardano, Harmony, and QuarkChain.
Example of Sharding protocols:
Scaling Solutions: More on Consensus and Sidechains
Hopefully, now you have a better overview of the major hurdles blockchain’s transaction times are facing and how Blockchain scalability trilemma works against the form in more detail. There are some potential solutions from sharding to the lightning network, and more solutions are proposed by the community. In related articles, we dive deeper into sidechains and consensus that are mentioned here, so give those a read too if you are keen to understand the nuts and bolts of blockchain.