Is it possible for a valid block to be added to an invalid one, and have it accepted by another client? This wiki page says invalid blocks aren't counted towards determining chain length 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.
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, 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.