Choice of Difficulty Adjustment Algorithm

I’m seeing talk of changes to the Difficulty Adjustment Algorithm. I even saw @h4x3rotab mention that we’re going to deprecate DigiShield and move to EMA. It makes sense to me, but I wanted to know if I’m following the logic… sometimes trying to explain something helps to understand it. So, here goes.

The current DAA is based on DigiShield V3. If I understand it properly, DigiShield is essentially a simple average, or linear average, over a span of recent times, with some boundary conditions (which are asymmetrical.) The boundaries attempt to put some limits on the rate of difficulty change, but the thing is generally responding to the simple average of a prior span.

This means that Digishield considers relatively recent and relatively old blocks as similar, in terms of weighting them to figure out the average. This is reasonable if the variation in the system is Normally distributed - in other words, if the time variation is largely caused by random chance in how quick the miners are finding blocks. A simple average will do well at averaging out those deviations.

In contrast, an EMA-based algorithm uses an Exponential Moving Average. It will weight recent block time intervals more heavily than older ones. The consequence is that the Difficulty will respond more rapidly to current deviations. This is a good thing if a change in block times is being caused by an outside event - something like a price move causing a bunch of miners to jump into or out of the pool can cause a rapid change, and responding rapidly to that is good! On the other hand, it’s a bad thing if a change in block times is part of random variance - every now and then, dumb luck will cause a bunch of fast or slow blocks, and you DON’T want the difficulty adjusting because of that; responding to random noise is just making things worse.

In real life, we’re seeing that significant numbers of miners are using “auto switching” to jump into a coin that is temporarily more profitable, for whatever reason. Maybe the coin price went up, and miners rush in… or maybe there were just randomly slow blocks, and the difficulty went down so miners rush in… Maybe the price of some other coin spiked briefly, and miners left for that other coin, but then that other thing collapsed in price, and the miners flock back to our coin… for whatever reasons, we see a lot of miner floods into and out of coins.

When these miner floods are happening more often than the natural fluctuations, it makes sense to use an algorithm based on an EMA which can respond more rapidly to current events… that’s better than an algorithm based on a Simple Moving Average which would help smooth out “natural variation.”

That is, if I’m understanding it right. :wink: