Tumpak na walk-through sa kasaysayan ng difficulty adjustment ng Parallax — BTC-style DAA mula sa genesis, ang ASERT upgrade sa block 17,560 (PIP-0002), at ang Nakamoto fork-choice rule based sa cumulative work.
| Parameter | Symbol | Value | Notes |
|---|---|---|---|
| Target block interval | τ | 600 s | Bitcoin-like target |
| Future time drift bound | — | 300 s | 5 minutes |
| MTP sample size | — | 11 blocks | Median ng huling 11 timestamps |
| Difficulty algorithm history | — | BTC-style DAA → ASERT | BTC-style 2016-block windows mula genesis–17,559; ASERT (aserti3-2d) para sa blocks ≥ 17,560 (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)
Sinusuri ang headers para sa Extra size, time (MTP at future drift), era-specific difficulty rules (BTC-style DAA para sa mga unang block, ASERT para sa height ≥ 17,560), gas limits/EIPs, height increment, at PoW seal. Pinapalawak ng valid blocks ang ChainWork, at ang heaviest tip ang canonical.