BTC
ETH
HTX
SOL
BNB
View Market
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

A comparison of virtual machine EVM and WASM: speed, precompilation, flexibility and interoperability

ChinaDeFi
特邀专栏作者
This article is about 1895 words, reading the full article takes about 3 minutes
The introduction of the Ethereum Virtual Machine allows developers to easily create and deploy smart contracts.
AI Summary
Expand
The introduction of the Ethereum Virtual Machine allows developers to easily create and deploy smart contracts.

first level title

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. EVM functions differently than traditional operating systems such as Windows, which can only run on one machine at a time. EVM is a high-level abstraction built on a native operating system to emulate a physical machine.

By using the EVM, the same platform can run on many different operating systems and hardware architectures. This feature makes virtual machines suitable for networks such as Ethereum, which can be accessed by different clients on different machines distributed around the world. The EVM can emulate functions performed on a physical CPU and is responsible for most functions on the Ethereum network.

EVM has the following characteristics:

Certainty

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, where dApps process millions of dollars at a time, various users need to know how the code reacts at every 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 a smart contract, it cannot affect other parts of the underlying protocol.

Ethereum smart contracts are Turing complete. So, given enough time and resources, they should be able to fix anything. Smart contracts should have a termination mechanism, because it is difficult to be sure that the contract will complete all operations within the stipulated deadline. Ethereum uses "gas" limits to terminate smart contracts that exceed execution limits.

first level title

  • Functions of the EVM

  • It is the decentralized processing unit of the Ethereum network. Every interaction, transaction and smart contract execution can only happen here.

  • Fetches and executes the instruction, then decodes the operands through the given instruction dispatcher.

  • Responsible for all data structures such as operands, data processing and instructions.

  • Responsible for creating the runtime environment for the different smart contracts on the Ethereum network.

first level title

  • EVM challenges

  • 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, including engineers from Google, Mozilla, and Apple. Essentially, WASM, often referred to as Ethereum 2.0, has all the features of the EVM, with additional features.

first level title

As mentioned earlier, engineers from large technology companies such as Google, Microsoft, and Apple are part of the development team. Therefore, these engineers make sure that WASM is compatible with their engines and protocols.

text

  • Designed with a specific set of goals in mind

  • WASM was created to be fast, efficient, and portable. WASM will leverage common hardware capabilities to execute at "near-native speed".

  • Be safe. It does this by enforcing the permissions policies of the host browser and maintaining backwards compatibility.

EVM and WASM

speed

speed

Simply put, EVM is a know-it-all, but knows nothing. How the EVM handles compilation is a good example of this. The native engine struggles to find the best path to perform certain operations, ultimately affecting the overall throughput of the EVM.

WASM translates directly to compiled code, which allows it to load faster while increasing the number of transactions processed per block.

Precompiled

Precompiled

EVM relies on precompilation (precompiled contracts). When a precompiled call is made, 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 hashes.

Although precompilations make cryptographic computations efficient without consuming a lot of gas, they also pose problems. Introducing a new precompiler usually requires the network to undergo a system-wide hard fork.

WASM removes Ethereum's reliance on precompiled contracts. Since WASM is so efficient, developers can create efficient and fast smart contracts without worrying about potential hard forks.

first level title

summary

summary

Source:https://medium.com/momentum6/the-war-on-virtual-machines-wasm-vs-evm-8e68f9d53ef4

ETH
Welcome to Join Odaily Official Community