- otta's newsletter
- Posts
- Layer-1 and Layer-2 protocols
Layer-1 and Layer-2 protocols
Learning concepts in Web3 through writing - this week focuses on what L1 and L2 protocols are, why L2s exist and what types of L2s there are.
Layer-1 (L1) and Layer-2 (L2) protocols are common terms in the Web3 world.
In this post, we’ll attempt to explain what an L1 and L2 is, what types of L2s are out there and why an L2 exists.
What is an L1?
Layer-1 solutions are blockchain protocols themselves. They are often referred to as the “main network” or “mainnet”. Think Ethereum, Bitcoin, Cardano, Solana, Polkadot, Avalanche, Binance, Fantom, etc.
They are the base blockchain networks on top of which projects are often built upon.
Layer-1 solutions operate by processing and validating transactions on their own dedicated blockchain, using their own native token that is required to pay transaction fees.
As such, all Layer-1 protocols (because they are native blockchain protocols), will have the following:
A network of node operators
A network of block producers
The protocol’s blockchain
The consensus mechanism for the network
Without these four (4), it cannot be a stand-alone blockchain and as such, an L1.
What is an L2?
Simply, an L2 is a protocol or blockchain built on top of an L1.
An L2 does not exist without an L1.
Why are L2s built?
Layer-2 solutions are built to address the scalability issues of the underlying Layer-1 blockchain.
For mass adoption, a blockchain needs to be able to sustain a very high number of users and their transactions.
Common issues that arise in very high transactional traffic include:
Higher transaction fees
Longer confirmation times for transactions
Limited transaction throughput
(the max amount of transactions that a blockchain can process in a given time frame)
Layer-2 solutions help to alleviate these issues by processing transactions off-chain or by delegating some of that processing to other protocols or networks.
In doing so, layer-2’s can make the layer-1 blockchain more accessible for mass adoption and efficiency.
What different types of L2s exist?
Rollups
Rollups are an L2 scaling solution. They aggregate multiple transactions into a single batch, which is then validated and committed to the main network.
These L2s are given the name because they “roll-up” several transactions into one and send it out as one.
There are two main types:
1. Zero Knowledge Rollups (ZK-Rollups)
ZK rollups use zero-knowledge proofs to verify the validity of off-chain transactions before committing them to the main blockchain.
ZK proofs are a cryptographic method that allows you to prove something is true without revealing any additional or unnecessary information.
They are useful for privacy-preserving transactions where parties may not trust each other but still need to share information with one another.
This means that the data is kept private while still being validated.
An example of this is Ethereum’s ZK Sync or Loopring.
2. Optimistic Rollups
Optimistic rollups rely on fraud proofs to verify the validity of off-chain transactions before committing them to the main blockchain.
If there is an invalid transaction on the layer-2 solution, anyone can submit proof to the main chain to prove that it is invalid. This system is called the ‘fraud proof’.
The optimistic rollup assumes transactions happening on their network (off-chain) are valid. This layer-2 solution will then periodically submit a summary of the transactions that happened with them to the main chain.
Before doing so, fraud proofs are used. Someone will send proof to the main chain, and if the network is satisfied, it can revert the invalid transaction and punish the party responsible for submitting it.
This punishment often looks like a penalty fee or a loss of staked tokens.
An example of this would be Ethereum’s Optimism or ArbitrumSidechains
Sidechains are a type of layer-2 solution that involves creating their own separate, interoperable blockchains that are linked to the main blockchain.
Transactions are moved off of the main blockchain and handled on the sidechain. Why? To reduce congestion on the main blockchain, subsequently improving transaction throughput, and ultimately lowering fees for users.
Example Sidechain - Bitcoin’s Liquid NetworkPlasma chains
Plasma chains are a layer-2 solution in which a separate, smaller copy of a blockchain is created. This smaller blockchain is often referred to as a “child chain”, and is connected to the main blockchain.
Plasma chains offload some of the transaction volume for the main blockchain. They are often designed for particular types of transactions so they can be optimized for transactional speed and cost efficiency.
They do not need to reach consensus with the larger network of validators on the main blockchain for every transaction. The plasma chain has its own, smaller network of validators.
Plasma chains rely on ‘fraud proofs’, a mechanism that ensures invalid transactions on the plasma chain are caught and challenged on the main blockchain. Basically, a summary of transactions on the plasma chain is sent over to the main blockchain periodically to carry this out.
This means they can process transactions more quickly and with lower fees, since it doesn’t require the same level of computational power and resources as the main blockchain.
Example Plasma chain - Ethereum’s Polygon
State channels
State channel layer-2 solutions allow parties to transact with each other off-chain.
In this context, state refers to the current state of a particular interaction between two or more parties on the blockchain. Two or more parties sign a smart contract on the main blockchain, which includes the initial state of the interaction. From there, they can exchange and update the state of the interaction off-chain, without incurring any costs or time delays associated with on-chain transactions.
The state being tracked could be the outcome of a game, the result of a voting process, or any other type of state that can be updated off-chain and then settled on the blockchain.
Once the outcome is finalised, ideally only then the main blockchain smart contract should be updated. Take for example voting, votes can be cast and counted off-chain, and only with the final results ready can they be taken onto the blockchain.
Example State channel - Ethereum’s Celer NetworkPayment channels
Payment channel layer-2 solutions allow for off-chain transactions between two parties and are used to facilitate simple and frequent transactions between parties, like sending payments or tipping.
They are a very specific type of state channel where the state being tracked is the balance of funds between two parties, and the state is updated with each payment transaction between the parties.
Two parties lock up a certain amount of cryptocurrency in a smart contract on the main blockchain. This smart contract is connected to the layer-2 protocol.
The two parties use layer-2 to conduct transactions with each other. After each transaction is done on the layer-2, the smart contract on the main blockchain is updated.
This layer-2 provides a faster and cheaper way for parties to transact with each other because they do the transactions off-chain and do not require verification from the main blockchain for each transaction.
Example Payment channel - Bitcoin’s Lightning Network