Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Bitophile on December 07, 2017, 09:00:32 PM



Title: Two miners solving a block at the same time
Post by: Bitophile on December 07, 2017, 09:00:32 PM
I assume this doesn't happen (or is effectively handled) but I just want to understand how. If two miners from different countries solve a block at the same time (may be a few milliseconds apart) and add to their chain and the nodes close to it verify the proof of work, how does the blockchain pick the correct block? by time?


Title: Re: Two miners solving a block at the same time
Post by: DannyHamilton on December 07, 2017, 09:20:20 PM
I assume this doesn't happen

It happens many times per week.

(or is effectively handled)

It is.

but I just want to understand how. If two miners from different countries solve a block at the same time (may be a few milliseconds apart) and add to their chain and the nodes close to it verify the proof of work, how does the blockchain pick the correct block?

Each node chooses whichever block they receive first.

For a short while the network is split.  Some nodes and miners have accepted one block and the miners are working on building a new block on top of it.  Other nodes and miners have accepted the other block and the miners are working on building a new block on top of it.

One of those sets of miners will eventually complete a next block.  When they broadcast it, any nodes or miners that received the same initial block as them will simply accept this new block and add it to their blockchain.  Any nodes or miners that initially received the OTHER block will see that there is a chain of TWO new blocks that is longer than their current chain of ONE block.  Since the protocol requires them to accept the longest valid chain (most proof-of-work), they will abandon the block that they have and replace it with the two blocks.  They will then relay these two blocks to any nodes or miners that they are connected to.

These abandoned blocks are commonly called "orphaned blocks" and are the reason that services will sometimes require multiple confirmations before they consider a transaction to be completed.

by time?

Nope.

If the blockheight is the same, then they accept the first block they see.  If the blockheights are different, then they accept the chain of blocks with the most proof-of-work (typically the chain with the most blocks).


Title: Re: Two miners solving a block at the same time
Post by: Bitophile on December 07, 2017, 10:26:24 PM
These abandoned blocks are commonly called "orphaned blocks" and are the reason that services will sometimes require multiple confirmations before they consider a transaction to be completed.

Thanks for a very detailed answer. Now I see why the miners reward need to wait for 6 confirmations to be spent.


Title: Re: Two miners solving a block at the same time
Post by: DannyHamilton on December 07, 2017, 11:30:59 PM
Thanks for a very detailed answer. Now I see why the miners reward need to wait for   6   100 confirmations to be spent.

Fixed that for you.


Title: Re: Two miners solving a block at the same time
Post by: Bitophile on December 15, 2017, 07:52:34 PM
Thanks for a very detailed answer. Now I see why the miners reward need to wait for  6    50 confirmations to be spent.

Fixed that for you.

Thank you so much. Had a wrong information set in my mind somehow.