Web3 Chinese | What is the Ethereum Virtual Machine (EVM) and how does it work?

Source | cointelegraph

Compile | [email protected]

Ethereum has become the second most important blockchain after Bitcoin. Ethereum can develop so well, its native Solidity programming language and Ethereum Virtual Machine (EVM) have played an important role.

The Ethereum blockchain continues to attract decentralized application (DApp) developers due to its flexibility, large number of available development tools, and large user base.

As the core of the blockchain architecture, the EVM is a program that executes Ethereum application code or smart contracts and provides them with an environment to run on the Ethereum network.

In addition, EVM is Turing-complete (all computable problems can be calculated, such a virtual machine or programming language is called Turing-complete), so in theory, it can run all programs written in programming language, so that Developers can easily create custom smart contracts and DApps.

In addition to these, EVM can also access all nodes in the network, handle the execution of smart contracts, and efficiently manage all transactions on the Ethereum blockchain, which also makes it one of the most powerful virtual machines in the world today.

What is the Ethereum Virtual Machine (EVM) and how does it work?

The concept of the Ethereum network was proposed by programmer Vitalik Buterin in 2013.

As the blockchain of choice for DApp developers, Ethereum’s success rests on the Ethereum Virtual Machine (EVM) designed by Gavin Wood during his tenure at Ethereum.

EVM is written in C++ and uses the LLVM project compiler (LLVM is the framework system of the architecture compiler, which is used to optimize the compile time, link time, run time and idle time of programs written in any programming language), it is a continuous running A special state machine that determines the state of each block in the Ethereum blockchain.

EVM not only manages the scope of operation of nodes on distributed ledgers, but also defines specific rules for changing states between different blocks. The latter functionality is fundamental to the successful functioning of Ethereum smart contracts.

To understand what the Ethereum Virtual Machine does, you need to know what it does to keep the Ethereum network running smoothly.

For every input received, the EVM produces an output that is deterministic in nature.

The EVM operates like a stack machine that pushes and pushes transient values ​​onto and off the push-down stack, which is 1024 entries deep and each entry is a 256-bit word.

Additionally, it maintains temporary memory in the form of byte arrays. Compiled smart contract code is executed by the EVM in the form of a set of 140 standard opcodes, and other blockchain-specific stack operations are also implemented by it.

Therefore, the EVM has an inherently unstable machine state in the process of processing transactions, and at the same time it has a global or world state to accommodate different account information on the Ethereum blockchain.

All operations on Ethereum are managed by the EVM code. Since the launch of the Ethereum network in 2015, the EVM code itself has undergone many iterations, which also makes there are currently a variety of EVM implementation tools.

The EVM is responsible for maintaining an abstraction level between thousands of Ethereum nodes and executing code, as well as delivering consistent information without leaking too many details to clients or nodes.

What is the purpose of the Ethereum Virtual Machine (EVM)?

The EVM has been reliably powering all applications on Ethereum.

For developers, the EVM is the primary program for running smaller executable programs (called smart contracts in Ethereum), while providing them with various programming languages ​​​​(such as Solidity, Vyper, Python, Yul, etc.) The freedom to write these smart contracts.

Due to this flexibility provided by the EVM, the Ethereum blockchain has spawned thousands of DApps in the DeFi and NFT space.

Every DApp and the smart contracts that make up them are converted into bytecodes, which are transmitted to the EVM and distributed among all nodes of the Ethereum network.

When deploying a smart contract, the EVM is responsible for contacting all nodes and making state changes after consensus is reached.

It can be said that it is because of EVM that Ethereum can use bytecode instead of basic programming language to execute smart contracts, so that the physical host can be distinguished from the machine code running on Ethereum.

Benefits of the Ethereum Virtual Machine (EVM)

The way the EVM works removes some concerns for developers executing code — without affecting the rest of the network or affecting data or personal files hosted on arbitrary nodes.

Additionally, developers can run complex smart contracts across different computing environments with distributed consensus.

This ensures that the failure of a single node will not have any negative impact on the overall operation of the DApp or smart contract, as the EVM code is the same on all nodes.

Not only that, because account data maintains a global state in the EVM, which creates good conditions for developers to write custom smart contract code and create unique DApps that can access global data sets and produce reliable outputs.

Generally speaking, the Ethereum blockchain is very suitable for the sustainable expansion of DApps and smart contracts.

In addition to the above mentioned, EVM also has a standard code base for developers to choose from, a growing number of layer 2 blockchains that are compatible with it, and a large number of potential EVM use cases, which is why EVM is the platform of choice for Web3 development .

Disadvantages of the Ethereum Virtual Machine (EVM)

But EVM is not perfect. Developers and entrepreneurs who plan to develop projects on Ethereum also need to understand the shortcomings of EVM, such as high transaction fees or Gas costs.

These fees need to be paid by users through ETH and will vary according to the complexity of the smart contract and the current network congestion, which requires developers and entrepreneurs to price the service accordingly.

In addition, Solidity is the most popular coding language on the EVM, which means that developers need to have sufficient experience and certain technical expertise to create efficient smart contracts using Solidity.

This is important because any additional computing requirements will result in higher Gsa costs, which is detrimental to the success of the project.

If a developer chooses to code in another language, then they need to seriously address any inherent duplication in the code.

The future of EVMs

The EVM has revolutionized the blockchain ecosystem, but many blockchain projects are also improving this technology for reading and executing code.

Cross-chain interoperability is of paramount importance to developers, and many EVM-compatible blockchains have been developed, most of which offer lower fees and faster transaction speeds than Ethereum.

Ethereum users can seamlessly interact directly with these blockchains and transfer funds on Ethereum to these blockchains through cross-chain bridges.

It must also be mentioned that with the completion of the merger in September 2022, the next goal of Ethereum is to complete the paradigm shift from EVM to Ethereum WebAssembly (eWASM).

Ethereum aims to build eWASM into a highly modular and platform-independent virtual instruction set architecture.

Many are touting eWASM as the next game-changer for Ethereum and think it may be used by other blockchains.

However, can eWASM replace EVM as the most trusted smart contract mechanism? This question may only be answered by time.

Disclaimer: web3 compiles works in Chinese, the content only represents the author's position, and does not constitute investment advice, please treat with caution, if the article/material is infringing, please contact the official customer service.

Guess you like

Origin blog.csdn.net/weixin_56136405/article/details/128148665