paint-brush
5 Steps to Build an Exchange-Optimized L3 Rollup "Eventum"by@evedex
9,150 reads
9,150 reads

5 Steps to Build an Exchange-Optimized L3 Rollup "Eventum"

by EVEDEXOctober 16th, 2024
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Why we chose the blockchain solution that forms the foundation of the Evedex ecosystem and 5 steps to build it.
featured image - 5 Steps to Build an Exchange-Optimized L3 Rollup "Eventum"
EVEDEX HackerNoon profile picture


Long Story Short: How to Build Your Own L2/L3 Blockchain?

This article aims to explain and justify the journey we undertook to choose the blockchain solution that forms the foundation of the EVEDEX ecosystem.

Step 1. Preface

The main goal of EVEDEX is to provide users with the same broad range of features as centralized exchanges (such as Binance, Bybit, OKX, and others) but without the need for KYC procedures while offering more transparent trading rules.


To achieve this, we have developed a hybrid decentralized exchange that leverages the best aspects of both CEX and DEX approaches, delivering maximum speed and security to users. Let’s highlight the key criteria on which our research was based on:


  • Security: The exchange should not use "hot" or "cold" wallets and should not have direct access to users' funds. In the event of a hack or if the exchange ceases operations, users must be able to recover their funds. All contracts should be public and audited.


  • Trading Speed: Order matching should take no more than 100 milliseconds, and settlements should occur within 2 seconds.


  • Competitive Fees: Since the fixed costs of the exchange are reflected in the fees charged to users, minimizing the exchange’s costs allows us to lower user fees.


  • Decentralization: In today’s world, decentralization adds an extra layer of security and promotes resilience without significantly increasing maintenance costs.

Step 2. Market Analysis

In analyzing the market and considering the insights of key experts, we concluded that our future network must be EVM-compatible for the rapid development of our product. We will use Solidity as the contract language, as it is the most widely adopted for smart contracts.


While other languages like Rust (used in Solana and Near) or Move can also achieve decentralization, their ecosystems are significantly weaker compared to EVM networks, and development on them is more expensive. Therefore, we are not considering these languages or specialized networks like Cosmos, Polkadot, or Solana.


This article is not about yet another "Ethereum killer". Instead, practicality, limited resources, and our timelines exclude the possibility of competing at the level of trading fees, as the development and maintenance costs require profitability.

A Bit About Ethereum

There’s no need to go too deep into the advantages of Ethereum; suffice it to say that it is one of the most secure and decentralized blockchain platforms, with high liquidity and strong user trust. The main drawback is its limited throughput, which leads to peak loads and high transaction fees. Although scaling solutions have been in development for years, these issues remain unresolved on the main network. Ethereum continues to be one of the slowest and most expensive EVM networks.

What is Scaling?


Scaling refers to methods designed to increase a network's throughput by enhancing its protocol. One of the earliest and most popular solutions was sharding—dividing the blockchain into separate parts (shards) that process transactions in parallel, increasing the network's capacity. Each shard requires its own validators, and individual nodes do not need to process all transactions, reducing load and allowing the network to handle more transactions over time.


Initially, sharding was expected to be implemented in Ethereum before its transition to Proof-of-Stake. However, development took much longer than anticipated, and the primary method of scaling has since shifted to L2/L3 solutions, which we’ll discuss below.


In his article «What Kind of Layer 3s Make Sense?», Vitalik Buterin wrote:


One topic that often re-emerges in layer-2 scaling discussions is the concept of "layer 3s". If we can build a layer 2 protocol that anchors into layer 1 for security and adds scalability on top, then surely we can scale even more by building a layer 3 protocol that anchors into layer 2 for security and adds even more scalability on top of that?


This led us to the idea of creating the most efficient solution for our exchange.


To fully understand the situation, let’s look at the primary scaling technologies for Ethereum:

What is Rollup?


A Rollup is a network that operates in parallel with Ethereum but records transactions on the main network. Transaction validity is verified on the Ethereum network. There are two types of Rollups based on the method of transaction verification: Optimistic Rollups and ZK-Rollups.

Optimistic Rollups

Optimistic Rollups form batches of their transactions and record them on the mainnet in a compressed format, which makes the recording cheaper. Because transactions are not directly executed on the Ethereum network, and due to savings in the recording format, it is possible to significantly reduce gas fees and make transaction recording cheaper. In Optimistic Rollups, the recorded data on transactions is considered valid, but there is a specific period during which the recorded data can be challenged. There is a potential risk that if an invalid transaction is not contested by anyone within the allocated time, it will be recorded on the mainnet as valid.

