BitcoinMachine
TECHNICAL_DOC // BLOCKCHAIN / CHAIN-REORGANIZATION
CHAIN RE-
ORGANIZATION
A chain reorganization (reorg) occurs when a node switches from its current best chain to a competing chain with more cumulative proof of work. Reorgs of 1–2 blocks happen naturally due to propagation delays. Deeper reorgs indicate network splits or attacks. During a reorg, transactions in orphaned blocks return to the mempool.
HOW A REORG UNFOLDS
Normal state: Node has chain A...X → Y tip = Y New competing chain arrives: A...X → Y' → Z' (more total work than A...X → Y) Node performs reorg: 1. Identify common ancestor: block X 2. Disconnect blocks back to X: - Undo block Y: remove its txs from UTXO set, restore spent UTXOs, add txs back to mempool 3. Connect new blocks from X: - Apply block Y': update UTXO set with its txs - Apply block Z': update UTXO set 4. New tip = Z' Transactions in Y that conflict with Y'/Z': → Dropped from mempool (cannot be re-added) Transactions in Y NOT in Y'/Z': → Return to mempool for re-inclusion
depth/">Reorg Depth Categories
SEVERITY
The depth of a reorg (how many blocks are rolled back) determines its cause and severity. Shallow reorgs are routine; deep reorgs signal serious problems.
1-block reorg (very common): Cause: two miners found blocks simultaneously Impact: one block becomes stale, its txs return to mempool Frequency: ~1-5× per month on Bitcoin mainnet 2-block reorg (rare): Cause: network partition or slow propagation Impact: low, but 0-conf transactions may be affected 3+ block reorg (very rare on Bitcoin): Cause: deliberate attack or major network split Impact: could invalidate "confirmed" transactions Last notable Bitcoin reorg: 2013 (value overflow bug) 51% attack depth: Attacker can extend reorg to any depth if they maintain majority hashrate throughout the attack
TERMINOLOGY_INDEX
Reorg
A chain reorganization: switching the best chain tip to a competing chain with more cumulative PoW.
Reorg Depth
The number of blocks rolled back during a reorganization. Depth 1 is most common.
Common Ancestor
The last shared block between the old and new chain. The reorg starts unwinding from here.
Undo Data
Data stored in rev.dat files allowing nodes to reverse block application during reorgs.