EVM Internals: Solidity, Bytecode, Memory, and Storage

Added:

EVM Basics
Opcode Guide
Deployment Code
Function Dispatch
Return Logic
Payable Logic
Storage Packing
Byte Arrays
Complex Types
Metadata Use

EVM Basics

2:02
Playing Section
  • 1

    Introduces EVM execution and Solidity compilation to bytecode.

  • 2

    Covers transaction structure including gas, data, and signatures.

  • 3

    Details stack, memory, storage, and code as key EVM data locations.

Basic proficiency in Solidity smart contract development, including contract structure, variables, and functions.
Fundamental understanding of the Ethereum blockchain network, including gas fees, state, and transaction execution.
Core computer architecture concepts, specifically stack-based virtual machines, memory allocation (stack vs. heap), and instruction pointers.
Familiarity with data representations such as hexadecimal, bytes, and basic cryptographic hashing (Keccak-256).
Advanced smart contract gas optimization, analyzing specific opcode execution costs to minimize transaction fees.
Writing and understanding Yul (Solidity's intermediate representation) and inline assembly for low-level contract control.
Smart contract security auditing and vulnerability exploitation, using bytecode analysis to identify deep-seated attack vectors.
Developing custom EVM tooling, such as disassemblers, decompilers, or custom local execution clients.
Exploring alternative and advanced execution environments, such as zkEVMs (Zero-Knowledge Ethereum Virtual Machines) and Layer 2 rollups.
54.7K views1.6Klikes1:30:40@EthereumEngineeringGroupOriginal Release: 2020-06-10

The Ethereum Virtual Machine (EVM) executes Solidity smart contracts using a stack-based architecture with five primary data locations: the stack (temporary, non-persistent), call data (read-only transaction parameters), memory (temporary scratch pad), storage (persistent world state), and code (static data and executable bytecode). Contracts deploy using transactions with empty 'to' addresses, where the data field contains initialization code that sets up initial state before returning the runtime code to be stored on the blockchain. Function calls use function selectors (truncated keccak-256 hashes of signatures) to route execution to appropriate handlers, with the EVM providing opcodes for arithmetic operations, stack manipulation, memory allocation, and storage access. Storage packing optimizes space by combining small variables into 32-byte words, while dynamic arrays and mappings use keccak-256 hashing to calculate storage locations. Memory expansion costs gas, incentivizing efficient data structure design.