One article to understand the difficulty adjustment of Bitcoin mining

From the birth of Bitcoin in January 2009 to November 2020, there have been 250 difficulty increases and only 53 difficulty decreases.

 Bitcoin mining
When I first learned about Bitcoin mining, I thought it was as simple as sitting at home and doing what I wanted to do, and my computer would go to work and make money while I was sleeping.

But not exactly. Facts have proved that there are many reasons that make the above situation completely impossible.

But in order to understand the reasons, we must first understand the entire concept of mining and its meaning in terms of cryptocurrency.

What is mining?

In essence, mining is to create new blocks, fill them with transaction records, and add them to the blockchain so that everyone can see and how a particular currency is used. Agree.

However, in order to add a block, miners must solve an “encryption puzzle”, or in more technical terms, they must get a valid block hash.

I will not talk too much about the Hash function, but simply put, Hash is to get all the information of the block, and then process it until it returns a random letter and number 64 that has nothing to do with the previous content Bit hexadecimal number.

If you change any data on the block, the random number will be very different, but if nothing changes, it will always return the same content.

But how do you know whether the hash value is valid? This is the origin of the difficulty target. The goal describes a threshold, and for the Hash to be valid, the value must be less than the goal.

You may ask, if you can’t change the transaction information, how to get a different Hash value? When creating a Hash, there is another factor to consider in the block-you can modify it, it is called a nonce.

                  Source: Khaled Salah

Miners have been working hard for this number until the output Hash value is less than the target value. Because the hash value is random, the lower the target, the harder it is to find a valid hash value. Just like rolling a dice, it is more difficult to roll a number less than 3 than to roll a number less than 4.

So how do you determine the value of the goal? The answer to this question is the topic we are going to discuss today: mining difficulty.

What is mining difficulty?

This is self-explanatory, but the difficulty of mining only refers to how difficult and time-consuming it is to find a valid Hash value for a block. A better question should be, why does mining need to be difficult in the first place?

The whole point of the blockchain is to establish consensus among multiple individuals in the network, that is, to reach an agreement on a truth. How do they do this? They take the longest effective chain in the network, which depends on how much work is invested in it (the time it takes to calculate the hash value), and accept it as the main chain for construction.

With this difficulty, the security of the network can be ensured because it can prevent fraud. If adding blocks is easy, someone might send a fraudulent transaction and then send spam to the network to create their own longest chain. However, due to the difficulty of mining, in order to prevent spam, the process of adding blocks is slow, and it takes an average of 10 minutes to mine a block.

The tricky thing here is that attackers can easily bypass this difficulty by finding ways to increase computing power. Fortunately, we thought ahead and came up with a way to make system control difficult.

How to determine the difficulty of mining?

Adjust the difficulty regularly to ensure that it always takes an average of 10 minutes to mine a block. After every 2016 blocks are added, the system will look at the time it took to create these 2016 blocks. Under normal circumstances, it takes about 2 weeks, or 2,160 minutes. If it is more than two weeks, the difficulty will decrease, and if it is less than two weeks, the difficulty will increase. The difficulty can be determined as follows.

The relationship between difficulty and goal

To prevent sudden changes, the increase or decrease in difficulty cannot be more than 4 times in one adjustment.

But back to the question of how we come up with goals, we need to explore different factors that affect the time required to mine a block.

Two things may affect this time: computing power and the number of individuals in the network.

Calculate ability

In the early days of Bitcoin, you may have been able to successfully mine, as I thought people did in the past-with their personal computers. However, the miners were quickly forced to upgrade.

Since mining is essentially a race, people race to find the hash value first and get rewards. Those with more powerful computers will be able to make more calculations at the same time and therefore have a higher chance of winning.

The upgrade was a simple conversion from the CPU to the graphics card at the beginning, but in recent years, the upgrade has been much larger. Now the so-called ASIC (application-specific integrated circuit)-a device specifically designed for mining-has It is the minimum required to be able to compete.

But even so, you are unlikely to earn anything. Currently, it may take you 40 years to mine a block. If you want to make money, you may have to join a mining pool-miners unite to increase their chances of winning.

Considering all these advancements and the fact that computers are constantly getting faster and faster, the difficulty of mining must compensate for this in order to keep up with them and maintain an average speed of 10 minutes.

Network size

Wait, but we don’t have faster computers every two weeks, right? Although the continuous improvement of computers is the main reason for the need to adjust the mechanism, the system also compensates for the number of individuals in the network.

The more miners, the less time it takes to find a valid hash value, because more calculation results will be performed in the same time. Therefore, when more miners are present, the difficulty increases, and when there are fewer miners, the difficulty decreases.

to sum up

So back to where we started-in today’s era, it is almost impossible to mine Bitcoin with your PC. The reason is that due to the compensation of equipment upgrades and increased network scale, the difficulty of mining continues to increase. Your PC simply does not have the computing power to keep up with others, so your chances of successfully mining a block are very, very low.

Even if the system is designed to reduce difficulty, it rarely does so. Faster and more powerful devices are constantly being developed, and more and more people are joining the Bitcoin network. In fact, from the birth of Bitcoin in January 2009 to November 2020, there have been 250 difficulty increases and only 53 difficulty decreases.

Comments

Leave a Reply