Ethereum’s performance issues have long been criticized
The popularity of DeFi and liquidity mining has caused congestion in Ethereum. Gas fees skyrocketed in 2020, and Layer 1 of Ethereum is obviously not sufficient enough to handle all the traffic. For top DeFi projects and protocols, they are concerned about how to deal with the contradiction between user growth and the current limitations of Ethereum, and how to choose the right Layer 2 solution. Ethereum is in urgent need of scaling, this has been an ancient problem since 2017. However, after more than 3 years of hard work, more and more layer 2 solutions are available, which is dazzling. It is critical to understand the nature of this track.
In order to solve the “impossible triangle” of “security, scalability, and decentralization” in blockchain, numerous solutions emerged, one of them being Layer 2. Layer 2 is often referred to as an “off-chain” solution. Its main purpose is to enhance the performance of blockchain while retaining the decentralized advantages of distributed protocols.
In Ethereum, the Layer 2 technology system is directly connected to Ethereum. Ethereum is used as the basic layer of security and finality, and the data processing on the blockchain can be reduced on a large scale by running calculations outside of the chain. This means that not all transactions need to be completed on the Ethereum mainnet. Once Layer 2 succeeds, it means that Ethereum can break through the existing performance limitations and support a larger ecosystem. The bottom layer of Ethereum will focus more on safe and high-value transactions, and projects based on Ethereum will no longer have to worry about excessive fees and bicycle-like speeds. DeFi will also usher in a new spring. Block Dream Fund will invest a lot of energy and funds to support high-quality projects on Layer 2 track, if you are on that track, don’t hesitate to contact us at firstname.lastname@example.org, we want to hear your big ideas!
The following is our in-depth investigation on the scaling of Ethereum or other blockchains. There are two major ways to achieve that:
- Layer 1 (security, fully distributed): Layer improvement refers to improving the scalability of a public chain through its own improvement, that is, on-chain improvement;
- Layer2 (scalability): It is a collective term for a series of off-chain scalability solutions. This kind of expansion does not affect the public chain itself, and the scalability is improved by other means, that is, off-chain improvement. Layer 2 has been included in the Ethereum expansion route. Transactions are processed on Layer 2, and Layer 1 is used only when necessary. Such solutions include state channels, sidechains, Plasma, and Rollup. Over the years, many projects have explored these options and made great progress.
Major Layer 2 technology
- State Channel
This is the earliest layer 2 scheme, one channel can realize the transfer of funds between two users; when a large number of channels coexist, a two-layer channel network can be formed; users who have not established a direct connection channel can realize the transfer of funds through network routing. To run the application in the status channel, there will be the following steps:
Step 1: All parties participating in the state channel deploy smart contracts on the blockchain. The contract contains a multi-signature contract (can be unlocked only when signed by each party), and deposit a certain amount of funds, part of which is used as the initial state, part of which is used as asset mortgage to prevent evil. After the channel is opened, all actions will be executed off-chain until the channel is closed.
Step 2: The application will run locally on the clients of all parties. At each step, the two parties construct and sign the transaction locally, and send the transaction to other parties through a peer-to-peer network or a simple gossip agreement and get the signatures of all parties to form a new status. The new status update includes the latest status of the parties (usually the Hash of the status), the signatures of the parties, and the version number of the status. At the same time, all parties save each state and signature during the operation.
Step 3: After the application ends, one party submits the final state to the smart contract on the blockchain, and there is a period of the dispute. All parties agree to confirm the state after the dispute period, the state channel is closed, and the assets are settled on the blockchain according to the final state.
- Instant certainty: As long as the signatures of all parties pass the status update, the status will be “confirmed”, and there is no need to wait for block confirmation on the blockchain;
- Highly secure: status updates are off-chain, peer-to-peer communication can ensure privacy, and only the final status will be submitted to the blockchain;
- Low handling fee: The state channel is transactional, and the handling fee for settlement and clearing on the blockchain is only required when the channel is opened and closed. At other times, no matter how the two parties update in the channel, it is free;
- In addition, it greatly improves throughput and supports cross-chain.
- Not suitable for low-frequency operation;
- Participants in the state channel must stay online at all times to avoid missing the challenge period;
- It is more suitable to have an application with a certain set of participants, because every time the participant changes, it is necessary to change the smart contract and rebuild a channel;
- The number of users is limited, capital utilization is low, not decentralized enough, network stability, network scalability, user-friendliness, and smart contract support are not good.
This is the general term for the agreement that realizes and anchors the value of the main chain in the form of blockchain. The core idea is to build a completely independent blockchain with its own validators and operators, which can transfer assets to and from the main chain, and selectively send snapshots of the block header to the main chain to prevent forks. The essence is to build a chain on the base layer and use a completely different set of validators. The entire security is separate. The TPS of the side chain depends on its validators, the more validators, the lower the TPS.
Although the side chain can use the security of the main chain to prevent bifurcation, the verifier can still launch an “invalid state transition attack” through conspiracy. The idea is that the main chain cannot verify all the blocks on the side chain. Therefore, as long as more than 50% of the validators conspire, an invalid block can be created to steal the assets of other participants, and the block snapshot of this side chain will be sent to the main chain to trigger the smart contract and execute it, thereby seizing Take the assets pledged by other participants in the smart contract of the main chain.
- Code and data are independent, and do not increase the burden on the main chain;
- The delay is relatively low, higher than the millisecond level of the state channel, and much lower than the ten seconds or tens of seconds delay of the main chain.
- Low security, and most validators must be trusted to be good people, so the security is much lower than the main chain.
Plasma was proposed by Vitalik in 2017. It is equivalent to a sub-chain. Users pledge assets on the main chain and generate mapped assets on the sub-chain. A series of contracts that run on top of the root chain (the main Ethereum blockchain). If you want to conceive architecture and structure, you can think of the main blockchain and the Plasma blockchain as a single tree. The main blockchain is the root, and the Plasma chain (also known as the sub-blockchain) is the branch. Greatly reduce the load on the main chain. The branched-chain periodically send reports to the main chain. All branch chains can issue their own unique tokens, which can incentivize chain verifiers to take care of the chain and ensure that it is trouble-free. Each branch chain has its own independent data, and when it does need to submit some data to the main chain, it will not dump all of its content, but only submit the blog header hash value to the main chain. Plasma not only saves a lot of space in the main-chain but also exponentially increases the speed of the transaction process.
Compared with the channel state, all parties agree to withdraw funds back to the main chain, and the withdrawal of funds can be executed immediately. Plasma’s withdrawal requires an “objection period.” (Because Plasma is based on the assumption that operators may conspire to commit evil at any time, users cannot exit instantly, and a specific exit mechanism is required.) The core principle is to transfer the calculation of the main chain to the Plasma chain to prevent crime by means of fraud-proof.
- Low cost, safer than most side-chains
- High storage requirements for users, complex exit mechanisms, cannot be applied to smart contracts;
- Users have a heavy burden on running nodes. When transferring tokens, they must provide a complete history of the tokens.
Rollup is similar to Plasma, which expands Ethereum by migrating transactions from off-chain to Layer 2 sidechain protected by the main network (Layer 1). Both of these expansion plans deploy smart contracts on the main network, which contain all funds stored in the side chain and proof of the current state of the side chain. Sidechain users and operators maintain the sidechain and ensure that effective state transitions are submitted to the mainnet contract.
The concept of Rollup can be traced back to 2014, and the failure of solutions such as Plasma and state channels led developers to re-examine Buterin’s Shadow Chain (now called Rollup). Rollup is based on the concept of “Shadow Chain”, which achieves data availability by executing the state off-chain and using only the Ethereum blockchain. Rollup can be subdivided into the following three categories:
 ZK Rollup (ZKR)
