header-langage
简体中文
English
Tiếng Việt
Scan to Download the APP
Partnered With:

A brief summary of cross-layer and cross-chain methods

Read this article in 33 Minutes
This article makes a brief summary of various cross-layer and cross-chain methods, hoping to make the "cross" thing clearer.

Original author: Li Hua, Mechanical Clock

Interviewees: p0n1, researcher at Ambi Lab;

Wang Dong, founder of Loopring;

Liu Yi, founder of Octopus Network; John, founding member of Poly Network    


Cross-layer, cross-chain, different ways of cross-layer, different ways of cross-chain, it seems complicated and confusing, but behind them The logic is simple. This article makes a brief summary of various cross-layer and cross-chain methods, hoping to make the "cross" thing clearer.


This article is more like an index, which revolves around the following figure. If the specific implementation of each method has been discussed in previous articles, only the key content will be quoted. Skip if you know about it; expand on it if not.




01 Cross-layer


Layer 2 and side chains (including other public chains ) are two different subjects, and cross-Layer and cross-chain are two completely different things. To illustrate with a metaphor:


The temples of ancient Greece used wheat to keep accounts for citizens. If the "main temple" was too busy to keep records, other The temple helps it keep records. These temples need to report to the main temple regularly after keeping accounts. Regardless of which temple the citizens’ accounts are recorded in, and regardless of whether there are changes in these temples, citizens can always take out assets when they want to withdraw assets. To the wheat that belongs to him, this is the cross-Layer.


Assuming there is another continent, a smart person provides a service for merchants in the two places, so that everyone’s assets on the ancient Greek ledger can be crossed to this continent After a person transfers assets over, this continent will not report the account information to the main temple when keeping accounts for him; in addition, this continent does not produce wheat, and its bookkeeping Units are not wheat. If a person wants to withdraw assets in this continent, what he gets is not wheat, but cross-chain. What he can get depends on different cross-chain methods.


Let’s jump out of the metaphor: Layer 2 is a sub-account book, and cross-Layer  is a change in the specific bookkeeping place under a set of account book systems. The accounting units of Layer 2 and Layer 1 are the same, and the accounts kept by Layer 2 need to be notified to Layer 1; chains are different books, and cross-chains are from one ledger system to another ledger system, and the bookkeeping of side chains and main chains The units are different, and the accounts recorded by the side chain will not inform the main chain.


Rollup


After distinguishing between Layer 2 and cross-chain, look at Layer 2. Rollup  is the most mainstream and most promising Layer 2. At the current stage, it seems that we only need to pay attention to it. What is Rollup:


"Rollup  refers to performing complex calculations and state maintenance off the chain first, and then calling the data related to the state change through the contract way, using cheaper CALLDATA  to save on the chain.


Anyone can restore the data based on the data saved on the chain Global state, thereby eliminating security risks caused by data availability issues. Rollup rolls up/summarizes a large number of transactions into one transaction, improving TPS while ensuring data availability.”


Plainly speaking: Rollup  is responsible for handling specific bookkeeping matters, but how its accounts are remembered is reported and recorded on Ethereum, This will allow Ethereum to recognize Rollup  accounts. Specifically, Rollup works as follows (take ZK Rollup  as an example):


"There is a technical thing called Merkle Tree, which is Hash different data layer by layer, and finally turn it into a simple hash value, which is called the root of the tree. This root can actually represent all the states in the tree, although I don’t know what the specific state is 。


The tree itself must be able to be found somewhere, if there is no such tree, only the root, then this The account is also insecure. ZK Rollup maintains such a tree at Layer 2 . It was very simple at the beginning, with nothing in it, and then when you trade or When paying, the data in this tree will be changed. This change itself is to be put on Ethereum and stored on Ethereum as a piece of data. (Note: This tree is not placed on Ethereum, this The tree is in Layer 2, but the data of the changes to this tree should be put on Ethereum)


Therefore, you The historical state of the tree at any point in time can be restored through Ethereum. After the restoration, you can verify whether the data you restore is correct through the root of the tree. Any user can move from the leaf node to the root This string of data is called Merkle proof.


Throw this proof to Ethereum In the smart contract of the Loopring protocol, the contract will count whether the Merkle proof can prove that you are in this tree. If you can prove that you are in this tree, it will mark you in this tree. How much money is unlocked from the Ethereum smart contract and transferred directly to your Ethereum account. This is the way to withdraw cash in the worst case.”


——Wang Dong, "Interview with Wang Dong: Everything About Loopring's New Version"


