Proof of Work

Now that Ethereum is getting closer to 2.0 and moving forward in changing its consensus algorithm, it is a good time think about distributed consensus.

So you want to reach a decision, any decision without a central authority, not even yourself as the authority.

Let’s describe the problem further.

You want to compute something, anything, but don’t want to keep a central state. You want it distributed, and consistent among multiple nodes.

Let’s say you want a system that returns results for simple mathematical calculations. What is 2+2? Somebody answers 4. You are not sure. A bunch more answers 4. It is settled, it must be 4!

How do you make the network interesting to other nodes? You incentivize, reward them for answering your question, the first few that return an answer get the reward.

But there are really fast nodes, they always answer first and your incentive is unable to attract a crowd. There are also rouge nodes that answer incorrectly to get the answer in first without caring for accuracy, or just for the lulz. What to do?

Make them work for it!

Work as a randomizer.

Let’s say Usain Bolt is running and winning all the races and after a while, nobody wants to race him. How do you make the race attractive? By throwing random obstacles onto the track. Usain Bolt will continue to win most of the time, but relative to their speed, other racers will also get to the finish line first on some of the races.

We can use the same method for our example above. We will ask nodes to not only return the answer 4 but also guess a random number that we pre-selected. If the node’s guess is not correct, we will tell it to try again. If the chance of guessing the correct answer on the first try is 1 in 100, even the slowest node will still be able to get the reward 1% of the time. This will also discourage nodes to return the wrong answer as they are competing with each other, not just the first, but a bunch with the same result plus the correct guess will be rewarded.

The problem is solved.

Any other problems?

Well, yes. If more than half the nodes decide to tell you 2+2 is 6, then 2+2 equals 6.

Bitcoin’s Proof of Work

So, somewhat similarly to our consensus design above, the purpose of Bitcoin mining is also to randomize the network. Most of the processing and hash calculations have nothing to do with wallets, public and private keys, or messaging between people using those public and private keys. It is about making the correct guess.

Bitcoin miners are trying to guess a little bit of random data. The hash of that random part and the actual solution needs to result in data that contains a certain number of zeros in it. If it doesn’t then they try again, change the random data, try again, change it again, try again. This usually goes on many trillions of times, until they find a result that starts with a lot of zeros. How many zeros? It depends on the amount of power available in the network and is adjusted to make the solution harder or easier. The little bit of data is called a nonce1, the hashing algorithm is sha2562 and obviously, this is a very simplified explanation omitting Merkel trees, limited supply, halving, and everything else3.

Proof of work is about randomization, incentivizing nodes to participate in the network and discouraging bad nodes, not something else. If you wanted to use blockchain technology in an application and had your own nodes distributed in your own environment, and they all acted according to the rules of your network, you would not need proof of work.

When put this way, and considering the amount of electricity and resources spent, it looks like a very big hammer for the problem, but the distributed consensus problem is indeed a very hard problem to solve.

Remember 2+2 equals 6 from above? That problem also applies to Bitcoin. If more than 50% of the nodes in the Bitcoin network were to get together and decide to transfer all of it to one specific wallet, they could indeed do it. But the beauty in chaining blocks together is, you can always chain more than two together and continue chaining on whichever one you choose, which would be called a fork5.

This was an attempt to overly simplify an itsy-bitsy part of what is called the Nakamoto Consensus6.

Next, I’ll write about proof of stake, and learn more about avalanche consensus7.

Leave a comment