Bitcoin Forum

Other => Beginners & Help => Topic started by: BlackHatCoiner on May 13, 2020, 09:53:02 PM



Title: I have a misunderstanding about nonce.
Post by: BlackHatCoiner on May 13, 2020, 09:53:02 PM
In mining, miners take the prevblockhash, the merkle root, some other stuff like version and also they set an interval called nonce that is nothing but a number that they change its time, because it changes completely the final result.

Miners also make more than trillions of hashes per second on their mining farms right? Isn't the only thing that they change the nonce? If yes, why is it always within that range and not above 10^15 (for example) ?

https://i.imgur.com/HvOuCTl.png


I hope I was clear.


Title: Re: I have a misunderstanding about nonce.
Post by: Loganota on May 13, 2020, 10:09:04 PM
AFAIK, nonce is a 32-bit number1, so it can range from 0 to 4,294,967,295 (232 - 1)

[1]: https://en.bitcoin.it/wiki/Nonce


Title: Re: I have a misunderstanding about nonce.
Post by: TravelMug on May 14, 2020, 03:29:36 AM
AFAIK, nonce is a 32-bit number1, so it can range from 0 to 4,294,967,295 (232 - 1)

[1]: https://en.bitcoin.it/wiki/Nonce

And just to make it clear, nonce is a 32-bit unsigned integers, thus they are always non-negative (0 or positive) so the range is from 0 to 4,294,967,295.

As opposed to a 32-bit signed integers, that can be both positive or negative, hence -2,147,483,648 through 2,147,483,647.


Title: Re: I have a misunderstanding about nonce.
Post by: nc50lc on May 14, 2020, 03:56:07 AM
AFAIK, nonce is a 32-bit number1, so it can range from 0 to 4,294,967,295 (232 - 1)
This ^

And if it reached the maximum, the miner should change "something" in the coinbase transaction (like a random character in "mined by ###" that they're adding);
That will change the merkle root and of-course merkle root hash, then they can start nonce from 0 again.

That's described as "extraNonce" here: https://en.bitcoin.it/wiki/Block_hashing_algorithm (https://en.bitcoin.it/wiki/Block_hashing_algorithm)


Title: Re: I have a misunderstanding about nonce.
Post by: pooya87 on May 14, 2020, 04:11:26 AM
And just to make it clear, nonce is a 32-bit unsigned integers, thus they are always non-negative (0 or positive) so the range is from 0 to 4,294,967,295.

As opposed to a 32-bit signed integers, that can be both positive or negative, hence -2,147,483,648 through 2,147,483,647.

since nonce has no meaning then how you interpret it makes no difference. it is simply 32 zeros and ones (aka bits) and goes from 000....000 to 000...001 and up to 111...111. keep in mind that there is no difference between Int32 and UInt32 when you look at them in binary.

And if it reached the maximum, the miner should change "something" in the coinbase transaction (like a random character in "mined by ###" that they're adding);
the correct way of saying it is that miner has to change something in "block header", that thing can be the extra nonce in coinbase transaction to change merkle root, or it could be the transactions in the block (change order, add/remove,...), it could be block time or block version. this last one is why we see weird block versions sometimes.


Title: Re: I have a misunderstanding about nonce.
Post by: nc50lc on May 14, 2020, 04:23:02 AM
the correct way of saying it is that miner has to change something in "block header", that thing can be the extra nonce in coinbase transaction to change merkle root, or it could be the transactions in the block (change order, add/remove,...), it could be block time or block version. this last one is why we see weird block versions sometimes.
Those are what overt ASIC-boost miners using to get "extra entropy" (block version), but it was just being exploited;
"block time" is changed every second (though can vary) which is the main concern of the OP since a mining pool's hash per second can reach more than the list of mined block's typical nonce.
So we're talking about what to change within that second (in which case, both are true)  :)

"extraNonce" however is what the link described.


Title: Re: I have a misunderstanding about nonce.
Post by: BlackHatCoiner on May 14, 2020, 07:28:23 AM
the correct way of saying it is that miner has to change something in "block header", that thing can be the extra nonce in coinbase transaction to change merkle root, or it could be the transactions in the block (change order, add/remove,...), it could be block time or block version. this last one is why we see weird block versions sometimes.
Those are what overt ASIC-boost miners using to get "extra entropy" (block version), but it was just being exploited;
"block time" is changed every second (though can vary) which is the main concern of the OP since a mining pool's hash per second can reach more than the list of mined block's typical nonce.
So we're talking about what to change within that second (in which case, both are true)  :)

"extraNonce" however is what the link described.

Blocktime is the current time? I thought time is this:
https://youtu.be/MJ0OzrkHvXA?t=2658


Title: Re: I have a misunderstanding about nonce.
Post by: nc50lc on May 14, 2020, 09:03:06 AM
Blocktime is the current time? I thought time is this:
https://youtu.be/MJ0OzrkHvXA?t=2658
Yes, and that video explains how much the "block timestamp" can vary to be still valid since each of the miner's/mining pool's clocks can't always be the same with each other.
It can also be used as another entropy since they can fake it as long as it's within the valid range.

I used "block time" because it was used in pooya's post that I replied to and the only "time" in the header is the timestamp.