Guides
1 year ago

What are Layer 2 Scaling Solutions?

Bridgit Murphy Aug 16, 2021 21:48

Blockchain’s moon race is on as the ecosystem grapples with developing scalability solutions to meet demand without sacrificing security or decentralization – the classic blockchain trilemma.

The rapid growth in decentralized finance, NFTs, and gaming has seen adoption congest the Ethereum network, in particular, leading to bottlenecks and high transaction fees, given its capacity for processing only a few transactions per second, rendering many dApps usable at times.

Ethereum’s transition to proof-of-stake sharded network may alleviate some of that pressure on layer 1, with sharding splitting the Ethereum network into new chains or shards to spread the load, reducing congestion, and increasing transactions per second.

However, given full deployment is still years away and participation isn’t showing signs of slowing down any time soon, the pressing need for scalable solutions has accelerated the adoption of layer 2 technology that runs on top of Ethereum’s layer 1, rather than trying to improve performance at the base layer.

Layer 2 and related technology offer several different solutions for Ethereum scaling, each with its own benefits and trade-offs, including:

  • Plasma
  • Sidechains
  • State Channels and Payment Channels
  • Optimistic Rollups
  • ZK-Rollups
  • Validium
  • Aggregators

But before we dive into the specifics, let’s have a look at the basics.

Layer 1 Explained

So what is layer 1? It is the base network and underlying infrastructure of a blockchain platform. The main network is responsible for validating and finalizing all on-chain transactions without depending on another network. This means the base layer defines the rule of the ecosystem. L1 protocols also have native tokens used for transaction fees or gas fees.

Every base network has its own mechanism for nodes to reach a consensus, such as proof-of-work (PoW) and proof-of-stake (PoS). However, there’s a very common concept in the industry known as the blockchain trilemma, where a network can achieve two of the three main goals – security, scalability, and decentralization – but not all three together. This was popularized by Ethereum’s co-founder, Vitalik Buterin.

Layer 1 blockchains such as Bitcoin and Ethereum focus on decentralization and security while sacrificing scalability – the ability to handle many transactions. This is where layer 2 protocols come in. Developers build L2 solutions on L1 to solve scalability issues.

What is Layer 2 and How Does it Work?

Layer 2 protocols are solutions built on top of a base network to help scale transactions and data. L2 serves as an extension or a secondary framework for their respective main networks.

So how does it work? Layer 2 networks process transactions in large bundles on their own before submitting proof of the transactions to the base layer. This process is commonly referred to as “off-chain” scaling, and it takes a massive load off the base network.

L1 focuses on security, decentralization, and data availability, while L2 handles scalability. This makes the entire blockchain ecosystem more scalable since the base network is less congested. So basically, it’s teamwork.

Now, let’s get more specific.

Plasma

Plasma chains are separate blockchains that anchor to Ethereum, sometimes called child chains, as they operate as smaller copies of the Ethereum mainnet. These child chains use a combination of smart contracts and cryptographic verification to offload transactions from the parent chain.

Each with its own mechanism for block validation, Plasma chains periodically report back to the Ethereum main chain, using its security to settle disputes when challenged via fraud proofs.

Plasma chains enable high throughput at a low cost per transaction. However, only basic transactions like token transfers and swaps are supported, there is a liveliness requirement, and chain withdrawals can be lengthy to allow for challenges.

Several projects provide implementations of Plasma for dApp integration, including OMG Network and LeapDAO.

It’s worth noting, though, that Plasma Group (the Ethereum research organization) ceased operating and donated the remaining of its funds to Gitcoin to be used on optimistic rollups.

Plasma. Image by Near.org

Sidechains

Layer 2 sidechains are independent Ethereum Virtual Machine (EVM) compatible blockchains running parallel to the Ethereum main chain. Validator nodes in the sidechain network are responsible for confirming and processing transactions, adding blocks, and maintaining the sidechain’s own consensus rules, such as proof-of-authority or delegated proof-of-stake, to provide more efficient transactions.

Compatibility is achieved via a two-way bridge to Ethereum, though its security is not directly inherited and is the responsibility of the sidechain.

Sidechains. Image by Near.org