ZK-Rollups

ZK-Rollups are also networks that operate in parallel with Ethereum, but they use a different method for verifying the validity of recorded data. They also form batches of transactions, but instead of recording all transaction details on the mainnet, they submit a summary of these batches along with a cryptographic proof of the transaction's validity.


ZK-Rollups are arguably one of the most promising scaling solutions for Ethereum at the moment because, unlike Optimistic Rollups, the recorded transaction data is cryptographically verified at the time of recording. This means there is no need to wait for the end of a challenge period to ensure that the transaction will not be reversed.


However, the mathematical complexity of ZK proofs imposes certain limitations: verifying general-purpose EVM computations is a very challenging task, and active development is currently underway to address these challenges.

State channels

State channels are a technology that allows a group of participants to exchange multiple transactions among themselves while only recording two transactions on the main network: the initial and the final transaction. Here’s how it works:


In the Ethereum network, a multi-sig smart contract is deployed. This contract verifies that the transactions are signed by the necessary participants involved in the interaction. Participants in the state channel deposit funds into this multi-sig contract and then engage in off-chain interactions with one another.


At the end of their interactions, the participants sign the final outcome of their engagement. Finally, the smart contract distributes the funds according to the recorded result. This approach significantly reduces the number of transactions that need to be recorded on the Ethereum mainnet, lowering fees and increasing transaction speed while still ensuring security through the use of a multisig contract.

Plasma

Plasma chain is a middle ground between rollups, where complete transaction verification occurs on Layer 1, and sidechains, which do not require such verification. The idea behind the Plasma chain is that not all transactions need to be verified by every node on the Ethereum network. Plasma chains periodically record the result of their operations along with a cryptographic proof of the current state of the network.


The actual data of this state is not recorded; instead, the proof is of a small size. As a result, the validity of the transactions themselves is not checked, but if a commitment has already been recorded on Ethereum, the Plasma chain cannot retroactively alter the transaction history. This approach helps in reducing the load on the Ethereum network while still providing a level of security through periodic commitments.

Validium/Optimium

In terms of architecture, Validium is similar to ZK-Rollup solutions, with the key difference being that transaction verification data is stored off-chain. This allows for greater throughput and lower fees but at a trade-off.


Validium solutions are less secure than ZK solutions because the operator of a Validium can potentially freeze funds without data on the Layer 1 network. While this architecture offers advantages in scalability and cost, it introduces additional risks regarding the control and access to user funds.

Sidechains

A Sidechain is a separate blockchain that operates independently of Ethereum but is connected to it through a two-way bridge. Unlike Rollup solutions, transaction verification is not conducted on the Layer 1 network for Sidechains.

As a result, the security of a sidechain is solely dependent on the implementation of that sidechain itself. However, this independence from the Layer 1 network provides greater flexibility in terms of architectural implementation and allows for more tailored solutions that can address specific use cases or requirements.

Optimal Technology

There have been many attempts to scale the Ethereum network, some more successful than others. Scaling Layer 1 itself would be the safest and most user-friendly option, but it has proven to involve significant technical challenges.


Therefore, at present, the preferred scaling vector is through L2/L3 solutions. Rollup solutions, in particular, provide the highest level of security among alternative options. Both Optimistic Rollups and ZK-Rollups have proven themselves as the most popular solutions, offering a high degree of security and relatively low integration costs compared to other methods.


Considering the recent Ethereum update (DenCun), which significantly reduced the cost of recording data for verification at Layer 1, Rollup-based solutions stand out over alternatives like Plasma and Validium, providing greater security with minimal additional costs.


For users, decentralization in Rollups ensures that they can withdraw their funds even in the event of a crash or other critical issues. User funds are locked on the main network, allowing withdrawal from the Rollup to the main network regardless of the Rollup's status.


However, one key drawback is that users are introduced to an additional network that may not be supported by all wallets, complicating deposits and withdrawals via a bridge. The process locks tokens in the main network and issues a “wrapped” token in the Rollup, which can complicate the user experience and create barriers to accessing funds.


With that said, there are undeniable advantages:


  • Infrastructure Management: Parameters of the network can be flexibly configured and optimized to meet the current needs of the product.
  • Transaction Speed: They accelerate the confirmation of operations, which is critically important for trading.
  • Reduced Fees: They lower the cost of transactions, affecting the operational expenses of the exchange and making the platform more efficient.
  • Scalability: They increase the network’s throughput, supporting a higher volume of trading operations.
  • Enhanced User Experience: They provide a more predictable and controlled experience for users interacting with the solution.

