Today I'll continue a review of the Linux Foundation's first Hyperledger blockchain class on edX, "Blockchain for Business - An Introduction to Hyperledger Technologies." Today's post will focus on how the Proof of Work (PoW) consensus algorithm works.
People have explained PoW to me a few different times and each time I walked away with questions and an incomplete understanding of the subject. This includes the edX course which does a good job of explaining the concept, but still didn't provide a good visual of how PoW works or connect all the dots. I'll try to provide a more comprehensive explanation here.
Please keep in mind why consensus algorithms such as PoW are necessary and important: They provide trust between different untrusting parties. Without trust there are no transactions between the parties. How do the consensus algorithms provide trust? As a process created by third-party developers consensus algorithms such as PoW do not benefit one side of a transaction or the other. They are impartial and so can be trusted to perform the transaction without bias.
Please keep in mind why consensus algorithms such as PoW are necessary and important: They provide trust between different untrusting parties. Without trust there are no transactions between the parties. How do the consensus algorithms provide trust? As a process created by third-party developers consensus algorithms such as PoW do not benefit one side of a transaction or the other. They are impartial and so can be trusted to perform the transaction without bias.
Now back to how PoW works. The edX course describes PoW as such:
"The Proof of Work consensus algorithm involves solving a computational challenging puzzle in order to create new blocks in the Bitcoin blockchain. Colloquially, the process is known as 'mining', and the nodes in the network that engage in mining are known as 'miners'. The incentive for mining transactions lies in economic payoffs, where competing miners are rewarded with 12.5 bitcoins and a small transaction fee."
"The Proof of Work consensus algorithm involves solving a computational challenging puzzle in order to create new blocks in the Bitcoin blockchain. Colloquially, the process is known as 'mining', and the nodes in the network that engage in mining are known as 'miners'. The incentive for mining transactions lies in economic payoffs, where competing miners are rewarded with 12.5 bitcoins and a small transaction fee."
"(...) guessing a combination to a lock is a proof to a challenge. It is very hard to produce this since you will need to guess many different combinations; but once produced, it is easy to validate. Just enter the combination and see if the lock opens."
Before we go into detail, let's get a visual of what the blockchain looks like so we can use it as a reference point going forward.
What does a blockchain look like?
Before we go into detail, let's get a visual of what the blockchain looks like so we can use it as a reference point going forward.
What does a blockchain look like?
Here are three blocks in a blockchain. Special thanks to Fudgy McFarlen for the graphic.
What is going on in this graphic? The first block is Block 0 and so on. If you look closely you'll notice that the Block Hash number at the bottom of Block 0 matches the Block 0 Hash number on Block 1 (following the black line from left to right). The same is true for the Block Hash number at the bottom of Block 1 and the Block 1 Hash number on Block 2. It is also important to notice that each block has two hash numbers: one that is the same as the hash number from the block before it and one hash number that is its own.
That's not true of Block 0! you say. And you're right. That's the Genesis block. It's the first block in the chain and it has no predecessor so it only has one hash number which then appears on Block 1 to confirm that they are verified and connected.
The fact that Block 0 is connected to Block 1 through its hash number is important. It's important because it confirms that one verified block is built on the next verified block. If, on the other hand, the Block 0 Hash number on Block 1 had a different hash number than Block 0 they would not match up, and Block 1 would not be verified.
What is a computational?
The edX course mentioned a "computational challenging puzzle", others talk about mining, or performing a "substantial amount of work" necessary to complete the Proof of Work consensus algorithm. What do these nebulous terms and expressions mean? In PoW it starts with a target.
What is a computational?
The edX course mentioned a "computational challenging puzzle", others talk about mining, or performing a "substantial amount of work" necessary to complete the Proof of Work consensus algorithm. What do these nebulous terms and expressions mean? In PoW it starts with a target.
What is a target?
In golf, the target is putting the ball in the hole. If you miss the hole on the first shot, you take extra shots till you get there.
For miners to mine blocks on the the blockchain, miners are given a target which is a 256-bit number (64 characters long). Miners must then create a hash number smaller or equal to the target. If a miner overshoots the target s/he can increment the nonce (completely changing the hash) and try again. The smaller the target, the more attempts it usually takes to hit the target. This is all the "work" mentioned earlier.
In this case, nonces are like the extra shots that golfers take to put the ball in the hole. Miners continue to add nonces until they hit the target.
What's a hash?
Here's a visual of what a hash looks like and how it works for reference:
A hash function takes in one thing - a word, a number, an image, a file, etc - and puts out a hash number. In the above examples, one person is sending another person a word or phrase ("Fox", "The red fox runs across the ice", "The Red fox walks across the ice"). Within this particular hash function every time someone sends the input "Fox" the output hash sum will always be the same number. To make this transaction unique it goes through a hash function such as Hashcash which creates a hash sum. There are different hash functions that provide different levels of security. Secure Hash Algorithm (SHA) 256 offers cryptographic security which means that the hashes it produces are "irreversible and unique." And this is how hashes are different from encryption: Something that is encrypted can be decrypted. Conversely, something that has been hashed cannot be de-hashed.
Issues with the PoW Consensus Algorithm
While PoW does provide a process that different parties can trust, it does have its issues:
First, because of all the attempts required to hit the target the Proof of Work consensus algorithm requires an enormous amount of computational power and hardware resources. So while a miner may get paid for his or her work, there is a substantial amount of cost in terms of pure energy to run one's computer to power the software and hardware to hit its target. (Source: https://coinsutra.com/proof-of-work-proof-of-stake-pow-pos/)
The edX course notes that because the concentration of blockchain mining power is located in countries where electricity is cheap network security becomes an issue as PoW is susceptible to the '51% attack', which refers to an attack on a blockchain by a group of miners controlling more than 50% of the network's computing power. Today electricity is cheap in China so miners there could consolidate power. Ten years from now electricity could be cheap in France, South Africa, or Nigeria which could mean different things for network security.
There is also concern that PoW does not scale well (transaction confirmation takes about 10-60 minutes; Source: https://www.coindesk.com/short-guide-blockchain-consensus-protocols). This hurts blockchain's argument that it is faster than traditional methods of clearing transactions.
That's a lot of information to to go over and that's just one consensus algorithm. There are more which we'll review in future posts.
There is also concern that PoW does not scale well (transaction confirmation takes about 10-60 minutes; Source: https://www.coindesk.com/short-guide-blockchain-consensus-protocols). This hurts blockchain's argument that it is faster than traditional methods of clearing transactions.
That's a lot of information to to go over and that's just one consensus algorithm. There are more which we'll review in future posts.



Comments
Post a Comment