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.
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.
Future limit = 60 blocks, window = 45 blocks: one forward-dated block can claim a large part of the window.
| Algorithm | Blocks | Mean gap | Longest gap | Gaps > 4×T | Max ahead | Max behind |
|---|---|---|---|---|---|---|
| SMA | 360 | 1.11×T | 14.3×T | 14 | +26 | −49 |
| DigiShield | 405 | 0.99×T | 11.9×T | 14 | +112 | −10 |
| LWMA | 360 | 1.11×T | 8.9×T | 12 | +24 | −42 |
| ASERT | 399 | 1.00×T | 9.5×T | 10 | +61 | −9 |
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.
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.