Why is the nonce bruteforced from 0 to n while mining?

Why is the nonce bruteforced from 0 to n while mining?

Manage alerts

Loading saved threads...

SimonSchuler · External communityPost link
External question — Bitcoin Stack Exchange Author: SimonSchuler Original post: https://bitcoin.stackexchange.com/questions/80752 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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.
Quote
Report
Ava Chow · External communityPost link
External answer — Bitcoin Stack Exchange Author: Ava Chow Original post: https://bitcoin.stackexchange.com/a/80755 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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.
Quote
Report
G. Maxwell · External communityPost link
External answer — Bitcoin Stack Exchange Author: G. Maxwell Original post: https://bitcoin.stackexchange.com/a/80771 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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 instead of an adder, but no one seems to have bothered with that optimization.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Bitcoin Stack Exchange Author: G. Maxwell Source score (net votes, not local likes): 4 Original post: https://bitcoin.stackexchange.com/a/80771 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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 instead of an adder, but no one seems to have bothered with that optimization.

Cancel quote

Checking account access…