Step 3. Network and Technology Selection


Initially, we considered existing blockchains like Arbitrum One and Optimism (both Optimistic Rollups) for deploying our exchange infrastructure. These networks offer high popularity, liquidity, and extensive third-party bridge support for cross-chain operations.


However, we identified significant downsides.


First, sooner or later, we would face the issue of scaling to other networks. Many popular projects, from Aave to Uniswap, have gone through this process after initially launching on just one network. This necessitates maintaining multiple parallel infrastructures, dilutes liquidity, and significantly increases the operational costs of the exchange.


Second, there is a challenge with protocol governance through a governance system. Distributing governance tokens across different networks can lead to vote manipulation, which undermines the very idea of decentralization.


Third, the settlement cost of orders on the exchange is considerably higher. Our estimates suggest that the settlement cost on the Optimism network would be around $0.03, whereas in our own Rollup, it would be 10 to 100 times lower. Moreover, in the case of our own L2/L3 network, infrastructure costs increase non-linearly, and the cost per transaction decreases with the number of transactions, thereby enhancing the competitiveness of the exchange.


After considering these factors, we began exploring the development of our own L2/L3 solution, and we reached out to partners from Hashex and Gelato.


Javier Donso, Head of Developer Relations at Gelato, shared:


“For projects like EVEDEX it makes total sense to have their own chain. The ability to customize block times, block gas limit, or base fee, among other parameters, gives their project an edge against the competition as they can build a more optimized chain for their needs.


We have seen protocols doing a two-step approach, yet EVEDEX has, from day one, a clear vision and roadmap that makes having their own chain the best choice!”



Before we dive deeper into the analysis, let's take a look at some competitors that are already utilizing similar solutions:


  • Aevo: They use their own L2 solution based on Optimism (OP Stack Rollup), which allows them to maintain high transaction speeds and low fees while ensuring security at the level of the main Ethereum blockchain.
  • dYdX: Initially used an L2 solution based on StarkWare (ZK-Rollup) but later announced a transition to their own L1 network based on Cosmos.
  • GMX: Focused on derivatives, GMX offers the ability to trade perpetual futures with leverage. The platform initially launched on the Avalanche network but later moved to the L2 solution Arbitrum.
  • Kwenta: Operating on the Optimism network, Kwenta focuses on trading perpetual futures.
  • Perpetual Protocol: This platform supports perpetual futures and operates on Optimism, although it was initially launched on the xDAI network (now Gnosis Chain).

Technology Selection

To begin, we need to understand the key terms related to Rollup components:


Sequencer: Responsible for ordering transactions on L2 and grouping them into blocks. It functions similarly to miners or validators in L1 blockchains. The sequencer collects transactions from users, combines them into batches, and sends them to L1 for recording, ensuring the order and integrity of the data.


Proposer: This entity or node proposes new blocks of transactions to be included in the transaction chain. It may be part of a consensus mechanism that selects one of many proposers to add a new block. Proposers play an important role in creating and proposing valid blocks.


Batcher: A batcher (sometimes called an aggregator) is a component that combines multiple transactions into a single package or batch. This reduces the load on the main blockchain and lowers gas fees. The batcher then sends this batch to the main network for final recording. Thus, the batcher helps to minimize the number of interactions with the main network and reduce costs.


State Validation: State validation involves checking the correctness of the blockchain state in the Rollup. This is a key process that ensures trust in the data. Different solutions use various approaches to state validation. Some (such as Optimistic Rollups) assume the correctness of transactions until proven otherwise, while others (like ZK-Rollups) use zero-knowledge proofs to verify the state.


Settlement Layer: Responsible for the final confirmation and recording of transactions on the main network. This layer is where financial settlements and consensus occur. The settlement layer serves as the foundation for ensuring that the data in the Rollup matches that of the main network.


Data Layer: The data layer manages the storage and access to the data needed to restore the Rollup's state in case of disputes or the need for recalculation. Various solutions may store data on-chain or use external off-chain solutions to minimize costs and ensure reliable storage.


Now, we need to understand the basic load parameters we are planning for:


  • Planned throughput (number of settlements per day): 100,000.
  • Gas required for one settlement: 400,000.
  • Gas per second for the required number of settlements: 463,000 gas/s.
  • Settlement mining speed: up to 2 seconds.
  • Peak load: 1,000 settlements per second.

