shuijian-xu / bitcoin

0 stars 0 forks source link

How a Miner Generates New Hashes? #118

Open shuijian-xu opened 5 years ago

shuijian-xu commented 5 years ago

Where does the miner get new numerical dirt to process to see if it satisfies proof-of-work? This is where the nonce field comes in. The miners can change the nonce field at will to change the hash of the block header.

Unfortunately, the 4 bytes or 32 bits of the nonce field (or 2^32 possible nonces that a miner can try) is insufficient for the required proof-of-work. Modern ASIC equipment can calculate way more than 2^32 different hashes per second. The AntMiner S9, for example, calculates 12 terahashes per second (Th/s). That is approximately 2^43 hashes per second, which means that the entire nonce space can be consumed in just 0.0003 seconds.

What miners can do when the nonce field is exhausted is change the coinbase transaction, which then changes the Merkle root, giving miners a fresh nonce space each time. The other option is to roll the version field or use overt ASICBOOST. The mechanics of how the Merkle root changes whenever any transaction in the block changes will be discussed in Chapter 11.