Nakamoto Consensus's Probabilistic Finality and Selfish Mining TODO
Concept
Nakamoto consensus produces blocks via proof of work and treats the chain with the greatest cumulative work as canonical — finality here isn't absolute, it's probabilistic. The more honest blocks get stacked on top of a given block, the bigger the gap an attacker has to make up to revert it, so the probability of reversion decreases exponentially as confirmations accumulate. This guarantee holds only under the assumptions that the attacker's hash power is less than the honest majority's and that network propagation is fast enough. Selfish mining is a strategy where a miner withholds a mined block instead of publishing it immediately, keeping a secret chain, then releases it strategically when an honest block appears, invalidating honest miners' work. This strategy shows that an attacker can earn a reward share above their actual hash-power share even well below a majority, revealing that a protocol's incentive-compatibility is a separate question from its safety threshold.
How many confirmations to wait for is a decision that converts a safety parameter into money, and the existence of incentive-based attacks means an honest-majority assumption alone can't justify a system's safety.
Code & Formula
# 나카모토 합의의 확률적 최종성 — 공격자 해시파워 비율과 확인 수(confirmation)에 따른
# 되돌림(reorg) 성공 확률을 랜덤 워크 시뮬레이션으로 추정한다 (selfish mining 없이 정직한 다수 가정).
import random
random.seed(11)
def simulate_reorg_attempt(attacker_ratio, confirmations, max_steps=10000):
"""정직한 체인이 confirmations만큼 앞서 있을 때, 공격자가 따라잡는지 랜덤 워크로 시뮬레이션.
lead > 0: 정직한 체인이 앞선 블록 수. 공격자가 lead를 0 이하로 만들면 추월 성공."""
lead = confirmations
for _ in range(max_steps):
if random.random() < attacker_ratio:
lead -= 1 # 공격자가 블록을 캔다
else:
lead += 1 # 정직한 채굴자가 블록을 캔다
if lead <= 0:
return True # 공격자가 따라잡음 (reorg 성공)
if lead > confirmations + 50:
return False # 격차가 충분히 벌어져 사실상 안전
return False
def estimate_reorg_probability(attacker_ratio, confirmations, trials=2000):
successes = sum(
simulate_reorg_attempt(attacker_ratio, confirmations) for _ in range(trials)
)
return successes / trials
print("공격자 해시파워 비율별, 확인 수(confirmation)에 따른 되돌림 성공 확률 (시뮬레이션):\n")
for attacker_ratio in [0.10, 0.30, 0.45]:
print(f"attacker_ratio = {attacker_ratio}")
for conf in [1, 3, 6]:
p = estimate_reorg_probability(attacker_ratio, conf, trials=1000)
print(f" confirmations={conf}: 되돌림 확률 ≈ {p*100:.1f}%")
print()
print("-> 확인 수가 늘수록, 공격자 비율이 낮을수록 되돌림 확률이 지수적으로 감소한다.")
print(" (해시파워가 정직한 쪽보다 크면(>=50%) 확인 수와 무관하게 결국 따라잡는다.)")
docs/code/algorithms/algorithms-58.py
Exercise
Write a script that takes an attacker's hash-power share and a confirmation count as input and estimates the probability of a successful reversion via a random-walk simulation, then plot the probability curve against confirmation count.
Practical Connection
In a prediction market, deciding how many confirmations to require before crediting a deposit or finalizing settlement has to weigh the probabilistic-finality curve against the amount at stake — and the same question resurfaces, just reshaped into finality rules and reorg risk, on a proof-of-stake chain.
Where it lands in Jayverse
- Verex: pick a confirmation count per collateral size, not one global number. Beyond weighing the finality curve, write an explicit table mapping deposit size to required confirmations, since a fixed low number is a subsidized attack surface as stakes grow.
- Devnet: document the finality assumption once it becomes a real L2. When Devnet moves past Anvil-forked-Sepolia to an OP-Stack L2, its own reorg/finality rule needs the same probabilistic-vs-absolute distinction spelled out for anything that credits deposits.
- Bridge: require a minimum confirmation depth before minting on the destination side. The lock-and-mint bridge's mint step should refuse to fire until the source-chain lock has enough confirmations for the value being moved, sized the way the finality curve suggests.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| canonical | 공인된, 정본으로 인정되는 · 가장 많은 작업량이 쌓인 체인을 공식으로 인정한다는 뜻. "treats the chain with the greatest cumulative work as canonical" |
| stack up (on top of) | (위로) 쌓이다, 누적되다 · 정직한 블록들이 계속 쌓이는 과정을 표현. "honest blocks get stacked on top of a given block" |
| make up (a gap) | (격차를) 메우다, 따라잡다 · 공격자가 따라잡아야 할 작업량 차이를 가리킴. "the bigger the gap an attacker has to make up" |
| withhold | (공개하지 않고) 보류하다, 숨기다 · 채굴한 블록을 바로 내놓지 않는 것. "withholds a mined block instead of publishing it immediately" |
| incentive-compatibility | 유인 양립성 · 보상 구조가 정직한 행동을 유도하도록 설계됐는지 여부. "a protocol's incentive-compatibility is a separate question" |
| convert ... into | ~을 ~으로 바꾸다, 전환시키다 · 안전성 파라미터가 곧 돈의 문제가 된다는 것을 표현. "converts a safety parameter into money" |
| Selfish mining | 이기적 채굴(전략적 블록 은닉) · 채굴한 블록을 즉시 공개하지 않고 비밀 체인을 유지하다 전략적으로 풀어 정직한 채굴자 몫을 가로채는 전략. "Selfish mining is a strategy where a miner withholds a mined block" |
| reorg | 재구성(체인 재조직, reorganization) · 이미 쌓인 블록이 다른 체인으로 교체되며 되돌려지는 현상. "reshaped into finality rules and reorg risk" |
If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/dev-100-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.