What is the difference between Layer 2 and sidechains? Is the sidechain secure enough?

AliAtiia
2021-03-21 22:58:03
Collection
"Many sidechain solutions are disguising themselves as Layer 2 solutions."

This article is from gourmetcrypto, authored by Ali Atiiaa, and translated by Chain Catcher.

During a bull market, misleading promotions in the crypto industry can significantly increase, with many sidechain projects misleadingly packaging themselves as Layer 2 scaling solutions. This article aims to explain to beginners what makes a chain a Layer 2, sacrificing integrity and rigor to make the article more accessible.

Typically, Layer 1 has higher security and liquidity, while Layer 2, as a new chain, hopes to obtain security and liquidity from Layer 1.

Let’s look at a simple example. For beginners, especially those who have just joined the cryptocurrency industry, if Metamask shows you have 100 DAI on Ethereum, how does Metamask know that? It communicates with the Ethereum p2p network through a service provider called Infura. But what does having 100 DAI actually mean? It means the DAI contract is a piece of software made up of code and data, existing on the Ethereum blockchain, with your address in your Metamask and the number 100 next to it.

Back to the new chain, which may or may not be L2, let’s call this chain Macau. You want to move 100 DAI from Ethereum to Macau because you want to trade there, or trade with cheaper gas fees, or you just want to do something to feel something.

So how do you move this 100 DAI to Macau? Do you email Vitalik’s Masternode headquarters to have him transfer it? No, you actually send your 100 DAI to another contract on Ethereum, which is usually referred to as a deposit contract (think of it like a deposit window at a casino).

Step 1: You send 100 DAI to the Macau deposit contract on the Ethereum chain.

The validators/workers of Macau can see your deposit because they constantly monitor Ethereum, especially that deposit contract. One of them says to the others, "Hey guys! We have a new user coming to our casino, quick! Looks busy, cough cough." Then she says to you, "Welcome Chad, glad you could join us, here are 100 synthetic DAI for you to play on our chain, freshly minted from this Macau block I just validated."

Step 2: You have received 100 IOU tokens issued by Macau (think of them as casino chips), representing a claim on the real DAI locked in the Ethereum deposit contract. We call these IOU tokens synthetic DAI, abbreviated as sDAI.

Macau is actually like some websites, where the front-end pages are very similar to those on Ethereum, such as borrowing money on the Aave protocol or trading on Uniswap. These front-end JavaScripts package a borrow/swap transaction for you and feed it back to your Metamask. Five minutes later, you see the gas fee and feel sad, then continue to click "Confirm" to sign and broadcast your transaction; you are familiar with this workflow.

The same logic applies in Macau. In fact, if Macau is a fork of Ethereum, it might even have the exact same workflow, like Binance's BSC or Avalanche's C chain, because you can use Metamask with both without needing a special wallet to sign and package transactions (since the address formats and cryptographic signature schemes of Ethereum/BSC, etc., are the same).

Step 3: Do something with this 100 sDAI on Macau, such as trading, mining, investing, etc.

