What is the Ethereum Virtual Machine (EVM)?
The Ethereum Virtual Machine is a lightweight virtual machine used to run various smart contracts on the Ethereum network. The function of EVM is different from traditional operating systems such as Windows, which can only run on one machine at a time. EVM is a high-level abstraction built on the native operating system to simulate a physical machine.
By using EVM, the same platform can run on many different operating systems and hardware architectures. This feature makes the virtual machine suitable for networks such as Ethereum, which can be accessed by different clients on different machines around the world. EVM can simulate the functions performed on the physical CPU and is responsible for most of the functions on the Ethereum network.
EVM has the following characteristics:
A deterministic program provides the same output for the same set of inputs, regardless of the number of times it executes the same code. In Ethereum, dApps process millions of dollars at a time, and various users need to know how the code reacts at each stage of execution.
Can be isolated
Smart contracts need to run in a completely isolated environment. This ensures that if a hack or bug occurs in the smart contract, it will not affect other parts of the underlying protocol.
Can be terminated
Ethereum smart contracts are Turing complete. Therefore, as long as they have enough time and resources, they should be able to solve any problems. Smart contracts should have a termination mechanism, because it is difficult to determine whether the contract will complete all operations within the specified time limit. Ethereum uses the “gas” limit to terminate smart contracts that exceed the execution limit.
- It is the decentralized processing unit of the Ethereum network. Every interaction, transaction and smart contract execution can only happen here.
- Fetch and execute the instruction, and then decode the operand through the given instruction dispatcher.
- Responsible for all data structures, such as operands, data processing and instructions.
- Track network components, such as storage status, block information, and world status.
- Responsible for creating runtime environments for different smart contracts on the Ethereum network.
The challenge of EVM
- EVM is not fast to handle so many different operations, but its opcode specification has not yet been developed to handle changing requirements.
- Failure to evolve means that language also has limitations.
What is WebAssembly (WASM)?
WebAssembly (WASM) is a new type of code that can be executed efficiently on modern browsers. This new code was created and defined by the World Wide Web Consortium (W3C). WASM was built for the web and includes engineers from Google, Mozilla, and Apple. In essence, WASM is usually called Ethereum 2.0, which has all the functions of EVM and comes with additional functions.
Built for the web
As mentioned earlier, engineers from large technology companies such as Google, Microsoft, and Apple are all part of the development team. Therefore, these engineers must ensure that WASM is compatible with their engines and protocols.
A specific set of goals were considered in the design
- WASM was created to be fast, efficient and portable. WASM will utilize common hardware capabilities to execute at “near local speed”.
- Easy to read and debug. It has a human-readable text format, and the code can be viewed, written, and debugged manually.
- Ensure safety. It achieves this by enhancing the permissions policy of the host browser and maintaining backward compatibility.
EVM and WASM
Simply put, EVM is a jack-of-all-trades, but it doesn’t understand anything. How EVM handles compilation is a good example of this. The native engine strives to find the best path to perform certain operations, which ultimately affects the overall throughput of the EVM.
EVM can only handle 256-bit bytecode, which means that bytecodes less than 256-bit must be converted to a 256-bit format before being sent to the EVM. The scalability problem of EVM is obvious because it only processes 25 transactions per second.
WASM is directly converted to compiled code, which enables it to load faster while increasing the number of transactions processed by each block.
EVM relies on precompilation (precompiled contract). When a pre-compiled call is issued, the EVM will execute the predefined native code and then display the result. These precompilations are specific to specific protocols used for basic operations, such as signature schemes and hashing.
Although precompilations make encryption calculations efficient without consuming a lot of gas, they also bring problems. The introduction of a new precompiler usually requires the network to undergo a system-wide hard fork.
WASM eliminates Ethereum’s reliance on precompiled contracts. Because WASM is very efficient, developers can create efficient and fast smart contracts without worrying about potential hard forks.
Flexibility and interoperability
Ethereum introduces certain features that are not available on the Bitcoin blockchain. The introduction of the Ethereum Virtual Machine allows developers to easily create and deploy smart contracts. However, EVM also has many limitations, and WASM is trying to solve these limitations. According to WebAssembly.org, WebAssembly 1.0 has been provided to the four main browser engines.
Posted by:CoinYuppie，Reprinted with attribution to:https://coinyuppie.com/the-battle-of-virtual-machines-wasm-and-evm/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.