With record volumes, increasing adoption and an increasingly array of products built on Ethereum, gas fees are soaring. Layer 2 (‘L2’) solutions are coming, with some already here to help slash gas fees. Simply, L2 is a collective term for solutions designed to help scale Ethereum.
This resource starts by explaining the need for Ethereum L2 solutions before covering some types of L2 solutions.
The Need for Layer 2 Solutions
Ethereum scaling has been a constant debate since its inception, but what does this mean?
Ethereum is restricted by how many transactions can be processed on the network, approximately 15 transactions per second. This is because each block can only contain a certain amount of data, known as the block size. In comparison, Visa processes more than 45,000 transactions per second. This means Ethereum is significantly restricted in the amount of transactions which can be verified, leading to significant congestion in the network in times of high demand. You can think of this like a queue of shoppers which moves at a certain pace. If more shoppers join the queue, it can take longer to reach the front and get your transaction processed.
READ: What is Network Congestion?
This is the central reason why L2 solutions are needed: to solve the scalability problem. This has been a common problem facing blockchains since they were created, or commonly referred to as the ‘The Scalability Trilemma’. This states that any updates or changes to increase scalability should not be at the expense of security or decentralisation. It might be possible to process 45,000 transactions like Visa, but if the network is less secure than there is a problem.
The Scalability Trilemma
Solving this problem is essential for creating a fair and well-run network. For example, when Ethereum is experiencing heavy congestion, gas fees can skyrocket—costing US$50 for a simple swap on Uniswap. This can make dApps unusable for the everyday person.
READ: What Is Gas On Ethereum?
What Are Layer 2 Solutions?
As the name implies, L2 solutions are built on top of layer 1 (‘L1’)—Ethereum’s base layer—to secure off-chain interactions. This simply means they process transactions on this additional layer, instead of Ethereum’s main chain.
L2 solutions can help solve the scalability trilemma as they’re built on L1, so they can secure off-chain interactions by leveraging the security of L1. This helps to ensure there are no security trade-offs, while helping to provide more block space for transactions to be processed—helping scale the network and reduce transaction fees..
Think of L1 as the settlement layer, making sure everything balances, is secure and is running efficiently. Whereas L2 is where all transactions are batched and processed before being sent to L1 for reconciliation.
Sidechains are another scaling solution, although are technically not a L2 solution. Sidechains are unique blockchains that are attached to a main chain and allow digital assets from one blockchain to be used in a separate one—moving back to the original when needed. They are independent from the main chain and can implement their own mechanism for achieving consensus. Examples of sidechains include Matic and the xDai Stable Chain.
Scaling via L1
L1 is the base consensus layer of Ethereum protocol, so you may ask why can’t you just improve the base layer Ethereum runs on?
As the scalability problem has been around since Etheruem’s inception, there has been extensive work on scaling Ethereum’s base layer through moving to a Proof of Stake (‘PoS’) system called Ethereum 2.0. This involves migrating from the computational heavy proof-of-work (‘PoW’) system.
PoS is a different kind of consensus mechanism blockchains use to agree on a single true record of a data’s history. Using PoS introduces sharding, a potential L1 scalability solution for Ethereum. Simply put, sharding refers to splitting the entire Ethereum network into smaller, multiple portions called ‘shards’. Sharding is one of the most complex scaling solutions, but the basic idea is to split up transaction processing between smaller groups of nodes to increase the amount of transactions that can happen. This is enormously difficult and poses significant technological challenges.
Although moving to PoS can help solve some scalability issues, there is still a need for L2 solutions to work together to maximise the amount of transactions Ethereum can process and reach the ultimate goal of processing thousands of transactions for widespread adoption.
This is where layer 2 solutions come in.
Types Of Layer 2 Solutions
There are many potential L2 solutions, each of which with unique benefits and trade-offs. Below, we define each L2 solution and provide examples of their application.
State channels
State channels improve blockchain performance by moving state-modifying operations off-chain. These are similar to the concept of payment channels in Bitocin’s Lighting Network, but instead of only being limited to payments, it supports general ‘state updates’. They simply minimise their use of ‘on-chain’ operations, reserved for only the necessary operations.
To contextualise this, imagine an example where you deposited funds into a contract and sign state updates representing the running scores of a basketball game. When the game is finished only the final outcome would be broadcasted to the Ethereum network, helping dApps to move transactions off-chain and increasing the usefulness of the network. Projects currently working on state channels solutions include Raiden Network and Connext.
Roll-ups
Rollups refer to solutions which bundle sidechain transactions into a single transaction—hence the name ‘roll up’—which generates a cryptographic proof. In its simplest form, it means all state and execution is handled in sidechains—with the Ethereum’s L1 only storing transaction data. They are useful for reducing fees, creating open participation and creating fast transaction throughput. For example, they can increase the throughput of the blockchain from 15 tps to more than a 1,000.
“Rollups are a powerful new layer-2 scaling paradigm, and are expected to be a cornerstone of Ethereum scaling in the short and medium-term future (and possibly long-term as well). They have seen a large amount of excitement from the Ethereum community because unlike previous attempts at layer-2 scaling, they can support general-purpose EVM (Ethereum Virtual Machine) code, allowing existing applications to easily migrate over. They do this by making a key compromise: not trying to go fully off-chain, but instead leaving a small amount of data per transaction on-chain.” – Ethereum founder Vitalik Buterin [An Incomplete Guide to Rollups; Jan. 5, 2021]
There are 2 types of L2 roll-ups, each with different security models: zero-knowledge (‘ZK’) rollups and Optimistic rollups.
ZK roll-ups use a validity proof, meaning the smart contract can verify all of the transfers from the bundling hundreds of transfers off-chain. This can be useful as you don’t need all the transaction data to verify it, just the proof.
- Loopring, Matter Labs, zkSync and Starkware are examples of projects working on ZK roll-up solutions.
Optimistic roll-ups do not do any computation by default, instead are assumed to be valid by default. Users only submit ‘fraud proofs’’ if they see any mathematically verifiable misbehavior. As computation is a slow, expensive part of using Ethereum, Optimistic roll-ups can offer up to 10–100x improvements in scalability dependent on the transaction.
- As of this writing, Optimism and Fuel Network are working on these implementations. Synthetix has deployed the first application on Optimism’s public testnet.
Plasma
Plasma is a framework for creating scalable dApps on the blockchain. They create smaller blockchains which are connected to the main blockchain via a smart contract. dApps then run via these smaller mini blockchains, greatly lowering the strain on the main network.
The communication between these mini blockchains and the main chain are secured by fraud proofs, with the main chain responsible for securing the network and punishing the malicious actors. Simply, fraud proofs are a mechanism in which a Plasma mini-chain files a complaint to the main chain.OMG Network and Loom Network are behind some common Plasma L2 implementations.