decrypt101
SocialOpen ProjectsSupport me My Resumes
  • Preface
    • Motivation
    • Roadmap’s
  • Introduction to Blockchain
    • A Brief History
    • Growth of Blockchain
    • Structure of Blockchain
    • Types of Blockchain
    • Key Technologies of Blockchain
    • Features of Blockchain
    • How Blockchain Works ?
    • Implementation of Blockchain
    • Summary
  • Components of Blockchain Architecture
    • Distributed Ledger
    • Blocks
    • Transaction
    • Chain
    • Peer-to-Peer Network
    • Blockchain Layers
    • Off-Chain & On-Chain
    • Wallet
    • Mining
    • Tokens
    • Assets
    • State Channels
    • Sidechains
    • Oracles on Blockchain
    • Atomic Swaps
    • Decentralized Identity (DID)
    • Blockchain Data Storage
    • Interoperability
    • Data structures for Scaling Blockchain
    • Maximal Extractable Value (MEV)
  • Consensus Mechanisms
    • Proof of Work (PoW)
      • Implemation Using Rust
    • Proof of Stake (PoS)
    • Proof of Burn (PoB)
    • Proof of Capacity (PoC)
    • Proof of Activity (PoAc)
    • Proof of Weight (PoWe)
    • Proof of Luck (PoL)
    • Proof of Ownership (PoO)
    • Proof of Existence (PoE)
    • Proof of Believability (PoBe)
    • Proof of History (PoH)
    • Proof of Authority (PoA)
    • Proof of Elapsed Time (PoET)
  • Cryptographics
    • Encryption & Decryption
      • Symmetric Encryption
      • Asymmetric Encryption
      • Key Management and Exchange
      • Implementation
    • Cryptographic Hashing
      • Secure Hash Algorithms (SHA)
      • Message Digest Algorithms
      • Ethash
      • Blake2
      • SCrypt
      • RIPEMD-160
    • Digital Signature
      • Digital Signature Algorithms
      • Digital Signature in Blockchain
    • Zero-Knowledge Proofs (ZKPs)
      • Types of Zero-Knowledge Proof and Protocols
      • A Case Study of Polygon Platform
    • Multi-Party Computation (MPC)
    • Cryptanalysis
    • Practical Implementation
  • Decentralized Application (DApp)
    • Design and UX in Web3
  • Smart Contract
    • Development Tools
    • Solidity
    • Testing Smart Contract
    • Developing Smart Contract
    • Interacting & Deploying with Smart Contract
    • Verifying Smart Contracts
    • Upgrading Smart Contracts
    • Securing Smart Contract
    • Smart Contract Composability
    • Testnet and Mainnet
    • Blockchain Platform Using Smart Contract
    • Application of Smart Contract
    • Practical Implementation
  • Blockchain Platforms
    • Ethereum
      • Ethereum Virtual Machine (EVM)
      • ETHER and GAS
      • Ethereum transaction
      • Ethereum Accounts
      • Ethereum Stacking
      • Ethereum Network
      • Ethereum Scaling Solutions
      • Ethereum Use-Cases
      • Getting Started with Ethereum
      • Ethereum Ecosystem and Support
    • Solana
      • Solana Architecture
        • Solana Account Model
        • Solana Wallet
        • Transactions and Instructions
        • Solana Programs
        • Program Derived Address (PDA)
        • Cross Program Invocation (CPI)
        • Tokens on Solana
        • Clusters and Public RPC Endpoints
        • Transaction Confirmation & Expiration
        • Retrying Transactions
        • Versioned Transactions
        • Address Lookup Tables
        • State Compression
        • Actions and Blinks
      • Solana Developments
      • Solana Client
      • Advanced Solana
      • Solana Scaling and Performance Architecture
      • Solana Solutions and cases
      • Practical Implemenation
    • Binance Smart Chain (BSC)
      • Create a BEP20 Token
    • Hyperledger Fabric
    • Cosmos
    • Polkadot
    • Quorum
    • Polygon
    • Algorand
    • Corda
    • Avalanche
    • TRON
    • Summary
  • Decentralized Finance (DeFi)
    • DeFi Components
    • DeFi Protocols
    • DeFi Platforms
    • DeFi Risk Classification
      • Infrastructure-layer Attacks
      • Smart Contract Layer-attacks
      • Application Layer-attacks
      • DeFi Risks
    • DeFi and Blockchain
    • DeFi Impact
  • Decentralized Ecosystem and Digital Innovation
    • Layer 2 Scaling Fundamental
    • Tokenomics
    • Cryptocurrency
    • Quantative Trading
    • NFTs
    • GameFi
    • Metaverse
  • Blockchain as a Service (BaaS)
    • Building Fullstack Blockchain Platform
    • Decentralized Digital Identity
    • Build a Cryptocurrencies Exchange
    • Play-to-Earn Gaming
    • Solana Token Airdrop Manager
    • Smart Contract Development on Solana with Rust
    • Quantitative Trading Platform
    • Insurances protocols
    • Flash Loans
    • Asset Management
    • Tokenized Derivatives
    • Automated Market Makers (AMMs)
    • Staking
    • Lending and Borrowing Platforms
    • Yield Farming
    • Stablecoin System
    • Security Token Offerings (STOs)
    • Initial Coin Offerings (ICOs)
    • On-Chain Voting Systems
    • Decentralized Autonomous Organizations (DAOs)
    • NFT Marketplaces
    • Provenance Verification
    • Supply Chain Tracking
    • Commodities Tokenization
    • Real Estate Tokenization
    • Digital Certificates
    • KYC (Know Your Customer)
  • Blockchain Development Across Languages
    • Blockchain using Go(Golang)
    • Blockchain using Rust
    • Blockchain using Python
    • Blockchain using Cairo
  • Distributed Systems & Infrastructure Technology
    • Classification of Distributed Systems
    • Networked systems versus Distributed systems
    • Parallel systems vs Distributed systems
    • Distributed versus Decentralized systems
    • Processes of Distributed Systems
    • Architecture of Distributed systems
    • Infrastructure Technologies
  • Distributed System Patterns
    • Distributed Agreements Algorithms
      • HoneyBadgerBFT
    • Data Replications
    • Data Partition
    • Consistency
    • Distributed Time
    • Cluster Management
    • Communication between Nodes
    • Fault Tolerance and Resilience
      • How to design better fault tolerance systems
      • Resilience Patterns
    • Coordination systems
      • Clock synchronization
    • Security
      • Trust in distributed systems
      • Design of Principal Security
      • Security threats, policies, and mechanisms
      • Authentication and Authorizations
      • Cryptography
      • Monitoring in Security
  • Distributed System Design
    • Page 1
    • Distributed Shared Memory
    • Distributed Data Management
    • Distributed Knowledge Management
    • Distributed Ledger
  • FAQs
  • Support and Community
