Post
Topic
Board Development & Technical Discussion
Merits 3 from 3 users
Re: Could one say there are at once as many chains as there are miners ?
by
Xynerise
on 16/04/2018, 18:49:34 UTC
⭐ Merited by Jet Cash (1) ,HCP (1) ,vapourminer (1)

His block only gets orphaned if after he published his valid block, another miner publishes a block with the same block height but higher cumulative difficulty,

I didn't realise that. So what happens if a 3rd miner finds a block almost instantly, and adds it to the first miner's block, but it happens just after the 2nd miner added his block in an attempt to replace the 1st block?
Competing blocks are not resolved immediately; other miners have to vote with their hashpower ON the block that they consider valid.
Also, blocks have to reference the previous block header hash to build upon them.
There are 3 miners: A, B & C.
Miner A & B found a valid block almost simultaneously and "published" their blocks
Right now there's a temporary fork in the blockchain.
Miner C then found and  published a block building on miner A's block.
The blockchain including miner A's block is the longest chain with the highest cumulative difficulty because it has the difficulty of the previous blockchain + that of miner C's block .
If other miners "vote" by building their block tip on miner C's block, then it becomes the valid block chain and the block by miner B gets orphaned.

Let's use numbers.
Let's say The current block height the miners are building on is block 100 with block header hash 000....100x
Then miner A finds a valid block that builds upon this, which should be block 101, with blockheader hash 000...101a
However miner B also finds a valid block also building on block height 100 with hash 00..100x, which is also a competing Candidate for block height 101.
Right now there are 2 block 101's -- that of miner A and that of miner B, and there's a temporary bifurcation in the blockchain. full nodes will store both blocks till it is resolved.
Then the miners will vote with their hashpower on the block they consider to be valid.
If miner C builds on miner A's block 101 with hash 000...101a and finds a valid block, 102, then the blockchain of miner A's block is longer, and it also has the highest cumulative proof of work (measured in the difficulty of the block), so his block is "more valid" than B's and if other miners agree with miner C and extend the blockchain by building on miner A's block, then miner B's block will get orphaned by the nodes.

In a rare scenario (eg the 0.8 bug) where after miners up to block 104  Are mining on the block found by A, and other miners decide to mine on the block found by B instead and overtake the length of the chain of A with higher hashpower, then the blocks found from 101 - 104 built on the block found by A will be orphaned and the blockchain will reorganise to the new chain with the highest cumulative proof of work.
Therefore a transaction mined in miner A's block 101 that now has 3 confirmations (3 blocks built on top), will be orphaned and invalid if the transaction was not included in any of the subsequent blocks found.
This is why you should wait for 6 confirmations before you consider a transaction valid even though block reorgs usually do not have a depth of more than 2 blocks.
It's also why the Coinbase maturity time is long (100 blocks)

The important factor in determining the valid chain is the one with the MOST proof of work, not the longest chain alone  or else it would be trivial to fork bitcoin, reduce the difficulty and  mine several blocks ahead of the main chain, forcing a block reorg of the "true" chain to my fake chain.