At the nucleus of the Ethereum protocol and operation is the Ethereum Virtual Machine, known as EVM. As it can be deduced from its name, it is a computation engine, not greatly unidentical to the virtual machines of Microsoft’s .NET Framework, or interpreters of other programming languages such as Java. Before delving fully into Ethereum Virtual Machine, let us look at what Virtual Machine and Turing-completeness is.
Virtual Machine
A VM is a program which emulates a computer system. It has a virtual CPU, memory, and storage and appears from the outside.
A virtual machine has an operating system, files, and applications. It works just like a physical computer; it can host websites, run programs, and exist on a network with other systems. If viewed on a screen, the virtual machine appears as a window running within that computer’s own operating system.
It also has a CPU, memory, and storage, but these are simulated, not physical. Because of this, multiple virtual machines can coexist on one server. When this happens, the server uses a piece of software called a hypervisor to manage them.
The hypervisor maps the VM’s virtual hardware to the physical components on the server. In this scenario, one physical server might have two, three, four, or even ten virtual machines running on it.
However, the number is limited by the resources of the server – too many VMs will lead to reduced performance.
Turing-complete
This concept came from renowned computer scientist called Alan Turing. He developed ideas around what a hypothetical computer or thinking machine can do. He argued that computers do not think or process thoughts like human beings, but go by a set of data processing rules to solve problems.
A Turing machine, once referred to by Turing as an a-machine (automatic machine) is a hypothetical machine that embodies his concept of non-human or machine thinking. The thinking process runs by way of algorithms.
In Turing’s paper, he mentioned that such a machine would have to process a reel of tape with a line of symbols or functions that can be moved backward and forward. The machine would be capable of processing a symbol or altering it. Such a machine could only direct its attention to one state at a time.
Now that we have had an overview of Virtual Machine and have a fundamental knowledge of Turing-complete. Let us inquire into our main objective.
Ethereum Virtual Machine
The EVM is the component of the Ethereum network that manages the deployment and implementation of Smart Contracts. While the EVM doesn’t need to be engaged for simple value transfers, it does compute updates to the network’s state.
In simpler terms, the EVM is a ‘world computer’ with its own permanent data storage and decentralized nodes across the globe handling millions of executable objects. It also has a stack-based architecture, storing all in-memory values on a stack, and works with a word size of 256 bits to enable elliptic curve operations and native hashing.
The EVM has many addressable data components, such as an immutable program code ROM containing the executed smart contract bytecode and a volatile memory with each location initialized to zero.
Since Ethereum clients comb through verified blocks to figure out which smart contracts to deploy, the execution order is organized outside the EVM. This means it has no scheduling capacity, making Ethereum similar to a single-threaded world computer without a system interface handling or hardware support.
How EVM Works
The Ethereum Virtual Machine’s instruction set is Turing-complete, allowing contracts deployed on the network to perform any task a regular computer program can do. Popular use-cases include the creation of fungible tokens that adhere to the ERC-20 standard, as well as NFTs under the ERC-721 standard.
These tokens have various properties and are used in crowdfunding, decentralized finance markets, prediction markets, and to a small degree, even gaming.
However, this ability comes with a crucial warning which is- some programs could take forever to execute. This is known as ‘the halting problem’ and puts the Ethereum network at risk of running a never-ending program.
The problem is that a program can’t be labeled as an infinite loop just from checking its code – the program must be executed. Without a scheduler, a program like this would completely stall the network, but luckily Ethereum has a way of getting around this. This brings us to what is known as ‘gas’.
Ethereum Gas
Deploying a conceptualization known as ‘gas,’ the network demands a fee for its computation costs. After a certain maximum computation has been performed, the execution ends after the gas fuelling the transaction is depleted, and the EVM halts the program.
This means that the EVM is only a supposedly Turing-complete machine, it runs any program you throw at it, but only if the program ends after using a certain amount of computational power.
On Ethereum, this limit is not set in stone, and network participants can pay to increase it to a maximum value called the ‘block gas limit’. Over time, the network can agree to increase this upper limit, but there is a limitation on the amount of computation a contract-call can consume at any given instance. Transactions that cross this limit are terminated.
The Ethereum Virtual Machine is an essential part of the Ethereum platform and is imperative to its consensus engine. By creating a trustless, deterministic environment for anyone to execute code, Ethereum is leading a shift in how the world approaches both money and finance.
It is a very powerful, sandboxed stack integrated into every Ethereum full node and is responsible for deploying smart contracts written in code compiled down to EVM bytecode. This isolates the machine code from the rest of the network, its filesystem, and any processes on the host node, with each node on the network running instances with identical instruction sets.
However, it has its own drawbacks. Even with the incredible proposals and innovative additions to the network, such as sharding, rollups, Plasma, and Casper, unless the base-layer can function at maximum efficiency, there will always be limitations to what it can achieve.
To solve these issues, Ethereum 2.0 will replace the EVM with eWASM, which allows the network to deploy any code compiled to WebAssembly, making the system much faster and more efficient.
The eWASM implementation will also be incredibly secure, highly compatible and enable the network to utilize standard hardware capabilities to run smart contracts at a near-native speed.
What do you think of this article? Let’s hear from you in the comment box!