Rollup  ;The principle of capacity expansion is as follows (taking ZK Rollup  as an example):


"Why can ZK Rollup  be able to expand, become so fast and save money, It is related to some calculations involved in the update of this Merkle Tree .


For example, a person How to change the root of the Merkle Tree ? It needs to be calculated layer by layer to get to the root. So a transaction may need to change about 4 or 5 leaf nodes, and a transfer may take about Change 3 leaf nodes, these changes are very many.


But now, these changes have nothing to do with Ethereum, it does not need to do these changes Calculations, calculations are all done on the Merkle Tree  in the relay, as long as the zero-knowledge proof is verified on Ethereum, it may cost 100,000 gas  or how much gas, probably so.


For example, to do 1000 transactions, the change may be about 4000 leaf nodes, it may be calculated Tens of thousands of hashes calculate a root, but these data are all in Layer 2, and the data that is finally thrown on Ethereum is actually three types: the first is how to change each leaf; the second is how to change the root ; the third is a proof to prove the consistency of the first two.


What does zero-knowledge proof do? Zero-knowledge proof is to verify that when so much data in the tree is changed, the calculation of the root can match various changes. Zero-knowledge proof just does one thing, which is to prove the consistency of data. It does not correspond to how to prove each transaction, but how to certify a large number of transactions into a package/block, which is a batch process. "


——Wang Dong, "Interview with Wang Dong: Everything About Loopring's New Version"


Plainly speaking: Rollup  helps the main chain to work, so there are more people working, and more work can be done at the same time.


ZK Rollup and Optimistic Rollup


After understanding Rollup , look at ZK Rollup and Optimistic Rollup Optimistic Rollup, the core difference between the two is as follows:


The key to the ZK Rollup scheme lies inZK, each of its All state transitions need to provide zero-knowledge proofs and be verified by the contract on the main chain. Only when the verification passes can the state be changed. That is, the state transition of ZK Rollup  strictly depends on cryptographic proofs.


Optimistic Rollup In the scheme, each state transition does not need to be strictly verified, it is an optimistic assumption first Each transformation is correct, and then a certain transformation can be challenged within a certain time limit. If the challenge is successful, it proves that there is a problem with the previous submission, and the submitter will be punished and the state will be rolled back. That is, the state transition of Optimistic Rollup depends on economic incentives and games.


——p0n1, "Funky and Useful: These 12 New Ethereum Things You Can't Miss"< /p>


The outstanding problem of ZK Rollup  is the realization of programmability, which is due to zero-knowledge proof. If you are interested in this, you can see"Comprehensively understand zero-knowledge proof and its implementation method: analyzing zk-SNARK" article, which introduces how to implement zero-knowledge proof, from which we can understand why it is difficult to achieve programmability . However, the VM  and related designs of zkSync (Matter Labs) can bring programmability to the ground, which is worth looking forward to.


Optimistic Rollup The most concerned issue seems to be when the funds return from Layer 2, because of the delay caused by the challenge period, but there can be middlemen Provide advance payment service to save the country, so this may not be a problem.


The above is all about cross-layer , it is keeping accounts in sub-ledgers, and the accounts should be reported to Ethereum in batches; ZK Rollup  Use cryptography to eliminate false accounts, and Optimistic Rollup  avoid false accounts by monitoring and reporting.


02 Cross-chain


Cross-chain is from one ledger system to another System, no matter which two chains the participants are, or how to cross-chain, when the cross-chain occurs, a third party is required to communicate between the two chains, otherwise the two chains will not know the other chain. What happened, there is no way to talk about cross-chain.


A complete cross-chain process is as follows (taking locking + casting as an example):


"The cross-chain bridge is very vivid, it has two piers and a bridge. The two piers are two sets of smart contracts, one runs on the A chain, and the other runs on the B chain; the bridge is in the middle, and the bridge is an off-chain process , is responsible for monitoring the events of the two sets of smart contracts on both sides.


Suppose there is an ERC20 For example, it is UNI, which is issued on Ethereum, and we want to transfer it to PlatON. Then there must be a smart contract on Ethereum, such as the Vault contract, which is a cross-chain A pier of the bridge; cross-chain users need to send to the Vault contract Lock method, pass in the currency and quantity to be locked as parameters, and then provide a PlatON The address, saying that I lock 500 UNI  is to cast 500 UNI on this address.


At this time, the Vault contract will call the UNI contract to transfer UNI , Transfer UNI from the user address to the address of the Vault contract, that is, lock UNI . After the lock, Vault The contract will send an event, such as AssetLock event.


