<blockquote>
  <p>Why not start at some other integer > 0 for example?</p>
</blockquote>

<p>Why would you? Going from 0 to <code>n</code> where <code>n</code> is the maximum possible value means that the miner will search through all possible values for the nonce. Starting anywhere else and going to <code>n</code> means that some nonce values will be skipped, which means that it is possible to miss the nonce value that will get you a block.</p>

<p>If you wrap around back to 0 when you reach <code>n</code>, then that is no different from going from 0 to <code>n</code>. It's just harder to implement. Going from 0 to <code>n</code> is the simplest to implement and guarantees that you will search through all possible nonces.</p>

CC BY-SA 4.0
2018-11-06T15:49:17.027Z
"means that it is possible to miss the nonce value that will get you a block." That's not how this works. Every nonce has an equal chance of constructing a valid block; the fact that you skip some doesn't affect your chances, as long as you try the same number of candidates per time unit. The right point is that if you reduce the range of nonces, you need to change the extranonce more frequently to reach the same number of candidates per second, which is more work.
Pieter Wuille
CC BY-SA 4.0
2018-11-06T14:06:07.887Z
2018-11-06T14:06:07.887Z
Ava Chow
<p>It doesn't matter which nonces you test or in what order that other than you need to avoid testing the exact same block header twice (since that would obviously be a waste of time).</p>

<p>It's useful to test all the nonce values since if you don't test them all you will need to update extranonce more often, though not critical.</p>

<p>Even though miners increment their nonces in similar ways this doesn't result in the duplication of work between miners: there are a myriad number of differences between the candidate blocks miners attempt, foremost being where their reward is paid. (And pooled miners that happen to pay to the same place get different extranonce ranges assigned by the pool).  As a result there is never any work duplication across miners unless something is embarrassingly broken.</p>

<p>Starting at 0 and incrementing until the maximum value is simply a convenient way to change the nonce that cannot duplicate and minimizes extranonce updates. Many devices assign distinct ranges to different chips, and so don't simply increment in a simple 0 to 2^32-1 manner.</p>

<p>A mining device could save a negligible amount of power by changing using a <a href="https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Uses_as_counters" rel="nofollow noreferrer">linear feedback shift register</a> instead of an adder, but no one seems to have bothered with that optimization.</p>

CC BY-SA 4.0
2018-11-07T10:39:36.247Z
Thank You for that answer, this was really helpful. But if I'm right everyone races to find a hash < target, and the first one to find such a hash gets the reward. When everyone starts at 0 and with the same extranonce, the one with most calculation-power always is first, right?
If I have less calculation-power than other ppl, wouldnt I want to try to "cheat" by not starting at 0 because other ppl would get the reward always? Did I miss something with this assumption?
SimonSchuler
CC BY-SA 4.0
2018-11-07T11:02:01.933Z
I added a paragraph ("Even though...") to address that question.
G. Maxwell
CC BY-SA 4.0
2018-11-06T20:57:44.033Z
2018-11-07T10:59:42.537Z
2018-11-07T10:59:42.537Z
G. Maxwell
<p>bitcoin noob here.</p>

<p>I was wondering why is the nonce increased from 0 to n while searching for a blockhash?</p>

<p>Why not start at some other integer > 0 for example?</p>

<p>My background is in ethereum-dev, so I know why the nonce needs to change, but I don't get why from 0 to n?</p>

<p>Thanks in advance.</p>

<hash><nonce><block-hash>
Why is the nonce bruteforced from 0 to n while mining?
SimonSchuler
# Why is the nonce bruteforced from 0 to n while mining?

(Asked by: username_0 on 2018-11-06)

bitcoin noob here.

I was wondering why is the nonce increased from 0 to n while searching for a blockhash?

Why not start at some other integer > 0 for example?

My background is in ethereum-dev, so I know why the nonce needs to change, but I don't get why from 0 to n?

Thanks in advance.

**Tags:** hash, nonce, block-hash


---

## 2 answers

### Answer by username_3 on 2018-11-06. Score: 3 | Accepted answer

It doesn't matter which nonces you test or in what order that other than you need to avoid testing the exact same block header twice (since that would obviously be a waste of time).

It's useful to test all the nonce values since if you don't test them all you will need to update extranonce more often, though not critical.

Even though miners increment their nonces in similar ways this doesn't result in the duplication of work between miners: there are a myriad number of differences between the candidate blocks miners attempt, foremost being where their reward is paid. (And pooled miners that happen to pay to the same place get different extranonce ranges assigned by the pool). As a result there is never any work duplication across miners unless something is embarrassingly broken.

Starting at 0 and incrementing until the maximum value is simply a convenient way to change the nonce that cannot duplicate and minimizes extranonce updates. Many devices assign distinct ranges to different chips, and so don't simply increment in a simple 0 to 2^32-1 manner.

A mining device could save a negligible amount of power by changing using a [linear feedback shift register](https://en.wikipedia.org/wiki/Linear-feedback_shift_register#Uses_as_counters) instead of an adder, but no one seems to have bothered with that optimization.

> **Comments:**
> **username_0**: Thank You for that answer, this was really helpful. But if I'm right everyone races to find a hash < target, and the first one to find such a hash gets the reward. When everyone starts at 0 and with the same extranonce, the one with most calculation-power always is first, right? If I have less calculation-power than other ppl, wouldnt I want to try to "cheat" by not starting at 0 because other ppl would get the reward always? Did I miss something with this assumption?  
> **username_3**: I added a paragraph ("Even though...") to address that question.  

---

### Answer by username_1 on 2018-11-06. Score: -1

> Why not start at some other integer > 0 for example?

Why would you? Going from 0 to `n` where `n` is the maximum possible value means that the miner will search through all possible values for the nonce. Starting anywhere else and going to `n` means that some nonce values will be skipped, which means that it is possible to miss the nonce value that will get you a block.

If you wrap around back to 0 when you reach `n`, then that is no different from going from 0 to `n`. It's just harder to implement. Going from 0 to `n` is the simplest to implement and guarantees that you will search through all possible nonces.

> **Comments:**
> **username_2**: "means that it is possible to miss the nonce value that will get you a block." That's not how this works. Every nonce has an equal chance of constructing a valid block; the fact that you skip some doesn't affect your chances, as long as you try the same number of candidates per time unit. The right point is that if you reduce the range of nonces, you need to change the extranonce more frequently to reach the same number of candidates per second, which is more work.  

---

