Ethereum Developer Ethereum Virtual Machine (EVM) and Gas Optimization 1 ā Questions and Answers
Question 1: What is the primary function of the Ethereum Virtual Machine (EVM)?
- To mine new Ether blocks
- To execute smart contract bytecode in a sandboxed environment (Correct answer)
- To manage peer-to-peer network connections
- To store transaction history on disk
Correct answer: To execute smart contract bytecode in a sandboxed environment
The EVM executes smart contract bytecode in an isolated, deterministic sandboxed environment across all Ethereum nodes.
Question 2: What is the native word size of the Ethereum Virtual Machine?
- 32 bits
- 64 bits
- 128 bits
- 256 bits (Correct answer)
Correct answer: 256 bits
The EVM uses a 256-bit word size, aligning with Ethereum's 256-bit cryptographic hash functions (keccak256).
Question 3: Which of the following is NOT a valid data location in the EVM?
- Stack
- Memory
- Cache (Correct answer)
- Storage
Correct answer: Cache
The EVM has four data locationsāstack, memory, storage, and calldataācache does not exist as a distinct EVM data location.
Question 4: What does the EVM opcode SSTORE do?
- Loads a value from storage onto the stack
- Writes a value from the stack into persistent contract storage (Correct answer)
- Stores a value in transient memory
- Stops execution and returns output data
Correct answer: Writes a value from the stack into persistent contract storage
SSTORE pops a key and value from the stack and writes the 32-byte value into the contract's persistent storage at that key.
Question 5: What is Ethereum bytecode?
- Human-readable Solidity source code
- The ABI specification of a contract
- Low-level instructions executed directly by the EVM (Correct answer)
- A JSON encoding of contract events
Correct answer: Low-level instructions executed directly by the EVM
Bytecode is the compiled, low-level instruction set that the EVM directly interprets and executes during transactions.
Question 6: What is the maximum stack depth of the EVM?
- 512 items
- 1024 items (Correct answer)
- 2048 items
- 4096 items
Correct answer: 1024 items
The EVM stack has a maximum depth of 1024 items; exceeding this limit causes a stack overflow and reverts execution.
Question 7: What is the key difference between CALL and DELEGATECALL opcodes?
- CALL is cheaper than DELEGATECALL
- DELEGATECALL executes the target's code in the caller's storage context (Correct answer)
- DELEGATECALL transfers Ether while CALL does not
- CALL preserves msg.sender while DELEGATECALL does not
Correct answer: DELEGATECALL executes the target's code in the caller's storage context
DELEGATECALL runs the target contract's code but uses the calling contract's storage, msg.sender, and msg.value, which is fundamental to proxy patterns.
What is the primary function of the Ethereum Virtual Machine (EVM)?