Whether you’re a web3 enthusiast or not, you’ll come across the term EVM if you haven’t already. The Ethereum Virtual Machine (EVM) is the underlying infrastructure of the Ethereum Blockchain. It allows developers to deploy smart contracts and build dApps (decentralized applications). How? Well, that’s what we’re about to dive into. Buckle up because it’s going to be a hell of a (technical) ride.
In tribute to Alan Turing, Turing completeness refers to any real-world general-purpose computer capable of solving any computational problem given enough time and infinite memory. Here, the EVM executes processes limited to a finite number of computational steps allowed by the amount of gas needed for given smart contract execution. The gas available in the system’s architecture plays a major role as it serves as a “traffic regulator” by halting the platform when a certain execution runs forever for instance.
Ethereum is a distributed state machine meaning it behaves as a state transition function. Given an input, it produces an output according to pre-defined rules. As you can see in the image below.
Y(S, T)= S'
“Given an old valid state
(S) and a new set of valid transactions
(T), the Ethereum state transition function
Y(S, T) produces a new valid output state
S' .“ (source)
From one block to another, Ethereum’s state changes. That state is a quite large data structure named a Merkle Patricia Tree, a data structure that has an efficiency of O(log(n)) saving lots of running time, and that keeps all the accounts linked by hashes.
To understand how hash functions work, check out Austin Griffith’s Introductory video using eth.build below.
Let’s talk about transactions now. After all, Ethereum is a blockchain where permissionless transactions can be executed. We now know that the EVM updates the Ethereum state when a smart contract code is executed. This points to the description of the transaction-based state machine, which illustrates the fact that account holders and miners initiate state transitions by interacting with smart contracts.
We previously mentioned that the Ethereum state is a large dataset but what kind of data does it contain? That state is also called a “world state” which is a mapping of addresses (160-bit values) referring to the accounts. Every address represents an account comprising a balance (ether), a nonce as the number of transactions successfully sent from this account, the account’s storage hash, and the account’s code hash. Every component is illustrated in the image below.
“When a transaction results in smart contract code execution, an EVM is instantiated with all the information required in relation to the current block being created and the specific transaction being processed.” (source)
Ethereum world computer is completely virtual. Every smart contract code execution instantiates a new EVM.
“The EVM’s physical instantiation can’t be described in the same way that one might point to a cloud or an ocean wave, but it does exist as one single entity maintained by thousands of connected computers running an Ethereum client.” (source)
The EVM implementations follow the specifications determined by the Ethereum Yellowpaper which allows anyone to create smart contracts and develop dApps in a seamless manner.
Thank you for reading!
Follow for more, Twitter: @le_kag7