3

As far as I have known, the mining process is as follows,

step 1: collect a series of transactions and construct a block by filling required information like hash of the previous block and the Merkle tree root, etc.

step 2: solving a puzzle by constantly changing the 'nonce' field of the block to make the hash of the block header less than a target.

When a miner have constructed a block (step 1) and is trying to solve the puzzle (step 2), a very attractive transaction with high fee comes, will the miner give up the work he has done, reconstruct the block and restart solving the puzzle?

2
  • What work would he give up exactly? Commented Mar 8, 2020 at 8:52
  • The work to change the "nonce" of the current block
    – Better
    Commented Mar 9, 2020 at 2:40

3 Answers 3

4

A modern mining system will do both.

Today, miners and mining pools have more hashpower than required to check all iterations of a nonce and extraNonce for a single block template. They get around this by consecutively operating on multiple block templates, usually varying on the block timestamp, data in the Coinbase transaction, and the list of selected transactions.

These updated block templates are constantly generated in parallel to the actual hashing operations - as more attractive transactions are discovered, the next set of block templates generated will be updated to contain those transactions. As soon as the mining hardware finishes with its current block template, it will grab a new, likely optimal template from the pool.

If a single worked discovers a valid block with a suboptimal template, miners will broadcast that block - there is little sense in discarding a block over a relatively small fee increase and giving up the entire block reward.

1
  • 1
    Perhaps importantly the cost of transmission for a solution is essentially zero.
    – Claris
    Commented Mar 7, 2020 at 9:24
2

The block template is updated, (maybe) every a few seconds, updated with new transactions.

will the miner give up the work he has done

Every block with a hash satisfying the target is propagated. But if a block wasn't made, remember that mining is a Poisson Process, with the most important property being memoryless-ness. If a block takes 10 minutes on average to mine, and after 5 minutes of mining, changing the block template wouldn't reduce the time expected until the next block (hence "give up" is not the best word)

reconstruct the block and restart solving the puzzle?

Yes.

3
  • Let's consider this situation: before the high-fee transaction comes, a miner didn't update his block and kept changing the "nonce" of the same block, the space of the useless results he got is S. Now the high-fee transaction comes, the miner reconstructs the block and restarts solving the puzzle, what if the results he gets fall into S again? Doesn't it mean that the work he has done is wasted?
    – Better
    Commented Mar 7, 2020 at 15:07
  • 1
    SHA256, like other good cryptographic hash functions, has avalanche effect, which means even one bit changed in the input will cause the output to be entirely different. The new hashes found will be entirely different as the Merkle hash of the transactions (or the hash of all TXIDs in the block) can also act as a nonce to change output hash. @Better
    – MCCCS
    Commented Mar 7, 2020 at 18:45
  • 4
    Computing a single hash takes time in the order of nanoseconds, and every attempt is independent. It's not because you've tried a billion failed hashes already that you're in any way "closer" to finding a solution. In other words: PoW is progress free, apart from the time it takes to compute a single hash, which is so short compared to the time scale at which transactions happen. Commented Mar 7, 2020 at 21:37
2

When a miner have constructed a block (step 1) and is trying to solve the puzzle (step 2), a very attractive transaction with high fee comes, will the miner give up the work he has done, reconstruct the block and restart solving the puzzle?

Either that work produced a block or it did not. If it produced a block, he will definitely broadcast that block. If it did not produce a block, then he loses nothing by giving it up. So there's no "work he has done" that he might "give up".

Work that miners do either produces a block or it doesn't. There's no way to be part way to producing a block only to start over.

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.