All funds in ZK Rollup are held by smart contracts on the main chain, and it performs off-chain calculations and storage, and the effectiveness of its side chains is ensured by zero-knowledge proofs.
ZK Rollup was originally proposed by Barry Whitehat in 2018. Its security is the same as the underlying Layer1 (Ethereum). It can produce blocks in one minute and increase the throughput to 2,000 tps. The essence of ZK Rollup is to compress the user state on the chain and store it in a Merkle tree, and transfer the user state change to the chain. At the same time, the correctness of the user state change process under the chain is guaranteed through the proof of zkSNARK. The cost of directly processing user status changes on the chain is relatively high, but only using the smart contract on the chain to verify the correctness of a zero-knowledge proof PROOF is relatively low. The main logic is as follows:
- Transaction compression + zero — knowledge proof;
- Compression mode-field compression and deletion:
- Responsible person — who is responsible for compression, relayer operator;
- Prevent cheating — zero knowledge proof
ZK Rollup is characterized by bundling hundreds of transactions into one transaction after the transaction data and zero-knowledge proof of the second-layer block are on the chain. For all transfers held in a transaction that is verified once on the chain, the waiting time for exit is very short. Use the main chain as a storage medium instead of a consensus engine; compress transactions and reach a state consensus under the chain; use zero-knowledge proof to ensure the security of the state consensus under the chain. The correctness verification is very simple. The verification can be completed directly in Layer1, and the confirmation is of high timeliness and is suitable for transfers.
- Fast and safe, upgrade to 2000–2500TPS, and wait for only a few minutes to exit;
- Prevent fraud through zero-knowledge proof.
- There is no general solution for the construction of the verification link, and there is no generalized virtual machine logic. It must be customized for each use case.
- The verification of the correctness of the program is relatively complicated, and it is necessary to verify the polynomial curcuit
- The two-layer packaging node is burdensome and costly, and it takes a long time to calculate the zero-knowledge proof. The user experience angle of delay is still relatively poor;
- When encountering stuck points, it is difficult to support universal smart contracts, and the development workload of each project is heavy.
 Optimisitic Rollup（OR）