Sidechains utilize established technology and support more complex transactions with EVM compatibility, though they are less decentralized and rely on their own consensus mechanisms rather than the security of layer 1 and so aren’t technically layer 2 in that sense.

Projects offering sidechain implementations include POA Network and xDai chain.

State Channels and Payment Channels

One of the first widely discussed layer 2 scaling solutions, state channels use multi-signature contracts to enable participants to transact quickly and frequently off-chain, settling back to layer 1 for finality as required.

State channels can manage more complex interactions like a game, whereas payment channels are simplified state channels that only deal with payments between two participants. State channels allow for extremely high transaction throughput at a very low cost, making them ideal for micropayments. However, the time and cost to set up and settle channels are not ideal for one-off payments, liveliness is required, and funds have to be locked up in open payment channels.

The main projects leveraging state channels on Ethereum are Celer, Perun, and Raiden.

Optimistic Rollups

Optimistic rollups sit in parallel to the Ethereum main chain on layer 2. They allow transactions to be executed cheaply and scalably in batches outside layer 1 while still using the security of the Ethereum base layer when submitting them as a single transaction.

As computation is the slow and expensive element of the Ethereum network, optimistic rollups offer up to 100 times scalability improvements as they don’t run any computation by default, a number that will increase further with the future introduction of Ethereum sharding.

Instead, optimistic rollups assume transactions are valid and only run computation if challenged via a fraud-proof. Optimistic rollups use a bonding system, and anyone proven responsible for a fraudulent transaction or challenge will forfeit their bond with some slashed and some used to incentivize the correct party.

Optimistic rollups can handle anything done on Ethereum layer 1 as they are EVM and Solidity compatible. As all transaction data is stored on the layer 1 chain, optimistic rollups remain secure and decentralized. At the same time, they are providing execution scalability. However, long wait times for on-chain transactions are possible due to the potential fraud challenges.

Optimistic rollups. Image by Near.org

As optimistic rollups support both simple payments and complex smart contracts, they are seen as more immediately suitable for DeFi applications, with Optimism, Arbitrum, and Cartesi among the multiple projects offering implementations.

In a sign of the future direction of the space, the leading DEX platform Uniswap recently also announced it would be taking the next step in adopting layer 2 tech by launching on Optimism to sharply reduce transaction costs for its users.

ZK-Rollups

Zero-knowledge rollups, or ZK-rollups, bundle transactions off-chain and generate a cryptographic proof, known as a SNARK. In contrast to optimistic rollups, ZK-rollups run computation off-chain and submit these validity proofs to the layer 1 chain.

ZK-rollup smart contracts maintain the state of all transactions on layer 2, which can only be updated with validity proof. As ZK-rollups only need the validity proof rather than all the transaction data, validating a block is quicker and cheaper as it includes less data and requires less gas.

Additionally, as the ZK-rollup contract has already verified the transactions, there are no delays in moving from layer 2 to layer 1.

As a result, ZK-proofs offer faster finality times while remaining secure and decentralized since the data needed to recover the state is stored on Ethereum layer 1. However, some ZK-rollups do not have EVM support, and validity proofs are intensive to compute, making them unsuitable for dApps with little on-chain activity.

Multiple implementations of ZK-rollups also exist, including zkSync and ZKSwap. zkSync offers a trustless protocol for scalable, low-cost payments on Ethereum using ZK-rollup technology, helping crypto wallets and defi platforms to unlock PayPal-like scale. ZKSwap provides a ZK-rollups-based layer 2 DEX with zero gas fees and high-transaction throughput, transforming the future of the AMM model.

Harmony’s interoperable layer 2 for Ethereum offers something more unique, combining the best of both the optimistic and ZK-rollup worlds. Harmony provides full EVM compatibility, unlike ZK-rollups, faster settlement with shorter withdrawal times compared to Optimistic rollups, and gas-efficient interoperability based on its sharded Proof-of-Stake blockchain that bridges to Ethereum via smart contracts.

By building on the benefits of both Optimistic rollups and ZK-rollups, generally seen to be the most promising of layer 2 scaling technologies, while addressing their shortcomings, Harmony can provide a more wholescale solution for projects to deploy. Harmony’s interoperability also extends beyond Ethereum with its Horizen bridge to Binance Smart Chain, opening up access to the broader defi ecosystem.

Validium

