Buidler DAO: What exactly are Layer 0, 1, and 2 as I understand them?

22-10-28 12:45
Read this article in 39 Minutes
总结 AI summary
View the summary 收起
Original title: "Buidler DAO: What exactly are Layer 0, 1, and 2 as I understand them? "
Original author: Buidler DAO


Layer0: Cross-chain communication 

              

Layer0 is the layer with the most vague definition and the most complicated understanding in the industry, so I will spend more time explaining it.


Many people define Layer0 as the blockchain infrastructure service layer, but I think this concept is still too big and too rough. I think Layer0's key words are chain issuance, multi-chain and cross-chain, and the core content falls on cross-chain communication and modular blockchain, so I made it clear about cross-chain communication and modular blockchain, the content of Layer0 That's basically covered.


Let’s talk about cross-chain communication first, and we should pay attention to the difference between cross-chain communication and cross-chain. Chain communication is a technical implementation, and cross-chain is a business scenario.


Cross-chain is an extremely important capability of blockchain, assuming each chain is a bank , if the blockchain cannot cross-chain, it means that bank transfers cannot be realized.  The cross-chain we often say refers to the asset cross-chain, that is, I want to cross the aToken of the A chain to the B chain. First, the Token project party needs to issue its own native Token on both chains, and then use the cross-chain bridge To carry out the "transfer" of Tokens on both sides. The reason for the transfer is that the transfer process is not moving from A to B as we understand it. Its working principle is to lock the aToken of the A chain, and then cast the corresponding amount in the B chain. bToken, as for chain A locking assets, there will be many problems in the middle process of casting assets on chain B, mainly communication problems, how chain A will notify chain B "Zhang San locked 20 aTokens with me just now, you now Quickly get him 20 bTokens"?


When the chain itself is closed, the two chains can only be connected through off-chain monitoring Asset changes, for example, I write a script or the like. But this is not native enough, nor safe enough, so cross-chain bridges often have problems, and cross-chain communication mainly solves the problem of native information transmission between multiple chains.


LayerZero protocol that focuses on cross-chain communication I have written an article related to it before The article "Will the cross-chain Gh0stlyGh0sts be the next Azuki?" 》, which is also the first project to use LayerZero to achieve native cross-chain communication to achieve the cross-chain effect of NFT assets.



Just said The traditional cross-chain bridge realizes pseudo-communication by monitoring the two chains under the chain, instead of the real two chains generating information transmission, as shown in the left and middle modes in the figure below, LayerZero is directly in the two chains. Each chain deploys its own nodes, and these nodes complete the communication between multiple chains.



As shown in the figure below, I can directly enter the contract code Write clearly what information I want to transmit to which chain (chainId), this is the native cross-chain communication of the blockchain.



I am very optimistic about the LayerZero protocol, it has also completed the red Shan Shan led the financing of US$135 million. The reason is that I think this is a truly pure native cross-chain solution, and asset cross-chain is only one of its application business scenarios. The communication between chains is not limited to assets, just like the communication between banks is not limited to transfers If I have a bad debt in ICBC and have a bad reputation, ICBC can tell CCB the news, and there will be problems with my loan at CCB, and the business scenarios behind the cross-chain communication will definitely be able to dig out a lot.


After talking about LayerZero, the main content of Layer0 cross-chain communication will be understood, here are some things to pay attention to Layer0 is a concept, and LayerZero is a specific protocol in this concept. Don't confuse the two.


Layer0: Modular Blockchain


Layer0 also has an important content of modular blockchain. The term cross-chain communication can be understood by everyone and is indeed quite low-level, which belongs to Layer0. "Big" is not like a layer concept, but a "full set", that is, if the blockchain is a hamburger, the layer is the lettuce, meatloaf and bread slices inside, but modularity sounds like A whole big burger instead of a single piece of lettuce.


