In our previous article on Beacon chain and Sharding, we explored how Ethereum will implement PoS and how transactions will be stored. But we didnโt talk anything about smart contracts. After all, Ethereum aims to be the worldโs computer. Ewasm is the missing puzzle in Ethereum 2.0 that will enable the smart contract functionality. Ewasm will replace EVM to bring more functionality and diversity to the smart contracts.
Overview of EVM (Ethereum Virtual Machine)
A virtual machine is a high-level abstraction that emulates a physical machine. For example, you can use VMWare to run the different OS on your computer. Since EVM is a virtual machine, it can run on any other operating system.
EVM is a state-machine. It means it takes in a bunch of inputs and, based on them, changes the current state to a new state. For example, when a transaction takes place, the EVM changes the state of the account based on the amount transferred from the account.
EVM is also a stack-based virtual machine. Every instruction(be it the smart contract code or transactions) in Ethereum are boiled down to their respective bytecode.
It is then in the stack in such a way that the first opcode that enters the stack is the last to leave it. This helps the EVM to increase efficiency and reduce storage requirements.
Like every machine, EVM also has a memory associated with it. The memory is divided into World State, Machine state, and Virtual ROM.
Ethereum Virtual Machine(EVM) is the engine that drives the Ethereum network. It is the virtual CPU that facilitates all the activities taking place in the network.
So, EVM has to take care of everything going on in the network. In heavy traffics, the burden on EVM becomes heavier. Transactions can take a lot of time to execute. This issue of efficiency is the primary reason why Ethereum plans to transition from the EVM to Ewasm.
Coming to Ewasm
Ewasm is the successor of EVM. Ewasm stands for Ethereum flavored WebAssembly.
It is a restricted version of WebAssembly. Letโs try to get our heads around Wasm first.
According to the official website
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.
Wasm is an improvement to the existing JavaScript and works alongside it and adds a new capability to the web apps. It is fast, safe, open-source, and efficient.
This new standard enables web applications to run video games, graphics designing, image & video editing, and other heavy computation tasks.
Through Wasm, various JavaScript frameworks can significantly reduce load times for heavy websites and provide optimized performance.
In the case of Ewasm, the Wasm framework is modified according to the requirements of the Ethereum network. The developers of Ewasm have set several goals for it.
Most important is to develop an Ewasm based contract and to provide an Ethereum interface to interact with the network.
Since it a version of Wasm, it meant to be human-readable and debuggable. With Ewasm, the team aims to provide an EVM transcompiler in the form of an Ewasm contract. They also aim to provide library support and instructions in languages like C, C++, Rust, etc.
Metering in the context of Ethereum refers to the act of calculating gas used for executing a transaction or smart contract in a deterministic way. Ewasm aims to provide a metering injector in the form of an Ewasm contract to facilitate the metering process.
After switching to Ewasm, one of the most significant changes we will see is the hike in the throughput of the network.
The network will be more efficient, and the execution time will shrink to a lot less time than before.
The issue with EVM was it was the perfect machine for an ideal world but in the real world. As stated by Lane Rettig, EVM is like a swiss knife. It has a lot of functionality, but it doesnโt use them in their best possible way.
When Ewasm combines with sharding and beacon chain, Ethereum scalability will go up.
Ewasm also aims to eliminate the need for precompilation. Precompiles are special bits of EVM bytecode. If a call is issued on a precompiles, the EVM will execute a pre-defined native code and return the results.
According to Nick Johnson, Ewasm is efficient enough at computation that most current precompiles could be eliminated and replaced with Ewasm contracts.
The development of contracts will get broader through Ewasm contracts. It is expected to support multiple languages like C, Rust, C++. It will also support many prominent JavaScript engines of Mozilla Firefox, Google Chrome, and Mircosoft Edge.
This will benefit Ewasm with a wider array of tooling and compilers than the EVM does.
Ewasm is set to make Ethereum as โthe worldโs computerโ with better performances and efficiency.
It will help scale Ethereum to a new level, which might not have been possible with EVM. Though it has seen his share of criticisms.
You can read more about Ewasm here.