Buy Crypto
Markets
Contract
Spot
Earn
Web3 new
Learn
Academy > Crypto Insights > The Ethereum Virtual Machine: How Does it Work? >

The Ethereum Virtual Machine: How Does it Work?

2021-04-12 03:58:56

Summary

  • A virtual machine is usually a representation of a real computer, providing a software abstraction of actual hardware, system calls, and other kernel functionality.
  • The Ethereum Virtual Machine (EVM) is the component of the Ethereum network that manages the deployment and execution of smart contracts.
  • The Ethereum Virtual Machine’s instruction set is Turing-complete, allowing contracts deployed on the network to perform any task a regular computer program can do.
  • Ethereum 2.0 will replace the EVM with eWASM, which allows the network to deploy any code compiled to WebAssembly, making the system much faster and more efficient.

ethereum-virtual-machine

Since its debut seven years ago, Ethereum’s impact on distributed networks is second only to Bitcoin. Satoshi Nakamoto‘s vision of a decentralized economy started with Bitcoin. However, despite having undergone over a decade of development to date, the world’s first cryptocurrency is still far from ready for mainstream use.

Conceptualized as a network for everyday payments, Bitcoin is hardly used as a peer-to-peer electronic cash system today. Its unparalleled rise in market price has pushed the industry into treating it more as a store of value, but blockchain networks can do a lot more than just transfer tokens.

Get 180 welcome bonus at Phemex

The Ethereum network went live just two years after Vitalik Buterin proposed the idea in 2013 and a year after its initial coin offering (ICO). Since then, Ethereum has been under constant development and is now the world’s most actively used blockchain network. Having pioneered the concept of programmable smart contracts, Ethereum has brought a world of decentralized financial services to the blockchain, influencing all kinds of trends in the space from ICOs to yield farming.

What are Smart Contracts?

Smart contracts are self-executing snippets of code instructions into which the terms of an agreement between a buyer and seller are directly written. This code governs the arrangements between the involved parties on the blockchain, allowing network participants to make controlled transactions without the need for a central authority, regulatory framework, or external enforcement system.

First proposed by American computer scientist Nick Szabo in 1994, he initially defined smart contracts as computerized transaction protocols executed based on the terms of a contract. Szabo is credited with creating a virtual currency long before the advent of Bitcoin, having invented Bit Gold in 1998. His goal with smart contracts was to extend the functionality of transferring value electronically.

Szabo also proposed utilizing smart contracts for synthetic assets like derivatives and bonds, creating securities formed by combining different financial instruments in various ways. At the time, the Bit Gold creator himself had said that this would eventually lead to complex term structures for payments being built into standardized contracts traded with low transaction costs due to their computerized analysis.

As it turns out, he was right. In fact, many of the predictions made by Szabo in his paper became realities long before anyone had heard about blockchain. For instance, today, derivatives contracts are largely traded over computer networks using intricate term structures.

Ethereum is a compilation of ideas conceptualized over the last few decades, and in its current state, it’s actually quite similar to Bitcoin. While the Ethereum 2.0 upgrade will shift the network’s consensus mechanism to Proof-of-Stake, today, they both use the power-hungry Proof-of-Work algorithm. However, Ethereum’s core is what sets it apart from anything developed at the time, and is the foundation of what the network is capable of today.

What is The Ethereum Virtual Machine (EVM)?

The Ethereum Virtual Machine (EVM) is a computation engine similar to other virtual machines like Microsoft’s .NET framework and even some interpreters of byte-code-compiled languages. The EVM is the component of the Ethereum network that manages the deployment and execution of smart contracts. While the EVM doesn’t need to be engaged for simple value transfers, it does compute updates to the network’s state.

Earn 8.5% apy on Crypto Interest account

In layman’s terms, the EVM is a ‘world computer’ with its own permanent data storage and decentralized nodes across the globe handling millions of executable objects. It also has a stack-based architecture, storing all in-memory values on a stack, and works with a word size of 256 bits to enable elliptic curve operations and native hashing.

The EVM has many addressable data components, such as an immutable program code ROM containing the executed smart contract bytecode and a volatile memory with each location initialized to zero. Since Ethereum clients comb through verified blocks to figure out which smart contracts to deploy, the execution order is organized outside the EVM. This means it has no scheduling capacity, making Ethereum similar to a single-threaded world computer without a system interface handling or hardware support.

What is a Virtual Machine?

A virtual machine is usually a representation of a real computer, providing a software abstraction of actual hardware, system calls, and other kernel functionality. In this context, the Ethereum Virtual Machine is just a computation engine and functions in a much more restricted environment than a traditional virtual machine.

Similar to the Java Virtual Machine specification, the EVM provides an abstraction of only computation and storage. The JVM was designed to offer a platform-agnostic environment for application runtime, enabling compatibility across various hardware/software combinations. Like the Java Virtual Machine, the EVM also requires high-level programming languages to be compiled into a bytecode instruction set.

How does the Ethereum Virtual Machine Work?

