Diving Into Bitcoin’s Difficulty Adjustment


Bitcoin difficulty has a cap on its adjustment, so there will be a lag in moving to a new equilibrium hash rate after big price moves.

One of the greatest innovations in Bitcoin is the difficulty adjustment. Satoshi built a system that was robust and would endure over time, regardless of the computing power of miners on the network. Every 2016 blocks, or roughly every two weeks, the Bitcoin protocol adjusts the target used in Bitcoin mining. Let’s dive deep into how Bitcoin difficulty works and its economic ramifications.

Mining and Difficulty

Bitcoin miners win the global mining lottery by producing a hash of a block header that is less than a target set by the Bitcoin protocol. Each hash operation takes energy and produces a random number. This number is, on average, quite large. But very occasionally, it can be small. Miners pick each random number as a single hash operation.

Over time, as computing hardware improve, miners can run more of these hash operations, producing ever more such random numbers and, therefore, ever more chances to win the lottery. If the target was fixed, miners would win their lottery in faster and faster times (as computing hardware improves) and therefore block times would shrink. This would be a problem since it would overload the blockchain saved on disk by all the full nodes.

To prevent this, Satoshi adjusts the target to revert to the average block time of 10 minutes per block. That means that if block times in any window of 2016 blocks, called a difficulty adjustment period, lie below 10 minutes, the difficulty will increase, i.e., the target will decrease (difficulty moves exactly inversely to the target). That way, as computers improve, even though block times may shrink in the short term, the target simply adjusts downwards so that the block times will revert to their mean of 10 minutes per block. And this works in reverse as well. If block time expands, then Bitcoin will automatically decrease the difficulty (and therefore raise the target), and this will return the block times to their average of 10 minutes per block.

To see this intuitively, imagine a lottery where the lottery administrator announces that anyone who picks a random number between one and a million will win if their number lies below 100. If each draw of the lottery is truly random, then the probability of winning the lottery is 100 in a million; there are 100 possible winning numbers (each number from 1 to 100), and probability of drawing any of them is 1 in a million. So the probability of winning is 0.01% for any given lottery ticket. If that target of 100 reduces to 10, then the lottery just became 10 times harder, with the chance of winning now 0.001%. This is essentially the Bitcoin mining lottery, except that the space of numbers is not up to a million but a much higher amount, 2256 .

The Caps on Difficulty

Satoshi implemented the difficulty adjustment with a cap. In fact, the target can adjust by, at most, a factor of four in either direction. To see this, here is a graph of what the new target will be in proportion to the old target:

Let’s explain this picture.

Time differential is the actual time it took to mine 2016 blocks. So if it takes longer than 2 weeks, the new target adjusts upward proportionately. Most of the adjustment happens in the intermediate range where the line is sloped. That is the area of reversion to the mean. Outside of those points, the target, and hence difficulty, is capped. So, in other words, if the difficulty adjustment requires a major increase from the current target, it will cap to at most four times the prior target. Similarly, if difficulty must be much smaller in this period rather than the last, it will shrink to at most 25% of prior target.

No one knows why Satoshi implemented these caps, but here are some of their effects. The main effect is that difficulty will adjust with a lag. To see this, let’s consider some simple scenarios.

Suppose that the US government outlaws Bitcoin and the price of Bitcoin collapses. This will dramatically reduce the returns to mining, since miners receive their compensation in Bitcoin but pay for their energy in dollars. So, their economics are highly sensitive to the BTC-USD exchange rate. Many miners may then turn off or exit the market, which would cause hash rate to collapse. Bitcoin will adjust its difficulty downward, but it can only raise the target by a factor of four in every difficulty adjustment period of 2016 blocks. If the price stays low, then it may take time before the hash rate will reach its new equilibrium level at the new price.

Similarly, suppose a major economy like Russia adopts Bitcoin as legal tender. This will cause the price of Bitcoin to spike, which would catapult the returns to Bitcoin mining. More miners would enter, and hash rate would increase. With this new hash rate, block times would shrink. Since more miners are mining, Bitcoin will then adjust difficulty upward, but lower the target only by at most a factor of four. In the short term, block times will sit below ten minutes per block until difficulty reaches its new equilibrium, corresponding to the permanent higher price.

The Data

I pulled data from my full node to examine if Bitcoin’s difficulty has ever hit its cap:

In Block 66529, difficulty adjusted upward to hit its upper cap. Since difficulty and target are inverses, this means at that block the target hit its lower cap:

This was early in Bitcoin’s history, when hash rate (and price!) was way more volatile, day-to-day, than today. For almost all of the time since, difficulty across periods adjusts upward (and the target adjusts downward), reflecting the steady increase in network hashrate. The few exceptions are the 2020 China ban on mining, when hashrate dipped and difficulty temporarily decreased.

The bottom line: the caps and floors on the difficulty adjustment just mean that Bitcoin difficulty will adjust slowly to its new equilibrium, but it will get there. In that time, block times may be greater or smaller than ten minutes for that period. How small or how large depends on the network hash rate, which itself depends on the price of Bitcoin.



Source link

Previous articleDyson is a champ at purifiying the air and keeping you comfortable – The Morning Sun
Next articleBitcoin Runes made up 57.7% of transactions on halving day – CryptoSlate