What happens if two miners mine the same block at the same time? Which of the blocks will be accepted and rewarded?
Let’s’ say that the two miners present their
valid/resolved blocks to the network. Both the miners consider the blocks as
valid. Now which one to choose? And which miner to reward?
Now the decision on which block will be chosen, depends on
all the miners in the bitcoin network. Both the blocks will be announced in the
network and different miners will add the first block they receive to their
copy of ledger, temporarily accepting that miner as the winner and allowing it
to assign the reward to itself. Immediately, all the miners will stop trying to
solve the current block (thinking it’s resolved) and start to work on the next
block.
Now like I discussed in the ‘Orphan/Uncle blocks’, there
will be two different version of the blockchain created within the short span
of time. This creates two versions of chains, and some miners will consider one
of the blockchains as valid while other miners will consider the other chain as
valid. Now depending on factors such as the computational power of the miners
working on each version /or even luck, the next succeeding block will be
discovered in one of the two versions before the other. When the longest
version starts spreading across the the network, the miners who had accepted
the other version (short version), they have no choice but to discard the one
they were working on since ‘the longest blockchain always wins in PoW’. The
rejected version of the blockchain gets discarded by the network; and all the
transactions included in the blocks are rejected and will be returned to
mempool for miners to consider them again. In other words, transactions
included in the rejected blocks will be released into the mempool so that
miners will work on those returned transactions. The discarded block is the
‘orphan block’. At the same time, the miners who got the block reward from the
discarded block will be removed from their balance.
Then what if the non-winning miner already spent the reward
before his block reward is removed?
All transactions made within the blockchain on the orphan
block are discarded, as if they had never existed. Thus, even if the miner
tried to move his reward between the wallets, the end result means that these
operations never existed.
Or is there any chances if the non-winning miners
already sold the BTC/reward (that they were already rewarded) in the form of
physical establishment?
This is not possible either. ‘Cos in the real world, to
confirm the reward/payment to the winning miner, they have to wait for 6
accepted blocks on top the one that contains a transaction, to be considered
that the block is no longer an orphan.
There could be so many orphans then?
Now remember the average time that is taken to mine a
block? 10 minutes time. Thus, 10 minutes is considered a perfect balance to
avoid too many orphaned blocks. Otherwise, considering a few seconds taken to
mint a block, there would be tons of orphan blocks and tons of versions of
blockchains at the same time.
Will review your comment and get back!