Validium uses validity proofs like ZK-rollups, but instead, data is not stored on Ethereum layer 1, allowing for scalability of up to 10,000 transactions per second per Validium chain, of which multiple can run in parallel.

Validium offers no withdrawal delays, improving capital efficiency, and is not vulnerable to certain economic attacks faced by high-value dApps using fraud-proof-based systems. However, Validium chains have limited smart contract support.

Projects providing implementations of Validium include Loopring and StarkWare. Immutable X, the first layer 2 scaling solution for NFTs on Ethereum, utilizes StarkWare’s Validium and ZK-rollup technology to enable transaction speeds of over 9,000 per second with zero gas fees while retaining Ethereum’s security for its ecosystem of marketplaces, apps, and games.

Aggregators

Polygon is something of an aggregator of these layer 2 solutions, offering multiple implementations of several layer 2 technologies. As a result, Polygon has become the fastest-growing layer 2 networks, bringing blockchain infrastructure to the masses by opening up the accessibility, usability, and use cases of decentralized applications on Ethereum’s internet of blockchains.

Polygon’s suite of layer 2 scalability solutions has witnessed adoption from Defi blue chips, with platforms like Aave, SushiSwap, and 1inch already integrating with it.

CVI, the decentralized volatility index for the crypto space powered by the COTI network, has also followed that lead in integrating with Polygon. CVI users can open positions and provide liquidity and stake while processing transactions out of the main ETH blockchain.

Bitcoin Lightning Network

The Lightning Network (LN) is Bitcoin’s most popular layer 2 scaling solution. It was proposed in 2016 to solve the scalability issues on the Bitcoin network by processing transaction bundles at a lightning-fast speed.

Like other L2 scaling solutions discussed above, LN takes multiple transactions from the mainnet and processes them off-chain through micropayment channels before returning the transaction data.

Although the Lightning Network was originally designed to scale Bitcoin, cryptocurrencies such as Litecoin and Dogecoin have also integrated the solution.

Benefits of Layer 2 Networks

Scalability: Scalability deals with transaction throughput and speed. In other words, it ensures higher transactions are processed per second with faster completion. Many base networks prefer to sacrifice scalability for decentralization or security, which leads to congestion during high network usage.

Layer 2 networks solve this problem as they help blockchain ecosystems to scale without compromising security or decentralization.

Lower fees: As mentioned earlier, L2 bundles multiple transactions and submits them to the mainnet as a single transaction. This helps to reduce transaction fees, making the base layer cheaper and faster.

Maintain Security: Security and decentralization are the core focus of layer 1 networks. Since layer 2 chains are built on top, users can benefit from the security of the primary blockchain.

Drawbacks of Layer 2 Networks

Liquidity Reduction: Liquidity is an important aspect of the crypto market. Layer 2 networks can reduce the liquidity of their primary blockchains, which ought to be robust and liquid at all times.

May Require Multiple Accounts: When multiple L2 solutions are built on top of a network, the L1 and its different applications will require more bridges to ensure smooth communication between the two layers. This means end-users will often have to create multiple accounts to transfer funds between the different protocols. The process can be daunting, especially since users have to track the movement of their assets at all times.

Security Concerns: While this is a matter of implementation, the past year saw multiple bridging solutions getting hacked, leading to hundreds of millions worth of cryptocurrency being compromised. 

Summary

No one scaling solution alone is sufficient to fulfill the secure, decentralized, and scalable vision of Ethereum 2.0, avoiding the problem of high fees and bottlenecks.

Sharding will certainly help on-chain scaling on layer 1, but off-chain layer 2 solutions that can flexibly tailor to the unique requirements and acceptable trade-offs of the plethora of dApp projects being developed are key to the future of blockchain.

The ecosystem as a whole is greater than the sum of its parts, and different layer 2 solutions can exist and work together in harmony to respond to the increasing demands of mainstream adoption, continuing to help reduce congestion and prevent single points of failure as we transition to the world of Web 3.0.

Share This Article
Bridgit Murphy

Bridgit Murphy is blockchain technology engineer specializing in integrated online services, smart contracts, fork development, and quality assurance. An open-source enthusiast, Murphy recently relocated from her hometown of Dublin to Hong Kong. Contact: LinkedIn