hashlyBETA
Data live
← Research

Hashly / research · TOOL

Difficulty adjustment: stress simulator.

Run SMA, DigiShield, LWMA and ASERT side by side against hashrate spikes, on-off mining, a hashrate cliff and forward-dated timestamps, in your browser.

Published
Sources checked
Scope
Consensus

Simulator

Pick a scenario, a block time and a window. Each algorithm mines the same chain with the same random draws; only the difficulty rule changes. Everything runs in your browser: nothing is sent or stored.

Scenario

Hashrate jumps to 5× between 25% and 45% of the run, then returns to baseline.

Future limit = 60 blocks, window = 45 blocks: one forward-dated block can claim a large part of the window.

Hashrate
Difficulty (1× = baseline hashrate at target block time)
Difficulty over time for each algorithm, against the hashrate0×1.5×3×4.5×6×0.0 h3.3 h6.7 h10 h13 h
Blocks ahead (+) or behind (−) the ideal schedule
Blocks ahead of or behind the ideal schedule over time-120-600+60+1200.0 h3.3 h6.7 h10 h13 h
Run of 13 hours (400 expected blocks)
AlgorithmBlocksMean gapLongest gapGaps > 4×TMax aheadMax behind
SMA3601.11×T14.3×T14+26−49
DigiShield4050.99×T11.9×T14+112−10
LWMA3601.11×T8.9×T12+24−42
ASERT3991.00×T9.5×T10+61−9
Seed 7. Same seed, same blocks for every algorithm.

How to read it

  • Above the zero line the chain is ahead of schedule: blocks were cheap, and whoever mined them was paid more than the hashrate warranted. This is the cost of reacting slowly when hashrate arrives.
  • Below the zero line the chain is behind: blocks are slow, transactions wait, and the remaining miners are underpaid. This is the cost of reacting slowly when hashrate leaves.
  • Longest gap and gaps over 4×T are what users notice. With random solve times a few long gaps are normal; compare algorithms on the same seed and then try a few seeds.
  • Switch the future time limit between Bitcoin’s two hours and ten block times on the forward-dated scenario: short windows react to the limit, not to the algorithm. The difficulty note explains why.

Model and limits

Difficulty is normalised so that 1× is the baseline hashrate at the target block time. Each block needs difficulty × T × E units of work, with E drawn from an exponential distribution (or fixed to 1 without random solve times), consumed at the current hashrate. Timestamps are honest except in the forward-dated scenario, and always respect a median-of-11 past limit.

Rules as implemented here (N = window, T = target block time)
SMA         D = mean(D, N) * N*T / (t[n] - t[n-N])
DigiShield  mean target over N, timespan between medians of 11,
            damped by 4, limited to 84%..132% of N*T
LWMA        D = sum(D, N) * T * (N+1) / (2 * sum(i * min(6T, st_i)))
            out-of-order timestamps count as 1 s
ASERT       D = D_anchor * 2^((T*(h+1) - dt) / (N*T*ln 2))

This is a model for comparing behaviours, not a substitute for testing your node. Real implementations work on 256-bit targets with integer rounding, have their own limits and warm-up rules, and real miners respond to price as well as difficulty. DigiShield is shown with the same window as the others for comparison; Zcash uses 17.

Sources

Public documents only, checked on 3 Dec 2026. No client work, private report or undisclosed issue is used or referred to on this page.

  1. Zcash, src/pow.cpp and src/chainparams.cpp (DigiShield variant)
  2. zawy12, difficulty-algorithms: LWMA
  3. Bitcoin Cash November 2020 upgrade: ASERT (aserti3-2d)
  4. Bitcoin Core, src/pow.cpp