Optimistic Rollups: Benefits of Developing on L2

In the blockchain ecosystem, gas is a fundamental concept that directly impacts the cost and efficiency of transactions and smart contracts. While Ethereum has been a pioneer in establishing gas parameters, Layer 2 (L2) solutions like Mode have emerged to address scalability and cost challenges.

This article focuses on how Mode, by implementing the Optimism OP Stack infrastructure, efficiently manages gas to enhance transaction speed and reduce costs. We will explore the mechanism behind Optimistic Rollups, how this approach contributes to greater scalability for Ethereum, and the specific benefits it offers to developers.

Before diving into how Layer 2 (L2) solutions like Mode manage to reduce gas costs and increase transaction speed, it's useful to review some basic concepts such as EVM, gas, and L2. Even if you already have a background in blockchain, this review will help you better understand the mechanism employed by L2s, particularly rollups, which solve Ethereum's scalability problem and address the trilemma by balancing decentralization, security, and scalability.

Ethereum Virtual Machine (EVM)

The Ethereum Virtual Machine (EVM) is an essential component of Ethereum's infrastructure, enabling the creation and execution of smart contracts and decentralized applications (dApps). Functioning as a distributed virtual machine, the EVM not only ensures the integrity and security of the Ethereum network but also has set standards that many other blockchains have adopted, thus expanding development possibilities and fostering innovation in the decentralized technology space.

Operation of the EVM

The EVM operates as a state machine, calculating new valid states from one block to the next based on a set of predefined rules. These rules govern the execution of smart contracts and the updating of the Ethereum blockchain's state. When a smart contract is executed, the EVM interprets the contract's code, which has been converted into bytecode by a compiler. This bytecode is essentially a list of opcodes, which are the fundamental instructions that the EVM can execute.

Main Features of the EVM

  1. Decentralized Execution: The EVM operates on a network of decentralized nodes, ensuring that no single entity controls its operations. Each node validates and executes the code, reaching a consensus on the validity and outcome of transactions.

  2. Immutability and Security: The EVM ensures that once deployed, the code of a smart contract cannot be altered, protecting the integrity of transactions. Although there are contracts that allow updates through design patterns like proxies, code immutability in the EVM remains a key principle to prevent unwanted manipulations.

  3. Turing-Complete: The EVM is Turing-complete, meaning it can perform any calculation that can be expressed algorithmically. This offers great flexibility to developers but also requires control mechanisms, such as the gas system, to prevent infinite loops.

  4. Gas System: The EVM uses a gas system to measure the cost of operations. This not only prevents resource abuse but also incentivizes miners to process transactions by offering gas fees.

  5. Deterministic Execution: The EVM guarantees that, with the same input and initial state, any node will produce the same result when executing a smart contract. This is crucial for maintaining integrity and consensus on the blockchain.

  6. Contract Isolation: Each contract is executed in an isolated environment, protecting the network in case one contains errors or vulnerabilities.

Gas

Every transaction on Ethereum requires a fee, known as a gas fee, for processing. These fees are essential to ensure that the network's resources are used efficiently.

Gas on Ethereum is a measure of the computational cost required to perform actions on the network, such as sending funds or interacting with smart contracts. Each action has a predefined gas cost based on the resources needed to carry it out. However, gas fees are not fixed and can vary depending on network congestion: when activity is high, costs increase, and when it is low, fees decrease.

When you send a transaction or execute a smart contract, you pay gas not only to cover the processing cost but also to compensate the validators who secure the network. This system incentivizes validators to include your transaction in a block and helps maintain Ethereum's security and decentralization.

Why Gas Fees Increase

Before explaining what causes high gas costs, it is important to understand that each mined block on Ethereum has a gas limit, known as the threshold. This threshold determines the maximum amount of gas that can be spent on transactions within a block.