If the modular blockchain is a kind of "architecture" in a broad sense, layer2 is also a modular blockchain, which abstracts the modularization of the computing layer, but from the current narrow definition of the positioning of the modular blockchain, we need to understand what the purpose of modularizing the blockchain is, so as to redefine Which layer is it at? I think the most direct purpose is how to send out a chain more simply and quickly. The effect of modularization is to be able to dismantle the blockchain technology architecture more clearly and package it more completely. Then Out of the box is like building blocks, you can directly use the ability of the modular blockchain to issue a new chain at a lower cost. You can roughly understand that the purpose of the modular blockchain is to send out a Layer1, so that you can understand why it is in Layer0.


The two representatives of modular blockchain Cosmos  and Celestia  are Everyone made an introduction to understand its meaning more clearly. Among them, Cosmos would like to thank @Kasey_ibc, who is an in-depth contributor to the Cosmos ecology, discussed with him and studied his high-quality Twitter content.


The preacher of the modular blockchain concept is Celestia Lian once posted an analysis Twitter. Here I quote the content of the Twitter to talk about Celestia. For the specific content, you can see my Twitter at that time. The link is as follows:


https://twitter.com/jason_chen998/status/1561576592337682434


You can see the official website for its Description of Advantages The first point is to deploy the blockchain as easily as a smart contract, reducing the threshold and cost of issuing the chain.



The opposite of the modular blockchain is currently most Layer1 All belong to the single block chain, that is, a chain undertakes the work of consensus, data availability and execution.


Consensus: nodes in the entire network decide which transactions to package and in what order to package them;

p>

Data availability: It is to verify that a certain block has been broadcast and written to the chain;

Execution: specific transactions and status changes.


If a chain does all these three things, then it is a single block Chain, which is the current problem faced by L1, transactions, settlements, and block generation are all queued up to complete. Therefore, the design idea is to disassemble the core work responsibilities of the consensus, data availability, and execution of the blockchain. Each responsibility is a separate chain, that is, a layer, and then each performs its own duties well, and then assembles them. group together.


Speaking of this, everyone should realize that this is the modular design principle that software development has followed for 30 years, and the concept of encapsulating polymorphic coupling and cohesion, Splitting a complex system into functions, each doing its own thing, and then assembling them together, so at least this top-level design concept has always existed. It is not very novel to apply this design concept to the blockchain design idea.


When it comes to splitting consensus, data availability, and execution into a chain, everyone It should be realized that this is what L2 is doing. The idea of rollup expansion is to separate the execution layer as a sub-chain to complete the transaction processing work of Ethereum, and then return the result to the main chain of Ethereum, so rollup is actually Modular design concept, so as mentioned above, the broad modular blockchain is not a specific thing, it is a concept or design concept, but the narrow modular blockchain refers to the blockchain consensus , data availability, and the underlying capabilities are encapsulated. These two layers are also the foundation for a blockchain, and the complexity and difficulty are also the highest. Then, if these two layers of capabilities are equipped with a new chain, the threshold and cost are very low. Focus on your business and calculations.


Then Celestia mainly modularizes the data availability capability, stores transaction records and provides data availability through the consensus mechanism, and does not need to participate in the settlement and execution layer. , Just store and ensure that the stored things are valid, other developers can build their own settlement layer and execution layer on Celestia in the form of rollup. So Celestia is like AWS in the blockchain field. Traditionally, a company needs to buy a server to put it in the computer room to develop software, and 10 companies need 10 servers. So AWS said that you should not buy it. I will build one myself Big ones, you only care about software development, if you need to access data, come to me, I can guarantee that your data is valid (stored in, retrieved out).


So why is Celestia doing data availability layer modularization? If I want to send a chain, the most difficult thing is to get as many nodes as possible to participate in my chain to complete the process of consensus and data availability for me. Only when there are so many nodes to maintain my chain can I do it on the chain. More things that the application layer does.


So you need to look at how the data availability of the L1 chain is done. We all know that the blockchain is composed of a large number of nodes that can be freely joined. The more nodes, the safer and more decentralized. Nodes are divided into full nodes and light nodes. A full node is to maintain a complete set of data ledgers, so malicious attacks by a small number of nodes will not affect the global nodes, which is also the foundation of the blockchain.


