5

What does this protect against? And why 4 in particular?

I know an adjustment of this magnitude is not likely to take place at this stage, but I'm wondering why this was implemented in the first place.

2 Answers 2

2

You need restrict how much difficulty can change. Imagine if someone managed to forge the timestamps on the block that they were creating, and make it so that it appeared that it only took one second to generate 2016 blocks. Should difficulty then go up by 1209600? Clearly, that would be ridiculous.

On the other hand, you need to make the adjustment flexible enough to adapt to unforeseen advances. 4 is an arbitrary value picked as a compromise between these two requirements.

1
  • Even worse, it would be easy to lower the difficulty by forking a very old difficulty period on its 2015th block. Then you could lower the difficulty by magnitudes by mining a single block. Although, that would probably only be useful in combination with an eclipse attack on a node undergoing IBD.
    – Murch
    Commented Jun 29, 2021 at 5:03
0

Difficulty is essentially calculated as ...

difficult adjustment proportional to actual time / ideal time

From the Bitcoin Wiki's Difficulty article, an example of calculating one of the difficulty values, ie actual time or ideal time:

0x0404cb * 2^(8*(0x1b - 3))

This is essentially k * 2^(8*(0x1b - 3)), where k is a constant.

So notice it's exponents we're dealing with, in base 2, ie 2^(a huge number).

Because the loss of precision occurs with way difficulty is expressed, were essentially dealing with ratios of 2^exponent1 / 2^exponent2.

So it has to be a multiple of 4, since we're taking ratios of base 2 exponents. Even if the bottom value were 0, so 2^0 = 1, 2^32/2^0, a multiple of 4

1
  • Huh? nBits doesn't have a constant mantissa - if it did, there would be no point in embedding the mantissa into the block header.
    – Nick ODell
    Commented Apr 10, 2015 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.