Skip to main content

What is Proof Of Work in Blockchain?

Proof of Work

This is in continuation  of what is blockchain ....
Now we understand miner needs to solve a puzzle before they get to add new block in the network. This puzzle is called Proof of Work.
What is Proof of Work?



Yes you have guessed it right, it’s like a rolling a dice. If we (ultra) simplify it, proof of work is similar to rolling a dice. Here it goes.

Let’s say only you and I are the only 2 miners in the network. To add a new block, we need a get a number say 5 by rolling a dice.

Now let’s say I have 1 dice and you have 1 dice.

I roll the dice got 3 (No luck )

You roll the dice, you got 1 (no luck).

I tried again, I got 6, again no luck.
You tried again and you got 5! .  Wow lady luck smiles upon you and you get to put the block in the network and you got rewarded for the same.

Ok… I felt, I need more processing power, I bought one more dice. So let’s solve the puzzle again. Now I have 2 dice and you have got 1.
Let’s assume we will need to get 5 to put block into the n/w.

You roll dice , you got 3 (No Luck).
In the same time, I managed to roll both the dices, I got 2 & 5. Wow I solved the puzzle and now I can put the block in the network and get the reward.
This is why compute power of miner play a big role on this.

Now let’s suppose 8 other members come to join the party , now we have 10 miners including you and me.
If 10 people are throwing a dice, there is a very good chance that one or more people will get the lucky number in the 1st go only.  Not much fun in the game now?  So what we can do to keep the complexity level same as when you and I were playing. One thing we can do is select the target number between 1 and 12, rather than from between 1 to 6.
Well bitcoin also does the same, manage the complexity of the puzzle based on the network capacity.


Like I said, it’s an ultra-simplified version to get the point through.
Now let’s see how the real world looks like.
♦♦♦

Bitcoin uses the hashcash  function to implement Proof Of Work. Again to simplify it a bit, networks set a hash target. To add a block on the network miner has to generate a hash which is lower than the network target hash number.  To achieve this, miners add a number (called nounce) along with pervious hash, transaction data to generate the hash. They keep on changing nounce until they get the hash which is lower than the network target hash.

The process of finding the correct number (nounce) that makes a valid hash is a random game of chance. Also the complexity of the puzzle is dynamic, it’s based on the network difficulty level. The Bitcoin network is designed to add a block to the blockchain every 10 minutes. As more computers are added to the network, there is more processing power on the network making more guesses for the possible correct value of nounce. To ensure block time remains at approximately 10 minutes, the difficulty target is adjusted after certain interval, adjusting the minimum and maximum numbers to add a valid block.

It’s a complex process, it’s perfectly ok if you don’t get it, and we will come back to this again and try to understand this with practical exercise in the coming chapter.

Why do we need Proof of Work?
There is no way to trust that everyone in the network is honest, so there has to be some way to prevent miners from creating new blocks that benefit themselves for example change the from address to their personal address in a transaction. . The way it works is that you have a bunch of people all trying to guess the answer to the math problem and no one knows who is going to get the correct answer first. Whoever does get the right answer first gets a reward, but only if all the other miners agree to accept that transactional record (If it becomes apparent that a certain miner is creating fraudulent transactions then the other miners can collectively refuse to accept their contributions). This is why the process of creating a new block is designed to be energy intensive, so that there is a cost associated with creating each new block. This prevents miners from simply creating a whole bunch of new fraudulent blocks with the hopes that maybe they’ll get accepted, because the cost of doing so offsets the potential reward.

How Secure is the blockchain network?


How secure is the blockchain network, can it be hacked? Well there is nothing impossible in the world, blockchain data can only be manipulated if hackers own 51% of the miners in the network. Since new block can only be accepted if there is a consensus among 51% or more miners. This means, yes technically it’s possible to hack but it’s extremely difficult to do that, the cost of doing the hack may offsets the potential reward.

Investing resources for solving puzzle, isn’t a waste of electricity and compute POWER?

Well this is the cost blockchain network is paying for the safety and soundness of the transactions over the network. But yes the electricity , compute power and any other resources that we are using for solving puzzle  here is not doing any productive work. Here comes Proof of Stake.

Proof of Stake


Proof of Stake is an alternative to the proof of work.

Proof of stake is a process where the amount held in a cryptocurrency determines the amount that can be mined by the holder. A person that’s holds 5% of a cryptocurrency can mine 5% of the blocks.

Proof of stake goes with the assumption that people with a stake in the cryptocurrency will not want to devalue their holdings so will act in their best interests of the network while saving computing power and resources.


This is being evaluated by major blockchain, but so far at the time of writing most of the major blockchain like Ethereum, Bitcoin are still using Proof of Work.

***************************************************************************
If you are looking to get started with blockchain or want to build basic concepts on blockchain, you may like to review this book.
Building Blocks Of Blockchain

****************************************************************************



Comments

Popular posts from this blog

Building Blocks of Blockchain

Basics of Blockchain BUILDING BLOCKS OF BLOCKCHAIN: Core concepts of Blockchain, Bitcoin and Ethereum are explained in layman’s term. Also a step by step guide is provided to build your own blockchain in Java. About the Book & Author “Simplicity is the glory of expression”  - Walt Whitman.  The aim of the book is to put the complexity of blockchain technology in the simplest possible form. I am a software engineer by profession. I am in the field of software development from more than 1.5 decades. I have architected and delivered couple of complex projects for the organizations I worked for. I love to play with the problem of distributed caching, distributed computing and Application Scalability. I am involved with Blockchain technology from last couple of years. The purpose of the book is to share the knowledge I have built over the time, in the simplest possible format. The book covers various aspect of Blockchain like Business, Technology and In...

Fake media - Can blockchain help ?

Fake media - A potential solution using Blockchain ? Media is an important pillar of democracy but this pillar is loosing trust and getting weaker due to TRP focused approach. This is a big risk for the democratic fabric of  any country. News channel /media industry needs a refinement to remain responsible and trustworthy.  What is the problem ? - Media is loosing trust due to fake or misrepresented facts. - There is no effective regulating body for media. - U nreliable information going viral online (aka fake news) is one of the biggest threats faced by society. What is the solution ? - Need an effective regulating body to control fake news. There is no central agency which can be trusted today.   - Need a central agency which is unbiased , run automatically and transparently without any human  interaction. How Blockchain can help ? Step 1:  Create an open community controlled by bloc...

PostgresSQL to Amazon RedShift

As in the today's world, volume of data is increasing significantly along with the need of real time analytics on the data. This is driving unprecedented demand for Big Data/No SQL type of databases.  More and more requirements are coming to migrate from traditional (relation) databases to more Morden database. The good news is there are plenty of options like Mongo, Cassandra , Dynamo DB, Redshift , Hadoop etc .  But the challenge is,  they all solve a special needs and selecting right database depends on the actual use cases , type of data etc. Here I am covering a generic use case of migration from Postgres (or any other relational databases) to Redshift. We will focus on 2 key area .. 1) Fundamental Architecture difference between Postgres and Amazon Redshift, especially the way Storage and Scaling is managed. Storage played a very important role when it comes to performance as most of the time its I/O that's impact performances. 2) Best P...