But as time goes by, more and more data, the cost of maintaining a full node is too high, If everyone is unwilling to be a full node, then the blockchain tends to be centralized and becomes insecure, so there will be light nodes, which will not maintain and verify the full amount of transaction data, but only store block headers, and when there is a need for verification When the data is available, it will be sent to the adjacent full nodes to help verify, and then the result will be returned.


So to sum up, the most difficult thing to build a chain is to get so many nodes To maintain the consensus and data availability of my chain. This is the problem that Celestia wants to solve. It said on its official website that it hopes to make creating a chain as easy as creating a smart contract. You don’t have to worry about the following data issues and leave it to Celestia to complete. You only need to focus on your upper layer to perform settlement and realize " "One-key hair chain" effect.


After watching Celestia, let’s take a look at Cosmos. In fact, the members of these two organizations overlap very much Gao, many people contribute to both organizations at the same time.


The goal of Cosmos is to become the Internet of blockchains. "Chain" capability, so that each community can have its own sovereign chain, which is an independent blockchain. Chain interconnection, this vision is still very inspiring.



As for why it thinks there is a need for the community to post its own chain Well, it is because it divides the blockchain into public chains and proprietary chains. On a public chain like Ethereum, developers need to face two layers of governance, chain and application, and the application must follow the constraints of the underlying chain. It is difficult to release the value of the application, so it wants to generate a tailor-made chain for each application.


So in order to achieve this goal, we must first solve the problem of issuing a new chain threshold and cost, and secondly Solve the problem of how to communicate between so many chains to form a snowball ecology.


The block chain architecture is divided into three major layers: network, consensus, and application. It encapsulates the network and consensus layers, and also includes atomic capabilities such as accounts, transactions, and signatures. It provides an SDK to enable developers to develop sovereign chains based on this , through the preset modules to customize the construction of the blockchain, and then publish it to the Cosmos network to interact with other brother chains. The interaction is to use the cross-chain communication protocol IBC to achieve the effect of a hub hub, and other The chains are all connected to this hub through IBC, where data relay is carried out.



So the concept of Layer0 is summarized here, and its work mainly focuses on In the three layers of distribution chain, multi-chain and cross-chain, it is easier to distribute the chain, but if so many chains are not connected to each other, it will not be able to form a joint force, so the problem of cross-chain needs to be solved.


Layer1 underlying blockchain

                       ;

Layer1 is the underlying blockchain. The well-known Bitcoin, Ethereum, and Binance Chain all belong to Layer1, as well as Avalanche, Near, and Terra, etc., because they are the main networks in their own ecosystems. It processes and completes transactions on its own blockchain, and also has its own native Token. The two new public chains Aptos and Sui are also Layer 1, but note that many people tend to confuse Layer 1 with the public chain. The public chain includes Layer 1 But not an equal relationship.


Layer1 public chain is the species with the deepest moat in the crypto world, when more and more After nodes, developers, and projects join its ecology, the advantages of snowballing will be very obvious. Unless there is a direct collapse of the basic tokens such as Luna and Terra, which leads to a big avalanche in this big snowball, otherwise a large number of intricate interests in the ecology The relationship will be firmly bound to each other, so that the root of the chain will be very deep, so creating a successful Layer1 public chain has always been the success of countless organizations in the entire crypto circle.


Currently the largest Layer 1 public chain in the application field is Ethereum, so competing chains will find ways Compete for developers and users from the Ethereum ecosystem, because the gas fee of tens of dollars in the peak period of Ethereum, an aristocratic chain, is still painful for ordinary little leeks like me, so most of the current competitors Chains mainly focus on low gas and high TPS strategies to compete for user resources. For example, Aptos, which has just completed its airdrop this week, is a hot topic. Here is a brief mention. At that time, after Aptos was launched on the mainnet, many marketing accounts rhythmically said that Aptos claimed to be 10KTPS. It was only 4TPS, and then the cynicism made others feel that it was flooded. 10KTPS was the theoretical maximum capacity, and 4TPS was the actual amount that was running at that time. It was like the Hong Kong-Zhuhai-Macao Bridge, which theoretically claims to pass 250,000 customs clearance in a single day. In fact, every day There are only a few cars running, but can it be said that the performance of the Hong Kong-Zhuhai-Macao Bridge has been flooded?