Rollup Technology

We have gathered an analysis of current market solutions and presented the results in a comparative table:




Data availability providers for rollups


(in development) *


It is important to note that in DA providers, data is not stored indefinitely. It is essential to store transaction data additionally. The infrastructure provider typically runs additional archive nodes from which the transaction history can be extracted if necessary.


Data source for costs - NEAR. Vendors were unable to provide reliable information on costs as per our request.

Arbitrum Nitro Stack

Arbitrum Nitro combines all existing approaches of Arbitrum in building L2/L3 networks: Arbitrum Rollup, Arbitrum Orbit, and Arbitrum AnyTrust. Arbitrum Orbit can operate in two modes: Rollup and AnyTrust. The main difference lies in how transaction data is stored. The Rollup mode is the most decentralized, with transaction data recorded on L1. Storing data on L1 represents the primary costs in this mode.


In AnyTrust mode, the Data Availability Committee (DAC) is responsible for data storage. Data is stored off-chain, which significantly reduces storage costs. DAC participants run servers that store transaction data. For the network's security, at least two DAC participants must be honest. The sequencer distributes transaction data to all committee members.


Arbitrum Nova has a DAC committee consisting of 6 members.

Advantages of Arbitrum Orbit

  • Higher block mining speed, which is important for exchanges.
  • Greater throughput.
  • The ability to launch L3 solutions, significantly reducing network fees.
  • The possibility of writing optimized contracts in Rust, which will run in parallel with the main ones in Solidity.
  • The protocol supports permissioned access: only the smart contracts of the required application can be deployed.
  • In the event of sequencer/proposer failure, users have the option to withdraw their funds to L1.

Disadvantages of Arbitrum Orbit

  • When launched in AnyTrust mode, the security of the network depends on the honesty of the members of the DAC committee, leading to high centralization.
  • Unlike OP Stack, there are no permissionless fraud proofs. Fraud proofs are conducted by whitelisted validators. In Arbitrum Nova, there are 13 validators on the whitelist.
  • Unlike ZK solutions, there is a risk that none of the validators will check the state, and invalid data may be recorded on L1.
  • Complex implementation of the prover due to support for Solidity and programming languages that compile to WASM (Rust, C++).

OP Stack

OP Stack is an open-source solution that plays a key role in the infrastructure of Optimism. The goal of OP Stack is to provide the necessary infrastructure for the development of a compatible ecosystem of rollups called Superchain. Superchain aims to ensure interaction and transactions between various Layer 3 networks.

Decentralized Withdrawal

The main technological distinction is the ability to decentralize the deposit/withdrawal of funds between networks based on OP Stack. In mid-2024, the Permissionless Output Proposals (PoPs) mechanism was implemented, allowing any network participant to create a withdrawal request through DisputeGameFactory.


Currently, the mechanism is not fully decentralized, as there is a Security Council that can veto withdrawals. There are plans to revise the rights and restrictions of the Security Council in the future, although there are no clear timelines for these changes.

Advantages of OP Stack

The Superchain ecosystem built on OP Stack offers several advantages:


  • Efficiency, simplicity, and scalability: You can launch your own Layer 2 blockchain with just "one click".
  • Interoperability: Layer 2 solutions based on OP Stack can easily interact with each other.
  • Security: Guaranteed by Ethereum.


The key difference from Arbitrum Orbit is that Superchain focuses on building horizontal Layer 2 blockchains instead of Layer 3. There are already many such networks based on OP Stack, including Optimism, Base, Zora, opBNB, Public Goods Network, DeBank, Aevo, and others.

Disadvantages of OP Stack

Currently, OP Stack is a leader among competitors in terms of the number of integrations and revenue. However, it also has its downsides:


  • Long withdrawal times: Users must wait for confirmations on the main blockchain.
  • Low privacy.
  • Excessive centralization: At present, there is only one sequencer processing transactions.


The Optimism team is actively working to address these issues, and Espresso is already offering its own sequencer for OP Stack blockchains.

Step 4. L2 or L3?


The Rollup technology is fundamentally suitable for building both L2 and L3 networks. The only difference is which network the data is published to. Typically, the main Ethereum network is used for L2, while any L2 network can be chosen as the target for L3. The cost of recording data in an L2 network is significantly lower than in L1, while providing a similar user experience. However, the question of security arises, as an L2 network may cease to function; thus, there must be sufficient liquidity and a level of trust in place to host your Rollup on that network.

Our Choice