Powered by GitBook
On this page
  • Core Functions of the EVM
  • How Does the EVM Work?
  • Gas and Fees
  • Deterministic Nature
  • EVM Compatibility
  • Smart Contract Lifecycle in EVM
  • OpCodes
  • Security and Isolation
  • Upgradeability
  • Challenges and Limitations of EVM
  1. Blockchain Platforms
  2. Ethereum

Ethereum Virtual Machine (EVM)

EVM is the runtime environment for smart contracts. Ethereum supports multiple scripting languages for writing smart contracts. These smart contracts are then compiled and converted into EVM bytecodes. Bytecodes are then executed by EVM to perform operations on smart contracts.

The EVM is essentially a virtual machine that operates as a global decentralized computer. It enables the execution of smart contracts and the management of Ethereum’s state (account balances, transaction history, and contract data).

It isolates and executes smart contracts, ensuring that they run deterministically (i.e., the same input will always yield the same output), regardless of the environment or node running them.

Core Functions of the EVM

Smart Contract Execution: The EVM processes smart contracts, ensuring they are executed according to predefined rules.

State Management: Ethereum’s state (accounts, balances, storage) is maintained and updated by the EVM during each transaction.

Gas Usage: The EVM ensures that the execution of contracts is resource-efficient by measuring “gas” — a unit of computational effort. Each instruction that runs on the EVM consumes a specific amount of gas, and users pay for that gas in Ether (ETH).

