What is EVM in crypto?
If you’ve been in the crypto world for a while, you’ve probably had to deal with the EVM.
This is an acronym that stands for Ethereum Virtual Machine, the beating heart of Ethereum’s protocol as well as the machine that makes all the operations work inside.
It aims to grant developers the ability to create smart contracts and dApps in the Solidity programming language.
This article will cover all you need to know to understand how EVM functions.
What is a Virtual Machine?
In order to better understand how an EVM works, you need to take a step back to understand what a Virtual Machine is.
Virtual machines “approximate” the computing power of physical machines using virtual architecture running on different operations systems (OPs) and hardware, making them the perfect engine for a decentralized ecosystem. Acting as a layer between machines and the executed code, virtual machines can be run on various hardware and operating systems from anywhere in the world.
In a nutshell, a virtual machine is a software that simulates the functionalities of a host computer.
An introduction to the Ethereum Virtual Machine
The EVM is the runtime environment that deploys and executes smart contracts. It is similar to JVM (Java Virtual Machine), and it provides an abstraction of computation and storage. Imagine it as an isolated global environment containing millions of executable objects and their related data store. Its execution processes are limited to a finite number of steps by the amount of gas available for any given smart contract; for this reason, it is considered a quasi-Turing complete state machine.
For a more complete explanation, it should be noted that Ethereum doesn’t have an individual CPU and isn’t considered a computer. It is distributed worldwide with computers running the EVM simultaneously. The EVM functions like a virtual CPU running inside a specific standalone program called Go Ethereum or Geth. We can say that the EVM is not a piece of hardware installed inside a machine running the programs. It is more like a software CPU that executes the bytecode (a compiled form of smart contracts). If you run Geth on your machine, you become a part of the Ethereum network.
Its architecture is stack-based, working in 256bits to facilitate hashing and elliptic curve operations.
It is made of:
An immutable program code ROM, loaded with the bytecode of the smart contract to be executed;
A zero-initialized volatile memory;
A permanent storage based on the Ethereum state;
A set of environment variables and data available during execution.
Moreover, the EVM has no scheduling capacity because execution ordering is organized externally to it – Ethereum clients run through verified block transactions to determine which smart contracts need executing and in which order. “Mastering Ethereum”.
For this reason, the Ethereum world computer is single-threaded and completely virtual.
The EVM instruction set offers these operations:
Arithmetic and bitwise logic operations;
Execution context inquiries;
Stack, memory, and storage access;
Control flow operations;
Logging, calling and other operators.
It also has access to account and block information such as block number, balance, gas price and so on.
The EVM requires that one has access to any network node to be able to execute the desired commands and create new tokens without any difficulties. In other words, the Ethereum Virtual Machine ensures that all transactions and smart contracts are executed in the correct and expected manner as desired by the smart contract code. This plays a crucial role in the entire Ethereum ecosystem facilitating the creation of a wide range of dApps.
For detailed information, visit Ethereum.org and read the book” Mastering Ethereum”.
Here you can delve more into what is an Ethereum Virtual Machine.
Benefits and downsides of EVM
EVM brings with it a lot of benefits, such as:
Execute untrusted code without risking data. EVM guarantees that its computations will not affect your data or programs in any way; it is isolated from the other parts of the system.
Deterministic processing: Smart contracts written on EVM have access to all of Ethereum’s states at any given time, allowing for processing to happen deterministically. For example, one cannot make an infinite loop in EVM by calling the same function twice.
Can run complex smart contracts.
Resilient against failure.
Easy to write.
Here you can read more about EVM characteristics.
Of course, it also has negative aspects that can be identified with
High cost of gas and storing data. Firstly the gas, the number of ETH fees you need to pay to run a smart contract. It depends on the difficulty of the transactions, in fact, the more difficult the computation for a transaction, the higher its gas cost will be. You need to pay attention to the congestion of the network. Secondly, the high cost of storing data on the blockchain could take up more than 3TB.
Technical expertise is required. Writing smart contracts and using EVM requires technical expertise. It’s a Turing-complete system which allows developers to write scripts in any programming language they wish. This can be excellent or disastrous, depending on the intention behind the code being written. Programming languages are not inherently good or bad in their nature; it all depends on who is using them and for what purpose.
EVM is one of the biggest projects in the world of cryptocurrencies. It paves the way for many future developments and numerous dApps.
There is a long list of projects that have launched an EVM-compatible layer1 blockchain, such as Binance Smart Chain, Fantom, Avalanche, Polygon, Cardano and many more. They offer greater speed and sometimes low transaction costs compared to Ethereum. The EVM-compatible chains help developers to migrate smart contracts without having to write the code from scratch again.