For example, you play cards and turn your 100 sDAI into 200 sDAI (the additional 100 sDAI you earned comes from others who also came to gamble in Macau, so they had previously locked real DAI in Macau's deposit contract on Ethereum).

For instance, you participate in trading and earn 200 sDAI from 100 sDAI (the additional 100 sDAI you earned also comes from other Macau users, so they had previously locked real DAI in Macau's deposit contract on Ethereum).

Now we arrive at the most critical part.

You want to withdraw your earnings from Layer 2 and transfer back to Ethereum because you are a user who values high security and deep liquidity, or you are a masochist who is fond of gas fees over a thousand dollars. If you can independently withdraw your 200 DAI from Macau's deposit contract on Ethereum at any time and no one can stop you… then Macau is an L2 solution.

If the validators of Macau can theoretically prevent you from withdrawing your 200 DAI or directly withdraw it for themselves, then Macau is not an L2 but a sidechain.

If you can theoretically withdraw more money than you are entitled to, such as 300 DAI, then Macau is also not L2.

When it comes to scaling solutions, it always comes down to "who controls the exit."

So how can we make the deposit contract on Ethereum smart enough to prevent you or other Macau users and Macau's miners/validators/operators from cheating?

You can imagine this is no small task, as it requires the contract to be smart enough to know who owes whom what on Macau and when: because while you indeed won 100 sDAI in a poker game in Macau an hour ago, giving you the right to withdraw 100 DAI on Ethereum, you might have lost in a subsequent game! Therefore, the contract must be able to determine the truth. Thus, the contract must be able to ascertain the latest transaction information from Macau.

Early solutions like state channels and Plasma attempted to do this: encoding fraud proofs and dispute resolution logic into the L1 deposit/withdrawal contracts. However, they placed a heavy burden on users, such as:

Users must constantly monitor the L1 contract on Ethereum to challenge/suppress/punish malicious withdrawal attempts that threaten their assets.

Users must store the data needed to raise disputes. In the case of a state channel, this data usually comes from signatures of the parties involved, proving state changes in the channel (e.g., "Alice: I prove I paid Bob 10 DAI," or "Charlie: I prove I moved the car to position H5 on this board when configured X").

Specifically for Plasma: users are vulnerable to the increased data storage requirements because the data of interest to users exists as part of the global Plasma chain state, rather than just being a party in a channel; Plasma operators (block producers) may attempt malicious withdrawals while concealing the data needed for users to raise challenges. This adds more complexity to the security logic of withdrawals on L1.

It wasn't until rollups emerged that these annoying problems were truly solved, requiring all data needed for users to exit to be available on L1. Whenever L2 advances the state, this data is updated by the rollup operator. Thus, the execution of L2 and the data updates on L1 progress synchronously. You can read more about rollups in these articles: beginner, intermediate, zk-rollup, and optimistic rollup.

In rollups, all participants are guaranteed to remain honest through mathematics (ZKRU) or cryptoeconomics (ORU), and if the rollup operator disappears or starts causing trouble: spamming, censorship, or (in the case of optimistic rollups) committing fraud, users can always safely exit their funds using the data on L1. All of this is reflected in the rollup contracts on L1 Ethereum, so the only thing users need to trust is the L1 network's faithful execution of these contracts (the same trust assumption applies to any other L1 contracts, such as MakerDao MCD or Aave).

image

Note 1:

Other Layer 1 blockchains, such as NEAR, Polkadot, or Cosmos Hub, can indeed become rollups relative to Ethereum; they just need to create a bridge that complies with the rollup design pattern and publish the necessary data to Ethereum, just like other rollups.

Note 2:

In the case of ZK Rollup, fraud cannot even be perpetrated, thanks to the validity proofs that ensure the correctness of rollup state updates, which are verified on L1 with each update. However, data still needs to be published on-chain so that if the operator disappears, users can still use this data to submit withdrawal requests themselves.

Note 3:

Can Bitcoin have Layer 2? No, it lacks the EVM and state channels necessary to create complex Layer 1 contracts to manage disputes and/or validate validity proofs. Of course, you will hear claims like: you can use some Bitcoin sidechain "without giving up control of your coins," but this is just false advertising.

Rollups are the only Layer 2 scaling solution that can guarantee you won't be robbed while you sleep, as the exit is under the control of the L1 chain.

Back to sidechains:

If Rollups are so magical, why would anyone choose to build sidechains that require additional trust and have been rejected by the market for the past seven years?

Sidechains fail because they are easy to operate, and often people create a promotional platform through detailed operations to raise funds from angel investors and then sell tokens to retail investors.

You can actually create a sidechain in an afternoon: you just need to establish a basic smart wallet-like contract on Ethereum where people deposit funds, simply choose a new chain ID for your sidechain and rebuild… Then voila, you are basically done… well, not quite… you still need to hire an army of scammers, graphic designers to create a shiny website, etc… but a lot of venture capitalists are happy to manage all of this for you; they have massive bots ready to deploy.

Some scammers will try to package sidechains as L2s to sell to you, and some may even shamelessly claim that their sidechain is more secure than rollups. But ultimately, it comes down to a simple question: who controls the exit? With rollups, the exit is under the control and protection of Ethereum L1's powerful EVM.

To summarize the above message:

Currently, any chain claiming TPS > 2000 in scalability solutions may imply a sidechain, with users making other undisclosed trust assumptions.

After the launch of ETH 2.0 sharding, Rollups may provide over 10k TPS, as they have high data demands.

Rollups are the only Layer 2 scalability solution that does not require additional trust and/or liveness assumptions from users.

When connecting to another chain, check the exit mechanism and make trust assumptions to safely withdraw your funds on top of that. They often have a lot of marketing jargon and meaningless technical terms designed to obscure these security trade-offs.

Other L1 chains can also be Rollups relative to Ethereum; they just need to comply with the Rollup design pattern and publish the necessary data to Ethereum.

Layer 2 without liveness assumptions cannot be built on Bitcoin, as it lacks the necessary programming primitives and state channels to provide the necessary protections on L1.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
banner
ChainCatcher Building the Web3 world with innovators