header-langage
简体中文
繁體中文
English
Scan to Download the APP
Partnered With:

MoleDao: Web3 public class notes on Ethereum and Layer2.

Read this article in 31 Minutes
This lesson explains Ethereum and its limitations, sidechains, Layer2 scaling solutions, the three difficult choices of Layer2, and the evolution of technology stacks.
Original Title: "MoleEdu | Web3 Public Welfare Course Review - Ethereum and Layer2 Notes"
Original Source: MoleDAO


The Web3 series of courses jointly organized by Moledao and OGBC finally officially began on January 16, 2023! The first week is the week of Web3 infrastructure, covering blockchain basics, Ethereum and Layer2, Layer0, and storage.


Today, let's review the "Ethereum and Layer2" course by mentor Neil Han on January 18, 2023! The course recording has been uploaded to Moledao's Bilibili:


Week 1: Infrastructure Week | Ethereum and Layer2


https://www.bilibili.com/video/BV1Z24y1h7Wu/?spm_id_from=333.999.0.0&vd_source=8497d6b38e91681ca1de4fd1c2530a4c


Let's learn together the notes of the "Ethereum and Layer2" course!


Introduction of Mentor


Neil HAN, Reddio Founder&CEO. Formerly the third employee in the Asia-Pacific region at Twilio, he led the team to achieve a 30-fold increase in revenue in the Asia-Pacific region over a period of 4 years. He was also the top employee for commercialization overseas at PingCAP/TiDB and served as the GM for the Asia-Pacific and Europe regions.


Neil 导师 2021 年底离职创办 Reddio,Web3 基础设施公司,以新加坡为总部面向全球开发人员提供了解决以太坊扩容的 PaaS 服务,让他们以更高并发、更低 Gas Fee、更安全快速地将资产上链,Reddio 是 Paradigm 投资的亚太第一家 Infra 公司。

Translation:

Neil, a mentor in the encryption industry, left his job at the end of 2021 to start Reddio, a Web3 infrastructure company based in Singapore that provides PaaS services to developers worldwide to solve Ethereum's scalability issues. This allows them to quickly and securely put assets on the chain with higher concurrency, lower gas fees, and more security. Reddio is the first Infra company in the Asia-Pacific region invested by Paradigm.


Neil is a mentor and angel investor who focuses on investing in American SaaS companies. He is an angel investor in companies such as growrk.com, getbean.com, mynurse.ai, and mileauto.com.


图片


Learning Gains


During this class, Tutor Neil explained Ethereum and its limitations, sidechains, Layer2 scaling solutions, the three difficult choices of Layer2, and the evolution of technology stack.


图片


Ethereum and its limitations


Why Ethereum? Even in 2022, when the state is not particularly good, Ethereum's dominant position in the entire ecosystem remains unchanged. At the same time, most of the major NFT transactions in 2022 occurred on Ethereum. Ethereum is a must-see chain for entering the blockchain industry. However, Ethereum has two major limitations that restrict its development:


First: Any operation on Ethereum will generate Gas Fees, and the Gas Fees are very high.


图片


In the above figure, GAS is the unit of measurement. 21000 GAS will be generated during the transfer process. Depending on whether the initiator of the transaction needs the transaction to be processed as soon as possible, the price of GAS will fluctuate within a certain range. Taking 100 GWEI as an example for one GAS. GWEI is a unit of measurement equal to 10 to the power of -9 ETH. Therefore, in the transfer process shown in the figure above, the Gas Fee is 0.0021 ETH. Assuming the price of ETH is $1800, this transfer cost $3.78.


Please note: This Gas Fee is not constant and may increase if the sender of the transaction is very eager for confirmation. This is due to the bidding mechanism of miners, where the higher the Gas Fee offered, the more likely it is to be selected. Therefore, eager transaction senders will offer higher Gas Fees. In 2021, the highest Gas Fee reached $150 for an NFT transaction, which is an exorbitant amount. If all transactions were this expensive, the entire chain's transaction system would be almost unusable.


