1
I'm learning about mining and the first thing that surprised me is that the nounce part of the algorithm which is supposed to be randomly looped until you get a number smaller than the target hash .. is just 32 bits long. Can you explain why then is it so difficult to loop an unsigned int and how come is it increasingly difficult over time? Thank you.
Edit: It's been suggested this is a duplicate, this is not. The other question asked if you could run out of nounces, that's nothing to do with my question. My question is about the difficulty of Hashing the exact same 4 billion unsigned int entry loops.
Short answer: With high probability, none of those 2^32 nonces will result in a hash smaller than the target. So then you change something else in the block header and try again. For instance, you can increment a number in the coinbase transaction, which results in a new value for the "Merkle root" hash in the block header. The smaller the target, the more times you are likely to have to do this before success. – Nate Eldredge – 2017-08-31T13:47:05.657
@NateEldredge It looks like you are saying that you do not really need to change the nounce since there is the possibility that none of the 4 billion different values may lead to a winning hash. What makes then a valid 'source material' to hash while attemting to discover a right answer? if you can point me to updated literature about it I will accept that as a right answer. Thanks – Pol – 2017-08-31T17:48:26.187
No, I'm not saying that. What you need is a valid 80-byte block header whose hash is below the target value. So you have to keep changing things in the header until you find something that leads to a winning hash. The easiest thing to change is the nonce, so you fix everything else and then try all possible nonces. If you are lucky then one of them works and you win. If not, which happens most of the time, then you change something else in the header and try all nonces for the updated header. Repeat indefinitely until you win. – Nate Eldredge – 2017-08-31T18:08:25.467
There isn't any need for "updated" literature; the block format and hashing algorithm hasn't changed in any relevant way since the initial introduction of Bitcoin. It was always possible that, with everything else in the header fixed, none of the 2^32 possible nonces wins, and this case always had to be handled; it already happens about 36% of the time even at minimum difficulty. – Nate Eldredge – 2017-08-31T18:09:05.533