3

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.

5
  • 4
    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... Dec 20, 2012 at 1:36
  • @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. Dec 20, 2012 at 1:39
  • @makerofthings7 Clients don't accept invalid blocks.
    – theymos
    Dec 20, 2012 at 1:51
  • 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" Dec 20, 2012 at 3:39
  • @HighlyIrregular Revised... I was getting ahead of myself there. Dec 20, 2012 at 4:00

2 Answers 2

4

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.