JOIN THE M6 DAILY BULLETS NEWSLETTER: Each day is filled with an overwhelming amount of information spread across various sources. Get curated news and research content directly in your inbox.
What is Ethereum Virtual Machine (EVM)
Ethereum Virtual Machine is a lightweight virtual machine that is designed to run various smart contracts on the Ethereum network. EVM functions differently from traditional operating systems such as Windows that can only run on one machine at a time. An EVM is a high-level abstraction built on a native OS to emulate a physical machine.
With an EVM, the same platform can run on many different operating systems and hardware architectures. This feature makes VMs suitable for networks such as Ethereum that are basically accessible through various clients on different machines distributed all over the world. An EVM can emulate the functions that can be done on a physical CPU and is responsible for most of the functions on the Ethereum network.
EVM has the following characteristics:
A deterministic program gives the same outputs to the same set of inputs irrespective of the number of times it executes the same code. In Ethereum, dApps deal with millions of dollars at a time, and various users need to know how the code reacts at every stage of its execution.
Smart contracts need to run in completely isolated environments. This ensures that if a hack or bug happens to a smart contract it will not affect the rest of the underlying protocol.
Ethereum smart contracts are Turing-Complete. Therefore, they should be in a position to solve any problem given enough time and resources. Smart contracts should come with a terminating mechanism because it is hard to determine if a contract will finish all of its operations within a given time limit or not. Ethereum uses the ‘gas’ limit to terminate smart contracts that exceed execution limits.
Functions of 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 instructions and then decodes operands through a given instruction dispatcher.
- Responsible for all data structures such as operands, data processing, and instructions.
- Keeps track of network components such as Storage State, Block Information, and World State.
- Responsible for the creation of a Runtime Environment for different smart contracts on the Ethereum network.
Challenges with EVM
- Not fast, EVM processes so many different and diverse operations, but its opcode specifications haven’t evolved to handle the varying needs.
- Failure to evolve means that the languages are also limited.
What is WebAssembly (WASM)?
WebAssembly (WASM) is a new type of code that executes on modern browsers efficiently. This new code is created and defined by the World Wide Web Consortium (W3C). WASM is built for the web and involves engineers from Google, Mozilla, and Apple. Essentially, WASM, often referred to as Ethereum 2.0, has all the functionalities of EVM and comes with extras.
Built for the web
As already stated, various engineers from big technology companies such as Google, Microsoft and Apple are part of the development team. Such engineers are thus ensuring that WASM is compatible with their engines and protocols.
Designed with a specific set of goals in mind
- WASM is created to be fast, efficient, and portable. WASM will take advantage of common hardware capabilities to execute at ‘near native speeds’.
- Designed to be easily readable and debuggable. It comes with a text format that is readable by humans, the code can be viewed, written, and debugged by hand.
- Designed to be secure. It achieves this by enhancing the host browser’s permissions policies and maintaining backward compatibility.
EVM vs WASM
Simply put, EVM is a jack-of-all-trades but a master of none. How EVM deals with compilation is a perfect example of this point. The native engine struggles with finding the optimal path for executing certain operations, eventually affecting EVM’s overall throughput.
EVM can only process 256-bit bytecodes, which means that those smaller than 256 must first be converted to 256-bit format before being fed to EVM. The scalability issue of EVM is apparent as it only processes 25 transactions per second.
WASM transitions directly into compiled code, which enables it to load faster while at the same time increasing the number of transactions processed by each block.
EVM relies on precompiles (precompiled contracts). When a call for a precompile is issued, the EVM will execute a predefined native code and then present the results. These precompiles are specific to a certain protocol for the basic operations, such as signature schemes and hashes.
Even though precompiles make cryptographic computations efficient without consuming loads of gas, they come with issues. The introduction of new precompiles usually demands the network to undergo a system-wide hard fork.
WASM eliminates Ethereum’s reliance on precompiled contracts. Because WASM is so gas efficient, developers can create smart contracts that are efficient and fast without worrying about potential hard forks.
Ethereum introduced certain capabilities that were unavailable on the Bitcoin blockchain. The introduction of the Ethereum Virtual Machine allowed developers to create and deploy smart contracts with ease. However, EVM came with many limitations that WASM is trying to solve. According to WebAssembly.org, WebAssembly 1.0 has already been shipped to four major browser engines.