Second: Scalability


图片


From the above figure, we can see that the TPS of Ethereum is approximately 20 transactions per second. However, compared to VISA's 24,000 TPS, it is still too low.   


图片


Due to this limitation, centralized exchanges can only process transactions in a centralized manner. Duke mentor has made a detailed introduction to this in the blockchain basics course. However, this approach is contrary to the concept of Web3 and has also resulted in malicious events such as the FTX explosion.   


图片


Ethereum certainly knows this issue, which is Ethereum's product roadmap. Ethereum switched from POW to POS last year, mainly to solve the problem of power consumption and eliminate the work of miners. This change largely saves resources and eliminates 99% of the electricity in the entire Ethereum ecosystem. However, it does not effectively improve TPS and effectively reduce Gas Fee. Therefore, these two limitations have not been significantly improved for the time being. Data Sharding can solve these two problems relatively well in the future, but before that, Ethereum alone cannot solve them. 


Blockchain Expansion


图片


Based on the above two limitations, the industry has made various attempts in blockchain scalability, and the above are various solutions listed. Below, we will focus on explaining the scalability of Ethereum.


2.1 Sidechain  


图片


One of the most representative sidechains in the encryption industry is Polygon's PoS chain. What it does is to create a new chain since Ethereum's Gas Fee is high and its processing power is limited. In this new chain, all nodes, consensus, and security are controlled by the chain itself. If assets on Ethereum want to be transferred to the sidechain, the assets must first be locked in the Ethereum wallet belonging to Polygon, and then corresponding tokens will be generated on the sidechain and sent to the corresponding wallet on the sidechain. The process of retrieving tokens from the sidechain is similar.


In this solution, the sidechain needs to prove that the money actually exists, using a proof mechanism called Merkle Proof.


2.1.1 Merkle Proof  


图片


Merkle Proof consists of a data block, Merkle Root, and a "branch" composed of all the Hashes from the data block to the root path. The verifier can verify the consistency of the Hash of the given data block (at least for the current branch) and all the nodes' Hash on the path to the root, and finally verify whether the given data block is really a node in the tree. This method is widely used in the blockchain industry.


2.1.2 Advantages and Disadvantages


The benefits of sidechain solutions are:


Due to its relatively central position, high-performance machines can be used to increase transaction throughput.


The transaction handling fee is controlled by the sidechain, so the transaction Gas Fee will be relatively low.


The privacy of transactions can be ensured. Because the data is controlled by the sidechain, some methods can be used to hide the data. Therefore, some enterprises may choose sidechains as a solution for on-chain transactions.


However, the shortcomings are equally prominent:


The biggest issue is security, because the entire security is centralized and controlled by third parties, such as Polygon PoS which is controlled by Polygon for security.


Cross-chain bridges are verified by relatively few nodes, making them vulnerable to hacker attacks. There have been countless incidents of hacker attacks in history.


Neil does not believe that sidechains are Layer2, because their security does not rely on Ethereum, but rather on their own security. It is only because Layer2 inherits the security of Ethereum that it can be called Layer2.


Layer2 Scaling Solutions


All Layer2 scaling solutions aim to move most transactions to Layer2 for off-chain computation. This way, only the entire transaction state needs to be put on Layer1 for confirmation. This optimizes the performance of Layer1.


3.1 State Channel  


图片


State Channel is a relatively early Layer2 scaling solution, and the method is relatively simple and crude. As we can see from the top half of the above figure, there may be many transactions between Player1 and Player2. However, for Layer1, the process is not important, and the final result is the most important. Before the transaction between these two people occurs, both of them must log in with their private keys, and then they can open this State Channel. When the Channel is opened, both parties must be online until all transactions are completed and the Channel is closed. Therefore, the entire transaction only records the starting and ending states on Layer1, saving a lot of computing resources.


However, the drawbacks of State Channels are:


