Understanding the Ethereum Virtual Machine

Ethereum smart contracts are generally written in high level programming languages.

The most popular is Solidity, which kind of looks like a mix between C++ and JavaScript.

There’s also Vyper, which is a newer language that’s currently under development.

Smart contracts written in these high level programming languages have to be compiled down to Ethereum Virtual Machine code, abbreviated as EVM code.

So we go from a higher level, human readable language, and compile that down into EVM code, which is lower level, simpler language — much easier for a machine to understand and execute.

After the code is compiled to EVM code, every node in the Ethereum network executes it.

And all nodes execute the code the same way, so long as they have an up-to-date version of the EVM software.

We say that Ethereum is a distributed computer because every node executes the Ethereum smart contracts.

Nodes then come to consensus on the new system state.

This should be fairly familiar.

In module 1, the high level overview of Bitcoin, we discussed how every full node in Bitcoin stores their own ledger, making everyone the bank.

In Bitcoin, nodes come to consensus on the state of who owns which UTXOs.

And in Ethereum…

…after executing EVM code, nodes come to consensus on the general state of the network.

And how do nodes actually come to consensus? With Proof-of-Work!

That’s right.

The same distributed consensus protocol used in Bitcoin is also used in Ethereum.

Of course there ARE differences between Ethereum’s and Bitcoin’s Proof-of-Work implementations, but the general concepts that we have learned in the past modules definitely still apply.

Remember that Proof-of-Work requires miners to expend computational power to increase their chances of being able to propose blocks to the network.

There’s no real smart way to go about solving the hash puzzle, so miners have to brute force.

And by tying voting power to computational power, a physical real-world resource, we can prevent naive Sybil attacks.

Here are some differences between Bitcoin and Ethereum’s Proof-of-Work algorithms.

In Ethereum, block creation time is 15 seconds long, whereas in Bitcoin, it’s 10 minutes.

This allows execution of smart contracts to be done and finalized fairly quickly.

However, having such fast block times does increase the rate of natural forks and orphaned blocks, but this is accounted for in Ethereum’s protocol.

In previous modules, we studied Bitcoin’s proof of work algorithm, and how it’s bound by computation and uses sha-256.

In Ethereum, the proof of work algorithm is called Ethash.

Ethash is memory bound and claims to be ASIC resistant.

And over on the right side, we can see a graph of Ethereum’s network hash rate, which is significantly lower than that of Bitcoin.

As of May 23rd, 2018, Ethereum has roughly 275,000 GH/s whereas Bitcoin has a whopping 31,000,000 TH/s

Ethereum Virtual Machine: Overview