DEV Community

Cover image for Ethereum and The EVM
Kinanee Samson
Kinanee Samson

Posted on

Ethereum and The EVM

Ethereum, a project that attempts to build a generalized technology which will serve as the base upon which a transaction-based state machine may be built on. Ethereum also aims to provide developers with a tightly integrated end-to-end system for building software on a trusfull unexplored compute instance on the the network. Ethereum was created as a result of the need to facilitate a protocol for exchanging value with trustless parties who would otherwise rather not do business with each other.

There are so much short comings of traditional finance especially when it comes to the issue of trust and identification. Ethereum values trust and as such transactions occuring on the nework are 100% transparent, a key feature lacking in traditional finance. Despite the transperent nature of ethereum it does not sacirifice the privacy of the participants as you are still anonymous when iteracting with the Ethereum network because you can only be identified with your public & private key pair, which is not really tied to your personality or data.

In this Article we are going to exploring the transaction-based state machine that powers the Ethereum network. This machine is called the Ethereum Virtual Machine (EVM).

What Is the EVM

From our introductory discussion you will agree with me that the Ethereum protocol is reponsible for keeping track of all the transactions that occur on the protocol, a feature of Ethereum, just like other blockchains is immutability. The state of the blockchain cannot be reverted or modified in any way because Ethereum as a blockchain protocol can only exist in one state.

The Ethereum Protocol is also devoted to ensuring that the transaction-based state machine is always operational, of course the blockchain can only be in one state, however it is the job of the state machine or the EVM to define the rules that governs how new blocks are added to the blockchain, in other words it is the EVM that transitions the blockchain from one valid state to another.

To fully understand how the EVM works, we need to take peek at the parent of all blockchains; bitcoin. Bitcoin is similar to Ethereum and infact as we all know, it is a pioneer in blockchain technology. You will often hear people use the term distributed ledger to describe bitcoin's blockchain and other blockchains. This is correct, because bitcoin is just a network of distributed ledger system, essentially a bitcoin node (just a computer) retains a copy of the ledger (blockchain) and a node can mine or add new blocks to the ledger. Now let's see how Ethereum differs slightly from this, In Ethereum, there is a distributed Ledger however every Ethereum node runs a large data structure which holds not only all accounts and balances, but a state machine, which can change from block to block according to a pre-defined set of rules, and can execute arbitrary machine code. The rules that govern state change from block to block are defined by this state machine.

The EVM in practice is turing complete machine and comes baked with stack machine, that can store 1024 items, each item inside the stack is a 256 bit word, this is because of the ease use with cryptographic hashing algorithim. A stack machine is a data structure that is used to store and access data in a last-in-first-out format. Every stack data structure is restricited to a max number of items the stack can contain and in the EVMs case, it is 1024.

What we mean when we say the EVM is turing a turing comple machine we are describing a system that can exists in an infinte number of states, thereby allowing the system to take any particular form depending on the state it is currently in. This also allows the EVM to change state depending on the input supplied to it.

When in execution the EVM will maintain a transient memory which does not persist between transactions. This memory is a temporary storage location where some data structures and objects from our code are stored during a transaction execution. Each time a transaction is logged on the Ethereum network unlike in bitcoin where a transaction fee is charged on the transaction, in Ethereum a gas fee instead is charged for the transaction.
Bitcoin charges a transaction fee to incentivise minners to validate your transaction and attach it to a block, the underlying concept is quite similar to how Ethereum works, however Ethereum charges a gas fee to pay for the computing power and resources neccesary to run the code that initiates the transaction. The difference lies here; in bitcoins the minners only validate a submited request by directly changing the state of the blockchain, but in Ethereum minners are providing computing power so that the EVM will validate and process rules that will govern how the state of the blockchain will be changed.

The concept of gas in Ethereum is a topic that deserves it's own separate article, but we have gotten a high level look at what gas is in Ethereum, i hope that in the future do an article to discuss this. However you should know that gas exists because with computer code things can easily get of out hand if not managed properly, we need to prevent a particular transaction from running for perpetuality for instance say an endless loop, once the gas for a particular transaction is used up, the transaction is halted immediately with an out of gas exception. If the operation for which the gas was charged failed to have the desired impact on the state of the blockchain the gas fee for the operation will still be paid. This is to deter malicious actors from continually submitting fraudulent or invalid transactions. The gas fee is usually paid in the native currency of Ethereum, Ether.

Transactions on Ethereum

Transactions are the heart of state changes to the blockchain, in Ethereum a transaction can occur only between Ethereum Addresses. An Ethereum address is a public key that is mathimatically linked to another key; the private key. They can both be used for encrypting, signing and validating information on the blockchain. An Ethereum address can initaite a only transaction between itself and another Ethereum address. You should know that in Ethereum there are two types of address, human address and smart contract address, but let's stop here for today.

That's it for this article, in our next article we are going to be looking Ethereum Address and The concept of gas on Ethereum, i hope you enjoyed this article and you learnt something from it.

Top comments (0)