When this gas limit is reached or exceeded, gas prices begin to rise. This happens because the network must prioritize transactions that pay more gas to process them first, while transactions that pay less gas are left for future blocks or may even go unprocessed if congestion persists. This mechanism acts as a "filter" that selects the most valuable transactions in terms of fees, helping to relieve network congestion and keep it operational, albeit at a higher cost.

Users can adjust the gas fee they are willing to pay for their transactions to be processed more quickly. The higher the fee offered, the more likely the transaction will be included in the next block, which can be crucial during periods of high congestion.

Why Do We Need Gas?

Gas in Ethereum is crucial to prevent the network from being overwhelmed by unnecessary or malicious transactions. Since each operation on the network consumes computational resources, gas acts as a cost associated with these operations, discouraging spam and attempts to overload the network. By requiring a payment for each computation performed, transactions are filtered, helping to keep the network functional and efficient.

Layer 2 (L2)

What Is a Layer 2 Network?

A Layer 2 (L2) network is built on top of a base blockchain (Layer 1 or L1) like Ethereum, and is designed to improve the scalability and efficiency of the underlying blockchain. By processing transactions off the Ethereum mainnet, L2 offers several significant advantages:

  • Enhanced Scalability: Increases the number of transactions per second without sacrificing decentralization or security.

  • Faster Transaction Speed: Transactions are processed more quickly on L2, reducing congestion on L1.

  • Reduced Gas Fees: By bundling multiple off-chain transactions into a single L1 transaction, gas costs are significantly reduced.

Motivation and Need for Layer 2

The blockchain trilemma states that it's difficult to simultaneously achieve decentralization, security, and scalability. Ethereum, which processes over a million transactions daily, faces high costs due to demand. Layer 2 networks address these challenges by enhancing scalability without compromising security or decentralization, allowing for a more efficient and cost-effective experience.

How Layer 2 Works

Layer 2 networks operate as channels that process transactions off the main blockchain (L1). These transactions are grouped and compressed before being sent back to L1, where they are stored as data and validated as a single transaction. This process increases Ethereum's processing capacity and reduces costs since only the information is stored and validated on L1, while the actual processing occurs on L2.

L2 also relies on the final order of transactions on L1 to derive its own state. If L1 reorganizes data, L2 will adjust its state accordingly to maintain consistency.

Testing and Settlement on Layer 2

To ensure that transactions processed on L2 are correct, optimistic proofs (fraud proofs) or zero-knowledge proofs (zk proofs) are used. These proofs are sent to L1 to verify the state of L2 and are essential for transaction settlement. Settlement allows users to withdraw funds from the L2 bridge to L1 once the proofs have been verified.

Benefits of Layer 2

  • Cost Reduction: By moving transaction processing off L1, gas fees are much lower, making Ethereum more accessible to all users.

  • Maintained Security: Although transactions are processed on L2, they are settled and stored on L1, benefiting from Ethereum's network security.

  • Expanded Use Cases: With lower fees and higher transaction throughput, L2 opens the door to new applications with an improved user experience.

With these basic concepts clear, we can now explore how Layer 2 (L2) solutions address gas reduction and improve scalability. Rollups are key to this optimization. Next, we will look at what rollups are and how Optimistic Rollups and Zero-Knowledge Rollups contribute to overcoming the scalability trilemma in blockchain.

Rollups

Blockchain Rollups is a Layer 2 scaling solution for Ethereum designed to improve transaction speed and efficiency without inflating gas costs. This technology processes transactions on a secondary blockchain (L2) and then bundles multiple off-chain transactions into a single transaction that is recorded on the main blockchain (L1).

By doing so, rollups reduce the load on the main blockchain, thereby increasing the transactions per second (TPS) capacity and accelerating transaction finality. Despite these improvements, they maintain Ethereum’s decentralization and security, effectively addressing the blockchain trilemma by balancing decentralization, security, and scalability.

Blockchain Scaling Trilemma

