7

A Bitcoin client has to download the whole blockchain from the P2P network in order to become a full node.

A full node is able to determine, if a transaction in the network is valid or not.

To download the blockchain, the client queries other peers in the network for more blocks by providing them with the hash of the last block it has currently in its downloaded blockchain.

The other nodes search in their currently best blockchain for the specified hash and return a list of hashes of further blocks the client can download.

After the client determines that the further block hashes are indeed in the longest block chain by crossvalidating other nodes, it requests those blocks from its peers by giving them the hashes of those new blocks.

After the download, it checks for itself that the blocks follow the rules of the bitcoin network and inserts them in its current blockchain.


This algorithm assumes that any valid block in the blockchain has a unique hash that identifies it. What happens, if by chance a block is inserted in the blockchain that has the same hash as a previous block and that complies with all rules of the bitcoin network?

Wouldn't that break the algorithm?

6

It would not break the algorithm.

As the inventory vector of the described new block would be a duplicate of an already known block, no other node would request this block. It would just be ignored, as if never discovered in the first place. Everybody else would still be hashing away happily, obsoleting the block eventually.

Tough luck for the miner, he'd not get the reward, because everybody would be convinced that no new block has been found at that height yet.

Of course, chances of that happening are negligible, because the block hash is a random 256 bit output (smaller than the current target), which allows for an immense number of possible hash outputs of a similar magnitude as the address space.

Actually, @NickODell made me aware that it can cause a problem, when nodes see the newer block before the older block that was already part of the longest chain. In that case the node would be unable to synchronize, as it would not be able to build the complete chain.

  • 2
    little bit less than 2^256 :)) because hashes have several leading zeros :)) – amaclin Jul 3 '15 at 10:58
  • 2
    Oh, of course yes. I totally forgot about that also being the metric being compared to the target. – Murch Jul 3 '15 at 12:01
  • Worth noting that you don't have to request an inventory item to receive it, you can push items directly to nodes and they will happily download and process it. Violation of the protocol and a waste of bandwidth, but it is valid behavior. – Anonymous Jul 3 '15 at 13:33
  • @Bitcoin: So, essentially, those that had it would remain on the fork until a longer chain orphaned it? Or those that hadn't gotten it and couldn't request it, would not be able to join the chain? – Murch Jul 3 '15 at 18:22
  • 1
    There are 2^256 = 1.1579209e+77 possible transactions. For the block hashes slightly fewer due to the constraints from difficulty. Either way, I think we're good for a few millenia. ;) – Murch Nov 2 '17 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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