The process under the chain is Connected to the Ethereum node through the RPC interface, it will subscribe to the AssetLock event of the Vault contract, as long as this event appears in the log, The off-chain process gets this event, which contains relevant parameters, such as which coin is locked, how much is locked, and who is the beneficiary on the other chain. The off-chain process also has a connection to PlatON RPC interface, it will submit a transaction to PlatON, assuming the transaction is called Mint.


PlatON There will also be a contract on the platform, such as the Control contract, which is another pier of the cross-chain bridge; the Control contract will create a similar ERC20 in advance > The contract is called EUNI, for example. After the Control contract receives the Mint request, it verifies that the request really comes from a witness, and it will call EUNI The Mint method of the contract tells it to mint 500 EUNI tokens for a certain address; At the address provided by the user before, the user can use it.


Assume that the user transfers EUNI to another user, and the new user wants UNI, what he has to do is to call the Redeem method of the Control contract, burn, for example, 100 EUNI, and release an event called AssetBurn.


The off-chain process monitors the AssetBurn event of the Control contract A transaction request will be sent to the Ethereum Vault contract, and the Release interface will be called. After Ethereum verifies that the transaction is from a witness, it will send UNI < em>Transfer from the address of the Vault contract to the specified user address, and the user will get the original UNI. This is a complete cross-chain process. "


——Liu Yi, "A detailed explanation of the technical points and difficulties of cross-chain: starting from the perfect cross-chain"


Simply speaking, cross-chain is to do an operation on chain A first, and then a messenger tells the news to chain B, and then B chain The chain does a corresponding operation. It can also be seen that the side chain is different from the Layer 2 method. The side chain only communicates with the main chain when cross-chain occurs, while Layer 2 regularly communicates with Layer 1.


Although cross-chain refers to crossing assets from A chain to B chain, B chain does not have real A chain assets (no wheat), for example, outside the Bitcoin chain There will be no real BTC on any chain of B, and there will be no real ETH on any chain other than Ethereum. What the user receives on the B chain depends on different cross-chain implementations.


Locking + casting


Locking + casting works like this: lock assets in chain A, and lock assets in chain B The corresponding assets are minted; the minted assets are destroyed on the B chain, and the corresponding assets are unlocked on the A chain.


What the user receives on the B chain is his The assets minted by the cross-chain protocol used, such as using the Ren  There will be no problem if there is a kind of exchange coupon.


Lock+Unlock


If there is a code The currency is called test, and its issuer has issued tokens in both chain A and chain B, so the lock + unlock method can be used for this token: lock assets in chain A, release the equivalent amount of assets in chain B; lock in chain B Assets, the equivalent amount of assets will be released on the A chain.


In this case, what the user receives on the B chain is not a "fake" asset similar to an exchange coupon, It is a "real" asset. Users don't have to worry about problems with the cross-chain bridge, because they no longer need to rely on the cross-chain bridge to cash out assets across the source chain, and the lock+unlock method can be used in one direction and one-time for the cross-chain bridge . (True and false in this article are not intended to be derogatory, but to clearly distinguish different cross-chain methods)


This cross-chain method is safe and neat, but only applicable Because tokens have been issued on multiple chains, and the issuer needs to cooperate with the cross-chain protocol. It may be the best choice, but it is not universal when used alone.


Cross-chain pool: exchange


The way of exchange needs to introduce cross-chain pool This new subject. The cross-chain pool is neither located on the source chain nor the target chain, it is located on the chain of the protocol that provides cross-chain services, and its working method is shown in the following figure (taking Poly Network as an example):

< br>


< p>

The process of user's USDT  cross-chain from Ethereum to BSC  is as follows: first lock USDT on Ethereum, then release PUSDT on Poly  Convert PUSDT  to PBUSD, then lock PBUSD on Poly , and finally release BUSD on BSC .


This process looks complicated, there are two cross-chain operations plus one transaction operation, but for cross-chain users, this process is indifferent, he Put in USDT on Ethereum and get BUSD on BSC  In the exchange mode, users receive "real" assets on the target chain, so there is no need to worry about problems with the cross-chain bridge.


The reason why this cross-chain method was invented and became popular is because it can bring two benefits:

< br>

1. Cross tokens at will . Users can put any token on Ethereum and get any token he wants on BSC . In the example below, the user puts in ETH and gets BNB.




Compared with the cross-chain of the corresponding currency, the cross-chain process requires one more transaction operation, and this transaction does not occur in the cross-chain protocol In the transaction pool, it occurs in the original transaction protocol of the source chain or the target chain. The cross-chain protocol provides the DEX  transaction price.