For the exchange's requirements, any of the aforementioned stacks could be suitable. ZK solutions appear promising, but they are still under active development and carry significantly higher infrastructure support costs.


Among the two main Optimistic solutions (OP Stack and Arbitrum Orbit), Arbitrum Orbit seems more appropriate for a decentralized exchange due to its focus on significant differences in speed and decentralization, as well as the highest liquidity within the ecosystem, concentrated in a single network — approximately twice that of BASE and OP Mainnet.


In July 2024, Arbitrum Orbit introduced the Fast Withdrawal initiative, which aims to significantly expedite fund withdrawals from the Rollup to 5-15 minutes, contrasting sharply with the 7-day wait required for withdrawals from OP Stack Rollups. Additionally, Arbitrum Orbit actively supports projects built on its infrastructure, while the Superchain initiative resembles a centralized, closed VIP club "for insiders only".



At the same time, it is worth noting that initiatives within OP Stack, such as Interop and Alt-DA, look intriguing. These initiatives will allow funds to be transferred between OP Stack Rollups without the 7-day delay and utilize alternative Data Layers, such as Celestia, which can further reduce transaction costs. However, the OP Stack team has made it clear that only select projects will be able to become part of Superchain (and fully utilize interop), and based on our assessments, Optimism likely aims to limit this number to no more than 5-10 projects across the entire Superchain. It is also important to remember that any network can be disabled at any time since the keys to the Sequencer are transferred to Optimism and are not disclosed to the network owner, which raises doubts about the core concept of decentralization.


After a month of intensive discussions within the team and analyzing various options, we concluded that our own L3 network based on Arbitrum Orbit + AnyTrust is the optimal balance of cost and speed for our exchange. Considering the developed ecosystem, marketing opportunities, and recent updates, Arbitrum Orbit stands out as the most decentralized and reliable option currently available in the market. Additionally, the ability to participate in the Fast Withdrawal initiative is a significant advantage, allowing for automatic fund withdrawals within 5-15 minutes without the need to wait for hours or even days, as is customary with traditional Optimistic Rollups.


Advantages of L3 Network Based on Arbitrum Orbit for Us


“Choosing the right blockchain for a hybrid exchange is a task that requires balancing the trade-offs between blockchain speed, decentralization, and the complexity of development and infrastructure support costs. Considering the outlined requirements, the most optimal solution appears to be based on Arbitrum Orbit in AnyTrust mode, which allows for the deployment of a secure blockchain that meets the specified requirements with minimal trust assumptions.”


-Gleb Zykov, CTO and co-founder of HashEx



  • Speed: Utilizing Arbitrum Orbit provides us with nearly an 8x increase in settlement speed compared to OP Stack, while maintaining a similar Block Gas Limit.


  • Arbitrum Orbit Ecosystem: It is one of the most popular ecosystems, boasting $16 billion in liquidity, strong marketing support, and a professional team.


  • Control Over Infrastructure: We can quickly implement changes to the network, adding necessary features and improvements that enhance the user experience.


  • Economic Efficiency: The cost of a single settlement is projected to be only 0.0001 to 0.0002 dollars, significantly reducing operational costs and allowing us to maintain low fees for users.


  • Token and DAO Issues Resolution: The use of a native token within a single network addresses the problem of vote manipulation and promotes greater decentralization (similar to what is implemented by Arbitrum, Optimism, and others).


  • Arbitrum Network Support on All Major Exchanges: The Arbitrum team has already done significant work to become a major player and ensure support for their network on all leading exchanges. Along with fast token deposits/withdrawals, this greatly simplifies the user journey.

Disadvantages of Our L3 Solution

  • Building from Scratch: Constructing a network from the ground up requires significant resources and time, even though we are using a ready-made SDK that simplifies the setup process considerably.


  • Self-Support: Unlike utilizing existing solutions, we will be fully responsible for maintaining the network's functionality and promptly addressing any issues that arise.


  • Higher Risk of L3 Network Downtime Compared to L1: While we believe this scenario is unlikely, it is theoretically possible. In such a case, the Rollup would continue to function but would not publish data to the L3 network.

Step 5. Conclusion

Building our own L3 network on Arbitrum Orbit offers unique growth opportunities for our exchange. This solution reduces operational costs, enhances user experience, and increases opportunities for participating in governance. Although constructing and maintaining our own network requires considerable effort, we are confident that this strategic decision will ensure the long-term success and sustainable development of our exchange.


Written by: Vlad Komissarov, CTO of EVEDEX