By Frederick KANG, CEO of Fox Tech, and Ivan Lin, CTO of Fox Tech
The Layer3 concept is currently getting a lot of attention in the blockchain community and is seen by many as a revolutionary advance because developers can create a wide variety of smart contracts and decentralized applications (dApps) on top of the blockchain platform. Layer3 is a great engineering innovation for the Ethereum expansion ecosystem. Layer2 solves the problem of Ethereum general-purpose scaling, and Layer3 solves the problem of faster, lower-cost, customized scaling.
There are already a number of decentralized DEXes on Layer2, so why build DEXes on Layer3? Most Layer2-based DEXes adopt AMM mode, while a few Layer2 Dexes adopt order-book mode, such as ZigZag, which has a higher transaction cost than CEX. Whether in AMM mode or order book mode, the transaction speed and cost of DEX on Layer3 will provide a much better user experience.
There are several reasons why Layer3 is perfectly capable of building a safe and efficient DEX:
- Layer3 DEX can be programmed in a stronger language(such as Rust) from Layer1 Solidity to write a powerful matchmaking engine.
- Layer3 can be highly customized to simplify the transaction steps of users, without the need to call wallet authorization every time an order is placed.
- Layer3’s TPS is again an order of magnitude increase over Layer2. The cost is reduced again by a hundredth for an order; Orderbook Mode supported.
- Layer3 and Layer2 are the same. The consensus layer of Layer3 and Layer2 is played by Layer1, and the security level is very high.
- Layer3 has an independent data availability layer, and the visibility of off-chain transactions and asset status can be easily known and obtained.
- Users can use EOA wallets or smart contract wallets to achieve self-custody of assets to better ensure asset security.
The layered structure of blockchain infrastructure
At present, the blockchain infrastructure is mainly divided into Layer0, Layer1, Layer2 and Layer3 layers. What do these “layers” actually mean? Layer1, which we are most familiar with, usually refers to the main network of blockchain, where P2P connections and transactions can be conducted through each node without a centralized client server, among which Ethereum is the most typical. Each transaction is registered as a block and stored in a distributed database. Layer1 is the earliest of the four layers. The Omnichain interoperibility protocol, or Layer0, was developed to enable cross-chain assets, and its main application is a variety of cross-chain Bridges.
The classic “Trilemma” of blockchain refers to different solutions in the same layer, which cannot meet the requirements of decentralization, scalability, and security at the same time. A typical example is ETH, which belong to Layer1, choose decentralization and security at the expense of scalability, while many later public chains rely on less decentralized frameworks to achieve higher TPS. Because of the Trilemma, delays and soaring fees inevitably followed as the number of transactions increased. To solve network congestion, developers came up with two scaling solutions based on OP or ZK in Layer2.
In this multi-layered design, Layer1 provides consensus and transaction security for Layer2, while Layer2 separates computing from the main blockchain as a relatively independent execution layer, minimizing latency and reducing transaction costs. Layer3 provides a layer of abstraction between users and the underlying blockchain technology, making it easier for users to interact with dApps and smart contracts while securing them through the underlying blockchain. Layer3 can further compress data on the basis of Layer2, and then package the proof back to Layer1 for on-chain verification through Layer2, so as to realize faster and lower cost transactions than Layer2.
After Layer2 completes its general-purpose expansion, developers and users will move to Layer3 for more customized features and higher performance, so expect a rich variety of large applications on Layer3. There are a number of dApps that are using decentralization to implement the various business models of Web2 on top of Layer2. Layer3 will bring more possibilities and imagination to these applications.
How to access DEX to Layer3 using zero-knowledge proof
DEX is an important class of Layer3 applications. If you want to build a DEX called OX Exchange on top of Fox Tech’s Layer3, what is the most critical technology to do that? In Layer3 deployment of such a decentralized exchange, the use of zero-knowledge proof is critical.
From the perspective of interaction logic, the user’s operations in OX Exchange will be implemented in the form of calling smart contracts, that is, each buy/sell oder will be converted into a transaction to the contract function, and each such transaction will be submitted to the Layer2 node and executed by zkEVM.
On the implementation side, smart contracts deployed specifically on Layer2 interact with Layer3 applications. After receiving batch transactions from Layer3, the Fox node of Layer2 will perform zkRollup proof generation, including opcode splitting and circuit generation, and then prove the correctness of execution according to zero-knowledge proof algorithm. Finally, the generated execution correctness proof is submitted to the Layer1 chain, and the status update is accepted through the verification of the on-chain contract.
Layer2’s zkRollup provides services with lower latency and a better user experience. Specifically, OX needs to interact with Fox zkRollup on Layer2 to take advantage of Fox’s “packaging” for greater throughput. OX provides a rich front-end operation interface, and the underlying complex interaction logic is completely transparent to users. Users can connect to Web3 wallet and directly use various services of DEX just as they do in all DEX.
As you can see from this process, Layer2’s zkRollup layer is still responsible for performing calculations down the chain and submitting proof updates up the chain, while Layer3 is mainly responsible for performing more specific order engine functions that interact directly with the user. By layering complex computations up and down the chain, efficiency can be increased, resulting in a qualitative change in transaction costs and throughput, and a significant improvement in user experience.
How to ensure user asset security by DA (Data Availability)
Data availability plays a critical role in all Web 3.0 projects. All traditional applications, including the centralized exchange CEX, typically do not use DA, so user data transparency is minimal, and the level of security of CEX users depends entirely on whether the exchange has done something bad. Layer3 DEX uses proprietary data availability (DA), which not only greatly reduces user fees, but also ensures the security of users’ transaction data and assets..
Layer3 DEX has high throughput, which means there is a huge amount of data to process. The data is stored in the mixed storage mode of “DA Layer +L2” to achieve both efficiency and security. Contracts deployed in L2 only need to record a few key data points and a Merkel root, while all other data in the process will be recorded in the DA layer. When the user interacts with the application of L3, the original data in the interaction process will be stored in the DA layer, and the DA layer will calculate the new Merkel root for the updated data. At the same time, the L3 application will also send a certificate to the L2 contract, which will check the correctness of the Merkle root update. This mechanism ensures that the L2 contract state is consistent with the DA layer, that is, the record state is always correct.
Centralized application data is like a black box, and L3 application with DA layer is like using a transparent strongbox. Users of L3 dApps do not have to worry about the project’s rug pull or going bankrupt, because the security of their assets no longer depends on the project side but on the Ethereum 3 Layer. In the case of a zkRollup like Fox, the Ethereum consensus layer provides the best security for Layer3 applications.