3

Good morning,

I'm reading about Blockchain technology but I have a couple of questions about the nonce that I cannot find the answers for. I'm hoping someone here will be able to answer them.

i) In order to adjust for the level of computing power available, how is the difficulty of the nonce changed? What is the mechanism that checks if this should happen and how?

ii) What is to stop a code-savvy miner from changing the difficulty of their generated nonce to something easy so that they are the ones to place the block in the blockchain and win the mined coins?

I'm finding this topic quite fascinating and so any help you guys can provide is always greatly appreciated.

2 Answers 2

2

Difficulty in Bitcoin is expressed by the hash of a Bitcoin block header being required to be numerically lower than a certain target. This difficulty target is reset every 2016 blocks by up to a factor four up or down. Hereby the difficulty is adjusted that the average hashrate available in the last 2016 blocks would take about 14 days to mine 2016 blocks. E.g. if the 2016 blocks took 10 days instead of 14, difficulty would increase by a factor 1.4.

The nonce is a mean to quickly iterate through many block candidates of the same block template, whereas the extra-nonce is a means to quickly make a slight change to the block template. Every time a new block candidate is hashed, the result is completely unpredictable, so eventually one block candidate will fulfil the difficulty requirement. When this happens, the successful miner broadcasts the new block to the network.

However, every other node in the network will also make sure that the block is actually valid. This includes testing the validity of the block hash from the header, as well as checking every single transaction. Hence, a miner that mines at a lower difficulty might simply broadcast a block that doesn't fulfil the difficulty requirement and thus will be rejected by all other network participants.

0
2

The Nonce is not difficulty based, the hash of the block is difficulty based. First, the miner hashes the block and checks if the block is solved. If it is not then the Nonce is incremented. If the Nonce overflows (which it does frequently) then the extraNonce portion of the transaction is incremented changing the Merkle Root and the block hash again, so the miner continues and again cycle the Nonce value.

There is some information here.

There is nothing stopping a miner changing locally the difficulty of the block it's mining, but such block simply won't be accepted by the other Bitcoin nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.