Proof of work explained simply, in pictures.

in #blockchain7 years ago (edited)

Proof of work is a concept that confused me when I first started reading about blockchain and cryptocurrency. 

I learn things best when I can visualize them. After I read a text-heavy paper/article, I always try to sketch what I learned. If I can visualize it, I can understand it.

After reading several sources to understand what this is, I've put together a short article where I explain proof of work simply, in pictures.  

...

Having a basic understanding of blockchain is the only prerequisite here. If you are new to or unfamiliar with blockchain, you can check out my article blockchain explained simply, in pictures. I also highly recommend Minimum Viable Block Chain.

Let's begin.

The blockchain is built on trust without a central authority. POW is how popular blockchains like Bitcoin establish distributed consensus.

What do we mean by ‘establish distributed consensus’?

In a connected peer to peer (P2P) network, nodes (computers) must agree on what is the ‘truest’ blockchain. In other words, the ‘truest’ blockchain is one that is the longest. The 'truest' blockchain is the chain that has the most ‘work’ put into it.

Let's talk about this 'work'.

Every transaction in the P2P network is broadcast to nodes in the blockchain.

Say Sam sends some cryptocurrency to Kim.

Each block is assigned a hash.

For simplicity, let’s have it such that this hash is generated from a timestamp and the previous block’s hash.

Let's call the node who wishes to add their block to the blockchain a 'miner'. For a miner to add their block to the chain, the miner must come up with a nonce (number used once), that when added hashed together with the block’s hash, generates a hash with a certain number of leading 0s’.

Now that sounds confusing, so here's an example.

Many hash functions can be used, but a common one is SHA-256.

Hash functions are very sensitive to their inputs. As you see in the images above, even a simple change from 1 to 2, generates a completely different hash. 

A computer must keep incrementing this nonce until it finds the correct one, that when hashed with the block's hash, produces a hash with the correct number of leading 0s. This means a computer must do the brute force of of generating thousands (and even millions) of hashes per second to generate a hash with 3 leading 0s in this example.

It is costly and time consuming for a computer to generate the POW for a block. POW works well because it is easy to verify but hard to generate. 

For Node A to verify whether Node B did the required work, Node A simply has to hash Node B's nonce with the block's hash to see if the output hash has the correct number of leading 0's. Because of this, the rate at which new blocks are added to the blockchain is very easy to manipulate.

As you can see, proof of work ensures that each block must do 'work' before adding a block to the blockchain. This prevents an evil node from simply validating fraudulent blocks and adding them to the chain. To compromise the goodwill of the entire network, the evil node(s) would have to have more CPU power than than at least 51% of the other nodes in the P2P network, which is unlikely.

Although it 'works', POW definitely has its share of flaws. Let's discuss some.

Disadvantages


  1. High amounts of electricity and CPU power are used to generate hashes. This is very wasteful, as this power is used for nothing more than to compute a silly math puzzle.

  2. POW creates an incentive to acquire large amounts of CPU power to gain a competitive advantage in mining blocks. This may create centralized CPU powerhouses, and this conflicts with the blockchain mantra of decentralization.
  3. The cost of mining (CPU power, electricity, etc) is usually paid in non cryptocurrency, like dollars. Moreover, a miner does not have to put any cryptocurrency as 'collateral' to mine. Both of these may incentivize hoarding of cryptocurrency. When many miners hoard, it causes a downward pressure on the price of the coin.


How do we combat these disadvantages? 

There is an alternative (and subjectively better, more green) consensus algorithm called proof of stake. Check it out. 

So there you have it - POW in a nutshell. I hope you learned a little here. 

If you are interested in developing smart contracts, and know a little Javascript as well, feel free to check out my Github project, where I combine Angular2 and Truffle.

Hope you learned a little :)

...

View my original article here

Sort:  

I'm still trying to get my head around all this. Thank you for sharing this information! Don't dream it, Steemit!

We're all in this blockchain journey together @bigskykilroy!

Very interesting. Thanks for your post

Thanks @jetblake! I am happy you found it interesting.

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.036
BTC 90080.39
ETH 3207.90
USDT 1.00
SBD 2.75