The Ethereum Virtual Machine’s instruction set is Turing-complete, allowing contracts deployed on the network to perform any task a regular computer program can do. Popular use-cases include the creation of fungible tokens that adhere to the ERC-20 standard, as well as NFTs under the ERC-721 standard. These tokens have various properties and are used in crowdfunding, decentralized finance markets, prediction markets, and to a small degree, even gaming.

However, this ability comes with a crucial caveat – some programs could take forever to execute. This is known as ‘the halting problem’ and puts the Ethereum network at risk of running a never-ending program. The problem is that a program can’t be labeled as an infinite loop just from checking its code – the program must be executed. Without a scheduler, a program like this would completely stall the network, but luckily Ethereum has a clever way of dealing with this issue.

What is Ethereum Gas?

Using a concept known as ‘gas,’ the network demands a fee for its computation costs. After a certain maximum computation has been performed, the execution ends after the gas fuelling the transaction is depleted, and the EVM halts the program. This means that the EVM is only a quasi-Turing complete machine – it runs any program you throw at it, but only if the program ends after using a certain amount of computational power.

On Ethereum, this limit is not set in stone, and network participants can pay to increase it to a maximum value called the ‘block gas limit.’ Over time, the network can agree to increase this upper limit, but there is a limitation on the amount of computation a contract-call can consume at any given instance. Transactions that cross this limit are terminated.

The EVM has a few other limitations to the network’s total throughput. Its opcode specification hasn’t been altered since its creation and isn’t optimized for different hardware platforms. Further, the EVM has to process such a large number of disparate operations, making it far more sluggish than it could be.

This creates an operational bottleneck which dramatically affects the blockchain’s efficiency. The EVM itself hasn’t evolved much since its original design, limiting the platform’s tool and language support for writing smart contract code.

Advantages of the EVM

The EVM is a very powerful, sandboxed stack integrated into every Ethereum full node and is responsible for deploying smart contracts written in code compiled down to EVM bytecode. This isolates the machine code from the rest of the network, its filesystem, and any processes on the host node, with each node on the network running instances with identical instruction sets.

get free crypto by just watching videos

Limitations of the EVM and How does it solve the issues?

However, even with the incredible proposals and innovative additions to the network, such as sharding, rollups, Plasma, and Casper, unless the base-layer can function at maximum efficiency, there will always be limitations to what it can achieve.

To solve these issues, Ethereum 2.0 will replace the EVM with eWASM, which allows the network to deploy any code compiled to WebAssembly, making the system much faster and more efficient. The eWASM implementation will also be incredibly secure, highly compatible and enable the network to utilize standard hardware capabilities to run smart contracts at a near-native speed.

Since eWASM will support a much wider variety of programming languages, it will also help make the Ethereum network much more interoperable. With competing smart contract platforms like Polkadot making interoperable decentralized applications a reality, this is definitely a critical aspect of the upgrade to Ethereum 2.0.

What is the Significance of The Ethereum Virtual Machine?

The Ethereum Virtual Machine is an essential part of the Ethereum platform and is imperative to its consensus engine. By creating a trustless, deterministic environment for anyone to execute code, Ethereum is leading a shift in how the world approaches both money and finance.

For every instruction implemented on the EVM, the network keeps track of the associated execution cost in gas units, and reserving this amount ensures the blockchain never runs into an ever-running algorithm. This guarantees that validators receive at least the gas fees even if execution fails and prevents any contract from running longer than the system allows.

When Ethereum receives a transaction, validators ensure the EVM doesn’t run into any exceptions during its deployment and verify the information associated with its execution. Instead of charging participants per financial transaction like Bitcoin, the EVM enables a service priced per software instruction. As a Turing-complete environment, Ethereum is technically a globally decentralized general-purpose computer and could eventually take on the role of the Internet as we know it today.

What is the Future of the Ethereum Virtual Machine?

The EVM is far from perfect. In fact, according to Ethereum developer Lane Rettig, the EVM was created without an “enormous amount of design thinking,” and this sentiment is shared by many prominent members of the Ethereum development community. While it is very internally consistent, the EVM wasn’t built with real-world implementation in mind.

However, with the shift to eWASM on Ethereum 2.0, the network is en route to prioritizing efficiency over correctness. WebAssembly is designed to be closer to actual hardware instructions, making it much better at translating code logic. Since WASM maps one-to-one with machine instructions, it will likely enable significant improvements to the network’s performance.

From file-sharing economies and peer-to-peer crowdfunding to renting out unused hard-disk space and decentralized social media platforms, the future of Ethereum looks bright. The Internet is the most valuable global network today, and just like how the development of TCP/IP led to the World Wide Web we love and adore, what blockchain technology and Ethereum have in store for the future could be just as extraordinary.


For any inquiries contact us at support@phemex.zendesk.com
Follow our official Twitter | Join our community on Telegram
Trade crypto on the go: Download for iOS | Download for Android
Phemex | Break Through, Break Free
giftRegister to get $180 Welcome Bonus!
Email
Password
Invitation code (Optional)
  • Facebook
  • Twitter
  • LinkedIn
  • Telegram
  • Discord
  • Youtube
Subscribe Phemex

Register on Phemex and begin your crypto journey today

Get $180 to Sign Up