I’ve written a lot about a block joining the blockchain. But, I didn’t really mention how this happens. It starts with the network agreeing on which transactions are valid. This is done using something known as consensus. Consensus is the name of a group of algorithms that we can use to create a voting process for the network. This voting process helps make decisions about information on the blockchain.
Right now, we’ll take a closer look at the consensus starting with the problem at the heart of the consensus known as the Byzantine Generals Problem. Let’s take a moment and take a trip back to the early 100’s during the rule of the Byzantine Empire in the midst of a war. Stick with me on this. In the end, the relationship with the blockchain will become very clear.
Nine generals, each commanding a part of the Byzantine army surround a city and they must form a plan to attack it. The generals must only decide, attack or retreat. The problem is that either all nine must agree to attack or all nine must agree to retreat. If only one portion attacks while the others hold back, then they will be overwhelmed and lose. In addition, there are some other complications.
Of the nine generals, there could be some who were traitors. They may try to disrupt the group’s vote. For example, if four out of nine support an attack, and another one supports a retreat, the final general may have bad intentions and ruin everything. To do this, they could send a vote to retreat to those in favor of retreating and a vote to attack the four who want to attack. The generals are physically separated, and they must send their votes using couriers. These messengers could be caught along the way, not deliver votes, or could create false votes. What we have just seen is referred to in computer science as the Problem of the Byzantine Generals.
The problem is an analogy for the blockchain network. Replace generals with us, and instead of war, think of our blockchain network. The same ideas apply in both situations. In a distributed system, you need a way to ensure trust between users when they cannot communicate effectively. The solution helps us understand a way to reach consensus among users who cannot communicate effectively, and cannot trust each other. It’s really cool to realize this problem of establishing trust and a distributed network has been around for centuries. Bitcoin originally proposed a solution to this problem using a proof-of-work algorithm. It’s a way of reaching consensus without a central authority, and it’s what allows Bitcoin to solve the double-spending problem. We will see the details of this proof-of-work algorithm next.
Problems with Proof Of Work
A consensus algorithm is critical to ensuring that a Blockchain remains a trusted version of the truth. It also prevents any potential adversaries from breaking the system. While this method of reaching consensus has been successful so far, it has some problems. There are two commonly discussed issues with proof of work. High energy consumption and minor monopoly problem.
First, proof of work leads to an extremely high amount of energy consumption. Proof-of-work calculations require a lot of computing power, all of this computing comes at a financial and environmental cost. To mine Bitcoin, miners set up mining rigs which are high-powered computers that process new blocks. The rig could be a dedicated computer design and built specifically for mining, it could also be a computer that was built for something else like a gaming system but which has enough memory and processing power to perform the calculations needed for mining. People can install mining rigs in their homes, but there are also mining farms run by larger operations that house hundreds and sometimes even thousands of rigs dedicated to mining Bitcoin.
In 2017, one of the largest Bitcoin mines in the world, located in Inner Mongolia, has 25,000 machines working 24 hours a day to mine Bitcoin. All these mining rigs around the world require a lot of processing power. Some reports claim that Bitcoin mining is consuming more electricity than 159 countries worldwide, including Ireland and most countries in Africa. At the end of 2017, Bitcoin mining global consumption consumed as much energy as two million American households combined. And it really is possible to use Bitcoin mining rig to heat your home.
The second problem is the minor monopoly problem. As Bitcoin mining requires a lot of computing power and energy, those who have the resources to access more equipment have an unfair advantage. In a fast search you can see the distribution of the largest mining pools around the world.
As you can see, it’s a little distorted. The mining farms we mentioned earlier really contribute to this problem, they helped lead to a monopoly of Bitcoin Miners who control the majority of the network. As these nodes dedicate more resources to the network, they have more say in which blocks are considered valid. This causes the network to lean towards becoming centralized, rather than remaining distributed as was originally intended.
So that ends the problems with the proof-of-work algorithm. Given these proof-of-work challenges, other consensus algorithms have been developed to try to fix some of these issues.
Proof of Work Demonstration
Guessing and manual random checking is exactly what mining computers are doing. This repeated assumption can be extremely tedious, but it is the only way to solve this problem. The more leading zeros we need, the longer it will take to find the answer. That’s because wanting a hash with more zeros is a more specific request. This makes it less likely that you’ll find a solution, and results in a lot more guesswork. This number of leading zeros requested is what we call the block’s difficulty. This block difficulty can be changed by updating the algorithm to ask for more or less zeros. You can change the difficulty whenever you want the computers to be able to solve the slower or faster algorithm.
In bitcoin, they automatically adjust the difficulty to help ensure a new block is created every 10 minutes. If blocks are created too quickly, they will increase the difficulty of slowing down the process. But if they are being made to slow down, they will lessen the difficulty to make the process go faster. You might ask yourself, why is 10 minutes important? Having a lock every 10 minutes was a decision made by the developers. This 10 minute time was considered a good balance between having a secure network and a network that can actually keep up with the creation of new blocks.
For example, if a block was created once every hour, the amount of transactions waiting to be verified would increase dramatically, and the network would be very slow. But on the other hand, if a lock could be made every second, then it might allow a hacker the opportunity to change data and get rid of the locks before the network can catch the attack. This is just a quick summary of why 10 is considered important, this decision may change for different networks depending on what developers find important. So that wraps up this quick proof-of-work demo. I hope you now have a better understanding of how it all works. Next, I’ll try to search for some of the problems with this system, and then see if we can discuss some other algorithms that could provide a solution.