Difficulty Adjustment
BTX difficulty adjustment: ASERT algorithm (aserti3-2d), half-life parameters, fast-mine phase, target block time, and chain guard system.
Overview
BTX uses ASERT (aserti3-2d) for MatMul proof-of-work difficulty adjustment, activated per-block from genesis. ASERT is a stateless exponential moving average algorithm that eliminates the window-memory oscillation problems inherent in DGW (Dark Gravity Wave) under single-miner conditions. The algorithm targets a 90-second block interval during steady-state operation and uses integer-only consensus arithmetic with no floating point.
ASERT Algorithm
ASERT computes the next target as an exponential function of the time deviation from the expected schedule, anchored to a reference block:
next_target = anchor_target * 2^((time_delta - expected_delta) / half_life)
The implementation uses aserti3-2d style fixed-point arithmetic
with a 216 radix for the exponent approximation. Key properties:
- Stateless: Each retarget depends only on the anchor block and the current block's timestamp/height, not on a sliding window of recent blocks.
- Integer-only: Polynomial approximation constants, bounded/saturating multiply/shift behavior, and compact encoding ensure deterministic consensus across all platforms.
- Anchor semantics: At activation height, the algorithm anchors on that block's target and timestamp, providing a deterministic starting point.
- Clamping: pow-limit and non-zero target clamps prevent degenerate states.
Consensus Parameters
| Parameter | Value | Notes |
|---|---|---|
| ASERT activation height | 50,000 (= nFastMineHeight) | ASERT governs difficulty from the first post-bootstrap block onward |
| Initial half-life | 14,400 seconds (4 hours) | Moderate reactivity for early-chain stability |
| Upgraded half-life | 3,600 seconds (1 hour) | Higher reactivity after height 55,000 for faster convergence |
| Target block time (steady-state) | 90 seconds | nPowTargetSpacingNormal |
| Target block time (fast-mine) | 250 milliseconds | nPowTargetSpacingFastMs for h < 50,000 |
| BIP94 timewarp mitigation | Enforced | Prevents timestamp manipulation attacks |
Half-Life Upgrade Mechanism
The half-life upgrade at height 55,000 (from 14,400s to 3,600s) is a consensus-critical height-gated change:
- At the upgrade height, the target is inherited from the parent block unchanged.
- ASERT re-anchors on that block, establishing a new reference point.
- All subsequent retargeting uses the new half-life (3,600s).
This mechanism is designed to be reusable: nMatMulAsertHalfLifeUpgradeHeight
and nMatMulAsertHalfLifeUpgrade are general-purpose consensus parameters
that can be set for future half-life adjustments. Any half-life retune is
consensus-critical and must be height-gated.
Fast-Mine Phase
Blocks 0 through 49,999 use a 250-millisecond target spacing for rapid chain bootstrap. This emits 50,000 blocks in approximately 3.5 hours, distributing 1,000,000 BTX (4.76% of total supply). Key properties:
- The halving schedule is by block height, not wall-clock time, so the fast-mine phase does not alter the halving interval (525,000 blocks).
- MTP and future-time-limit rules are unchanged during fast-mine; miners should use NTP-synchronized clocks.
- Phase 2 transcript verification is deferred to a bounded queue during 250 ms blocks. The queue must drain completely after the transition to 90-second blocks at height 50,000.
- Difficulty scaling uses
nFastMineDifficultyScale = 1(no additional scaling factor beyond the target spacing change).
Retune Mechanisms
The consensus layer includes several one-time retune mechanisms for operational recovery after bootstrap or drift:
| Mechanism | Parameters | Effect |
|---|---|---|
| Bootstrap factor | nMatMulAsertBootstrapFactor | Multiplier applied to parent target at ASERT activation height. Values > 1 ease difficulty immediately. |
| Retune hardening | nMatMulAsertRetuneHeight, nMatMulAsertRetuneHardeningFactor | At the retune height, next_target = parent_target / factor to quickly recenter cadence. |
| Retune recentering | nMatMulAsertRetune2Height, Retune2TargetNum/Den | Scales target by (num/den) and re-anchors ASERT on that block. |
All retune mechanisms are disabled by default (heights set to int32_max).
They require explicit consensus deployment via height-gated activation.
Chain Guard System
BTX includes a reorg-protection chain guard that prevents deep reorganizations:
- Max reorg depth: Configurable via
nMaxReorgDepth. Reorgs deeper than this threshold are rejected at the validation layer. - Protection start height:
nReorgProtectionStartHeightgates when the guard becomes active, allowing the early chain to stabilize before enforcement. - Runtime counters: Rejected deep-reorg attempts are counted and exposed
via the
getdifficultyhealthRPC for operational monitoring.
The chain guard interacts with difficulty adjustment by preventing an attacker from using a sustained low-difficulty private chain to force a deep reorganization after ASERT has adjusted difficulty upward on the public chain.
DGW Legacy (Disabled)
BTX previously used Dark Gravity Wave for difficulty adjustment. DGW has been
deliberately replaced by ASERT for all MatMul difficulty adjustment.
The DGW height-gate fields remain in Consensus::Params for KAWPOW-era
compatibility but are set to int32_max for all MatMul networks.
Re-enabling DGW for MatMul requires explicit project approval.
DGW parameters that were previously active (window=180, timespan intervals=179, clamp=3/4..3/1, slew=4x) exhibited window-memory oscillation under single-miner conditions, which ASERT eliminates through its stateless exponential design.
Monitoring and Observability
The getdifficultyhealth RPC exposes comprehensive retargeting observability:
- Recent interval statistics (mean, p50, p90, p99, stddev)
- Shock detection and settling-time scoring
- Health score and alerts
- Reorg-protection configuration and runtime rejection counters
- Reward-distribution concentration and longest-streak metrics
- Freivalds transcript-binding upgrade visibility
Post-activation monitoring focuses on interval distribution contraction toward the 90-second target, disappearance of DGW floor-bounce patterns, and tail latency under attack/recovery scenarios.