XHash

Ang memory-hard na Proof-of-Work na ginagamit ng Parallax. Ethash-style Hashimoto na may ASERT-based difficulty, consensus rules, at epoch handling ng Parallax.

Consensus-Relevant Details
Tulad ng nakikita sa xhash/consensus.go at Parallax chain config.
AspectValue / BehaviorNotes
Hash function (seal)
Legacy Keccak-256
RLP sa specific header fields
Target mapping
target = ⌊(2^256−1)/D⌋
Dapat ≤ target ang result
MixDigest
Dapat katumbas ng computed digest
Mismatch ⇒ invalid PoW
MTP
Median ng huling 11
Ipinapatupad: Time > MTP(parent); future drift ≤ 300s
Epoch length
Config-defined (e.g., 720 blocks)
Dini-determine ang cache/DAG regeneration cadence
Difficulty algorithm
ASERT (per-block, anchor-based)
aserti3-2d; kinacompute ng consensus ang D, ipinapatupad ng XHash sa pamamagitan ng PoW
Overview
Ang XHash ang Proof-of-Work engine ng Parallax: Ethash-style Hashimoto (light/full) na may Parallax-specific consensus wiring, ASERT-based difficulty mapping, at epoch handling.
  • Ina-evaluate ng mining ang Hashimoto sa header seal hash at 64-bit nonce, gamit ang cache (light) o dataset (full).
  • Sinusuri ng verification ang MixDigest equality at inihahambing ang result sa target na derived sa difficulty: target = ⌊(2^256−1)/D⌋.
  • Gumagamit ang seal hash ng Legacy Keccak-256 sa RLP list ng specific header fields.
SealHash
pseudocode
SealHash(header):
  enc = [
    header.ParentHash,
    header.Coinbase,
    header.Root,
    header.TxHash,
    header.ReceiptHash,
    header.Bloom,
    header.Difficulty,
    header.Number,
    header.GasLimit,
    header.GasUsed,
    header.Time,
    header.Extra,
    header.EpochStartTime,
  ]
  if header.BaseFee != nil:
    enc.append(header.BaseFee)
  return keccak256(rlp.encode(enc))
Mining Loop
Hashimoto-light/full na may 64-bit nonce search at little-endian target compare sa inner loop.
  • Iniiterate ng miners ang nonce ∈ [0..2^64−1], na nagcomcompute ng (digest, result) = hashimoto(cache/dataset, sealHash, nonce).
  • Dapat tumugma nang eksakto ang MixDigest sa header field; dapat ≤ target ang result.
  • Gumagamit ang full miners ng per-epoch dataset; pwedeng mag-validate ang light verifiers/nodes gamit ang caches (walang full DAG).
  • Nagre-regenerate ang dataset/cache sa epoch boundaries (e.g., kada 720 blocks).
Nonce search (pseudocode)
pseudocode
mine(header, cacheOrDataset):
  target = floor((2^256 - 1) / header.Difficulty)
  nonce  = random64()
  loop:
    (mix, res) = hashimoto(cacheOrDataset, SealHash(header), nonce)
    if mix == header.MixDigest and Big(res) <= target:
      return nonce
    nonce = (nonce + 1) mod 2^64
Header Verification
Ano ang sinusuri ng node bago tumanggap ng PoW header.
  • Size ng Extra ≤ MaximumExtraDataSize.
  • Time ≤ now + 300s at Time > MTP(parent) (median ng huling 11).
  • Dapat tumugma ang Difficulty sa consensus difficulty engine (ASERT) para sa given parent at header.
  • PoW seal: MixDigest equality at XHash(header) ≤ target(two256m1 / D).
verifySeal (conceptual)
pseudocode
verifySeal(h):
  require(h.Difficulty > 0)
  if fulldag:
    (mix, res) = hashimotoFull(dataset(epoch(h.Number)), SealHash(h), h.Nonce)
  else:
    (mix, res) = hashimotoLight(datasetSize(h.Number), cache(epoch(h.Number)), SealHash(h), h.Nonce)
  require(mix == h.MixDigest)
  target = floor((2^256 - 1) / h.Difficulty)
  require(Big(res) <= target)
Epochs, Cache at Dataset (DAG)
Regeneration cadence at miner compatibility notes.
  • Ang epoch number ay derived mula sa block height; ang cache/dataset sizes ay nakadepende sa epoch via datasetSize(height).
  • Gumagamit ang Parallax ng mas maikling epochs kaysa legacy Ethash (e.g., 720-block epochs) para magkasya ang ~5-day regeneration sa 10-minutong blocks.
  • Pinananatili ng nodes ang caches para gawing light ang verification; hindi kailangan ng full DAG para mag-validate ng headers.
Regeneration trigger
pseudocode
if newEpoch(height):
  regenerate cache
  if mining full: regenerate dataset
Difficulty at Anchors
Interaksyon sa pagitan ng PoW at ASERT difficulty schedule.
  • Ang difficulty ay kinacompute ng ASERT scheduler; ipinapatupad lang ng XHash ang napiling difficulty sa pamamagitan ng target check.
  • Pinapanatili ng consensus ang ASERT anchor (height, parentTime, target) at gumagamit ng header metadata (e.g., EpochStartTime o dedicated fields) para i-reconstruct ang anchor context.
  • Kinacompute ng CalcAsertDifficulty(config, anchor, parent, header) ang expected difficulty para sa header.
  • Ipinapatupad ang difficulty at anchor invariants sa header verification bago ang fork-choice.
Difficulty invariants (conceptual)
pseudocode
verifyDifficulty(h, parent, anchor):
  expected = CalcAsertDifficulty(config, anchor, parent, h)
  require(h.Difficulty == expected)