Blockchains aim to have the following three properties:

  1. Decentralization: The system is not controlled by a central authority.

  2. Security: The system is protected against security vulnerabilities, such as 51% attacks, Sybil attacks, and replay attacks.

  3. Scalability: The system can grow without sacrificing speed or operational costs.

The blockchain trilemma states that a blockchain system can only achieve 2 out of these 3 properties. If the system is decentralized and secure, scalability is sacrificed.

Ethereum's Scalability Problem

Ethereum can process only 15 transactions per second. As Ethereum's popularity grows, so does the number of transaction requests, which increases the gas price per transaction. Users often pay higher fees to speed up the processing of their transactions and avoid long wait times.

This scalability problem is one of Ethereum's main challenges. Although Ethereum excels in decentralization and security, the limitation in transaction processing capacity highlights the need for solutions to improve its scalability.

Rollups aim to address the scalability problem posed by the blockchain trilemma. They seek to enhance Ethereum's performance without sacrificing decentralization or security.

How Rollups Work

Rollups process transactions off the main blockchain (L1) on a secondary layer (L2). These transactions are then grouped and compressed before being published on L1. By doing this, the transactions inherit Ethereum's security, as reversing a rollup would require reversing Ethereum itself. This also significantly reduces gas costs, as the cost of adding the grouped and compressed transaction to L1 is shared among all the transactions included in the rollup, making the process more cost-effective and efficient.

There are two main types of rollups, which differ in how they validate that off-chain transactions are legitimate and not fraudulent.

Types of Rollups

There are two main types of rollups:

  1. Zero Knowledge Rollups: Also known as validity proofs.

    Zero-knowledge rollups use validity proofs where transactions are computed off-chain, and then the compressed data is provided to the Ethereum Mainnet as proof of its validity.

    More information on Zero-knowledge rollups.

  2. Optimistic Rollups: Also known as fraud-proofs.

    Optimistic rollups are 'optimistic' in the sense that transactions are assumed to be valid but can be challenged if necessary. If a transaction is suspected to be invalid, a fraud proof is executed to check if this has occurred.

Before explaining Optimistic Rollups, let me present the process of a transaction in a Layer 2 rollup, from when the user sends it until its inclusion in the main blockchain (Layer 1).

Transaction in a Layer 2 Rollup to Layer 1

The following diagram illustrates the flow of a transaction in a Layer 2 using rollups, from the moment the user sends it until it is finally included in Layer 1.

Optimistic Rollups

Validation Process

  1. Assumption of Validity

    Transactions are assumed to be valid by default, which allows for processing a higher volume without real-time checks. This assumption is key to scalability as it reduces computational load by not requiring immediate validations.

  2. Proposing the Rollup Chain State

    Operators propose the valid state of the rollup chain based on the processed transactions. These proposals determine how the chain evolves in Layer 2, and, after passing the challenge period, are finalized in Layer 1.

  3. Challenge Period

    During the challenge period (approximately 7 days), other operators can review and challenge suspicious transactions. This period is crucial for security, as it allows for correction of errors before the state is finalized in Layer 1. Once finalized, the included transactions can no longer be contested.

  4. Fraud-Proof Process

    If an operator detects a potentially fraudulent transaction, they can challenge it using a fraud-proof. This mechanism ensures that only legitimate transactions are confirmed.

  5. Call-and-Response Game

    The fraud-proof triggers a call-and-response game between the defending operator and the challenger. This process continues until the dispute is reduced to a single computational step, which is executed in Layer 1, ensuring that only valid transactions are included in the main chain.

  6. Fraud-Proof Outcome

    If the fraud-proof results in a successful challenge, the rollup is re-executed in Layer 2 without the fraudulent transactions before being finalized in Layer 1, ensuring the integrity of the state.

  7. Fraud Penalty

    The operator who included fraudulent transactions loses their staked deposit, acting as a deterrent against malicious behavior and reinforcing the system’s security.

  8. State Finalization

    If no challenges are presented during the challenge period, the rollup is assumed to be valid. The state is finalized and sent to Layer 1, completing the validation process.

