If you are into crypto space for a period of time, you might be aware of Ethereum Blockchain. Ethereum was created with an aim to provide a decentralized ecosystem for coders to design amazing applications using solidity coding language and EVM. Ethereum Blockchain is a dedicated network for developing smart contracts (digital agreements for automated execution of transactions). These smart contracts (one of the Ethereum applications) are successfully executed with the help of ETH Virtual Machines (EVM). These machines create a level of abstraction between the execution code and the execution machine. The layer of EVM is required to enhance the portability of software along with separating the applications from each other and also from their host. This article is primarily an “Ethereum Virtual Machine Tutorial” which will brief you about the EVM and related concepts.
Ethereum Virtual Machine or EVM is a sandboxed virtual implicit encompassed within each complete Ethereum node that has the potential to perform contract bytecode. Each and every node in the network of Ethereum works on EVM which permits them to agree on implementing the same executions. Smart contracts or simply contracts are generally imbibed in a higher-level coding language like Solidity and then congregated to EVM bytecode or programming language of EVM. This process ensures that the machine code is completely enclosed from the network, filesystem or any other process of the host computer.
EVM is needed for the Ethereum Protocol and is mandatory for the consensus generator of the Ethereum system. It allows everyone to acquire code in a trustless ecosystem confirming the result of the execution, thereby being completely deterministic in administering smart contracts. Thus, EVM is one of the significant components of the Ethereum construction as it manages the internal state and computation on the network. Also, it handles the account information consisting of addresses, balances, current gas price and information of Block.
The Ethereum network is completely decentralised so there is no central authority for the execution of smart contracts, thereby the contract is executed on all the Ethereum nodes. So, to maintain the security and network free of congestion, every operational code has transaction fees or base GAS cost. For the implementation of every instruction on the EVM, a user has to reserve some quantity of Ether in exchange for GAS for the execution of code. Thus, GAS is a token which is used for executing the transaction on EVM. The main purpose of issuing the GAS token is to guarantee the validator of the initial pre-paid amount (if the execution fails!) and limiting the work required for operation.
GAS actually serves as the tool to measure the fees for the execution code consisting of GAS limit which is the maximum amount a person can spend to buy GAS and GAS price that is the amount of Ether which an individual has to pay for each unit of GAS. So, both the GAS limit and price must be set beforehand of the execution. The price paid in terms of ETH coins is utilised to reward the miners for securing the Ethereum Blockchain rather than storing in any ethereum wallet or assistance provider.
Ethereum Virtual Machine or EVM is meant to handle the internal state of the Ethereum Blockchain network by tracking the status of numerous components to support the successful completion of the transaction. Ethereum is described as the transaction-based state machine as the state of components drives the level of change in the Blockchain network. The components which have been tracked by Ethereum Virtual Machine architecture are Account State, World State, Storage Sate, Block Information and Runtime Environment Information.
Ethereum consists of a number of small accounts that can capably interact with each other. There are two types of accounts, externally owned which have no code related to them and controlled by private keys and contract accounts which are based on codes and controlled by that code only. An externally owned account can send messages to both types of accounts with the help of digitally signing transactions using a private key. While the contract accounts can only interact with transactions serving as a response to other transactions which have been received either from externally controlled or contract accounts.
The World State of Ethereum consists of a mapping of 160-bit address identifiers and account state. The information related to mapping is maintained in a data structure called the Merkle Patrica Tree consisting of leaf nodes (housing underlying data), intermediate nodes and a single root hash.
Storage State is the information of a specific account which is maintained at runtime on the Ethereum Virtual Machine.
To support any transaction on Ethereum network, there are the state values or Block information tracked by Ethereum Virtual Machine. Block information consists of:
The information of execution of the transaction is tracked using runtime environment state which includes GAS price, codesize, caller or the address of account initiating execution and origin of the sender.
While wrapping up this Ethereum Virtual Machine Tutorial, it can be advocated that the EVM plays an important role in the execution of transactions associated with smart contracts on Ethereum Blockchain. You can have the related coding information form EVM Github.