Previous articles introduced layer0-3, let's review the definitions first.
Layer1#
Layer1 is the underlying blockchain. Ethereum and Bitcoin are both Layer1 blockchains because they are the foundation on which various Layer2 solutions are built. Examples of Layer2 projects include "Rollups" on Ethereum and the Lightning Network based on Bitcoin. All user transaction activities on these Layer2 projects can ultimately be traced back to the Layer1 blockchain.
Ethereum also serves as the data availability layer for Layer2. Layer2 projects publish their transaction data to Ethereum and rely on Ethereum to achieve data availability. This data can be used to determine the state of Layer2 or to dispute transactions on Layer2.
Layer2#
Layer2 is a collective term used to describe a range of specific Ethereum scaling solutions. Layer2 is an independent blockchain that extends Ethereum and inherits Ethereum's security guarantees.
Why do we need Layer2?#
The three main attributes of blockchain are decentralization, security, and scalability. Simple blockchain architectures can only achieve two of these attributes, and achieving a secure and decentralized blockchain means sacrificing scalability.
Currently, Ethereum has reached the capacity limit of the current network, processing over a million transactions per day, each with high demand. The success of Ethereum and its usage demands have led to a significant increase in gas fees. Therefore, there is an increasing demand for scaling solutions. This is why Layer2 networks were created.
The main goal of scalability is to increase transaction speed (faster confirmation of transactions) and transaction throughput (increased transactions per second) without compromising decentralization or security.
The Ethereum community has taken a firm stance and will not sacrifice decentralization or security for scalability. Until sharding is adopted, the Ethereum mainnet (Layer1) can only process about 15 transactions per second. As Ethereum usage increases, the network becomes congested, which increases transaction costs, making it difficult for users to afford. This is why we are currently using Layer2 networks to scale Ethereum.
Benefits of Layer2#
1. Reduced costs
By combining multiple off-chain transactions into a single Layer2 network transaction, transaction fees are significantly reduced, making it easier for everyone to participate.
2. Security maintenance
Layer2 blockchains settle transactions on the Ethereum mainnet, allowing users to benefit from the security of the Ethereum network.
3. Scalability
With increasing transaction volume, reduced transaction fees, and advancements in new technologies, projects will expand to new applications and improve user experience.
Layer2 off-chain scaling solution - State Channels#
There are currently three popular Layer2 off-chain scaling solutions: state channels, sidechains, and rollups. This article will first provide a detailed introduction to state channels.
The core idea of state channels is to separate the transaction process from the main chain and move it offline (i.e., trade within the state channel), and then transmit the final result of the transaction back to the main chain.
The diagram below illustrates state channels:
State channels are the first scaling solution for Layer2. When two or more users want to conduct a series of transactions in a trusted environment without paying gas fees for each transaction, state channels can be used.
You may still be confused, so let's take a small example. Suppose someone has developed a tic-tac-toe game on Ethereum, and the two players (Player A and Player B) need to deposit 10 ETH each, and the winner will receive the other player's 10 ETH deposit.
If each move in the game needs to be recorded on the chain, it means that gas fees need to be paid for each move, and the final gas fees will be very expensive, even exceeding the reward received.
Is there a way to reduce these gas fees? That's where state channels come in. State channels are like opening a small room off-chain for game players. I don't care how you play, I only care about who wins, and I only need to transmit the result of who wins back to the Ethereum main chain.
In the previous example, using state channels only requires paying gas fees twice: once when starting the game to open the state channel, and once when ending the game to close the state channel.
In addition to reducing transaction costs, state channels also have the potential benefit of enhancing privacy because only the start and end states are written on the main chain, and every step of the actual operation is done off-chain and not publicly visible.
At first glance, state channels seem perfect, but they have a significant drawback: they need to be established in a trusted environment, meaning that the two players in the game trust each other.
For example, if one person goes offline during the game, the state channel can never be closed. The inability to close the channel will prevent the other person from receiving the reward, and they won't even be able to retrieve the initial 10 ETH deposit.
That's a brief introduction to state channels. In the next article, we will continue to explain other Layer2 solutions.