Building a public chain is like building a city, the prosperity of a city needs to be built first Good housing, hospitals, shopping malls, railways and other infrastructure, creating a livable environment, residents will move here to live, if a chain has no application, it is useless to snatch users over, no matter how strong the performance of Aptos is, no matter how high the theoretical TPS is. Enough applications to verify the state of the Hong Kong-Zhuhai-Macao Bridge without cars running, so the public chain can be divided into several ways to attract developers:


< /p>

The public chain gives enough support to developers, come to me to develop applications and give money to flow, so this is why a large number of public chains are behind the trading platform platform, and it is concluded that Make money, and then hold hackathons all day long, and send grants to attract investment.


The biggest attraction of the new public chain for developers is that it is blank enough, because mature The competition in Ethereum is already too fierce and complicated. Going to the new public chain can even directly copy the applications that have been successfully verified on Ethereum. For example, you should see that the NFT trading platform and domain name service providers on sui have already Things that are well-known in Ethereum still received a large amount of financing. In the group, I saw many people jokingly saying that any project can be re-done by changing the language.


There is another method that I think is effective is direct EVM Ethereum virtual machine compatibility, For developers, the biggest cost is not to write code, but to learn code. A completely unfamiliar technology stack starts from scratch, and then develops it in practice, debugs it, and so on. Is there any way to allow developers of the Ethereum ecosystem to migrate to the new chain smoothly and at low cost? Is there a way I can develop and debug applications running Windows on a Mac computer? Installing a virtual machine, you should have such friends around you who bought a Mac and changed it to a Windows system, or actually ran a virtual machine, which uses software to simulate a computer system.


EVM is a smart contract that serves Ethereum, so if you use EVM compatibility, developers can directly and smoothly migrate Ethereum applications to On the compatibility chain, the well-known BSC is the EVM compatibility chain.


Layer2 mainstream solution: rollups

    

Let’s talk about Layer2 again, just said Many Layer 1 competition chains aim at the "expensive" and "slow" of Ethereum, but is there any way to optimize Ethereum itself? Layer2 is one way.


When I talked about the Layer0 part, I talked about the monomer chain. It's all done, can this not be blocked? At this time, someone thought about whether it is possible to take out the transactions on Ethereum and execute them outside, and then return the results to Ethereum for data availability processing. This method of operation is called rollups, and it is also the mainstream solution of Layer 2, just like the original One road was very congested, so I built a viaduct for it. Of course, I also saw an interesting explanation, doing nucleic acid 10-person mixed management is rollups.


So by placing transactions off-chain, there is no need to go through the slow consensus process of Ethereum , so as to reduce the amount of calculation on the Ethereum mainnet and improve the overall processing speed and throughput.


When I was studying, my research direction was also blockchain expansion. The scheme is similar to rollups as shown in the figure below.


< br>

As mentioned earlier, rollups are the process of performing calculations off-chain and then putting the results on the chain. The biggest problem in this process is how to prove that the results are valid. The two proof methods are also There are two mainstream rollups schemes: Optimistic rollups and zk rollups.


As the name suggests, the English meaning of Optimistic is optimistic, that is, Optimistic rollups use Fraud proof is used as a verification method for data validity. After synchronizing the off-chain calculation results to the Ethereum main network, the optimistic default data is correct. If someone thinks that the data is incorrect, there is fraud. Period, also known as the challenge period, challenges the outcome of aggregated transactions by computing fraud proofs.


If successful fraud is proven, the transaction will be re-executed to update the data status, and the The ordering node that packaged the transaction will be punished, the security deposit it submits will be reduced (it is required to pay a security deposit to become an ordering node), and distributed to the verification node that submitted the fraud proof.


