The EVM Simplified Series :

EVM Simplified Series Part 2:

Table of contents

No heading

No headings in the article.

Picking off from where we stopped in our last series we are going to be discussing an interesting subject in a simplified manner. I’d recommend you read the part 1 before hopping over this one as it will give you an in-depth understanding on the subject of discussion.

In this article, I’m going to be going down the rabbit hole as the image above depicts as I explain the stack, storage and memory components of the EVM.

— The Architectural Design of the EVM

The EVM has a stack-based architecture and this means that data is stored using a stack data structure. It works like a stack of items, where you can add things on top and take them off as needed and it also follows a specific set of instructions by adding values, performing operations on them, and then taking out the results from the stack. It operates on a LIFO data structure which stands for “Last-In, First-Out”. In this type of Data Structure, the last item added to the structure is the first item to be removed.

In a LIFO stack, the latest items are placed on the top of the stack, and they are also the first ones to be removed from the top, so whenever anyone wants to access information inside the stack, they first take away the most recently added item to be able to access the data being sought for. Imagine a scenario where there is a stack of plates on a table. When a new plate is added to the stack, it is placed on the top of the existing stack. When the need arises to remove a plate from the stack, the one situated at the top will definitely be the first to be removed. The EVM stack has a maximum size of 1024 items and this simply means that one can only have up to 1024 items stored on the stack at any time during the execution of a smart contract. Also each item on the stack has a fixed size of 32 bytes which also means that each data stored in the EVM, occupies 32 bytes of memory. The EVM stack has several instructions that can be used to manipulate the data on the stack. They are:

PUSH: It involves adding a new item to the top of the stack.

POP: It involves removing and retrieving the top most item from the stack.

ADD, DIV, SUB, MUL, and MOD carry out arithmetic operations using the top two items on the stack. These instructions manipulate the values on the stack to perform addition, division, subtraction, multiplication, and modulo operations, respectively, etc.

Before we wrap up this series let’s look briefly at :

— THE EVM STORAGE

The Storage is an essential component of the Ethereum Virtual Machine (EVM) that allows smart contracts to store data permanently.

— THE MEMORY

The EVM contains a memory component that provides a temporary storage space for data while executing smart contracts.

Gotta run along now.. I hope you really enjoy reading through this most Basic information.

See you in the next series where I still discuss the EVM and dive in a little into Gas.

Thanks for reading.

Follow me on Twitter