Original title: "In-depth 丨 One article to understand BTC mining difficulty adjustment"
Original author: Samantha Ouyang
Original compilation: Sherrie, Crypto Valley Live
When When I first learned about bitcoin mining, I thought it was as simple as sitting at home and doing whatever I wanted while my computer would go to work and earn money while I slept.
But not quite. As it turns out, there are many other reasons that make the above scenario completely impossible.
But in order to understand why, we first have to understand the whole concept of mining and what it means in terms of cryptocurrencies.
In essence, mining is creating new blocks, filling them with transaction records, and adding them to the block In the blockchain, everyone can see and agree on how a particular currency is used.
However, in order to add a block, a miner must solve a "cryptographic 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 all information, and process it until it returns a random alphanumeric 64-bit hexadecimal number that has no relationship to the previous content.
If you change any data on the block, the nonce will be very different, but if nothing changed, it will always return the same content.
But how do you know if the Hash value is valid? This is where the difficulty target comes in. The target describes a threshold, and for the hash to be valid, this value must be less than the target.
You may ask, if the transaction information cannot be changed, how to get a different Hash value? There is another factor in the block that is taken into account when creating the hash - you can modify it, it's called the nonce.
< span>Source:Khaled Salah
The miners have been working on this number until the output The hash value is smaller than the target value. Because the hash value is random, the lower the target, the harder it is to find a valid hash value. Like rolling a dice, rolling a number less than 3 is harder than rolling a number less than 4.
So how do you determine the value of a goal? The answer to this question is what we are going to discuss today: mining difficulty.
This is self-explanatory, but mining difficulty simply refers to how difficult and difficult it is to find a valid hash value for a block time consuming. A better question would 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 say, on a truth agree. How do they do this? They take the longest valid chain in the network, depending on how much work was put into it (the time it takes to calculate the hash value), and accept it as the main chain to build on.
With this difficulty, the security of the network is ensured because it prevents fraud. If adding blocks was easy, someone could send fraudulent transactions and then spam 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 slowed down, and it takes an average of 10 minutes to mine a block.
The tricky part here is that attackers can easily bypass this difficulty by finding ways to increase computing power. Fortunately, we thought ahead and figured out a way to make the system difficult to control.
Difficulty is adjusted periodically to ensure that it always takes an average of 10 minutes to mine a block. After every 2016 blocks are added, the system looks at the time it took to create those 2016 blocks. Normally, it takes about 2 weeks, or 20160 minutes. If it is more than two weeks, the difficulty will decrease, and if it is less than two weeks, the difficulty will increase. Difficulty can be determined as follows.
< span>The formula for deriving the new difficulty
As you can see from the inverse function, if it takes more than 2 weeks , the score will be less than 1, and the new difficulty will decrease. If it takes more than 2 weeks, the score will be greater than 1 and a new difficulty will be added.
If the difficulty decreases, the target value increases, making it easier to find valid hashes, and vice versa. The maximum target value is 1, which shows that the difficulty is also inversely proportional to the target value.
< span>Relationship between difficulty and goal
In order to prevent sudden changes, the increase or decrease of difficulty cannot exceed 4 times in one adjustment .
But back to the question of how we came up with the goal, we need to explore different factors that affect how long it takes to mine a block.
Two things can affect this time:
< /p>
-computing power
-number of individuals in the network
In the early days of Bitcoin, you might have been able to successfully mine Mine, like I used to think people did—with their PCs. However, miners were quickly forced to upgrade.
Since mining is essentially a race, people race to find the hash value first and get rewarded, those with more powerful computers Humans will be able to perform more calculations at the same time, and thus have a higher chance of winning.
But even then, it's unlikely you'll earn anything. Currently, it can take you 40 years to mine a block. If you want to make money, you probably have to join a mining pool - miners banding together to increase their chances of winning.
Given all these advances and the fact that computers keep getting faster and faster, in order to keep up with them and maintain a 10-minute Average speed, mining difficulty has to compensate for this.
The more miners there are, the less time it takes to find a valid Hash value, because updates will be many calculation results. Thus, the difficulty increases when more miners are present, and decreases when there are fewer miners.
So back to where we started - in this day and age, it's almost impossible to mine Bitcoin with your PC due to the difficulty of mining due to equipment upgrades and compensating for increased network size Increasing. Your PC simply doesn't have the computing power to keep up with everyone else, so the chances of you being able to successfully mine a block are very, very low.
Even though the system is designed to reduce difficulty, it is rarely done. Faster and more powerful devices are constantly being developed, while more and more people join 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.
Original link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia