<p>Nodes would reject it immediately.</p>

<p>If you simply alter the data of B2 and send it, the block will be invalid by definition as the proof of work and merkle tree will not be valid anymore.</p>

<p>If you modify the data <em>and</em> rebuild the merkle tree <em>and</em> redo the proof of work to produce an alternative, valid <code>B2'</code> (note that everything else in this new block must also be valid, including transactions), nodes will still reject it as the chain going up to B4 has a greater amount of work.</p>

<p>Nodes will consider the chain with the greatest amount of total work as the valid chain. If you want to rewrite history, you will need to mine a new chain going back to the block you want to start rewriting from, and mine it to a point where its total work exceeds the current best chain. If you then broadcast this new chain of blocks, it will cause nodes to perform a reorganization, and drop the previous chain.</p>

<p>As for transactions returning to the mempool, that does happen in the event of a reorganization. All transactions from the dropped blocks are returned to the mempool. Usually, since miners generally pick similar transactions, the new blocks replacing the old ones will confirm mostly similar transactions, so the mempool will usually only be slightly different at the end of it.</p>

CC BY-SA 4.0
2018-10-20T18:25:36.513Z
Thanks for the answer! For anyone's information: I happened to come across the article ["Blockchain: how a 51% attack works (double spend attack)"](https://hackernoon.com/what-is-a-51-attack-or-double-spend-attack-aa108db63474) which does say that the malicious user must grow a long enough chain in order to make the reorganization happen (see the "Stealth mining" section).
yaobin
CC BY-SA 4.0
2018-10-20T05:31:27.057Z
2018-10-20T05:31:27.057Z
Raghav Sood
<p>I am reading the book <a href="https://github.com/yaobinwen/bitcoinbook/tree/second_edition_print2" rel="nofollow noreferrer">"Mastering Bitcoin"</a> and have finished reading Chapter 2 and 10, but I still don't find the answer.</p>

<p>Suppose the current main chain has 5 blocks:</p>

<pre><code>B0 &lt;- B1 &lt;- B2 &lt;- B3 &lt;- B4
</code></pre>

<p>As new transactions flowing in, the honest miners are mining <code>B5</code>, the 6th block.</p>

<p>If I publish a modified <code>B2</code>, say <code>B2'</code>, to the Bitcoin network, what happens to this modified block when it is received by the other peers? Suppose <code>B2'</code> contains all the transactions that <code>B2</code> has except that the amount of transferred bitcoin of one transaction is slightly modified but still a valid amount.</p>

<ul>
<li>Would <code>B2'</code> be rejected immediately? It doesn't look like so because the modified transaction seems to be still valid. As far as I have learned, the recipient node uses the earlier blocks, <code>B0</code> and <code>B1</code>, to validate <code>B2'</code>, and I think the validation would succeed. Am I right?</li>
<li>If <code>B2'</code> is not rejected immediately, would the peer nodes link it to <code>B1</code> as a secondary chain? I actually think <code>B2'</code> should be rejected but after reading Chapter 10 of Mastering Bitcoin I don't seem to find a reason to justify why it should be rejected.</li>
<li>Furthermore, if <code>B2'</code> is linked to <code>B1</code> anyway, what would happen when the 6th block, <code>B5</code>, is now mined and published? According to the Chapter 10, "the transactions ... are re-inserted in the mempool for inclusion in the next block, because the block they were in is no longer in the main chain." so I think now <code>B2'</code> would be removed and its transactions would be re-inserted into the mempool. Then all the unmodified transactions in <code>B2'</code> will be removed again because they have been included in <code>B2</code> in the main chain, and the modified transaction in <code>B2'</code> would be rejected because it conflicts with the counterpart in <code>B2</code>.</li>
</ul>

<p>Thanks for any help!</p>

<security><block><blockchain-fork><validation>
What would happen if I publish a modified version of an earlier block? Would it be rejected immediately by peer nodes?
yaobin
# What would happen if I publish a modified version of an earlier block? Would it be rejected immediately by peer nodes?

(Asked by: username_0 on 2018-10-20)

I am reading the book ["Mastering Bitcoin"](https://github.com/yaobinwen/bitcoinbook/tree/second_edition_print2) and have finished reading Chapter 2 and 10, but I still don't find the answer.

Suppose the current main chain has 5 blocks:

```
B0 <- B1 <- B2 <- B3 <- B4

```

As new transactions flowing in, the honest miners are mining `B5`, the 6th block.

If I publish a modified `B2`, say `B2'`, to the Bitcoin network, what happens to this modified block when it is received by the other peers? Suppose `B2'` contains all the transactions that `B2` has except that the amount of transferred bitcoin of one transaction is slightly modified but still a valid amount.

* Would `B2'` be rejected immediately? It doesn't look like so because the modified transaction seems to be still valid. As far as I have learned, the recipient node uses the earlier blocks, `B0` and `B1`, to validate `B2'`, and I think the validation would succeed. Am I right?
* If `B2'` is not rejected immediately, would the peer nodes link it to `B1` as a secondary chain? I actually think `B2'` should be rejected but after reading Chapter 10 of Mastering Bitcoin I don't seem to find a reason to justify why it should be rejected.
* Furthermore, if `B2'` is linked to `B1` anyway, what would happen when the 6th block, `B5`, is now mined and published? According to the Chapter 10, "the transactions ... are re-inserted in the mempool for inclusion in the next block, because the block they were in is no longer in the main chain." so I think now `B2'` would be removed and its transactions would be re-inserted into the mempool. Then all the unmodified transactions in `B2'` will be removed again because they have been included in `B2` in the main chain, and the modified transaction in `B2'` would be rejected because it conflicts with the counterpart in `B2`.

Thanks for any help!

**Tags:** security, block, blockchain-fork, validation


---

## 1 answers

### Answer by username_1 on 2018-10-20. Score: 2 | Accepted answer

Nodes would reject it immediately.

If you simply alter the data of B2 and send it, the block will be invalid by definition as the proof of work and merkle tree will not be valid anymore.

If you modify the data *and* rebuild the merkle tree *and* redo the proof of work to produce an alternative, valid `B2'` (note that everything else in this new block must also be valid, including transactions), nodes will still reject it as the chain going up to B4 has a greater amount of work.

Nodes will consider the chain with the greatest amount of total work as the valid chain. If you want to rewrite history, you will need to mine a new chain going back to the block you want to start rewriting from, and mine it to a point where its total work exceeds the current best chain. If you then broadcast this new chain of blocks, it will cause nodes to perform a reorganization, and drop the previous chain.

As for transactions returning to the mempool, that does happen in the event of a reorganization. All transactions from the dropped blocks are returned to the mempool. Usually, since miners generally pick similar transactions, the new blocks replacing the old ones will confirm mostly similar transactions, so the mempool will usually only be slightly different at the end of it.

> **Comments:**
> **username_0**: Thanks for the answer! For anyone's information: I happened to come across the article ["Blockchain: how a 51% attack works (double spend attack)"](https://hackernoon.com/what-is-a-51-attack-or-double-spend-attack-aa108db63474) which does say that the malicious user must grow a long enough chain in order to make the reorganization happen (see the "Stealth mining" section).  

---

