Comprehensive Review of Proof-of-Work Consensus in Blockchain

By Matt Zand, in collaboration with Brian Wu

Blockchain technology is gaining tremendous popularity among developers and cloud architects as its use cases are growing among enterprise applications. Currently, the top 3 most popular blockchain platforms include: Ethereum, Hyperledger, and Corda. Hyperledger is slowly becoming the number one choice among private enterprise blockchains. Also, Hyperledger Family consists of many projects (like Hyperledger Fabric), libraries and tools. Regardless of the choice of platform, every blockchain will have common components like smart contracts, consensus algorithms, and just to name a few.

A fundamental problem in large-scale distributed systems is how to achieve overall system reliability in the presence of failures. Systems need to be fault-tolerant. This requires a process for distributed, often heterogeneous systems to reach a consensus and agree on the network state, whether it is a database commit or an action to take. The following 3 consensus algorithms are widely used in blockchain systems:

  • Proof of Work (used by Bitcoin and Ethereum)
  • Proof of Stake (used by Ethereum)
  • Byzantine Fault Tolerance (used by Hyperledger)

In this article, we start off by briefly explaining what a consensus is and then we will discuss what the Proof of Work algorithm is and how it works. We move on covering more topics like how Proof of Work was invented to solve double-spend issues and what are main advantages and disadvantages of using Proof of Work. We won’t be focusing on the technologies behind blockchain and its use cases in this article, but you can check out this article if you are interested to learn more.

What Is a Consensus?

Proof of Work

How PoW Works

The cryptographic puzzle that miners race to solve is identifying the value of the nonce. A nonce is an attribute in the block header structure. In the beginning, each miner guesses a number to start with, checking whether the resulting hash value is less than the blockchain specific target. Bitcoin uses the SHA-256 algorithm for this. SHA-256 outputs a fixed-length number. Every number between 0 to 2³² has the same chance to solve the puzzle, therefore a practical approach is to loop through from 0 to 2³² until a number can meet the criteria, as shown in the following diagram:

Once a miner finds the nonce, the results, including the previous block’s hash value; the collection of transactions; the Merkle root of all transactions in the block; and the nonce are broadcasted to the network for verification. Upon being notified, the other nodes from the network automatically check whether the results are valid. If the results are valid, they add the block to their copies of the blockchain, stop the mining work in hand, and move on to the next block.

Targets and Difficulty

The difficulty of a cryptographic puzzle depends on the number of leading zeros in the target. The lower the target, the more difficult it is to generate a block. Adding leading zeros in the target number will increase the difficulty of finding such a nonce exponentially. As you can imagine, the higher the difficulty setting, the more difficult it will be to evaluate the nonce. Adding one leading zero in the target will reduce by 50% the chance of finding the nonce. The difficulty is decided by the blockchain network itself. The basic rule of thumb is to set the difficulty proportionally to the total effort on the network. If the number of miner nodes doubles, the difficulty will also double. The difficulty is periodically adjusted to keep the block time around the target time. In Bitcoin, it is 10 minutes.

Incentives and Rewards

The PoW consensus is a simple and yet reliable mechanism to maintain the state of the blockchain. It is simple to implement. It is a democratic lottery-based system that lets you participate in the game of mining and get the rewards, where every node can join and higher CPU power may not translate into higher rewards. Currently, the winning miner is rewarded with 12.5 BTC for each block created in the Bitcoin blockchain.

Double-Spend Issues

  • The first transaction goes through the PoW and is added to the blockchain when the second transaction is submitted. In this case, the second one will be rejected when miners pull it from the transaction pool and validate it against all parent blocks.
  • Both transactions are submitted simultaneously and both go into the unconfirmed pool of transactions. In this case, only the first transaction gets a confirmation and will be added in the next block. Her second transaction will not be confirmed as per validation rules.
  • Both get confirmed and are added into competing blocks. This happens when miners take both transactions from the pool and put them into competing blocks. The competing blocks form a temporary fork on the blockchain. Whichever transaction gets into the longest chain will be considered valid and spent, and the other one within the block on the short chain will be recycled. When it is reprocessed, it will be rejected since it is already spent. In this case, it may take a few blocks to get the other one recognized as the double-spent one.

Advantages and Disadvantages of PoW

  • Energy consumption: PoW consensus, which uses a network of powerful computers to secure the network, is extremely expensive and energy-intensive. Miners need to use specialized hardware with high computing capacity in order to perform mining and get rewards. A large amount of electricity is required to run these mining nodes continuously. Some people also claim these cryptographic hash calculations are useless as they can’t produce any business value. At the end of 2018, the Bitcoin network across the Globe used more power than Denmark.
  • Vulnerability: PoW consensus is vulnerable to 51% attacks, which means, in theory, dishonest miners could gain a majority of hashing power and manipulate the blockchain to their advantage.
  • Centralization: Winning a mining game requires specified and expensive hardware, typically an ASIC type of machine. Expenses grow unmanageable, and mining becomes possible only for a small number of sophisticated miners. The consequence of this is a gradual increase in the centralization of the system, as it becomes a game of riches.

On the flip side, it requires huge computing power and electricity to take over the PoW- based blockchain. Therefore, PoW is perceived as an effective way to prevent Denial-of- Service (DoS) and Distributed Denial-of-Service (DDoS) attacks on the blockchain.

Additional Insights

Alibaba Cloud BaaS is an enterprise-level PaaS (Platform as a Service) based on leading blockchain technologies, and is powered by Ant Financial Blockchain Team. This service helps you build a stable, secure blockchain environment, and manage the deployment, operation, maintenance, and development of blockchains easily and that’s will enables business companies and users to focus on business innovation. It plans to address the issues faced by sectors such as healthcare, retail, finance, pharmaceutical, insurance, logistics, and manufacturing. As an add-on feature to secure the network, Alibaba’s BaaS uses chip encryption technology.

Currently BaaS supports Linux Foundation Hyperledger Fabric, Ant Blockchain technologies from Ant Financial, and Enterprise Ethereum of Quorum by J.P. Morgan.

Summary

About the Author

This article is written in collaboration with Brian Wu.

Reference: Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts

Original Source:

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store