2

I am trying to understand how the consensus mechanism works. My understanding is that multiple nonces can satisfy the target hash requirement. What I'm trying to understand now is: if two miners come up with two different nonces, how does consensus take place?

Is this "tie" broken with the longest chain rule or is there another tie-breaking mechanism?

1 Answer 1

6

The tie is broken by the first of the two that gets extended with a child block.

In practice, in case two conflicting blocks at the same height appear on the network, every node will pick the one they saw first as winner. Because communication across the earth happens at a finite speed, some miners may see one side of the fork first, and other miners may see another one first, even if there is some time between them (up to ~seconds). However, the one that was actually first will most likely reach more other miners first than the other one, and that one will thus have the most chance of being built upon first.

Note that in theory it is possible for this discrepancy to persist: it is possible that a block is found on both sides of the split ~simultaneously again. In that case, it will be the block after that that determines the winner, and so forth. However, under reasonable assumptions, the probability that this persists for long is extremely small, and that is also what is observed in practice. Reorganizations of more than 2 blocks deep are extremely rare.

6
  • Are there historical records with exact numbers on this? For instance, "only 32 reorganizations of depth 3 happened in the history of bitcoin, and 0 of depth 4". Not an expert, just curious. Commented Oct 12, 2021 at 11:11
  • 1
    I don't have an actual source (as observing reorganizations isn't deterministic - it depends on which blocks you see first), but it wouldn't surprise me if the only reorg more than 2 deep after 2010 was the July 2015 BIP66 activation fork, where some new miners kept mining on top of an invalid block produced by an old node through spy mining. IIRC that was around ~30 blocks deep before it was resolved. Commented Oct 12, 2021 at 11:42
  • What happens if by some fluke both miners find the nonce at the exact same time, down to the nanosecond?
    – nick012000
    Commented Oct 12, 2021 at 11:50
  • 2
    It doesn't matter how close the two blocks are found, the procedure is the same: every node will accept the first one they see, but switch over when the other one is extended first. Commented Oct 12, 2021 at 11:52
  • 1
    All three blocks are valid. The validity is just a function of the block's contents and that of its ancestors, and absolutely nothing else (specifically, it does not depend on when the node learned about these blocks). There is a difference between validity and which block is considered active however: the 1% see blockB, and then learn blockA+blockZ, which have more work, so they switch over. Commented Dec 30, 2021 at 19:59

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