<p>Imagine that the blockchain is 210000 blocks long and TWO miners both find valid blocks within a few seconds of each other and broadcast them to the network.</p>

<p>This is perfectly normal as the Bitcoin network is peer to peer and global.</p>

<p>You now have two chains, each of length 210001. Neither of these are longer than each other. Some bitcoind nodes will see the first miner's block and some bitcoind nodes will see the second.</p>

<p>Temporarily you have two forks of the blockchain, each of length 210001 blocks long. They are identical for 210000 blocks, but the 210001st is different on the two forks.</p>

<p>Sometime later another miner finds another valid block, the 210002nd block, and that will be attached to exactly one of the forks.</p>

<p>This chain is now the longest at 210002 blocks and becomes the longest chain. It becomes the "definitive" blockchain.</p>

<p>(The transactions in the alternate fork don't disappear - they simply get put back into the pool of unconfirmed transactions and miners will put them into a subsequent block).</p>

CC BY-SA 3.0
2012-11-29T15:40:48.207Z
But is that one block that was on the 210001 chain awarded? The network chose the 210002 chain, and the transactions from the 210001 chain get recycled for the next block (210003?) and the 210001th goes away?
Colin Dean
CC BY-SA 3.0
2012-11-30T09:26:04.080Z
My understanding is that under most circumstances the transactions in each of the forks are mostly the same. Any fee-paying transactions in the (soon-to-be) orphaned block (eg 210001B) would likely be included in the block immediately following (ie 210002) because those transactions are considered still available by miners working on their own fork (210001A). They wouldn't need to wait for block 210003, as the final paragraph implies.
Highly Irregular
CC BY-SA 3.0
2017-07-14T04:14:30.937Z
This excellent description cleared things up for me, thanks! and the answer I was looking for is: it may be that at block N two blocks are broadcast at nearly the same time, but it is very unlikely that happens twice in a row, and vanishingly likely it happens three times in a row, thus things converge quickly.  My next question is: has it ever happened (or recently happened) that it happened twice in a row, thus there were 3 or four chains each of the same length and miners start working on each?  I guess I'll find a blockchain explorer and start looking ...
davidbak
CC BY-SA 4.0
2019-04-09T13:50:36.117Z
This is a nice answer!
Jinhua Wang
CC BY-SA 3.0
2012-11-29T11:08:50.587Z
2012-11-29T11:08:50.587Z
jim618
<p>Bitcoin's block chain system is really two quite separate systems, and they are easily confused. The first one is the <em>block tree</em> and the second is the <em>active chain</em>.</p>

<p>The <em>block tree</em> consists of all valid blocks whose entire ancestry is known, up to the genesis block. The rules for validness include no double spending, valid signatures, no introduction of more currency than allowed, ... These are the network rules, and every full Bitcoin node verifies them.</p>

<p>The <em>active chain</em> is one path from genesis block at the top to some leaf node at the bottom of the block tree. <strong>Every</strong> such path is a valid choice, but nodes are expected to pick the one with the most "work" in it they know about (where work is loosely defined as the sum of the difficulties). Relativity and technological constraints prevent us from doing instant communication across the globe, so two nodes can not be expected to pick the same chain as the active one. This is no problem: the mining mechanism makes sure that the chance two nodes disagree about blocks in the past decreases exponentially as they are older.</p>

<p>So no, there is not one "right chain", there are many. Nodes choose for themselves, but the system is designed to make sure consensus arises quickly.</p>

<p>The rules in practice are this: when a new block arrives, and it extends the previous active chain, we just append it to the active chain. If not, it depends on whether the branch it extends now has more work than the currently active branch. If not, we store the block and stop. If it does have more work, we do a so called "reorganisation": deactivating blocks from the old branch, and activating blocks from the new branch.</p>

CC BY-SA 3.0
2015-01-25T18:23:10.623Z
Sir, how a node selects the most recent block on the longest path; e.g., assume node knows two sub-chains, how it identifies which one is longer? Is it just going compare their lengths (number of blocks)? Thanks.
Nur
CC BY-SA 3.0
2015-01-25T19:32:29.643Z
We look at the amount of work in each chain: the expected number of hashes that were necessary to build them. This loosely corresponds to the sum of the difficulties of the blocks in both chains (which is almost always the same as just comparing the length, unless the fork spans a retarget).
Pieter Wuille
CC BY-SA 3.0
2017-02-04T04:47:37.237Z
This answer doesn't precisely define "work". The work of a block is actually defined as floor(2^256 / (target + 1)), where 'target' is the target threshold converted from the 'nBits' field of the block header. (See the GetBlockProof function in src/pow.cpp.)
Daira-Emma Hopwood
CC BY-SA 4.0
2020-01-23T21:56:54.733Z
@DairaHopwood helpful comment, although technically the comment right above yours does define it ("expected number of hashes..") :) . For those wondering where the formula comes from: the expected number of hashes is 1/p where p is the probability of hashing to the target or below, so p = (target + 1) / 2^256.  (the "+1" is to count the hash with all 0s).
Chan-Ho Suh
CC BY-SA 3.0
2012-11-29T11:24:15.820Z
2012-11-29T11:24:15.820Z
Pieter Wuille
<p>What does the term "Longest chain" mean, as there is only one 'right' blockchain exists? How another longer chain would make the 'right' chain invalid?</p>

