What would happen if two blocks had the same hash?

7

1

Consider the following scenario:

  • January 2016 block A gets submitted. Its hash is 0001010.

  • January 2017 block B gets submitted. Its hash is also 0001010 (collision).

  • 10 minutes later, block C gets submitted and the previous field points to the hash 0001010.

Is it still possible to determine that the previous block is block B and not block A?

Note that while this is unlikely, there are not 2^256 possibilities a block hash can be. Every block hash has to start with zeroes which decreases the amount of possibilities. In this scenario there are only 2^4 possibilities even though the hash has 7 bits which would theoretically allow 2^7 possibilities.

Peter111

Posted 2017-09-17T17:51:55.110

Reputation: 247

Answers

11

Blocks are identified by their hash.

This means that in your story, in Jan 2017, when B gets broadcast, any node that it is advertized to will think "I already have this block", and ignore it.

However, when we consider block hash collisions to be a realistic situation, there is another issue that may arise:

If two blocks with the same hash and the same parent are produced ~simultaneously, one of which is valid, and the other is invalid (but does have valid proof of work), some nodes in the network will see one first, and others will see the other first. Those who see the invalid version first will mark the block as permanently invalid, and they won't bother even trying to learn about the valid one when another block builds on top. This would lead to a permanent chain fork between the nodes who saw the invalid block first and those who saw the valid one first.

Pieter Wuille

Posted 2017-09-17T17:51:55.110

Reputation: 54 032

The regular Democracy of majority is appliedIvan Cantarino 2017-09-20T18:23:31.977

I have no idea what you're trying to say, Ivan.Pieter Wuille 2017-09-20T18:25:49.690

@pietier What do you mean "one of which is valid, and the other is invalid' ? why wouldn't both be valid ?franck 2018-03-30T15:45:21.657

@franck That is the premise I'm starting from: it would be possible to create two blocks with the same hash, only one of which is valid. It's also possible to have two valid blocks or two invalid blocks with the same hash, but that isn't what I'm talking about.Pieter Wuille 2018-03-30T23:18:25.537

@PieterWuille thanks just wanted a confirmation. Did you check the code to be certain of this thing ? That would mean there's no timeout in some "invalid blocks list"franck 2018-04-02T14:07:19.027

1

They would be the same block ;-)

If a block happen to have the same hash of another one then all the odds are for those two blocks to share the same exact data i.e. be the same block. Before arguing if we managed to create a collision (extremely low probability, zero I would say) we should investigate if we managed to mine the same transactions in the same order and using the same nonce (low probability, but order of magnitude greater than the previous case)

Gianluca Ghettini

Posted 2017-09-17T17:51:55.110

Reputation: 282

1We would still have two different coinbase transactions, unless we're also trying to pay the same address. :)Murch 2017-09-27T14:17:55.543

Sorry, we had someone spam one sentence answers in the past two days from multiple accounts, I first thought that this answer was part of that series when I added my vote to delete, as there was one on this very question before. Thanks for the fast edit.Murch 2017-09-27T14:23:16.673