* How do EVMs work?
Ethereum developers write the smart contract code in a programming language called Solidity. The code is then converted into bytecode so that the EVM can read the instructions.
In the process of converting code from Solidity to bytecode, the instructions are first broken down into 'opcodes' or opcodes: each line of code is converted into an opcode so that EVM knows exactly how to execute the transaction.
As you know, every transaction on Ethereum requires a gas charge to execute. Therefore, the relationship between opcodes and gas prices is also important for understanding how EVMs work.
In theory, when you pay for gas, you are actually paying for the opcodes that EVMs execute. The more opcodes there are, the higher the gas price.
* Key features of EVMs
Turing-complete virtual machine
EVMs are designed as Turing-complete virtual machines. Turing completeness refers to a machine that can solve any problem given the necessary resources of time, energy and complete instructions.
Turing completeness in Ethereum is the network's ability to understand and enforce future agreements for smart contracts.
Deterministic code execution
EVMs execute code deterministically. A given smart contract will always produce the same output for the same input. Regardless of where the smart contract is executed or who executes it, the output is always consistent for a given input.
Isolation.
EVMs are designed to operate in isolation from other computer systems. This allows smart contracts to operate in a secure environment.
* EVM architecture
EVM code: Byte code that EVMs can execute.
State: ethereum is a large data structure that holds information about accounts and balances; the state of this information changes from block to block as EVMs process new inputs and produce deterministic outputs.
Transaction: a transaction is a cryptographically signed instruction from the user that is executed by the EVM. There are two types of instructions:
Message calls are simple transaction instructions used to send ETH from one account to another.
Contract creation is an instruction to create a new smart contract.
Field: EVMs use three field components
Stack - temporary storage with a capacity of up to 1024 items. All operations are performed on the heap.
Memory - temporary storage that can only be accessed during the execution of a smart contract. Once the execution of the contract is complete, its contents are destroyed.
Storage - permanent memory that cannot be lost because the data is stored on the Ethereum blockchain. Compared to heaps and memory, storage memory is more expensive to use in terms of gas.
Gas - the amount of computation required to perform transactions on the blockchain network; all EVM calculations require a gas fee, otherwise transactions will not be processed.
* Conclusion
EVM software is the lifeblood of Ethereum, maintaining the state of the blockchain and executing smart contracts.
Due to Ethereum's rapid growth, EVM has become an industry standard, so much so that competing blockchain networks have designed systems compatible with EVM.