Both parties involved in the transaction need to log in with their private keys. If the private key is exposed on the chain, it may be vulnerable to attacks.


The two parties involved in the transaction must remain logged in at all times, otherwise the channel will automatically close.


The assets involved in the transaction must be locked at the beginning of the transaction, and therefore cannot be used for other purposes during the transaction period.


Cannot execute smart contract.


However, this model is more suitable for chains like Bitcoin that do not have contract functionality. Payment channels are used for Bitcoin's scalability and are also the basic principle of the Lightning Network.


3.2 Layer2 Architecture  


图片


Layer2 mainstream solutions can be divided into on-chain and off-chain storage. Proofs can also be divided into two types: Validity Proof and Fraud Proof. This also leads to different solutions.   


3.3 Fraud Proof


图片


  After downloading transaction data from the Layer11 contract, validators can reconstruct the (Layer2 state) merkle tree locally. Validators can confirm whether there is any fraudulent behavior by comparing the local and contract merkle roots (state roots). If fraud is detected, validators need to provide a merkle proof to the Layer1 contract, which is the green part in the diagram, in order to initiate a challenge.


3.4 Plasma Solution  


图片


Plasma is a Layer2 solution, which operates by processing transactions through corresponding smart contracts and then placing them on a sub-chain through an operator. Different sub-chains handle different tasks, allowing for various operations to be performed on different sub-chains. To ensure security, when a user wants to transfer assets from a sub-chain to Layer1, Plasma reserves 7-14 days for fraud-proof nodes to challenge the transaction.


Benefits of this solution::


You can transfer assets to anyone.

The content you provided is:

Secured by the main chain.


缺点在于:
(The disadvantage is:)


Withdrawal operations require a 7-14 day review period, during which time is reserved for verification by fraud proof nodes.


Cannot run any arbitrary smart contract, because the smart contract is fixed and cannot be changed from the beginning.


Only Merkle roots are recorded on the main chain, so security will be compromised to some extent. 3.5 Rollups scheme.


图片


Firstly, a contract needs to be written on Layer1, which aims to generate a Merkle root for all operations to be packaged on Layer2, and then put this Merkle root state into Layer1. Once the packaged operations change, this Merkle root will also change, and the state needs to be updated through the contract on Layer1. If there are any issues with the operations, there are two ways to prove their validity. All Rollups operations are implemented based on the above logic.


Main Factions


Regarding the validity proof of transactions on Layer2, there are currently two main factions: Optimistic rollups and zkRollup. Currently, Optimism has the largest global lock-up volume. However, it has a major issue in that it cannot quickly withdraw assets because it uses a fraud-proof method. zkRollup is a better solution, but its contract deployment solution is not yet fully mature.

图片


Optimism If you want to withdraw, you need to download all the data and run the Merkle tree, and then verify the fraud proof, which is very time-consuming. And there is a paradox in the mechanism, that is, if the node running the fraud proof does not find fraud, the node cannot earn money. But if there is fraud, this chain will become very slow.


Arbitrum has made a small improvement, which is that it is not necessary to download and run all transaction-related data. It uses binary search to prove the validity of specific node results. However, it still takes a lot of time on fraud proof.


3.5.1 zK-Rollup


There is a very important concept in zK-Rollup called zero-knowledge proof. We can use the example of a restaurant receipt to understand it simply.


图片  
Translation:

Image  


The specific items in the restaurant receipt are actually not important to most people. Generally, customers simply add up the cost of each dish and compare it to the total amount on the receipt to verify the transaction. This can prove the effectiveness of the transaction without knowing the details. This is just a very practical analogy for zero-knowledge proof, and the specific principles can be studied in depth.


图片


Therefore, the proof speed in zK-Rollup is very fast, taking only a few hundred milliseconds, which can be verified in real-time and can be done for ownership confirmation on Layer1 in just a few minutes. This innovative solution is highly regarded by many, including Vitalik Buterin. This solution can greatly improve the efficiency of Layer1. For example, StarkEx can increase the storage capacity of NFTs on Layer1 from 150 to 1.8 million per block, making it almost unnecessary to spend Gas Fees when issuing NFTs on Layer2.


