Layer 2 (L2) is a collective term to describe a specific set of Ethereum scaling solutions. A layer 2 is a separate blockchain that extends Ethereum and inherits the security guarantees of Ethereum.
Layer 1 is the base blockchain. Ethereum and Bitcoin are both layer 1 blockchains because they are the underlying foundation that various layer 2 networks build on top of. Examples of layer 2 projects include “rollups” on Ethereum and the Lightning Network on top of Bitcoin. All user transaction activity on these layer 2 projects can ultimately settle back to the layer 1 blockchain.
Ethereum also functions as a data availability layer for layer 2s. Layer 2 projects will post their transaction data onto Ethereum, relying on Ethereum for data availability. This data can be used to get the state of the layer 2, or to dispute transactions on layer 2.
Three desirable properties of a blockchain are that it is decentralized, secure, and scalable. The blockchain trilemma(opens in a new tab)↗ states that a simple blockchain architecture can only achieve two out of three. Want a secure and decentralized blockchain? You need to sacrifice scalability.
Ethereum has reached the network’s current capacity with 1+ million transactions per day(opens in a new tab)↗ and high demand for each of these transactions. The success of Ethereum and the demand to use it has caused gas prices to rise substantially. Therefore the need for scaling solutions has increased in demand as well. This is where layer 2 networks come in.
The main goal of scalability is to increase transaction speed (faster finality) and transaction throughput (higher transactions per second) without sacrificing decentralization or security.
The Ethereum community has taken a strong stance that it would not throw out decentralization or security in order to scale. Until sharding, Ethereum Mainnet (layer 1) is only able to process roughly 15 transactions per second(opens in a new tab)↗. When demand to use Ethereum is high, the network becomes congested, which increases transaction fees and prices out users who cannot afford those fees. That is where layer 2 comes in to scale Ethereum today.
As we mentioned above, Layer 2 is a collective term for Ethereum scaling solutions that handle transactions off Ethereum Layer 1 while still taking advantage of the robust decentralized security of Ethereum Layer 1. A layer 2 is a separate blockchain that extends Ethereum. How does that work?
A layer 2 blockchain regularly communicates with Ethereum (by submitting bundles of transactions) in order to ensure it has similar security and decentralization guarantees. All this requires no changes to the layer 1 protocol (Ethereum). This lets layer 1 handle security, data availability, and decentralization, while layer 2s handles scaling. Layer 2s take the transactional burden away from layer 1 and post finalized proofs back to layer 1. By removing this transaction load from Layer 1, the base layer becomes less congested, and everything becomes more scalable.
Rollups are currently the preferred layer 2 solutions for scaling Ethereum. By using rollups, users can reduce gas fees by up to 100x(opens in a new tab)↗ compared to layer 1.
Rollups bundle (or ’roll up’) hundreds of transactions into a single transaction on layer 1. This distributes the L1 transaction fees across everyone in the rollup, making it cheaper for each user. Rollup transactions get executed outside of layer 1 but the transaction data gets posted to layer 1. By posting transaction data onto layer 1, rollups inherit the security of Ethereum. There are two different approaches to rollups: optimistic and zero-knowledge – they differ primarily on how this transaction data is posted to L1.
Sidechains and validiums are blockchains that allow assets from Ethereum to be bridged over and used on another blockchain. Sidechains and validiums run in parallel with Ethereum and interact with Ethereum through bridges, but they do not derive their security or data availability from Ethereum.
Both scale similarly to layer 2s – they offer lower transaction fees and higher transaction throughput – but have different trust assumptions.
Some layer 1 blockchains have higher throughput and lower transaction fees than Ethereum. These alternative layer 1s have had to sacrifice on security or decentralization in order to achieve higher transactions per second and lower transaction fees.
The Ethereum ecosystem is firmly aligned that layer 2 scaling is the only way to solve the scalability trilemma while remaining decentralized and secure.
Happy coding!!