Ethereum Virtual Machine Basics

Leonid Astakhov
Intrachain Insights
3 min readAug 24, 2018

Dear Intrachain Community,

I am Intrachain’s Core Blockchain Developer. With more than 20 years of experience I am a computing specialist — especially in the field of HPC Clustering Solutions, a Big Data analytic, a Smart Contracts professional and a cryptography and blockchain expert.

In the following weeks, I will share with you technological insights into the blockchain world. Today, I want to elaborate on Ethereum Virtual Machine (EVM).

EVM

You can think of Ethereum Virtual Machine (EVM) as of a computational device which is able to compute any mathematical problem which could be solved with an appropriate algorithm. This class of machines are called Turing Complete machines.

The machine basically refers to a set of data manipulation rules which are used to solve any mathematical problem by an appropriate algorithm with a given time and memory. Good examples of Turing complete systems are CPU in your home computer or a programming language. The EVM is quasi-Turing complete because computations are bound by the given amount of GAS, which limits the number computations that can be done.

GAS

The abbreviation GAS on an Ethereum ecosystem is equivalent to a fee. Every transaction that is performed on the Ethereum blockchain requires a certain amount of gas to be attached to it. The GAS is used then as a fee for computational resources used to perform the transaction. The concept of GAS used on Ethereum blockchain has two definitions:

· GAS — a measurement tool to calculate the required fee to perform a particular computation

· GAS Price — the exchange rate of GAS unit to Ether crypto currency. Usually measured in ‘Wei’ which is Ether.

In order to complete any transaction on the Ethereum blockchain the GAS limit and GAS price should be attached to it. This two parameters define the maximum fee that transaction creator will pay for his transaction to be computed on the Ethereum blockchain. If the amount of GAS attached to the transaction is not enough to complete the transaction the transaction will not be performed with the error ‘run out of gas’. The amount of GAS that was already spent for computations is not returned.

So, GAS limits the number of computations performed by the EVM and transaction created should be attached to the gas limit to it which will be enough to complete the transaction.

Like many other virtual machines the EVM operates with instructions (data manipulation rules) written in it’s own language called ‘EVM bytecode’. You don’t have to write programs directly on this language but you can rather use a high level language which is then translated (compiled) to EVM bytecode. The most popular high level language is Solidity.

State machine

In computer science a state machine refers to a machine that is able to read a series of inputs and, based on those inputs, transaction to a new state. Ethereum’s state machine functions exactly like this.

The EVM is also responsible for handling internal state and computation on the Ethereum blockchain. The machine must also handle account information, addresses, balances, current gas price, and block information. The EVM must keep track of the status of numerous components in order to successfully support a transaction.

In the following weeks, I will share with you technological insights into the blockchain world. Stay tuned to learn more.

--

--