EVM and other Virtual Machines
Ever wondered how smart contracts are able to be created, stored, and executed on-chain? This is possible thanks to the use of a Virtual Machine, the mechanism responsible for operating smart contracts. The most prominent of the blockchain VMs is the Ethereum Virtual Machine (EVM), which is responsible for operating the Ethereum network and all of the smart contracts deployed onto it.
Traditional blockchains that do not operate with a virtual machine, such as Bitcoin, act solely as distributed ledgers; they simply keep track of how much cryptocurrency each address on the chain holds. The ledger follows a strict, predefined set of rules, such as that a Bitcoin wallet can’t send more BTC than it holds. This is simple and effective, yet it doesn’t let users execute more complicated transactions.
A chain such as Ethereum that operates using the EVM, is more complex. The Ethereum network does not act solely as a distributed ledger, but rather as a distributed state machine. Each transaction made on the Ethereum network changes the state of the chain, and EVM processes each of these changes to maintain balance and keep all the smart contracts functioning correctly.
This system lets the EVM track the entire state of the Ethereum network including wallet balances, smart contracts, and the global state of the entire blockchain.
The EVM creates an easy way for developers to write and deploy their own code onto the Ethereum blockchain. They simply create a smart contract using a programming language such as Solidity (a popular language for developing smart contracts) and then compile them so that they are compatible with the EVM. The code is then deployed onto the blockchain as a transaction that includes the contract itself, as well as the initial state of the contract - for example, if the contract is meant to hold ETH, it will initially have a balance of 0 ETH until ETH is added into it. Once it is deployed on-chain, users are free to interact with the smart contract by sending transactions directly to it. Each state change made by the transactions is handled directly by the EVM.
The EVM is also responsible for dictating how much in gas (fees) users have to pay per transaction. Gas cost primarily depends on the type of transaction, where more complex ones that require additional computational power will cost more than simple ones.
For example, a transaction with a smart contract that has to call on an external data source or send an external message will cost more than a transaction that is simply sending money from one wallet to another because it requires more computing power to process. The EVM is responsible for determining an appropriate gas cost based on these types of factors in order to maximize the efficiency of the network.
This image illustrates the process that a transaction goes through in the EVM. An operation, such as a smart contract, costs a certain amount of gas to execute. If the operation:
- Creates a message to call another contract or external data source
- Retrieves data stored on-chain
- ends data to be stored on-chain
…it will cost extra gas to create that transaction. The amount of gas needed for each of these operations is determined by the EVM code, which looks at the amount of compute required and how busy the network is.
Source: Ethereum.org
To learn more about the technical aspects of the EVM, check out the official Ethereum documentation.
The EVM is the most popular virtual machine, so many other existing blockchain networks are built to be EVM compatible. The main benefit of having an EVM compatible chain is that it lets developers deploy their smart contracts on the network without having to rewrite or edit them - they can immediately be launched on-chain just like they would be on the Ethereum network, which saves a lot of time and effort for developers deploying a dApp on multiple chains. Many other EVM compatible chains also tend to be much cheaper and faster to transact on than Ethereum, which can appeal to dApps that want to avoid having users pay high transaction fees. Check out this article by Unchained for a more comprehensive list of pros and cons of EVM compatible chains.
What are some other virtual machines popular in the blockchain space?
Solana, the 5th largest blockchain by market cap, has surged in popularity because of its speed and low transaction cost. It runs on its own virtual machine called the Solana Virtual Machine (SVM) that operates a bit differently than the EVM.
Solana is able to operate at a much faster rate than the Ethereum network because the SVM has a unique capability:
it can process multiple transactions at the same time.
Source: Squads.so
This is because the SVM utilizes parallel processing, which lets multiple smart contracts be executed simultaneously. Ethereum can only process one transaction at a time, making it far less efficient.
Solana is able to do this because instead of using Proof of Stake as its consensus mechanism like Ethereum does, it utilizes Proof of History (PoH), which creates a system that timestamps each transaction to help put them in order. The SVM then utilizes Sealevel, the engine responsible for processing transactions, to identify non-overlapping transactions to be executed simultaneously.
This image illustrates how parallel processing on Solana works. Transactions arrive and are put into queues, where each transaction is timestamped so they can be sorted in order of arrival. Validators then take in transactions from this queue and process them simultaneously, instead of all the validators processing one transaction at a time. This system makes Solana so efficient and cheap because incoming transactions are processed so quickly.
If multiple transactions are going to or from the same wallet(s) and need to be executed in a specific order, they can’t be executed in parallel to one another. However, if these transactions are completely unrelated and going to different places, then they can be executed in parallel because the state of one does not impact the state of the other. This allows the SVM to be able to settle the states of multiple transactions at the same time, making it far more efficient than the EVM.
💡 Complexity can cause problems
While the SVM system makes Solana far faster and more efficient than Ethereum, it is far more complex and requires much more compute intensity. This has been evident with the Solana blockchain, which has experienced several instances of downtime. While it is built to handle a high amount of transactions per second, large loads of transactions can still overwhelm the system, causing the network to shut down. The most recent outage occurred in February of 2024, where the Solana network went completely down for almost 5 hours.
Ethereum, while not as efficient, has a higher level of safety and security because of the more limited transaction throughput. As a result, it is far less likely to experience an outage and is considered one of the most secure chains, which has contributed to its popularity.
As blockchain knowledge evolves and the development of these blockchains continues to increase, these issues will become less and less prevalent. As of June 2024, Solana has only experienced one outage since February 2023, compared to incidents occurring almost monthly in 2022. Check out this tracker that tracks all incidents of downtime of Solana’s blockchain to see in-depth details about what went wrong during its outages.
For a more in-depth look at how the SVM operates, Squads offers a comprehensive overview in this article.
Other chains also have their own virtual machines that are custom built to propagate certain tasks: Filecoin has its Filecoin Virtual Machine (FVM) that is custom built to tailor to its storage solution, Cosmos utilizes the CosmWasm Virtual Machine for advanced smart contract development, and Neo uses the Neo Virtual Machine (NeoVM) to operate its enterprise infrastructure offerings.
📋 Practice Question