In Beginners’ lesson 8, you learned the basics of Bitcoin mining. Now we are going to elaborate on how the Bitcoin network depends on a set of rules called the Proof of Work consensus algorithm.
- Proof of Work is the consensus algorithm of the Bitcoin blockchain
- In simple terms, a consensus algorithm is a process in computer science to achieve a common agreement on data among distributed processes or systems
- Proof of Work eliminates the need for trust in a bank or the requirement for a third party during transaction processing
In this lesson, you’re going to learn about the Proof of Work consensus algorithm.
What is the Proof of Work consensus algorithm?
Proof of Work is the consensus algorithm of the Bitcoin blockchain. It is called “Proof of Work” because it requires some type of work - usually computer processing - from participating nodes (miners) in the Bitcoin network.
In a nutshell, a consensus algorithm is a set of rules that governs a blockchain network. It is an agreement on the rules of a specific blockchain and how users can participate in the network.
What are miners?
Disregarding mining pools for the moment, which you learned about in lesson 16 in the Beginners’ section, it is a special group of Bitcoin users called miners who carry out the validation of transactions in the blockchain. Miners have downloaded the full Bitcoin blockchain and chosen to run it on powerful computers.
These users (nodes) in the Bitcoin network are called “miners” because they check and prove the accuracy of a transaction in a process called mining - similar to the computation of a complex mathematical problem. Throughout this process, miners are incentivised to act in a way that benefits everyone in the Bitcoin community because honesty pays off.
Once a request to record and complete a transaction is disseminated into the blockchain, usually the transactions with the highest fee offered are selected to go into the next block on the blockchain.
In order to reach consensus on a valid block in the blockchain, the Bitcoin algorithm provides a difficulty as a parameter that needs to be met for a block to be valid. This “difficulty” is regularly modified by the Bitcoin network depending on the computational power of the miners. Difficulty may be decreased or increased to maintain a constant speed at which new blocks are added.
An arbitrary number called a nonce (the abbreviation for “number only used once”) is added to the block for purposes of cryptography. Miners alter the nonce until a value is found that gives the block's hash the required difficulty level. Once this requirement is met the block cannot be changed without redoing the work.
An arbitrary number called a nonce (the abbreviation for “number only used once”) is added to the block for purposes of cryptography.
The node then “hashes” the selected set of data. The word “to hash” originates from the French word “hacher” which means “to chop up into small pieces.”
During hashing, an algorithm called a hash function is used to convert one value (the selected set of data) into a fixed-size as the output - the hash value, thus masking the original value.
A hash function cannot be reverse-engineered, meaning that the hash value cannot be used to find out the original data. Thus, the hash value is a “fingerprint” providing thorough authentication and ensuring that no tampering took place with the transmitted content. Each hash value contains information on all previous network transactions.
Difficulty is regularly modified by the Bitcoin network depending on the computational power of the miners.
The newly generated hash is checked against the current difficulty. A hash value always has to contain a specific number of zero-bits. If the hash meets the criteria of difficulty, it is broadcast to the other miners in the network. If it does not, another nonce is selected and hashed. Miners generate many hashes with different nonces until they find one that meets the needed criteria. This repetitive process is known as “mining” and now you know why it requires so much energy.
Therefore, the first miner who finds a valid hash validates the block into a new block and gets a block reward in Bitcoin. Presently, the Bitcoin block reward is 12.5 BTC and a new block is mined approximately every ten minutes.
Each time a new block comes up, there is a new chance for a different miner to be rewarded. For this reason, the verification of transactions on the Bitcoin blockchain is like a never-ending gold rush with thousands of miners around the world simultaneously mining to be the first to discover a block.
Consensus in the blockchain
It’s always the longest version of the Bitcoin blockchain in existence that is recognised as the true Bitcoin blockchain. If a dispute on the rules for handling and validating transactions arises among the majority of participants in the network-operating miners, such a discussion may eventually result in an independent chain of a blockchain, a so-called fork.
Most of the time, however, miners have no real reason to break the rules because of the sheer cost in terms of both time and money required to mine continuously.
The Bitcoin network, and by extension, the Proof of Work consensus algorithm, has eliminated the need for users to vest their trust in a traditional bank. Instead of transactions being stored in one central location, such as a bank, transactions take place on a public network for everyone to view. Once completed, a transaction can never be reversed or modified.
When any amount of Bitcoin passes from one person to another, it is considered a transaction that the network needs to keep a record of.
The disadvantages of Proof of Work
As a process, Proof of Work has been historically slow in terms of the rate at which transactions are processed. The most common measure of Bitcoin transactions per second has been seven transactions, which is miniscule in comparison to the VISA network’s estimated 1,700.
Furthermore, vast amounts of energy are required for the mining process in the Bitcoin blockchain. In Germany, for example, mining just 1 (one) bitcoin carried an average cost of more than 12,000 euros in 2018. For this reason, miners try to improve their chances by joining mining pools. In some cases, cloud mining services may be the only viable option for the average user to participate in light of the resource-intensive process involved.
Another disadvantage of the Proof of Work process is that larger mining pools have more computational power at their access and thus greater chances of mining valid blocks, putting individual miners at disadvantage.
Protocols like the Lightning Network have the objective to improve the speed and scalability of the Bitcoin network. Currently only implemented in a very basic fashion, the Lightning Network is a second-layer protocol atop the Bitcoin network projected to take the pressure of large numbers of transactions away from the central Bitcoin blockchain.
Protocols like the Lightning Network have the objective to improve the speed and scalability of the Bitcoin network.
By enabling the setting up of payment channels between two parties on a separate layer for as long as needed, the Lightning Network is the reason that someday users could use Bitcoin to pay for a cup of coffee. At the same time, numerous companies are working on developing mining hardware running on renewable energy sources instead of traditional electricity.
The advantages of Proof of Work
Other mechanisms and algorithms may be superior to Proof of Work, however, Proof of Work is the most well established and time-tested against attacks in terms of the relative nascence of Bitcoin and blockchain technology. The high cost is also a factor in reinforcing consensus and deterring network participants from dedicating resources to alternative chains. Hence, chances are high that the Proof of Work algorithm will continuously be improved upon by developers to address its shortcomings.
- Werbach, Kevin - The Blockchain and the New Architecture of Trust