As for whether the transaction occurs on the source chain or the target chain, it depends on which cross-chain path has a better price. For example, the cross-chain process can also be: ETH-PETH-PBETH-BETH-(BETH:BNB)-BNB.


Going further, assuming that the user wants to exchange ETH  for USDT, and the transaction price on BSC  is better than Ethereum at this time, then a possible transaction path It is: ETH-PETH-PBETH-BETH-(BETH:BUSD)-BUSD-PBUSD-PUSDT-USDT. There are some agreements that open up the liquidity of different chains. I think it refers to this matter to a large extent. This cross-chain architecture can provide users with the best transactions on multiple chains through the selection of transaction paths. price.


2. Cross-chain at will . The locking + unlocking method is a direct connection of two chains: the cross-chain protocol builds a cross-chain bridge between Ethereum and BSC , and builds a cross-chain bridge between Ethereum and Polygon  at this time, if you want to realize The cross-chain between BSC  and Polygon  requires a new cross-chain bridge between BSC  and Polygon .


However, the exchange method connects multiple chains through a cross-chain pool, which can realize cross-chain between any two chains in this architecture


em>: The cross-chain protocol is connected to Ethereum and BSC. At this time, if it is connected to Polygon, it can provide cross-chain between Polygon  and Ethereum, Polygon and BSC, without the need to build bridges one by one. Its structure is shown in the figure below:




The method of "cross-chain pool: exchange" may give birth to one or more cross-chain underlying protocols: Each protocol that wants to provide cross-chain functions in its own application only needs to access these cross-chain protocols to support cross-chain; on the other hand, "cross-chain pool: exchange" is also the application of its own chain There are already some DeFi  applications that have declared that they will be chains. Their chains are not chains that support various applications like public chains, but are likely to maintain their own multi-chain liquidity as described above. Chain of pools.


It should be noted that the exchange method and the locking + casting method do not replace each other, they solve different problems. The cross-chain exchange method is based on the assets that already exist on the two chains. It cannot "bring" assets that are not on the target chain from the source chain. When it is necessary to cast source chain assets on the target chain, you need to use locking + casting The way.


Other classification dimensions of cross-chain


Cross-chain requires a third party to be in the two chains The above three cross-chain methods are no exception. The third party of this message can be permissioned, such as an alliance formed by a cross-chain protocol; it can also be non-permissioned, such as a node that does not require permission to enter. Therefore, there are 3×2=6  cross-chain methods.


Cross-chain can also be divided into witness cross-chain and relay cross-chain. Their differences are:


"When the target chain receives a message, if the witness cross-chain, it is verified that the message comes from the witness, if you believe the witness, perform the operation that should be performed; if it is Relay cross-chain, the verification is not which relay the message comes from, but whether the message comes from the source chain, and if so, perform the operation that should be performed.


That is to say, the witness can be regarded as a relay that needs to be trusted, and the relay can be regarded as a witness that does not need to be trusted. This is the core of the two The difference, the relay is obviously more in line with the principle of trustless than the witness.”


——Liu Yi, "A detailed explanation of cross-chain Technical points and difficulties: Talking about perfect cross-chain"


Relay cross-chain is better than witness cross-chain, in this way, The third party responsible for spreading the message cannot do evil, but this method requires the light client of the other chain on the two chains, and some chains cannot implement the light client of other chains, such as Bitcoin.


Therefore, this classification method will not bring 6×2=12  cross-chain methods, but: if there are conditions to realize relay cross-chain, cross-chain The chain protocol will realize it or aim to realize it; if there is no condition to realize the relay cross-chain, it can only cross-chain in the form of a witness.


The above is all about cross-chain. Cross-chain is crossing to another account book. There are 3 different cross-chain methods. Different methods determine what you have when crossing to the target chain, and also determine the different degrees of dependence on the cross-chain bridge.


Conclusion


When it comes to cross-chain, we will also talk about Polkadot and Cosmos. But in fact, Polkadot does not serve cross-chains. It is a structure with chains as the unit. Its cross-chain refers to the interaction between chains within this structure; Cosmos serves cross-chains. , what it does is the communication standard between chains, and the chain that adopts its standard is easy to realize cross-chain, but the premise is to adopt its standard.


The last thing I want to express is that although there are a number of developing public chains, most of them are similar to Ethereum. I really hope that in the future There can be some public chains that are not the same as Ethereum, not because they are different in performance, but because they are different in what they can do.


Original 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