Understanding Ethereum’s virtual machine (EVM), requires first recalling its predecessor, BitTorrent software. Ethereum’s inventor Vitalik Buterin says BitTorrent was the very first Decentralized Application (DApp): a community of independent users generating and exchanging data for each other across an open internet network.
The programmer Bram Cohen invented BitTorrent as a file sharing protocol in 2001, and it is still very much alive today, despite concerted, international, billion-dollar efforts to destroy it. The latest movies or software can still be downloaded through the BitTorrent protocol in minutes straight to your laptop. To truly stop BitTorrent, you’d have to shut down every single computer in every home in every country across the planet. The same is true of the EVM. This is why the decentralized Ethereum Network is referred to as “The Unstoppable World Computer.”
What is the Ethereum Virtual Machine?
The Ethereum Virtual Machine (EVM) is a powerful, sandboxed virtual stack embedded within each full Ethereum node, responsible for executing contract bytecode. Contracts are typically written in higher level languages, like Solidity, then compiled to EVM bytecode.
This means that the machine code is completely isolated from the network, filesystem or any processes of the host computer. Every node in the Ethereum network runs an EVM instance which allows them to agree on executing the same instructions. The EVM is Turing complete, which refers to a system capable of performing any logical step of a computational function. JavaScript, the programming language which powers the worldwide web, widely uses Turing completeness.
Ethereum Virtual Machines have been successfully implemented in various programming languages including C++, Java, JavaScript, Python, Ruby, and many others.
The EVM is essential to the Ethereum Protocol and is instrumental to the consensus engine of the Ethereum system. It allows anyone to execute code in a trustless ecosystem in which the outcome of an execution can be guaranteed and is fully deterministic (i.e.) executing smart contracts.
For every instruction implemented on the EVM, a system that keeps track of execution cost, assigns to the instruction an associated cost in Gas units (See our What is Gas? article). When a user wants to initiate an execution, they reserve some Ether, which they are willing to pay for this gas cost (the best Ethereum wallets have very reasonable fees).
By using the Gas mechanism, two major issues are solved: A validator is guaranteed to receive the initial pre-paid amount, even if the execution fails. An execution cannot run longer than the pre-paid amount would allow. Instead of looping indefinitely the execution would run until it runs out of Gas.
When a transaction is sent to the network, validators may take the transaction, executing the associated code. The validator will ensure that:
- All information on the transaction is valid.
- The sender has enough funds to pay for the execution of the transaction.
- The EVM didn’t run into any exceptions during the execution.
The EVM achieves Turing Completeness by enabling an economy that charges per software instruction executed instead of per financial transaction executed like Bitcoin does. Instead of a transaction fee, you have a kind of fee for running programs.
Being Turing complete means that Ethereum is technically a peer-to-peer general purpose worldwide computer, and could even assume the functions of the internet as we know it. Ethereum could enable us to create file-sharing economies, peer-to-peer crowdfunding events, smart contracts, markets for renting out the unused hard-drive space on your laptop, a disintermediated Uber or Facebook (the products without the companies), etc. It’s basically like the internet in 1994: no-one knows what the future will bring.