1

What happens when two miners include same or set of transaction in their block, mine it and then broadcast it at same time? Can the transaction be included in two separate block like this OR a fork happens?

2 Answers 2

1

If both blocks are broadcast at the same time, and we assume both miners are equally connected to the network, a fork may occur.

Since the default mining policy is mining on the top of the longest chain, or the first one heard in case of a fork, the network should mine in two different blocks until a new one is found, moment when all should go back to "normal".

1

It is possible for two miners find blocks at the same height simultaneously, and for those two blocks to have an overlap of included transactions. Each block is valid in it's own right, but eventually only one can be included in the longest chain, and the other will become an 'stale block'. Lets call these two blocks Block A and Block B.

When the blocks are found, the lucky miners will immediately broadcast them to the network. Block propagation has been optimized very well over the years, so in reality it takes very little time for the entire network to hear about a new block (and miners generally stay very well connected to the network), but lets pretend it takes much longer than normal. In this situation, some nodes may hear about Block A first, and other nodes will hear about Block B first. Many nodes follow the rule of 'first seen is valid', so they will reject the second block they hear about (even though it is valid). This creates a fork, since the network is not all agreeing on a common history.

This situation resolves once the next block is found**. Miners run nodes as well, so each miner will begin mining the next block on top of whichever block they heard about first. So if a miner that saw Block A finds the next block, then Block A will be included in the final blockchain history, and Block B will be made stale (and vice versa). This brings the network back in sync, as all nodes that heard about Block B first would drop Block B in order to stay in sync with what is now the longest chain.

** note that it is possible for the situation to repeat, and for a miner on each side of the fork to again find blocks simultaneously. The resolution is no different, but now the stale blocks will be two deep, instead of just one. In practice it is very rare for this situation to occur (it is equal to the probability of a stale block occurring, squared)

2
  • But what would that mean to the remaining transactions within the other block? 1 of the 2 blocks is accepted and appended to the chain, right? Let's assume that 50 similar transactions existed in both blocks. Will these be automatically removed from the block that didn't make it and the miner needs to add 50 different ones?
    – Oliver
    Aug 24, 2022 at 10:17
  • @Oliver: There can be only one block at every height in the chain. As soon as the winning block emerges, every node reorganizes their view of the chain to the best chain-tip, and the stale block is essentially ignored as if it had never existed.
    – Murch
    Aug 31, 2022 at 18:41

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.