What is an Optimistic Virtual Machine?

IntermediateFeb 01, 2024
Learn how the Optimistic Virtual Machine could be the key to solving Ethereum’s scalability issues.
What is an Optimistic Virtual Machine?

With the constant expansion of the blockchain industry, the most popular projects, including Ethereum, face a critical issue- transaction congestion on the blockchain. Irrespective of size, computer networks can only hold so much traffic. The more popular the network gets, the more likely it is to become congested. This issue restricts scalability and affects user experience in general.

As such, Ethereum needs different layer 2 networks to help with its scalability issues. Amongst these layer 2 networks attached to Ethereum’s layer 1 chain is the Optimistic Virtual Machine. This article delves into the inner workings of the OVM and sheds light on its importance to the smooth operation of the Ethereum ecosystem.

What is an Optimistic Virtual Machine?

The Optimistic Virtual Machine (OVM), built by Optimism using their Optimism Rollup (OR) technology serves as a Layer 2 scaling solution for Ethereum. It was designed to leverage EVM compatibility, offering a stable framework for developers to easily and efficiently scale their smart contracts.

The OVM provides a unified ecosystem for Layer 2 protocols, combining other scaling solutions under one umbrella. Instead of updating transactions directly on the Layer 1 blockchain, the OVM uses off-chain data to guarantee (or make optimistic decisions on) updated transactions on the Ethereum blockchain.

How Does the OVM Work?

Each computational process done by the OVM is called a transition. These transitions are evaluated on the client’s side by individual users who want to confirm the latest state of a smart contract or verify fraud proofs(mechanisms designed to detect and prove fraudulent behavior in decentralized systems) on-chain.

The OVM works as a dedicated workspace for smart contracts. Smart contracts are deployed, executed, and monitored on the OVM, ensuring that any other smart contract task is performed efficiently. When a node in the Layer 2 chain submits a transaction, the OVM processes these transactions and then activates different state changes within its environment, consequently leading to varying outputs like settling payments.

The OVM also implements a gas limit system to protect itself from malicious transactions that constantly run and drain network resources. When performing a transaction, users must set a gas limit, specifying how much gas they can spend on a transaction. These fees also serve as compensation to nodes for providing the additional computational resources to execute transactions.

Furthermore, the OVM can only interpret and execute smart contracts written in bytecode. While high-level EVM-compatible languages like Solidity are more human-friendly and simplify the deployment process, they must be translated and compiled into bytecode before they can be deployed. However, due to the OVM’s compatibility with the EVM at the bytecode level, developers can directly deploy existing EVM smart contracts in the OVM.

Optimistic Decisions: What Makes the OVM Special?

While the above section dissected the complexities of the OVM, its true innovation lies in its “optimistic decision” process. As stated earlier, an optimistic decision is a concept where the OVM uses off-chain data to predict the future state of the Ethereum layer 1. This approach paves the way for faster and more efficient transactions. The optimistic decision process involves three major steps:

  1. Examine Layer 1 and estimate what could happen in the future.
  2. Examine off-chain messages and consider their impact if integrated into Layer 1.
  3. After studying the insights from the previous steps, the OVM has a good idea of the future EVM state. This vision will guide the OVM’s next decisions.

Nonetheless, one might wonder how exactly the OVM arrives at these decisions despite seemingly infinite possibilities. The following concepts will help us understand the methodology behind optimistic decisions better:

Ethereum Futures Cone

Future Ethereum states are infinite, encompassing every possible transaction, every DAO that could be hacked, and any other event. Despite dealing with infinite futures, the EVM’s rules help to filter out future states that are less likely to happen. We can liken this process to a vast cone that shrinks from a large hole into a tighter funnel every time a new block is mined and finalized.

Local Information

Layer 2 expands the consensus protocol by incorporating local information, including off-chain messages, a signed channel update, or an inclusion proof for a plasma block. The OVM uses this local information to make decisions, but it must first define assumptions to be used in deriving possible future Ethereum states.

Local Assumptions

OVM programs define assumptions based on local information explained above, serving as filters to differentiate realistic future states from impossible ones. An example of this is the use of a “dispute liveness” assumption, which is used by many Layer 2 solutions. Since channel participants expect malicious withdrawals to be disputed, any state that contains a malicious withdrawal will be considered impossible and rejected. When the local assumptions have removed these impossible futures, we may finally make “optimistic decisions” about the future.

Pros and Cons: OVM vs EVM and zkEVM

Now that we understand how the OVM works, it is essential to understand its strengths and weaknesses, especially when compared to other virtual machines like the Ethereum Virtual Machine (EVM) and Zero-Knowledge Ethereum Virtual Machine (zkEVM). Examining their differences will highlight the OVM’s unique value and how they work hand-in-hand to boost scalability.