Operators

Operators play a crucial role in rollup solutions, such as Optimistic Rollups and ZK-Rollups. Their primary function is to process and bundle transactions in Layer 2 (L2) to optimize scalability and reduce costs. These operators can be individual nodes or composed entities. Their responsibilities include managing transactions off the main chain (L1) and proposing the new state of L2 to L1 for validation. Although the types and functions of operators may vary among different rollups, they all must ensure the proper functioning, security, and efficiency of the system.

Types of Operators in Optimistic Rollups

  1. Proposers

    • Description: Proposers are responsible for submitting the updated state of the rollup to Layer 1 (L1).

    • Function: They collect and process transactions in Layer 2 (L2) and send the new state to L1 for validation. Their role is crucial for maintaining system consistency and data flow.

  2. Sequencers

    • Description: Sequencers are responsible for ordering and bundling transactions.

    • Function: They can be either a decentralized network of nodes or a centralized entity. Their function includes ordering transactions and sending transaction batches to L1 for validation. This role is essential for ensuring efficiency and order in transaction processing.

  3. Validators

    • Description: Validators propose new rollup blocks and must provide a deposit in the rollup contract on L1.

    • Function: The deposit determines their likelihood of being selected to create the next rollup batch. Validators can also be penalized with the loss of their deposit if they act maliciously, ensuring the validity of the proposed blocks.

Mode

Mode is built on the Optimism OP Stack, enabling it to use Optimistic Rollups to enhance scalability and reduce costs. This integration offers Mode:

  • Gas Efficiency: More cost-effective transactions by processing operations on Layer 2 before sending them to Layer 1.

  • Compatibility and Ease of Deployment: Simple implementation for developers familiar with other EVM chains.

  • Security and Finality: Use of Optimistic Rollups' proofs and validations to ensure that only valid transactions are finalized on Layer 1.

In addition to the aforementioned benefits, Mode offers additional advantages to developers through specific technologies and programs:

  • Sequencer Fee Sharing (SFS): Mode implements a Sequencer Fee Sharing (SFS) system that allows developers to receive a portion of the fees generated by transactions on the network. This incentivizes the creation of applications and fosters collaboration, as developers can earn recurring revenue directly tied to the usage of their applications while contributing to the ecosystem's growth.

  • Developer Airdrops: Airdrops for developers in Mode are token rewards distributed to those who actively contribute to the ecosystem. This program motivates developers by providing tokens that reflect their participation and success within the network, aligning their interests with Mode's growth and offering a financial incentive to continue innovating.

  • Optimism RPG Funding: The Optimism RPG Funding program, with a $2 billion fund, is available for developers creating applications and tools on Mode. Mode facilitates access to this resource, helping developers secure funding for projects that benefit the blockchain ecosystem, allowing them to expand their initiatives with the necessary financial support.

  • Contribution to the Superchain: Being built on the OP Stack, Mode is part of the Optimism Superchain, an ecosystem of interconnected blockchains. This integration allows Mode to collaborate and share resources with other networks, strengthening its role as a DeFi hub and offering developers greater opportunities for growth and collaboration in a scalable and interoperable environment.

Conclusion

Mode, a Layer 2 solution based on Optimistic Rollups, optimizes efficiency and reduces costs on Ethereum. In addition to accelerating transactions and lowering gas usage, it offers incentives such as Sequencer Fee Sharing (SFS), developer airdrops, and access to Optimism's RPG Funding. Integrated into the Optimism Superchain, Mode provides a scalable and interoperable environment. We invite developers to join Mode and take advantage of these benefits to innovate and expand their projects on a growing platform.

I want to thank Cyfrin and Ethereum.org, as they were essential sources for the creation of this article. Cyfrin helped me gain an in-depth understanding of rollups in blockchain, while Ethereum.org helped me better understand the EVM (Ethereum Virtual Machine), which was key to developing this content.

Additional Readings

Subscribe to wispy
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.