Ethereum Virtual Machine (EVM)
The Ethereum protocol is the environment in which all Ethereum accounts and smart contracts live, and it exists exclusively to ensure the continuous, uninterrupted, and immutable operation of this particular state machine. Ethereum has one and only one 'canonical' state at any given block in the chain, and the EVM is what establishes the rules for computing a new valid state from block to block.
The EVM's job is to add a few new features to the Blockchain so that consumers have fewer problems with the distributed ledger. The EVM is used by every Ethereum node to maintain blockchain consensus.
Requirements
Some basic familiarity with common terminology in computer science such as bytes, memory, and a stack is necessary to understand the EVM. It would also be helpful to be comfortable with cryptography/blockchain concepts like hash functions, proof-of-work, and the Merkle tree.
Distributed Ledger
Blockchains like Bitcoin, which utilize core cryptographic tools to enable a decentralized currency, are frequently referred to as a "distributed ledger." Because of the rules that control what can and cannot be done to edit the ledger, a cryptocurrency operates like a 'regular' currency. A Bitcoin address, for example, cannot spend more Bitcoin than it has received. All transactions on Bitcoin and many other blockchains are governed by these rules.
While Ethereum's native cryptocurrency (Ether) follows nearly the same basic rules as Bitcoin, it also allows for a far more powerful function: smart contracts. A more elaborate analogy is necessary for this more complex feature. Ethereum is a distributed state machine rather than a distributed ledger.
The state of Ethereum is a massive data structure that contains not only all accounts and balances but also a machine state that can change from block to block according to a set of rules and run arbitrary machine code. The EVM specifies the rules for altering the state from one block to the next.
EVM FUNCTION, STATE, AND TRANSITION
The EVM behaves as a mathematical function would: Given an input, it produces a deterministic output. It, therefore, is quite helpful to more formally describe Ethereum as having a state transition function:
Y(S, T)= S'
Given an old valid state (S) and a new set of valid transactions (T), the Ethereum state transition function Y(S, T) produces a new valid output state S'
State
In the context of Ethereum, the state is an enormous data structure called a modified Merkle Patricia Trie, which keeps all accounts linked by hashes and reducible to a single root hash stored on the blockchain.
Transactions
Accounts issue cryptographically signed instructions in the form of transactions. Transactions fall into two categories: those that result in message calls and those that result in contract generation.
When you create a contract, you get a new contract account with built smart contract bytecode. When another account sends a message to that contract, the bytecode is executed.
EVM INSTRUCTIONS
The EVM is a stack machine with a depth of 1024 items. Each item is a 256-bit word, which was chosen for ease of use. The EVM maintains a transient memory (as a word-addressed byte array), which does not persist between transactions.