In addition to two important roles in this process: ordering nodes and verification nodes, There are two other important roles involved: CTC transaction contract and  SCC status contract.


The logic here is a bit complicated and needs to be patiently understood. All Optimism transaction data blocks are stored In Ethereum, there is a special contract called CanonicalTransactionChain, referred to as CTC, the contract address is:


0x5E4e65926BA27467555EB562121fac00D24E9dD2


You can see that the ordering node Sequencer writes about two batches per minute (the technical term for batches is called Batch), and each batch may contain several Hundreds of transaction data, the CTC contract mainly stores transaction data summaries.



In addition, the state root StateRoot after the transaction is stored in the StateCommitmentChain contract , referred to as SCC, the contract address is: 


0xBe5dAb4A2e9cd0F27300dB4aB94BeE3A233AEB19


< p>

A batch is written about every 6 minutes, and the verification node can read the records in the two contracts to verify and calculate whether the transaction is fraudulent.



The above is the way Optimistic proves the validity of the data, which is a bit of a game According to the feeling of theory, through the two-party confrontation plus incentive model to achieve the effect of the minimum degree of evil and fraud, let's see how ZK solves it.


zkSync is the main player of zk rollups, its official website slogan is rely on math, not validators , rely on mathematics, not verifiers, this sentence is aimed at Optimistic fraud proofs, it can be seen that Optimistic is full of gunpowder.



The validity of each transaction in zk rollups is verified before the transaction takes place. Ordering nodes cannot do evil. But in Optimistic  Rollup, the behavior of sorting nodes is not constrained, so there must be verification nodes to monitor fraudulent transactions, and once found, fraud proofs need to be submitted to the main network.


The biggest advantage of zk rollups compared to Optimistic rollups is that it uses pure mathematics of zero-knowledge proof The calculation is used to verify the transaction validity, so there will be no delay in transferring funds to Ethereum, because the transaction will be executed once the zk rollup contract has completed the validity verification. Conversely, withdrawing funds from Optimistic rollups will be delayed to allow time for fraud to be proven.


The core architecture of zk rollups:


1. On-chain contract: The logic is the same as Optimistic, and the corresponding smart contract is deployed in Ethereum to store block summary data, verify contracts, etc., but There is no need to publish too much transaction data in contracts on the Ethereum chain like Optimistic, because its validity has been proven before going to the chain, instead of Optimistic, which needs to send data to the chain for verification by others, but zk rollups The transaction data can also be stored in the calldata of the smart contract, which is an unchangeable but non-persistent temporary storage area, similar to memory, so transaction data can also be obtained if necessary.


2. Off-chain virtual machine: Although zk rollups is attached to Ethereum, the transaction execution process Exists in a separate EVM virtual machine, the environment where the actual zk rollups execute.


It is similar to Optimistic in the large process, after the user signs the transaction, submit it to zk rollups Layer 2 orderers process and pack in a batch, which is then submitted to Ethereum.


The zero-knowledge proof used by zkSync is too complicated and involves a lot of Encrypted mathematics, the head is too big to understand, so I don’t make complicated and pasted some mathematical formulas in the development manual that I can’t understand myself, pretending that I understand.


< img100%" alt="image" src="https://image.blockbeats.cn/upload/2022-10-28/6513c036eb8b7f825f221630ef691c845850a6e9.png?x-oss-process=image/quality,q_50/format,webp">

The above is my personal research and understanding of Layer0, 1, and 2. The concept of the Layer layer mentioned at the beginning has no clear and unified definition, so this article is my personal understanding and analysis, and does not represent the official position. There will definitely be a certain degree of subjectivity, deviation, and insufficiency. Welcome to exchange, discuss, and learn together.


Original link


欢迎加入律动 BlockBeats 官方社群:

Telegram 订阅群:https://t.me/theblockbeats

Telegram 交流群:https://t.me/BlockBeats_App

Twitter 官方账号:https://twitter.com/BlockBeatsAsia

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