3 ms·
As you note, the difficulty adjusts based on the amount of computational power being used. However, there's a really fun corner case failure mode. The difficul
by mikeash 9y ago
As you note, the difficulty adjusts based on the amount of computational power being used.
However, there's a really fun corner case failure mode. The difficulty is supposed to adjust about once every two weeks to make for a roughly 10 minute interval between blocks. If more power is added to the network such that the interval is, say, 9 minutes, then when the next adjustment hits, the difficulty will be bumped up by 11%.
But! That "every two weeks" thing is based on the block interval. The actual adjustment period is 2016 blocks. When blocks are mined every 10 minutes, that works out to two weeks. If they're mined faster, the network adjusts faster. If they're mined slower, the network adjusts slower.
When the changes in hash rate are slow, this is fine. But what happens if there's a sudden massive change in the hash rate? Like, what happens if the hash rate somehow changes by a factor of a thousand in a brief period?
If it goes up by a factor of a thousand, then the network will start mining blocks roughly every 0.6 seconds. Within about 20 minutes, the 2016 block interval will hit and the difficulty will also go up by a factor of 1000, then everything continues as usual. No problem.
The problem is if the hash rate goes down by a factor of a thousand. Then the network will start mining blocks roughly once a week. The difficulty will readjust to bring that back down to 10 minutes... eventually. But the interval to the next readjustment is measured in blocks! Let's say you're halfway through the adjustment period when this crash happens, so you have 1008 blocks to go before the next adjustment. That would have taken about a week, but now it will take about twenty years! Unless you can get the hash rate back up substantially, the network will be in extreme slow mode for a long time.