-
Notifications
You must be signed in to change notification settings - Fork 346
New difficulty algorithm (Jacob Eliosoff's EMA) #237
Description
BTG may fork someday and it needs a new difficulty algorithm. Here's the best algorithm. If you can extract the existing Digishield v3 (a la Zcash) and put this in its place, that would be great. I'll do it if no one else does.
Digishield v3 code error
In a previous issue you can see where I got BTG to modify the Zcash code, and how my modification, combined with an ancient Digishield error, messed things up. It's issuing coins 3.5% too fast and it is having delays that are twice as bad compared to if the code were left alone. It's not a big problem, but it's ugly.
The code that's causing BTG's difficulty problem is in a LOT of coins. Normally the bug only shows itself as new coins have to wait 500 blocks before they reach the correct difficulty. In the linked issue above I explain the problem in detail. If you have the following code in your coin, please delete it and spread the word to get rid of it. It's behavior is the opposite of what's expected and needed. If you set the parameter to allow up to 16% rise per block, it results in a 1% limit exactly when you need it to be 16%.
if (nActualTimespan < params.MinActualTimespan())
nActualTimespan = params.MinActualTimespan();
if (nActualTimespan > params.MaxActualTimespan())
nActualTimespan = params.MaxActualTimespan();
All the smooth lines in the graph are where the above code is limiting the difficulty to 0.5% to 1.5% rise per block when no limit was needed. This causes blocks to be issued too quickly, followed by spikes in the solvetimes because the difficulty then overshoots.
