Parallaxの難易度調整の歴史 — ジェネシスからのBTC型DAA、ブロック17,560でのASERTアップグレード (PIP-0002)、そして累積ワークに基づくNakamotoのフォーク選択ルール — を正確にたどります。
| パラメータ | 記号 | 値 | 備考 |
|---|---|---|---|
| 目標ブロック間隔 | τ | 600秒 | Bitcoin型の目標値 |
| 未来方向のタイムドリフト上限 | — | 300秒 | 5分 |
| MTPサンプル数 | — | 11ブロック | 直近11個のタイムスタンプの中央値 |
| 難易度アルゴリズムの履歴 | — | BTC型DAA → ASERT | ジェネシス〜17,559ブロックはBTC型2016ブロックウィンドウ、17,560ブロック以降はASERT (aserti3-2d、PIP-0002)。 |
// Given difficulty D (big integer)
TWO256M1 = (1n << 256n) - 1n
target = TWO256M1 / D
valid = BigIntFromBytes(result) <= target
// Difficulty selection by era
CalcDifficulty(config, anchor, parent, header):
if height(header) < 17560:
// BTC-style DAA: 2016-block window with epoch anchors
return CalcNakamotoDifficulty(config, parent)
else:
// ASERT: per-block retarget relative to fixed anchor
return CalcAsertDifficulty(config, anchor, parent, header)
// ASERT core idea (fixed-point, aserti3-2d)
CalcAsertDifficulty(config, anchor, parent, header):
Δh = height(header) - anchor.height
Δt = header.Time - anchor.parentTime // seconds
// τ = 600 s target, T_half = 172800 s (2 days)
e = ((Δt - Δh * τ) * RADIX) / T_half // fixed-point exponent
target = anchor.target * 2^e // via cubic approximation in integer math
target = clamp(target, 1, maxTarget)
return DifficultyFromTarget(target)
MTP(n):
ts = timestamps(n, upTo=11) // back from n inclusive
sort(ts)
return ts[len(ts)//2]
Work(block):
target = TWO256M1 / Difficulty(block)
// Use an approximation that preserves ordering; e.g.,
return TWO256M1 / (target + 1)
SelectBest(tips):
return argmax(tips, ChainWork[tip])
OnNewTip(candidate):
if ChainWork[candidate] > ChainWork[currentTip]:
currentTip = candidate
ReorgTo(candidate)
ValidHeader(h, parent):
require(len(h.Extra) <= MaximumExtraDataSize)
require(h.Time <= now() + 300)
require(h.Time > MTP(parent))
require(h.Difficulty > 0)
// difficulty rules depend on height:
// < 17560: BTC-style DAA epoch invariants
// ≥ 17560: ASERT anchor-based invariants
// PoW: MixDigest match & XHash(h) <= targetFrom(D)
ヘッダは、Extraサイズ、時間 (MTPと未来ドリフト)、時代固有の難易度ルール (初期ブロックはBTC型DAA、高さ17,560以降はASERT)、gasリミット/EIP、高さ増分、PoWシールをチェックされます。有効なブロックはChainWorkを延ばし、最重量のティップが正規となります。