Ethereum summary

Shi Yan
6 min readJun 10, 2017

I tried to understand Ethereum a while back, but I was discouraged by some irresponsible document and video, describing it as a “Turing complete world computer”. Turing complete is true, but it’s definitely not a world computer, not in the sense of High Performance Computing, as Ethereum is not combining the computation power of all joined computers. On the contrary, it asks everybody to execute everybody else’s programs in an inefficient and redundant way. And what does Turing Complete mean for program developers? What program can you write under the limitation that the program has to be deterministic? You can’t have I/O, can’t have good random generator, timer and threading. Therefore, I felt that the term “Turing Complete World Computer” is a bit misleading marketing bullshit. There was also another article trying to explain Ethereum as a “blockchain that runs code”. Blockchain is a data structure, a fancier version of linked list. A data structure stores data, it doesn’t run code!

Recently, Ether, the money of Ethereum, skyrocketed to a point that I didn’t want to stay ignorant about it, so I have been reading Ethereum’s official yellow paper this week. The experience was painful. There are many things I hate about the yellow paper.

First, I dislike the use of mathematical symbols. In the world of programming, you get yourself spanked, if you dare to name variables and functions with a single character, such as “int ω = ϴ(ψ);”. Somehow, in the world of paper writing, people do this and think this is better! Though the yellow paper does a good job explaining its symbol usage, it imposes an extra decoding effort for me to understand the paper.

The second thing I hate is lacking intuition and rationale, ideas are presented in their final form, without a trace of how the ideas were developed, and why the inventors made certain decisions. Nobody comes up with a complex idea all at once. It must be developed from a naive form, and evolved into its mature form. Knowing how an idea was developed helps you understand it. But documents just don’t bother talking about history.

However, both issues are shared among almost all documents and papers, not unique to this paper. It’s a culture thing. I just feel frustrated every time I read papers. The yellow paper is a well written document, certainly better than the irresponsible ones I read few years ago. And I understand document like the yellow paper is not optimized for understanding, but for accuracy.

Anyway, enough complaining, I want to summarize what I have learned. Hopefully this could ease your pain of understanding Ethereum. The idea of Ethereum was evolved from Bitcoin. But I will not start from Bitcoin. My previous posts [1] and [2] should give you brief introductions to Bitcoin. At its core, Bitcoin is built based on blockchain. People often describe blockchain as a decentralized database, but I found this description not so accurate. What a blockchain really is, in my opinion, is the journal of a decentralized database, not the database itself. As on the blockchain, only the history of updates are kept. In order to recover the database, you will have to scan through the entire chain and perform each update one by one.

I found blockchain resembles Git, the source code management system a lot. Git is decentralized, each programer has a local duplication. What’s saved by Git is a journal of updates to source files (commits). To get the latest file, you apply a series of patches onto the initial commit. You can generate local git commits. These commits will not be written to other people’s Git repository yet, until you perform a “git push”. This is like having a local Bitcoin block, but only when you have won a lottery (mined a lucky number), you have the opportunity to write your local block to the blockchain. You also cannot write random data to the blockchain. Your change has to be verified by others, just like doing code reviews before a “git push”. Or in Bitcoin, a commit (a data write to the blockchain) has several recent transactions. Each of them needs to be cross verified by others.

A transaction is a movement of value, which can be formalized with a program like below:

void transfer(Account from, Account to, int amount)
{
if (balance[from] >= amount)
{
balance[from] -= amount;
balance[to] += amount;
}
}

Now if you build a cryptocurrency network and let people execute this program every time they receive a transaction, and cross check other people’s results of running the same program, you end up creating a cryptocurrency network similar to Bitcoin.

A natural question to ask is “Can we run different programs this way?”. This is what Ethereum has added on top of Bitcoin.

Ethereum lets you publish a piece of program in the form of a programing languages defined by Ethereum to the Ethereum network. You can trigger this program at anytime. Once triggered, everybody in the network will run this program within a virtual machine. Upon finishing the program, the states changed by the program, such as changes to account balances, virtual machine’s memory, storage and many other things will be cross checked by everybody and will be written back to the blockchain by a lucky miner.

In detail, Ethereum has 2 types of accounts and 3 types of transactions. The first account type is the human account. Similar to the account of Bitcoin, this account is generated randomly at the first run of the Ethereum program. The second type of account is the program account, or the smart contract account. This type of accounts are created by a human with a program (smart contract) attached to it.

3 types of transactions, or commands, include “Create Program (Contract)”, “Execute Program” and “Send Money”. Sending money is similar to that of Bitcoin. The other 2 kinds of transactions are added by Ethereum. Create Program transaction allows you to publish your program. A miner will write your program to the block chain. Then at any time, you could send the “Execute Program” transaction. People will then execute the program you wrote and cross verify the results and state changes your program has caused and write the results back to the blockchain.

The program you can write is Turing Complete, but because there is no way to pre-determine if your program can finish in finite time (i.e. no infinite loop.), you need to attach some money whenever you want to execute a program. Execution of every line of the program (and among other things) will cause you money. The program will halt when the attached money run out. The lucky miner who mined the current block will get the attached money as a reward.

The amount of money you pay to run a program is measured in “gas”, as if your program consumes fuel when executing. But, in my opinion, the use of the word “gas” to describe this concept is very misleading, because this word implies that it was another currency, or a virtual object, or virtual liquid in the network, same as Ether. As a lot of people, including myself, would ask questions like, “how gas is mined”, “how gas can be transferred/trade and stored/accumulated”, when they first heard about “gas”. And in the official document, they would say “purchase gas”, but in reality, gas is not purchased.

What best and accurately describes “gas” is basically “price tag”. It is the price tag you attached to your program, a measurement of the amount of money (Ether) you would like to pay for the execution of your program. It’s not a virtual object or another currency you need to trade. It’s like a tag labelled to a piece of meat chop, saying “8 pound for $3 / pound”.

People execute a program independently on their own computer. They only compare the results afterwards. Therefore, the program that can be run by Ethereum has to be deterministic. To fulfill this requirement, Ethereum builds a sealed virtual machine environment to run the programs. Within it, there can’t be any I/O, timing, threading and “quasi real” random number generator and any factors that could potentially cause different execution results. This means perhaps 90% programs that are of practical use can’t be ported to Ethereum. And because program execution on Ethereum network is inefficient, it is impractical to port most of the rest 10% programs to Ethereum. That’s why I think calling it a “Turing Complete World Computer” is much exaggerated.

Then what’s good of Ethereum if it can’t run many kinds of programs. I think the best use of Ethereum is implementing another cryptocurrency. Suppose you want to implement a cryptocurrency today. Starting from scratch is more of a marketing challenge than an engineering challenge. You will have to convince a lot of people to use your cryptocurrency to jump start the currency’s network. The less people who use your currency, the more vulnerable your currency’s network is exposed to attacks, like the 51% attack. If the currency is implemented on Ethereum in the form of Ethereum program, you could benefit from the existing users and infrastructure of Ethereum. As everyone will cross check the correctness of your currency’s transactions among all other programs. It’s harder to perform attacks on your currency as the Ethereum network is already big and secure. Simply put, Ethereum is a great framework to implement cryptocurrencies.

--

--

Shi Yan

Software engineer & wantrepreneur. Interested in computer graphics, bitcoin and deep learning.