A Short Handbook of Layer 2 Solutions

Layer 2 Solutions

Optimistic and Zero-Knowledge Rollups, Channels, Plasma, and Sidechains: A Short Handbook of Layer 2 Solutions

Layer 2 solutions are a way to improve the scalability of the Ethereum mainnet. They, through a variety of methods, ease congestion on the chain. By doing so, they make it possible for Ethereum to handle a wide range of applications that would otherwise clog the network and either make it unusable, or render those applications worthless. This article will dive into the various layer 2 solutions and how they work.

Note: Although layer 2 solutions can exist for any blockchain – as the term just refers to frameworks and protocols that exist on top of a given blockchain structure – we will focus on layer 2 through the lens of Ethereum – as that is where most innovation is happening in the space, and arguably where it is most needed.

Layer 2 solutions, as well as providing a base functionality for these applications to work (types of which we’ll explore shortly), also have the add-on effect of drastically reducing the gas fees on Ethereum, as well as making transactions far faster to resolve. This is because by amplifying the throughput of the chain and making faster transactions possible, the gas fees required for each transaction is correspondingly lower.

Layer 2 solutions, however, vary enormously. Approaches have differed in the attempt to make the great, clanking beast that is Ethereum fit for the rapid innovation of Web 3.0. In this article, we’re going to look at all the main Layer 2 solutions and the protocols that are using that technology to keep Ethereum on its slender throne.

Why Layer 2 is Essential

Without Layer 2 solutions, Ethereum would not be able to handle the new wave of dApps that are currently being made. Play to Earn games would run horribly slow. NFT trading would slow the network to a crawl.

Sophisticated financial instruments and chains of smart contracts would not be able to execute at the rate required. HFT (High Frequency Trading) – so important to onboard financial institutions to the crypto space – would be impossible. DeFi (at any level of efficiency on a large scale) would be merely a dream.

This is because Ethereum’s current tps is 12 to 15 transactions per second. As such, competition for block space is fierce, and fees can spiral out of hand at times of high activity, pushing out low-level community activity on-chain that is so important for the continued health of the ecosystem.

Challenges Facing Layer 2

The key challenge for layer 2 is to provide scalability and throughput – not in itself too difficult – without sacrificing security and decentralisation. This, the fabled blockchain trilemma, is at the heart of layer 2.

The reason there are a multitude of layer 2 solutions is because no one solution has completely solved the issue, and new innovations in layer 2 technology are continually being made, taking on the problem in different ways.

Ethereum’s security, i.e the consensus mechanism that makes it function (and what makes it worth anything at all), is paramount. Layer 2 solutions are all about maximising Ethereum’s speed as far as possible without violating that consensus. Layer 2s do processing work on data ‘off-chain’ before integrating with Ethereum in different ways.

Types of Layer 2 Solutions

Rollups: Zero-Knowledge (zk) and Optimistic

Rollups are a layer 2 solution with three main features. One, transactions take place off chain (to improve speed). Two, Proof of transactions and data remain on layer 1 (to maintain security). Three, the rollup smart contract on layer 1 (Ethereum) can ensure that transactions are executed properly on layer 2 by using the data stored on layer 1.

zkRollups are validity proofs. A validity proof asserts – through a computational check – that the data on the L2 is correct. It means new states can be relied upon and trusted straight away, but the time and work it takes to validate states impacts scalability.

Optimistic rollups, on the other hand, use fraud-proofs and disputation. This can be faster, but has its own drawbacks as data can’t always be relied upon. And, due to the method of disputation, sometimes it’s actually slower.

Zero-Knowledge Rollups

zkRollups are a method by which hundreds of off-chain transactions are put together (‘rolled up’) before being sent to the Ethereum mainnet for validation. They are what Numio uses to offer its lightning fast services.

They use zero-knowledge proofs. These are proofs that show they are correct without revealing the actual data contained, akin to showing a gift receipt for a purchase that doesn’t tell you the item bought. These zkProofs are generated for the bundle that the Ethereum consensus mechanism can then validate. There are two main types, SNARKs and STARKs, that are sent to Layer 1.

The zkRollup exists in a smart contract that maintains the state of all the Layer 1 transfers that occur off-chain. This can only be updated by a validity proof. That validity proof is orders of magnitude smaller to ‘process’ that the transactions it is vouching for would be, increasing throughput.

Validity proofs themselves, however, are very computationally intensive. So an application with little activity would not be able to successfully implement zkRollups. They are also complex to code, using Merkle Trees.

However, the benefit of zkRollups is clear. As the zkRollup contract has already validated the transactions within it, funds can be withdrawn on Layer 2 instantly (as soon as the zkSNARK transaction has been mined on Ethereum), a fact that isn’t the case with our next solution, optimistic rollups.

Optimistic Rollups

Optimistic rollups is the more common ‘rollup’ technology that exists as a layer 2 solution. Like zkRollups, transactions are processed off-chain before being sent to Ethereum.

The key fact about optimistic rollups, and why they are given their name, is that they assume that all transactions are correct until proven otherwise. Optimistic roll ups include a period of time wherein transactions can be disputed by submitting a fraud proof.

Successful disputations are rewarded by the contract to incentivise users to root them out. It also disincentivises aggregators who are bad actors as they can lose their funds if they submit fraudulent transactions to the contract