The structure is based on the design of Plasma and ZK Rollup, but fully universal smart contracts are allowed in Layer2 protected by Layer1. The core idea is as follows:
- Transaction compression + fraud proof, compression method-due to the support of general smart contracts, the compression effect is weakened
- Responsible person- compressor is responsible for the Aggregator
- Prevent cheating — fraud proof, as long as one node in the operator is honest (provided evidence can be provided)
In OR, the operator submits the new Merkel root together with transaction data to the Rollup contract on Layer 1. Everyone will assume that this is a valid state transition (it will not be verified as in the ZKR scheme) and move forward optimistically. Because if the status proof is invalid, there will be participants using the fraud proof to challenge it. These guarantees are cryptographically economic in nature, because token rewards and staking and forfeiture mechanisms will incentivize operators to remain honest.
- Can support any smart contract logic of unlimited participants, and can pack many at one time
- High security
- The transaction delay of Optimisitc Rollup itself is higher, even higher than Layer1
- Slow speed and long dispute period (operator custody, not settle on the spot, to curb operators from doing evil)
The mechanism of Validium is very similar to ZK Rollup. The main difference is that every transaction data on ZK Rollup will be broadcast through the Ethereum network, while on Validium, the data is managed by a group of data notaries. Validium’s data transaction costs are low, but it requires trust in the data notary. This allows Validium to achieve higher throughput, but the price is that Validium operators can freeze user funds. Without the data availability guarantee of zkRollup, the operator of Validium (the manager of data availability) can deny any user the right to transfer funds. Operators make minor changes to Merkel’s status without revealing the changes to users. Without this information, users cannot create Merkel proof of ownership for their account.
- Low data transaction cost, higher throughput than ZK Rollup
- User funds can be frozen and confiscated
Layer 2 solution does not have a fixed direction. This also means that each solution is created for different applications. So there is a big problem here. If different projects adopt different Layer 2 solutions, how can they realize value interoperability? How can the liquidity between agreements be realized?
If DeFi’s Maker, Uniswap, Compound, Curve, Synthetix, etc. cannot realize value circulation, then DeFi will lose its original meaning. Even if it achieves extremely high transaction throughput and extremely low fees, its value will be greatly reduced if it only works behind closed doors. In fact, it is easier to achieve interoperability using the same Layer 2 technology project. You can boldly assume that if Layer 2 technology can still maintain Layer 1 composability and security, projects using Layer 2 technology can achieve value flow, transaction throughput is hundreds of times today, and transaction costs are greatly reduced. Then the liquidity of the agreement will be greatly enhanced, and more agreements will be introduced. As liquidity increases, so does value. The pain points of DeFi will disappear, and the transaction volume of the industry can show a qualitative leap.
Ethereum 2.0 provides new solutions, and the initial stage of Ethereum 2.0 is coming fast, but the basic scalability of the application is only the last major stage of Ethereum 2.0, and it will take several years. If Layer 2 can support DeFi and achieve the composability and security of Layer 1, then Layer 2 will gain its seat in the entire DeFi development process and lead the industry to a breakthrough.