Ethereum is renowned for its programmability and is currently home for approximately 3000 DApps and 5000 smart contracts. Though this number calls for a big shout out, it could have been much more extensive. The dearth in blockchain such as scalability, cost and relaxed transactions are capping the DApps from choosing Ethereum. What next??
Thanks to the blockchain fanatics. Researchers in the domain have come up with various ideas to solve the scalability issue. Some straight suggestions are: changing the consensus mechanism, optimizing data storage in a block, sharding and alternatives to blockchain storage structures such as like using DAG and so on. Well, all these solutions propose changes to the underlying blockchain infrastructure and protocols. They are termed Layer 1 or L1 solutions. However, changing the fundamentals of a currently live blockchain platform is both challenging and risky. It can root to compatibility issues that may impulse forking.
But in Ethereum we do have the options to bring changes that do not affect the live blockchain layer. Ethereum has built a programmable base layer for deploying smart contracts and facilitating ether transfers. It also supports creating applications on top of this base layer, which can help improve the scalability. Such solutions are termed Layer 2 or L2.
L2 is a collective term used to denote those protocols which try to push the majority of activities “off-chain” and report to a smart contract on-chain (L1) with a summary of its off-chain activity. Since L1 is freed from intensive computations and storage requirements, it helps improve the scalability.
Working Off-chain — What is it like?
Every time a transaction happens, it should be broadcasted to all the nodes, verified by all of them and finally added in a block by a validator. The transaction will take a minimum of 12 seconds to get included in a block. If we had a smaller network with a different consensus mechanism, the transaction processing time could have been reduced.
Let us see an example.
In the Ethereum network, transactions from an account can only occur sequentially. Alice wishes to transfer some tokens to Bob, Carol, David and Elsa. She has to first transact with Bob, wait for it to be confirmed, next transact with Carol and so on. When she finishes the transactions, it will take approximately 48 seconds (assuming an optimal situation) or longer.
Imagine we have a sidechain: A minor blockchain running alongside the leading Ethereum network. It will have its consensus mechanism and an independent ledger. In this sidechain, Alice can perform the same transactions, using its native assets (let’s say TKN) at a lower cost and faster pace.
How can Alice use the sidechain to perform the transactions?
> Alice will transfer a part of her assets to the sidechain using a bridge. The bridge is a two-way peg component that allows the transfer of assets back and forth between blockchains. Just like how you transfer money from your bank account to wallet applications like Paytm, Mobikwik etc. But this may take longer.
> Alice then initiates the transfer to Bob, Carol, David and Elsa on the sidechain. The nodes in the sidechain network process these transactions. Since it’s a shorter and faster chain, the transactions happen faster.
>Occasionally, the sidechain pushes a proof, which will be a comprehensive representation of a list of L2 transactions, onto the Ethereum chain. It can be a hash of headers of sidechain blocks, a Merkle proof and so on. This will be done using a smart contract deployed on the mainchain. Anytime the state of the sidechain can be confirmed by referring to the proof on Ethereum.
Proofs are usually based on cryptographic algorithms. A simple example will be Merkle tree. A list of data items is represented using repeated hashing in a Merkle tree. The Merkle root serves as the finger print of the data set. Other techniques include Zero-knowledge proofs, polynomial commitments etc.
>The users can transact on the sidechain without informing the main chain. If the users want to transfer the funds to the main chain, they use the bridge. Since chains are independent, assets are typically locked on one chain and minted(created) on another. They are burned(destroyed) and unlocked when they are transferred back.
An off-chain process will facilitate all the interactions between sidechain and Ethereum. This process will act as an intermediary by interacting with smart contracts on both chains.
What is L2 Scaling Solutions?
The basic idea of L2 is to build a secondary framework which can handle transactions off-chain. The L2 does the transaction processing, whereas the state changes will be summarized and updated to L1. A fundamental requirement is L2 should preserve the security and risk models of L1. This also implies that, if in case, the L2 needs to be abandoned, users should be able to recover their state from L1.
Strictly speaking, the sidechain model we described cannot be counted as L2 scaling.
Let’s see the reasons.
Remember that sidechains are independent blockchains that work on their consensus mechanism and exist differently from the leading network. Nodes within the sidechain network are responsible for processing transactions, adding transactions to blocks, and maintaining consensus across the network. Note that security is the responsibility of the sidechain; it is not directly inherited from Ethereum.
How can L2 improve Ethereum?
L2 options offer the advantage of smaller and faster networks alongside utilizing the security and decentralization of Ethereum.
L2 applications try to reduce the workload of the main network. It will perform the major computations to itself (off-chain) and occasionally communicate with the main chain. It uses the decentralized security features offered by L1 as a guarantee. So main chain will continue to serve decentralization, security and data availability, whereas the L2 protocol will handle scalability.
State channels, Rollups, and Plasma chains are well-known L2 solutions. We will see them in the upcoming blogs.
 Cosimo Sguanci, Roberto Spatafora, Andrea Mario Vergani, “Layer 2 Blockchain Scaling: a Survey”.
Gangwal, Ankit & Gangavalli, Haripriya & Thirupathi, Apoorva. (2022). A Survey of Layer-Two Blockchain Protocols.