However, this disputation method takes time, and is one of the reasons optimistic rollups are slower than zkRollups, and indeed all other Layer 2 solutions. It takes longer to achieve true finality, and thus it takes longer to withdraw funds back to L1.

Despite these drawbacks, Optimistic rollups are flexible – they support general computation – all the data needed is available on-chain, they are relatively easy to implement and do increase the scalability of Ethereum.

Plasma

Plasma refers to a separate blockchain that is anchored to the Ethereum mainnet, using fraud proofs to dispute transactions and ensure validity. They are often called ‘child’ chains. This is because they are miniature copies of the Ethereum mainnet, which the mainnet offloads transaction data to when it suffers congestion.

These child chains can themselves create smaller copies to further increase the throughput. These chains all operate independently, and are built on top of one another in a tree-like structure. In essence, plasma-chains are smart contracts that produce their own, independent, blockchain that feeds data back to the parent – ultimately the Ethereum mainnet.

Like Optimistic rollups, it uses fraud proofs to validate the plasma chain. However, there is no requirement for a child chain to use the same consensus mechanism as the main chain. As the data-availability is off-chain, the transactions aren’t technically secured by Ethereum. The other problem with Plasma chains is that the predicate logic they run on does not support general computation, so only token transfers, swaps, and other types of general transactions are possible.

Sidechains

Sidechains are often confused for Plasma chains – but actually they are very different. A sidechain is a blockchain that runs alongside the mainchain, not one that sprouts from the roots of the main chain itself. The idea behind a sidechain is to create a special communication method (i.e, a smart contract) between the main chain and side chain so the main chain can easily validate activity on the side chain and the side chain can easily source data from the main chain.

When users want to move an asset to the sidechain (to take advantage of its faster speed), they just deposit their assets into the layer 1 smart contract, and it’s released on the sidechain. Once withdrawn, it is released on Ethereum. Even if the asset is moved multiple times on the sidechain, only the deposit and withdrawal take place on Ethereum.

The benefits are obvious. Transactions can happen faster on the sidechain, as it’s less congested. And because the sidechain and mainchain are operating a bespoke bridge (through the smart contract), transfers between the two are fast.

The cons, however, are legion. The sidechain is then subject to all the same scrutiny any other chain would be. Who runs consensus? Who are the validators? What is the user base? Are fraudulent transactions occurring? And what is the smart contract risk in terms of hacks? This all applies to the bridge being used as well. Over $1 billion in funds have been stolen from bridges alone. Even if the sidechain performs well, can the bridge be relied upon?

A sidechain has to be every bit as unimpeachable as a main chain. To keep it well validated, you have to pay fees, and if you don’t, or if the chain gets popular, it may suffer the exact same problems the main chain does – rendering its purpose obsolete.

State Channels

State channels are a method by which users interact directly off chain in an agreement that, once finalised, is sent to Ethereum for validation. All users must have a stake in the channel, to prevent malicious actors. They then sign transactions and send them to one another, keeping copies. The transactions contain nonces so the smart contract is aware of the chronological order. Once finished, the entire ‘state’ is updated and then sent to Ethereum. The smart contract then sends parties the transactions that occur.

It allows for private, fast-paced transactions between consortiums that can maintain trustless interaction and keep the security that is afforded by the blockchain, but it can all occur at a faster pace. Transactions within the state channel have instant finality and, due to the trustless nature of the set up and the fact that actors are eventually being checked by Ethereum itself, state channels are a fast, effective way to work off-chain.

The issue with state channels lie in their custom connectivity, and the fact that should another user begin acting maliciously or fraudulently, either by accident or design, the state channel must be reverted on-chain for resolution, and the main chain can only make an approximation of the transactions that have taken place, as the transactions aren’t directly secured by the mainnet. It creates problematic incentives for users to close down state channels early if – for whatever reason – maintaining it is not to their advantage.

Have Your Layer Cake and Eat It

Layer 2 solutions are still being developed. zkProofs, although technologically complex and resource intensive, so far offer the fastest and most effective way to scale Ethereum. Other layer 2 solutions are not to be discounted, however, and each serve their purpose well. As innovation continues, layer 2 solutions will continue to be at the forefront of blockchain development, so that Ethereum – and in time other blockchains – can operate at the speed required to make blockchain a fundamental part of daily life.

About Numio

Buy, sell, trade, earn crypto with DeFi, collect NFTs, and more, while saving you up to 100x on Ethereum fees. Numio gives you more control over your digital assets in one convenient app. Numio can be used pseudonymously, or with an optional zkProof powered identity verification system. All Numio products are non-custodial.

Available on Android and iOS, Numio was the first zkRollup powered mobile payments app to be released on Google Play.

Share on Facebook
Share on Twitter
Share on LinkedIn

Categories

Categories

Signup to our Newsletter

Signup and stay up to date with our products and upcoming releases.

Download Numio

Numio is fast, cheap, and secure. Download for free and start saving money today.

Ethereum wallet NFTs and more

Get the Latest News

Sign up to our newsletter and stay up to date with our products and upcoming promotions.

Backed By

Copyright © 2022 Numio. All Rights Reserved.

Stay Updated

Subscribe and stay up to date with our latest products and upcoming promotions.