<blockquote>
  <p>Wouldn't this mean that every time a new transaction is added to the block (before its mined), that all nonces previously attempted need to be tried yet again?</p>
</blockquote>

<p>Yes, but "need" is a bit too strong of a word in this context.  Because you can't predict the outcome of a hash without performing the hash, each new hash attempt is just as likely to meet the target as the previous one.  As such, yes, it is possible that a nonce that has already been attempted will now succeed given that the merkle root has changed...but it is no more likely than the nonce you were about to attempt before adding the new transaction.  There's no real reason to re-try nonces.  The odds aren't any better.</p>

<blockquote>
  <p>Wouldn't this discourage miners from adding transactions to the block if they have to hash everything with nonces again?</p>
</blockquote>

<p>No.  Because the odds do not change, there is no negative incentive to adding a new transaction.  However, transactions come with miner fees, so the positive incentive is still in place.</p>

<blockquote>
  <p>Also, is it possible that no nonces could produce a valid successful/winning hash?</p>
</blockquote>

<p>Yes, it is possible, although not probable.  Remember that a successful hash is one that is <em>less than</em> the target.  These means there are quite a large number of nonces that will be successful, however, as a set they represent a very small proportion of the total possible nonces.  Even if hypothetically there is a block header that is "unmineable", a competing block would not be.  A block will still be found, and it will likely have a very similar set of transactions in it.</p>

CC BY-SA 3.0
2017-12-12T12:03:32.573Z
Great answer(s), thank you. I think the key take away is that just because a miner has performed a hash that was unsuccessful doesn't increase their chances of finding the winning hash with the next nonce - this is because there's no guarantee that any nounce with a Merkle root hash will be the winning hash. Have I got that right?
alexkb
CC BY-SA 3.0
2017-12-11T15:09:50.337Z
2017-12-11T15:09:50.337Z
Jestin
<p>There are no transactions dynamically added to a block that miners try to solve.<br>
Transactions are taken from mempool in the moment the last block was mined and the merkelroot has to be calculated only once for those picked transactions.</p>

<p>It´s every miners free choice to discard transactions from this list (e.g. tx with low fees) and the list is limited by the 1MB blocksize. So it´s approximately 2000 tx per block.  </p>

CC BY-SA 3.0
2017-12-11T13:25:35.327Z
2017-12-11T13:25:35.327Z
d00d
<p>The block header contains a <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">number of things</a>, among them the Merkle root hash. Wouldn't this mean that every time a new transaction is added to the block (before its mined), that all nonces previously attempted need to be tried yet again?</p>

<p>Wouldn't this discourage miners from adding transactions to the block if they have to hash everything with nonces again?</p>

<p>Also, is it possible that no nonces could produce a valid successful/winning hash?</p>

CC BY-SA 3.0
2017-12-11T15:10:53.730Z
You may want to consider breaking up this into multiple questions.  The third and fourth questions, in particular, don't directly relate to the overall question.
Jestin
CC BY-SA 3.0
2017-12-11T16:17:53.040Z
Sometimes miner's will mix up the transactions *on purpose* to get a new hash if they aren't able to find a valid nonce in a reasonable amount of time.
DjangoBlockchain
CC BY-SA 3.0
2017-12-12T12:07:28.127Z
Hi @Jestin, as suggested, I've removed the forth question but I still think the 3rd question relates as per my other comment. Cheers.
alexkb
CC BY-SA 3.0
2017-12-12T13:14:22.893Z
@alexkb, the point isn't to have related questions grouped correctly.   The point is to have questions be independent posts so that people with the same question can find it easier.  Each of these could have been independent, and therefore simpler for someone to find in the future.
Jestin
<hash><merkle-tree>
Block hashing algorithm
alexkb
# Block hashing algorithm

(Asked by: username_0 on 2017-12-11)

The block header contains a [number of things](https://en.bitcoin.it/wiki/Block_hashing_algorithm), among them the Merkle root hash. Wouldn't this mean that every time a new transaction is added to the block (before its mined), that all nonces previously attempted need to be tried yet again?

Wouldn't this discourage miners from adding transactions to the block if they have to hash everything with nonces again?

Also, is it possible that no nonces could produce a valid successful/winning hash?

**Tags:** hash, merkle-tree

> **Comments:**
> **username_1**: You may want to consider breaking up this into multiple questions.  The third and fourth questions, in particular, don't directly relate to the overall question.  
> **username_2**: Sometimes miner's will mix up the transactions *on purpose* to get a new hash if they aren't able to find a valid nonce in a reasonable amount of time.  
> **username_0**: Hi @username_1, as suggested, I've removed the forth question but I still think the 3rd question relates as per my other comment. Cheers.  
> **username_1**: @username_0, the point isn't to have related questions grouped correctly.   The point is to have questions be independent posts so that people with the same question can find it easier.  Each of these could have been independent, and therefore simpler for someone to find in the future.  

---

## 2 answers

### Answer by username_1 on 2017-12-11. Score: 2 | Accepted answer

> Wouldn't this mean that every time a new transaction is added to the block (before its mined), that all nonces previously attempted need to be tried yet again?

Yes, but "need" is a bit too strong of a word in this context. Because you can't predict the outcome of a hash without performing the hash, each new hash attempt is just as likely to meet the target as the previous one. As such, yes, it is possible that a nonce that has already been attempted will now succeed given that the merkle root has changed...but it is no more likely than the nonce you were about to attempt before adding the new transaction. There's no real reason to re-try nonces. The odds aren't any better.

> Wouldn't this discourage miners from adding transactions to the block if they have to hash everything with nonces again?

No. Because the odds do not change, there is no negative incentive to adding a new transaction. However, transactions come with miner fees, so the positive incentive is still in place.

> Also, is it possible that no nonces could produce a valid successful/winning hash?

Yes, it is possible, although not probable. Remember that a successful hash is one that is *less than* the target. These means there are quite a large number of nonces that will be successful, however, as a set they represent a very small proportion of the total possible nonces. Even if hypothetically there is a block header that is "unmineable", a competing block would not be. A block will still be found, and it will likely have a very similar set of transactions in it.

> **Comments:**
> **username_0**: Great answer(s), thank you. I think the key take away is that just because a miner has performed a hash that was unsuccessful doesn't increase their chances of finding the winning hash with the next nonce - this is because there's no guarantee that any nounce with a Merkle root hash will be the winning hash. Have I got that right?  

---

### Answer by username_3 on 2017-12-11. Score: 0

There are no transactions dynamically added to a block that miners try to solve.  
Transactions are taken from mempool in the moment the last block was mined and the merkelroot has to be calculated only once for those picked transactions.

It´s every miners free choice to discard transactions from this list (e.g. tx with low fees) and the list is limited by the 1MB blocksize. So it´s approximately 2000 tx per block.


---

