<p>With the Bitcoin.org client, the node accepts a block only after none of the verification steps fail.  </p>

<p>Each block in the block*<em>chain</em>* is linked to a prior block with a reference to that prior block's hash.  </p>

<p>So take the case where a node sees the longest chain ending at height 1,000.  Then it receives a block 1,001.  The client will then verify that the hash that block gives for block 1,000 truly matches the hash the client already knows about (from the longest chain) for block 1,000.   It won't match, so this 1,001 doesn't extend off of the block 1,000 the client already knows about. </p>

<p>And since the client doesn't have knowledge of any other block 1,000 with that hash that 1,0001 purports to extend from, the client will not accept block 1,001 -- there is no link tying it to any previously received blocks.</p>

CC BY-SA 3.0
2012-12-20T04:34:33.223Z
2012-12-20T04:47:01.237Z
2012-12-20T04:47:01.237Z
Stephen Gornick
<p>As every Client verifies each block they receive and reject every Block that is invalid, this situation is rather unlikely to happen. However, if by chance some invalid Block would propagate (such as in case of <a href="https://bitcointalk.org/index.php?topic=822.0" rel="nofollow">value overflow bug</a>, or perhaps by being spread by some alternative Clients that don't follow the Protocol to the letter), it would eventually be wiped out of the Block history and orphan all Blocks attached to it. Alternatively, the Protocol could change to accommodate the Block, but that is a lot less likely to happen.</p>

<p>When part of the Block Chain would become invalid, all Transactions contained in it would be re-evaluated - coin generation Transactions would be discarded, all Transactions that spend their outputs would also be invalidated, and all other Transactions that are still valid would be added back to the pool of Transactions to be added to future Blocks. Same thing would happen in case of some Blocks being overwritten with a longer Chain of Blocks.</p>

<p>All in all, an invalid Block being accepted as valid and having valid Blocks appended to the Chain after it is a bug. Such cases have happened in the past at least once, and the result has been to fix the bug and erase the invalid Block along with all other Blocks attached to it. All normal Transactions from those Blocks would have to be added again to newly created Blocks and any coin generation Transactions would be invalidated.</p>

CC BY-SA 3.0
2013-01-19T11:38:34.607Z
2013-01-19T11:38:34.607Z
ThePiachu
<p>This wiki page says <a href="https://en.bitcoin.it/wiki/Invalid_block" rel="nofollow">invalid blocks aren't counted towards determining chain length</a> and that make me want understand how invalid blocks are treated.</p>

<ul>
<li>Can an valid block be added to an invalid one.. and have it accepted by one or more clients?</li>
</ul>

<p><em><strong>If so...</em></strong></p>

<ul>
<li>Do miners of invalid blocks receive a reward for the block? Are the Tx's valid? Are there any examples?</li>
</ul>

<p>Suppose an invalid block is created and valid block is added to that invalid one.  Both blocks are added to the primary chain. ( assume the attacker has 25% compute and has a custom client that pushes both transactions to all peers)</p>

<ul>
<li><p>Since every block has a reward, is the reward in the invalid block counted?</p></li>
<li><p>Are the transactions within an invalid block still considered valid?</p></li>
</ul>

<p>I'm interested in tracing the transactions the occur from these "broken" blocks and to see if my hand-coded client processes the transactions correctly.  </p>

CC BY-SA 3.0
2012-12-20T01:36:52.683Z
By definition, a block is only valid if it's added to a valid block. Therefore, it is impossible to have a valid one added to an invalid one. Sorry, I can't just go with you on that one...
Highly Irregular
CC BY-SA 3.0
2012-12-20T01:39:21.520Z
@HighlyIrregular I updated the scenario with details.  According to the wiki, clients will accept invalid blocks but won't relay them.  If an attacker crafts and relays both blocks... what happens?  Less than 51% of CPU is needed for this to happen.
makerofthings7
CC BY-SA 3.0
2012-12-20T01:51:25.947Z
@makerofthings7 Clients don't accept invalid blocks.
theymos
CC BY-SA 3.0
2012-12-20T03:39:30.787Z
For the record, I still think this is a good question, even if the underlying assumptions happen to be incorrect, so I've upvoted it. A better question though might be "Is it possible for a valid block to be added to an invalid one, and have it accepted by another client"
Highly Irregular
CC BY-SA 3.0
2012-12-20T04:00:24.843Z
@HighlyIrregular Revised... I was getting ahead of myself there.
makerofthings7
<blockchain><block><verification>
Is it possible for a valid block to be added to an invalid one, and have it accepted by another client?
makerofthings7
# Is it possible for a valid block to be added to an invalid one, and have it accepted by another client?

(Asked by: username_0 on 2012-12-20)

This wiki page says [invalid blocks aren't counted towards determining chain length](https://en.bitcoin.it/wiki/Invalid_block) and that make me want understand how invalid blocks are treated.

* Can an valid block be added to an invalid one.. and have it accepted by one or more clients?

***If so...***

* Do miners of invalid blocks receive a reward for the block? Are the Tx's valid? Are there any examples?

Suppose an invalid block is created and valid block is added to that invalid one. Both blocks are added to the primary chain. ( assume the attacker has 25% compute and has a custom client that pushes both transactions to all peers)

* Since every block has a reward, is the reward in the invalid block counted?
* Are the transactions within an invalid block still considered valid?

I'm interested in tracing the transactions the occur from these "broken" blocks and to see if my hand-coded client processes the transactions correctly.

**Tags:** blockchain, block, verification

> **Comments:**
> **username_1**: By definition, a block is only valid if it's added to a valid block. Therefore, it is impossible to have a valid one added to an invalid one. Sorry, I can't just go with you on that one...  
> **username_0**: @HighlyIrregular I updated the scenario with details.  According to the wiki, clients will accept invalid blocks but won't relay them.  If an attacker crafts and relays both blocks... what happens?  Less than 51% of CPU is needed for this to happen.  
> **username_2**: @username_0 Clients don't accept invalid blocks.  
> **username_1**: For the record, I still think this is a good question, even if the underlying assumptions happen to be incorrect, so I've upvoted it. A better question though might be "Is it possible for a valid block to be added to an invalid one, and have it accepted by another client"  
> **username_0**: @HighlyIrregular Revised... I was getting ahead of myself there.  

---

## 2 answers

### Answer by username_4 on 2013-01-19. Score: 4 | Accepted answer

As every Client verifies each block they receive and reject every Block that is invalid, this situation is rather unlikely to happen. However, if by chance some invalid Block would propagate (such as in case of [value overflow bug](https://bitcointalk.org/index.php?topic=822.0), or perhaps by being spread by some alternative Clients that don't follow the Protocol to the letter), it would eventually be wiped out of the Block history and orphan all Blocks attached to it. Alternatively, the Protocol could change to accommodate the Block, but that is a lot less likely to happen.

When part of the Block Chain would become invalid, all Transactions contained in it would be re-evaluated - coin generation Transactions would be discarded, all Transactions that spend their outputs would also be invalidated, and all other Transactions that are still valid would be added back to the pool of Transactions to be added to future Blocks. Same thing would happen in case of some Blocks being overwritten with a longer Chain of Blocks.

All in all, an invalid Block being accepted as valid and having valid Blocks appended to the Chain after it is a bug. Such cases have happened in the past at least once, and the result has been to fix the bug and erase the invalid Block along with all other Blocks attached to it. All normal Transactions from those Blocks would have to be added again to newly created Blocks and any coin generation Transactions would be invalidated.


---

### Answer by username_3 on 2012-12-20. Score: 2

With the Bitcoin.org client, the node accepts a block only after none of the verification steps fail.

Each block in the block\**chain*\* is linked to a prior block with a reference to that prior block's hash.

So take the case where a node sees the longest chain ending at height 1,000. Then it receives a block 1,001. The client will then verify that the hash that block gives for block 1,000 truly matches the hash the client already knows about (from the longest chain) for block 1,000. It won't match, so this 1,001 doesn't extend off of the block 1,000 the client already knows about.

And since the client doesn't have knowledge of any other block 1,000 with that hash that 1,0001 purports to extend from, the client will not accept block 1,001 -- there is no link tying it to any previously received blocks.


---

