0

When mining a block, who gets to choose the hash from the previous block, the nonce and its adjustment. Is it all the miners who choose or the ones who successfully found the block?

For either answer, how do they not know the correct answer to the nonce if they are the once who set it up?

1 Answer 1

2

Previous block hash

When mining a block, who gets to choose the hash from the previous block,

Nobody.

It isn't chosen. The current top block in the chain is known and its contents are fixed. The hash value depends only on the contents. Therefore the hash of the current top block is also a fixed value.

A good cryptographic hash algorithm, such as SHA256, produces a value that cannot be predicted from the data being hashed. Other than by doing all the work of actually computing the hash. Changing one bit in the data makes the hash result wildly different in a completely unpredictable way. The hashes look completely random.


Nonce

how do they not know the correct answer to the nonce if they are the once who set it up?

Nonces are not things that have an answer.

The nonce is just a numeric data item whose value has no meaning. It is provided for the miner's use as described below.


Hashes & Nonces in Mining

Lets look at the role of block-hashes and nonces in mining:

A new block has a header that contains a reference to the previous block. When creating their block template a miner must set the previous block reference to the block-id (hash) of the current top block in the chain of blocks. This is necessary for their new block to become the next top block of the chain. Each block links to the previous block.

Then the miner computes a hash of their new block and if the resulting hash value is higher than the network target the arrangement of data is a failure and they must change something in their block template and try again. One of the things they can change is a number in the block header provided for this purpose. That number is called the nonce.

If the miner finds a set of data that has a hash less than the target, they publish it. It takes a lot of tries before a set of data is found that has a low hash.

All nodes (wallets etc) check every part of the new block and either discard it or add it to their copy of the Blockchain.

One of the checks made by every node is to calculate the hash of the block to see if it is less than the network target. Nodes don't need to check all the miners failed arrangements of data, they only see the successful ones.


See What exactly is Mining?

2
  • When you say "One of the things they can change is a number in the block header provided for this purpose" do you mean all the miners or only a group of miners make this change? I really appreciate your answers, thank you.
    – Ghost
    Commented Aug 3, 2022 at 20:32
  • @Ghost. Outside mining pools, miners do not need to collaborate or share information. Conceptually at least, each miner acts in isolation. Each miner can create their own block template individually. Each miner can vary their template in whatever way they see fit. Each miner individually can do whatever they like with the nonce value. Commented Aug 3, 2022 at 20:49

Your Answer

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

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