BitcoinMachine
TECHNICAL_DOC // BLOCKCHAIN / LONGEST-CHAIN
LONGEST
CHAIN
Bitcoin nodes follow the chain with the most accumulated proof of work — commonly called the "longest chain" rule, though more precisely it is the heaviest chain (most total difficulty). This rule is Bitcoin's decentralized consensus mechanism: honest miners extend the heaviest chain, making it progressively harder for any attacker to rewrite history.
HEAVIEST CHAIN — NOT JUST BLOCK COUNT
Chain weight = sum of difficulty for every block Example: two competing chains Chain A: 900 blocks, avg difficulty = 1.0T → weight = 900T Chain B: 850 blocks, avg difficulty = 1.1T → weight = 935T Winner: Chain B (higher total difficulty, fewer blocks) Nodes always switch to the chain with highest total work regardless of block count. In practice: difficulty retargets every 2016 blocks, so longer chains almost always have more total work unless there's a dramatic difficulty drop mid-fork. Bitcoin Core tracks chainwork as uint256 cumulative difficulty target in the block index database.
WHITEPAPER
Satoshi's whitepaper describes the chain selection rule as the foundation of Bitcoin's consensus — honest nodes always extend the longest (heaviest) chain, forming a majority that outpaces any attacker.
From the Bitcoin Whitepaper (Section 5): "The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power." Key insight: if honest nodes control majority hashrate: → honest chain grows faster than any attack chain → attack chain eventually falls behind → nodes reject shorter (lower-work) competing chain The rule is self-enforcing: - Miners waste resources if they mine on a shorter chain - Rational miners always build on the heaviest chain - Game theory favors honesty when attacker < 50%
The "longest chain" terminology is technically imprecise. Bitcoin Core uses GetBlockProof() to compute cumulative chainwork as the true selection criterion.
TERMINOLOGY_INDEX
Longest Chain
Common name for the chain selection rule. More precisely: the chain with the most cumulative proof of work.
Chainwork
The sum of all block difficulties in a chain from genesis to tip. Stored as uint256 in Bitcoin Core.
Nakamoto Consensus
Bitcoin's decentralized agreement mechanism: nodes follow the heaviest chain, enforced by economic incentives.
Heaviest Chain
The technically correct term for the chain Bitcoin nodes prefer — total work, not block count.