"Universal" Difficulty Algorithm
zawy12 opened this issue · 0 comments
zawy12 commented
This shows the similarity of all difficulty algorithms.
T = target solvetime
n = number of blocks in averaging
r = a dilution aka tempering aka buffering factor
w = a weighting function based on n. It's 1 for all but LWMA. In LWMA it increases from 1 to n from oldest to more recent blocks, giving them more weight.
target = avg(n targets) / r * [(r-1) + sum(n w*STs)/sum(n w's) / T]
Less accurately:
difficulty = avg(n Ds) * r / [ (r-1) + sum(n w*STs)/sum(n w's) / T ]
For clarity, here it is w=1 (no increased weight given to more recent blocks like LWMA and OSS)
target = avg(n targets) / r * [(r-1) + avg(n STs) / T]
w=1, r=1 Dark Gravity Wave (a Simple Moving Average in deep disguise)
w=1, n=1 for EMA. Larger r means smoother, slower response. Other articles show this is almost precisely ASERT (BCH) & ETH's.
w=1, r=4 for Digishield, r=2 for Grin
r=1, w = function of n. LWMA for linear increase in w for more recent blocks. Pretty close to EMA.
r = 4, and simple w function. OSS (like a combination of LWMA and Digishield)