<p>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.</p>

<p>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.</p>

CC BY-SA 4.0
2021-06-29T05:03:04.480Z
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
CC BY-SA 3.0
2015-04-10T20:28:10.963Z
2015-04-10T20:28:10.963Z
Nick ODell
<p>Difficulty is essentially calculated as ...</p>

<p><code>difficult adjustment</code> proportional to <code>actual time / ideal time</code></p>

<p>From the <a href="https://en.bitcoin.it/wiki/Difficulty%23What_is_the_formula_for_difficulty.3F" rel="nofollow">Bitcoin Wiki's Difficulty article</a>, an example of calculating one of the difficulty values, ie <em>actual time</em> or <em>ideal time</em>:</p>

<p><code>0x0404cb * 2^(8*(0x1b - 3))</code></p>

<p>This is essentially <code>k * 2^(8*(0x1b - 3))</code>, where <code>k</code> is a constant.</p>

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

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

<p>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  </p>

CC BY-SA 3.0
2015-04-10T19:55:46.663Z
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
CC BY-SA 3.0
2015-04-10T19:05:15.797Z
2015-04-10T19:05:15.797Z
Wizard Of Ozzie
<p>What does this protect against? And why <strong>4</strong> in particular?</p>

<p>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.</p>

<difficulty>
Why is the difficulty adjustment restricted to a factor of 4?
inersha
# Why is the difficulty adjustment restricted to a factor of 4?

(Asked by: username_0 on 2015-04-03)

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.

**Tags:** difficulty


---

## 2 answers

### Answer by username_1 on 2015-04-10. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_2**: 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.  

---

### Answer by username_3 on 2015-04-10. Score: 0

Difficulty is essentially calculated as ...

`difficult adjustment` proportional to `actual time / ideal time`

From the [Bitcoin Wiki's Difficulty article](https://en.bitcoin.it/wiki/Difficulty%23What_is_the_formula_for_difficulty.3F), 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

> **Comments:**
> **username_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.  

---