Validium Solution


Some relatively fixed operations, such as NFT transfer, are converted into standard contracts. Then these operations are proven on Layer1 through zero-knowledge proof. Because data stored on Layer1 is always limited by Ethereum TPS, storing some data offline or on Layer2 is a better solution. Although there is a certain discount on security, it is a better solution for projects that do not have such high security requirements.


zkRollup Solution


zkRollup is a method of storing all calldata that is stored off-chain in Validium on layer1, while transactions are processed on Layer2. These operations are then proven on Layer1 using zero-knowledge proof.


Volition Plan


Volition is the integration of Validium's off-chain solution and zK-Rollup's on-chain solution. Users can freely choose between the two options.


StarkEx Project


This is currently the most mature zkRollup/Validium solution.   


图片


Its Validium processing capacity can reach 9,000 transactions per second, and the processing capacity of zK-Rollup can reach 2,000 transactions per second. In April 2022, StarkEx processed four million transactions in one day, setting the record for the highest on-chain transaction processing volume in history.


3.5.2 zK-Rollup and zKEVMStarkEx 


The biggest limitation is the inability to write contracts. The following projects have added contract functionality. The more green boxes in the picture, the better the compatibility with EVM. Currently, these solutions have not reached the stage of large-scale production use, and the closest one may be StarkNet. Other projects will need a few more years to approach maturity.


图片


EVM compatibility can help many engineers who have already written EVM contracts to migrate easily. However, the more compatible with EVM, the more performance is compromised, as detailed in the following chart. For zkRollup that is fully compatible with EVM, its performance ceiling is the same as that of Ethereum. However, the zkRollup solution designed from the principle of zkRollup, although not well compatible with EVM, has huge imagination space.   


图片


 3.5.3 Optimistic Rollup and zK-Rollup Comparison


图片  
Translation:

Image  

Layer2's Three Dilemmas


The trilemma of Layer 2 solutions is different from that of Ethereum. The following are projects and chains that balance both characteristics.


图片


Composability: whether or not it is possible to write contracts.

Decentralization


Project parties can choose the corresponding solution according to their own focus. For example, for Web3 applications or games, where the logic and transactions are relatively fixed, StarkEx seems to be a better choice at present. For project parties with higher requirements for contracts such as DeFi, if they care about performance, Polygon Pos may be a better choice. For scenarios with higher requirements for decentralization and not caring about long withdrawal time, Optimistic Rollup may be a better solution.   


Evolution of Technology Stack


With the support of zkRollup, we have seen significant changes in the technology stack of decentralized solutions. Taking the decentralized exchange dYdX as a representative example, users match buy and sell orders on relatively centralized servers within the exchange, and then all transactions occur in zK-Rollup. Users use custodial wallets, which means that assets still belong to the users and can be withdrawn at any time.


图片  
Translation:

Image  

Below is Reddio's technology stack. We serve developers by providing APIs and SDKs in languages familiar to them, allowing them to quickly deploy ERC20 and NFT to Ethereum and Layer2 zkRollup, achieving higher concurrency (up to 10K TPS) and very stable use of our products and Layer2 solutions. We also translate the language specific to Layer2 proprietary chains into APIs and SDKs commonly used by developers, greatly reducing the time developers spend integrating Layer2 and Ethereum. Even if it is not an EVM compatible zkRollup, developers can still use it quickly. If you are interested in Reddio's solution, please visit www.reddio.com for a free test.   


图片


With the improvement of zkRollup, we will see more fully decentralized on-chain DeFi, Web3 Apps, and games being deployed and booming, and the landscape of Web3 will undergo significant changes. This also provides unprecedented opportunities for more entrepreneurs. Looking forward to building such a future with everyone.   


Original article link


Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

举报 Correction/Report
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit