In Nakamoto consensus, every node follows the fork-choice rule: always extend and accept the chain with the greatest accumulated proof-of-work (in practice, the longest valid chain). Two branches can temporarily coexist after a fork; whichever branch's miners find the next block first pulls ahead, and the shorter branch is discarded (its blocks "orphaned") the moment the longer one is seen.
Block discovery by each side is an independent Poisson process with rate proportional to hash-power share. Honest miners control fraction p = 1−q, an attacker controls q. If a merchant waits for z confirmations before accepting a payment, the attacker must mine z+1 blocks faster than the honest network extends its lead. Satoshi Nakamoto's original paper gives the exact probability the attacker ever catches up:
λ = z · (q / p)
P(catch-up) = 1 − Σ(k=0..z) [ e^(−λ) λ^k / k! ] · ( 1 − (q/p)^(z−k) )
This simulator runs that exact race live: two independent exponential-waiting-time processes compete to append the next block to their branch. When the attacker's branch length reaches the honest branch's length, the fork-choice rule flips every observer over to the (formerly shorter) attacker branch — a chain reorganization — and the trial counts as a successful double-spend. Run enough trials and the empirical reorg rate converges on the closed-form P(q,z) above.
- Attacker hash power q — the attacker's share of total network hash rate (real Bitcoin security assumes q < 50%).
- Confirmations z — how many blocks the honest chain is ahead of the attacker when the race starts (the depth a merchant waits before treating a payment as final).
- Mining tempo — animation speed only; it scales both Poisson rates together and does not change the outcome probability.
Real-world relevance: this is the exact model behind the "wait for N confirmations" guidance used by every Bitcoin-derived blockchain, and the reason 51%-attack economics (q ≥ 0.5) make double-spending a near-certainty regardless of z.