How Does the EVM Work?

Bytecode Execution: Smart contracts on Ethereum are written in high-level languages like Solidity or Vyper, which are compiled down to EVM bytecode. The EVM interprets and executes this bytecode.

Stack-Based Architecture: The EVM operates as a stack machine, where operations are executed based on a last-in, first-out (LIFO) stack. Each contract has its own stack, with a maximum depth of 1024 elements.

Storage and Memory: The EVM has two forms of data storage:

  • Persistent Storage: Data stored on the blockchain that persists across transactions and is tied to smart contracts.

  • Memory: Temporary storage that is only available during the execution of a transaction and gets cleared afterward.

Gas and Fees

Gas is the unit that measures the amount of computational work required to execute operations, including contract execution and transactions.

Users pay for gas in Ether (ETH). The more complex a contract, the higher the gas cost. This ensures that resources are not overused and prevents infinite loops from clogging the network.

Deterministic Nature

One of the key features of the EVM is its deterministic execution. This means that, given the same transaction and starting conditions, the EVM will always produce the same result, regardless of where or when the transaction is processed.

EVM Compatibility

The EVM is not only used by Ethereum but also by other blockchains that are EVM-compatible, such as Binance Smart Chain (BSC), Polygon, Avalanche, and Fantom. These blockchains use the same EVM architecture, which allows developers to port their Ethereum-based applications to these chains easily.

EVM-Compatible Chains: Developers can deploy their Ethereum dApps or smart contracts on any EVM-compatible chain without needing to rewrite the code, making the EVM a widely accepted standard.

Smart Contract Lifecycle in EVM

Deployment: Smart contracts are first compiled into EVM bytecode and deployed onto the Ethereum network. When deployed, they receive a unique contract address.

Invocation: Once deployed, users or other contracts can interact with the contract through transactions. These interactions are processed by the EVM, which then updates the contract’s state based on the rules in its code.

Execution: The EVM processes the instructions within the contract, consuming gas for each operation. Execution can modify the contract’s state, send ETH, or interact with other contracts.

OpCodes

The EVM uses OpCodes, low-level instructions that the virtual machine processes. These operations include mathematical calculations, data storage/retrieval, control flow (e.g., loops and conditionals), and interactions with accounts or other contracts.

Every opcode has a specific gas cost. For example, adding two numbers may have a low gas cost, while more complex operations, like interacting with other contracts, may have a higher gas cost.

Security and Isolation

The EVM operates in an isolated environment. This means smart contracts cannot interact with the external world directly (no network, file system, or system-level access), which enhances security. Any interaction with the external world has to go through transactions.

This isolation ensures that the execution of smart contracts remains secure and minimizes the risk of malicious code affecting the network.

Upgradeability

The EVM is designed to be backward-compatible, meaning new versions of Ethereum and protocol upgrades do not break existing smart contracts.

Ethereum 2.0 and Beyond: With Ethereum’s transition to Ethereum 2.0 (Proof of Stake), the EVM remains central to the execution of smart contracts. It is likely to see further optimizations to improve scalability and performance.

Challenges and Limitations of EVM

  • Scalability: The EVM is not inherently scalable, which is why Ethereum has faced congestion issues. Solutions like Layer 2 (e.g., Optimistic Rollups, zk-Rollups) aim to alleviate these problems.

  • Gas Fees: High gas fees have been a recurring issue on Ethereum, making transactions expensive during network congestion.

  • Complexity Limits: The EVM is designed to handle a wide range of computations, but some complex algorithms can be expensive to execute in terms of gas.

The Ethereum Virtual Machine (EVM) is a crucial component of Ethereum and other blockchains, providing a robust, decentralized environment for running smart contracts and dApps. Its compatibility across various chains, gas mechanism for resource management, and deterministic nature make it an essential platform for decentralized applications and blockchain innovation.

PreviousEthereumNextETHER and GAS

Last updated 8 months ago