<blockchain><mining-theory><consensus><terminology><best-chain>
What does the term "Longest chain" mean?
vi.su.
# What does the term "Longest chain" mean?

(Asked by: username_0 on 2012-11-29)

What does the term "Longest chain" mean, as there is only one 'right' blockchain exists? How another longer chain would make the 'right' chain invalid?

**Tags:** blockchain, mining-theory, consensus, terminology, best-chain


---

## 2 answers

### Answer by username_6 on 2012-11-29. Score: 36 | Accepted answer

Bitcoin's block chain system is really two quite separate systems, and they are easily confused. The first one is the *block tree* and the second is the *active chain*.

The *block tree* consists of all valid blocks whose entire ancestry is known, up to the genesis block. The rules for validness include no double spending, valid signatures, no introduction of more currency than allowed, ... These are the network rules, and every full Bitcoin node verifies them.

The *active chain* is one path from genesis block at the top to some leaf node at the bottom of the block tree. **Every** such path is a valid choice, but nodes are expected to pick the one with the most "work" in it they know about (where work is loosely defined as the sum of the difficulties). Relativity and technological constraints prevent us from doing instant communication across the globe, so two nodes can not be expected to pick the same chain as the active one. This is no problem: the mining mechanism makes sure that the chance two nodes disagree about blocks in the past decreases exponentially as they are older.

So no, there is not one "right chain", there are many. Nodes choose for themselves, but the system is designed to make sure consensus arises quickly.

The rules in practice are this: when a new block arrives, and it extends the previous active chain, we just append it to the active chain. If not, it depends on whether the branch it extends now has more work than the currently active branch. If not, we store the block and stop. If it does have more work, we do a so called "reorganisation": deactivating blocks from the old branch, and activating blocks from the new branch.

> **Comments:**
> **username_7**: Sir, how a node selects the most recent block on the longest path; e.g., assume node knows two sub-chains, how it identifies which one is longer? Is it just going compare their lengths (number of blocks)? Thanks.  
> **username_6**: We look at the amount of work in each chain: the expected number of hashes that were necessary to build them. This loosely corresponds to the sum of the difficulties of the blocks in both chains (which is almost always the same as just comparing the length, unless the fork spans a retarget).  
> **username_8**: This answer doesn't precisely define "work". The work of a block is actually defined as floor(2^256 / (target + 1)), where 'target' is the target threshold converted from the 'nBits' field of the block header. (See the GetBlockProof function in src/pow.cpp.)  
> **username_9**: @DairaHopwood helpful comment, although technically the comment right above yours does define it ("expected number of hashes..") :) . For those wondering where the formula comes from: the expected number of hashes is 1/p where p is the probability of hashing to the target or below, so p = (target + 1) / 2^256.  (the "+1" is to count the hash with all 0s).  

---

### Answer by username_1 on 2012-11-29. Score: 13

Imagine that the blockchain is 210000 blocks long and TWO miners both find valid blocks within a few seconds of each other and broadcast them to the network.

This is perfectly normal as the Bitcoin network is peer to peer and global.

You now have two chains, each of length 210001. Neither of these are longer than each other. Some bitcoind nodes will see the first miner's block and some bitcoind nodes will see the second.

Temporarily you have two forks of the blockchain, each of length 210001 blocks long. They are identical for 210000 blocks, but the 210001st is different on the two forks.

Sometime later another miner finds another valid block, the 210002nd block, and that will be attached to exactly one of the forks.

This chain is now the longest at 210002 blocks and becomes the longest chain. It becomes the "definitive" blockchain.

(The transactions in the alternate fork don't disappear - they simply get put back into the pool of unconfirmed transactions and miners will put them into a subsequent block).

> **Comments:**
> **username_2**: But is that one block that was on the 210001 chain awarded? The network chose the 210002 chain, and the transactions from the 210001 chain get recycled for the next block (210003?) and the 210001th goes away?  
> **username_3**: My understanding is that under most circumstances the transactions in each of the forks are mostly the same. Any fee-paying transactions in the (soon-to-be) orphaned block (eg 210001B) would likely be included in the block immediately following (ie 210002) because those transactions are considered still available by miners working on their own fork (210001A). They wouldn't need to wait for block 210003, as the final paragraph implies.  
> **username_4**: This excellent description cleared things up for me, thanks! and the answer I was looking for is: it may be that at block N two blocks are broadcast at nearly the same time, but it is very unlikely that happens twice in a row, and vanishingly likely it happens three times in a row, thus things converge quickly.  My next question is: has it ever happened (or recently happened) that it happened twice in a row, thus there were 3 or four chains each of the same length and miners start working on each?  I guess I'll find a blockchain explorer and start looking ...  
> **username_5**: This is a nice answer!  

---