OVM vs EVM

The OVM prioritizes faster transactions as opposed to the EVM. With the OVM, a node can write directly to the blockchain, eliminating the need for the multi-node verification process of the EVM. On the other hand, the EVM demands consensus from all nodes by making each of them vote on each transaction before updating the blockchain. This thoroughness is reasonable because it ensures absolute trust, but the cost is reduced throughput compared to the OVM.

The OVM and EVM also differ In terms of validity, as the OVM does not enforce the validity of state changes. With the OVM, a user with malicious intentions can transfer another user’s assets to themselves before submitting the transaction to Layer 1. If the transaction is unchallenged, the OVM accepts it.

On the other hand, all state changes in the EVM must follow the network’s consensus rules before getting accepted. As such, the above scenario would follow different rules as the sender’s signing key would not match their public key, which is a requirement for transactions to be accepted.

Additionally, the EVM guarantees instant finality. Instant finality refers to when a state change is accepted on the network, it cannot be altered or reversed. The OVM does not guarantee instant finality since it does not enforce transaction validity and finalizing invalid or malicious transactions would corrupt the blockchain. Therefore, OVM states are only final when they are accepted on the Layer 1 chain.

OVM vs zkEVMs

The OVM mainly focuses on execution of transactions and smart contracts and leaves the Layer 1 EVM to enforce blockchain rules, especially on state changes. The OVM prioritizes speed by submitting completed transactions without proof of validity. This boosts scalability, but there is a risk that invalid transactions could go unnoticed and be finalized on Layer 1, especially if they are left unchallenged.

A Zero-Knowledge Ethereum Virtual Machine (zkEVM) tackles this problem by creating cryptographic proofs for each off-chain transaction, similar to receipts. This boosts the assurance of the validity of state updates, further boosting confidence in the overall system.

With the zkEVM, state transitions are finalized as soon as they are verified on-chain. This reduces delays in completing Layer 2 transactions on Layer 1. Zero-knowledge proofs also confirm the validity of status updates, eliminating the need for fraud proofs unless it is necessary.

zkEVMs are generally more challenging to implement than the OVM because developing such elaborate proofs for several computation steps is costly. This accessibility makes the OVM easier to launch than zkEVMs. Nonetheless, both projects are EVM-compatible and can run smart contracts.

Use Cases of the OVM

Running on Layer 2, the OVM allows users to use the Layer 1-based EVM without constantly updating the EVM’s state directly. Imagine the OVM as an assistant for the EVM, working behind the scenes on Layer 2 and handling transactions so the EVM doesn’t get overwhelmed.

In context, let’s assume User A owns 2 WBTC and sends 1 WBTC to User B using an optimistic rollup. An aggregator will then submit the transaction details to the Layer 1 rollup contract. If it is not challenged, it will be integrated permanently on the Ethereum blockchain, making it official.

This guarantee is made possible on two conditions. The first is that the OVM executes transactions according to the EVM’s rules, so transactions processed correctly off-chain are guaranteed to be accepted on Layer 1. The second factor is that the aggregator shares the transaction data publicly, allowing anyone to point out inconsistencies in a transaction’s execution and, by extension, keeping all parties honest.

Nonetheless, whether both parties decide to withdraw their assets or make other transactions, they have still benefited from the EVM without having to execute any transactions on Layer 1.

Aside from executing faster transactions, the OVM can be used in various other ways. The OVM has also revolutionized blockchain gaming, enabling faster gameplay with no lag or delays, where transactions happen instantly and the game world reacts in real-time. Its use in enhancing DeFi applications cannot go unnoticed as well, as it provides near-instant token swaps on decentralized exchanges with lesser gas fees.

Conclusion

With the Optimistic Virtual Machine, developers can deploy smart contracts, and users can make transactions without the hassle of high gas fees and slow processing times plaguing Ethereum. While it faces challenges concerning security and potential centralization risks, the OVM holds the key to unlocking a new era of blockchain-powered applications and mass adoption in general. With the evolution of blockchain technology, the OVM is one of the innovative tools expected to shape the future of decentralized applications.

Author: Tamilore
Translator: Cedar
Reviewer(s): Matheus Piccolo、Ashley
* The information is not intended to be and does not constitute financial advice or any other recommendation of any sort offered or endorsed by Gate.io.
* This article may not be reproduced, transmitted or copied without referencing Gate.io. Contravention is an infringement of Copyright Act and may be subject to legal action.
Start Now
Sign up and get a
$100
Voucher!
Create Account