Layer 2 refers to a set of off-chain solutions (separate blockchains) built on top of layer 1s that reduce bottlenecks with scaling and data.
Layer 2 extends Ethereum as a separate blockchain above the layer 1 network. As mentioned, it communicates and helps offload the heavy burden of transactions from the mainnet through smart contracts that integrate and benefit from Ethereum’s robust decentralized security model.
Work that would be performed by the main chain can be moved to the second layer. Layer 2 applications then post the data of transactions to layer 1 where it’s secured in the blockchain ledger and history.
To start, we need to define what a layer 1 is: A layer 1 network is the base layer, or the underlying infrastructure of a blockchain. Also known as the main network or “mainnet,” it not only defines the core rules of the ecosystem, but can also validate and finalize transactions, as seen with examples like Ethereum, Bitcoin and Solana.
Layer 1 blockchains often start with an emphasis on decentralization and security – both of which are core tenets of any sound network and (with some exceptions) are maintained by a diverse, global network of developers and participants like validators.
Due to a lack of any central authority or oversight, these platforms require the technology itself to have an innate amount of security to protect users from scams and attacks. And because of this priority in design, not to mention the immense resources it takes to maintain a fully functional ecosystem, they’ve often lacked scalability.
While some developers believe that the inability to achieve a state of equilibrium between security, decentralization and scalability is an inexorable flaw of the technology (dubbed the Blockchain Trilemma), layer 2 solutions, such as rollups on Ethereum, and the lightning network on Bitcoin are one solution used to solve these issues.
What are layer 2s?
Layer 2 refers to a set of off-chain solutions (separate blockchains) built on top of layer 1s that reduce bottlenecks with scaling and data. Think of it like a restaurant kitchen – if every order had to be made by a single person from beginning to end before the order was confirmed and delivered, it would be a very slow process that could only fulfill a few orders an hour. But layer 2s are like prep stations – there’s a station for cleaning and cutting food, a station for cooking, a station that assembles the dishes – that is able to focus and do each task much more efficiently. When the time is right, a final person can match each assembled dish to the order and confirm it before it is sent to the final destination (the customer).
Payment platforms like Visa also use a similar system. Instead of separately managing thousands of daily micro transactions from a vendor like Starbucks that would clog the network in minutes, Visa groups them into batches to be settled in the banking system at regular intervals. The banks then store and sort transactions through their internal equivalent of a settlement layer. In this case, Visa would be a layer 2 and the broader network of institutions and government that keep a record of transactions and define the rules of the financial industry as a layer 1.
Ethereum also uses a similar method through features like Optimistic and zero-knowledge (ZK) rollups that offload the burden of managing transactions from the mainnet and thereby enable greater transaction inclusion and throughput (higher transactions per second). All of which makes for a more seamless and practical user experience. Examples of layer 2s on Ethereum include solutions like Arbitrum, Optimism, Loopring and zkSync.
Why are layer 2s important?
While decentralization and security are a modus operandi of the layer 1, or mainnet, of Ethereum, the ensuing market popularity over the years has caused the network to reach its current capacity of just over 1.5 million daily transactions. Furthermore, as the mainnet can only process around 15 transactions per second, periods of high network activity often lead to data congestion. This, in turn, causes gas (transaction fees) to rise and slows the performance of applications, most recently seen by the Yuga Labs Otherside virtual land sale and during the bull market of 2021.
To combat these issues, layer 2 extends Ethereum as a separate blockchain above the layer 1 network. As mentioned, it communicates and helps offload the heavy burden of transactions from the mainnet through smart contracts that integrate and benefit from Ethereum’s robust decentralized security model. In essence, Layer 1 handles security, data availability and decentralization, while layer 2s handle scaling related to transactions.
For the most part, layer 1 blockchains have:
A network of nodes to secure and validate the network.
A network of block producers.
The main blockchain and transaction data.
An associated consensus mechanism.
Layer 2 differs by offering:
Lower fees: Layer 2s bundle multiple off-chain transactions into a single layer 1 transaction, which helps reduce the data load. They also retain security and decentralization by settling transactions on the mainnet.
More utility: Through the combined advantages of higher transactions per second and lower fees, layer 2 projects can focus on improving user experience and expanding the scope of applications.
As mentioned, most scalability issues relate to decentralization. Unlike traditional banks that have a closed and more efficient method of regulating payments, transactions and data management with blockchains must undergo a series of systematic steps, such as acceptance, verification and distribution on a network (with thousands of participants), all while maintaining security and transparency.
As such, networks like Ethereum need to include a layered and scalable design that can compete with (and eventually supersede) the more streamlined, yet restricted, channels of systems like Visa and Mastercard. Layer 1s and layer 2s are important because they work together towards the goal of making the network faster and more user friendly.
How does layer 2 work?
Layer 2 protocols provide a second framework where transactions can take place separately from layer 1. This means that a decent amount of the work that would be performed by the main chain can be moved to the second layer. Layer 2 applications then post the data of transactions to layer 1 where it’s secured in the blockchain ledger and history.
As with any other open or closed platforms, layer 2s also vary in accessibility. Some can be used by a range of applications, while others only cater to the whims of a specific project. That said, several of the key components that layer 2s leverage include rollups and sidechains.
Layer 2 rollups
A rollup is a specific layer 2 solution that executes hundreds of transactions outside of layer 1, rolls them up into a single piece of compressed data and then posts the data back to the mainnet for anyone to review and dispute if deemed suspicious. By doing so, rollups not only utilize the security of Ethereum but can also reduce gas fees by up to 10-100x.
Although rollups all help with deposits, withdrawals and verify proofs, there are subtle variations in the way rollups, such as Optimism and ZK rollups, post data back to layer 1.
Optimistic rollups sit in parallel to the main Ethereum chain, run all the transactions and then post the data back to layer 1. Users are incentivized to transact on these layer 2s due to the competitively low fees. If a fraudulent transaction is suspected, it can be challenged and assessed through fraud proofs. In this scenario, the rollup will run the transaction’s computation using the available state data. Compared to ZK rollups (explained below) this means that the time to exit the rollup and withdraw funds back to layer 1 will be slightly longer. However, “inside” the rollup users will still receive fast transaction confirmation.
In general, Optimistic rollups are Ethereum Virtual Machine (EVM) and solidity compatible, which means that anything possible on layer 1 of Ethereum can be replicated on layer 2.
Several examples of Optimistic rollups include Arbitrum, Optimism and Boba.
In contrast to Optimistic rollups, ZK rollups generate cryptographic proofs to validate the authenticity of transactions. These proofs (posted to layer 1) are called validity proofs or SNARK (succinct non-interactive argument of knowledge), or STARKs (scalable transparent argument of knowledge).
ZK rollups are more efficient because they maintain the state of all transfers on layer 2, which are updated solely through validity proofs. As ZK rollups don’t need the entire transaction data, it’s easier to validate blocks and transfer ether (ETH), the main token of the Ethereum blockchain, to layer 1. The validity proof (accepted by the ZK rollup contract) has already verified the authenticity of transactions. That said, they do not have full EVM support and are more intensive to run computations for applications with little on-chain activity.
Several examples of ZK rollups include dYdX, Loopring and zkSync.
As seen through projects like XDai and Polygon PoS, a sidechain is an independent, EVM-compatible blockchain that runs parallel and interacts with the mainnet through bridges. As they use a separate consensus mechanism and are not secured by layer 1, they are not technically considered layer 2. However, the chain works the same as Ethereum because it models the EVM. That said, there’s greater levels of risks surrounding sidechain operators because users trust them with funds, rather than the Ethereum protocol (or a proper layer 2).
Validiums, such as StarkWare, use validity proofs (similar to ZK rollups) but don’t store the data on layer 1. Multiple validity chains can run in parallel with one another and are each able to process approximately 10,000 transactions per second. However, as more specialized languages are required, there is limited support for general smart contracts.
Both sidechains and validiums are blockchains that run in parallel with Ethereum and interact with assets through bridges that connect to the mainnet. They do not gain security or data from Ethereum itself and therefore aren’t considered to be a proper layer 2 like Optimistic or ZK rollups. This is especially the case given the potential security and trust implications. However, both scale similarly to layer 2s by offering lower transaction fees and high throughput.
Why are there so many layer 2s?
Various layer 2 channels have been created to prevent any overdependence or the potential collapse of a single part of the network. However, as we’ve covered the main layer 2s (Optimistic rollups, ZK rollups and sidechains), the ecosystem is constantly shifting, and some applications end up abandoned, such as Plasma and State Channels.
Examples of common layer 2s
Overall, as layer 2s harmonize and work with the entire Ethereum ecosystem, the various options, which anyone can build, offer a greater, more balanced range of options for end users. What one layer 2 blockchain lacks can be balanced with advantages of another and vice versa. The following is a summary of the more commonly used layer 2s:
General layer 2s
A general layer 2 project mirrors the performance and functionality of Ethereum’s mainnet, with cheaper fees (gas). Some examples include:
Although a new fraud-proof system is still being built, Optimism is an EVM-equivalent system that uses Optimistic rollups to make transactions fast, simple, and secure.
Arbitrum is another Optimistic rollup that mirrors the dynamics of Ethereum mainnet but with cheaper transaction fees.
Forked initially from Optimism, Boba is an Optimistic rollup that aims to reduce fees, improve transaction throughput and strengthen the capacity of smart contracts.
Application-specific layer 2s
In comparison, application-specific layer 2 networks are more specialized and focus on improving the performance of a niche market sector. Examples include:
Loopring is a ZK rollup that aims to provide the same security as Ethereum’s mainnet with more scalability, such as throughput increased by 1000x and transaction costs reduced to 0.1% of layer 1.
Used by platforms like Binance, zkSync is a ZK rollup from Matter Labs. It’s already live on the Ethereum mainnet and supports payments, token swaps and non-fungible token (NFT) minting.
Abandoned layer 2s
Not every experiment or idea for a layer 2 works. Here are some examples of projects that aimed to solve a problem but failed to catch on.
In January 2020, the Ethereum research organization Plasma Group announced it ceased operations in its current form and has donated the remaining funds to Gitcoin. The decision was made to focus on Optimistic rollups instead.
As seen through projects like Polygon, OMG Network and Gluon, plasma chains are separate blockchains tied to the Ethereum mainnet. They use fraud-proofs like Optimistic rollups to regulate disputes and manage security. As they are smaller copies of the Ethereum mainnet, they are also known as “child chains.” Merkel trees enable an endless stack of these chains that can work to help offload heavy data bandwidth from parent chains, including the mainnet. However, plasma isn’t useful for arbitrary contracts, only for transfers. And hence, along with issues like expensive costs and difficulties withdrawing funds from a plasma chain, it was abandoned in favor of Optimistic rollups.
State channels are pathways opened between two users that wish to communicate with each other via transactions. By utilizing multi-signature contracts (a type of contract that requires signatures of multiple parties to execute), they allow participants to transact freely off-chain and settle with the mainnet. This enables high transaction throughput and minimizes congestion and fees. Two main types of channels are state channels and payment channels. However, due to the rigidity in needing users to lock up funds, coupled with the lack of support for general-purpose smart contracts and DeFi applications in 2021, it was also mostly abandoned. According to Ethhub, teams that are still working on it include CelerX Connext Network. Raiden Network may also be near or in production.
Further layer 2 resources and considerations
Due to the nascency of these layer 2 platforms, there are still risks and varying degrees of faulty trust assumptions compared to transacting on the mainnet. It’s also worth noting that despite leveraging the security of layer 1, layer 2s are only truly safe if they have fraud proofs enabled, which (at the time of this writing) they do not.
Blockchain bridges (that people can use to transfer assets to layer 2) are also in the early stages of development and carry high degrees of risk. With all this in mind, thorough due diligence through resources like L2BEAT is recommended before engaging with any layer 2. L2BEAT is a comprehensive risk and analysis platform committed to educating users about projects that match their high standards and rigorous definitions of what it means to be a layer 2.