Closed mhredmond21 closed 11 years ago
I've had time to think about this, and I'm going to officially accept it, but mark it as a "Someday/Maybe" issue. This means it will be scheduled for implementation sometime after public release of Freicoin.
I recognize the potential value, as I see the connection between difficulty and interest rates with Freicoin. However every well-meaning adjustment to the difficulty algorithm so far has introduced new attack vectors. I am more concerned that messing with the difficulty adjustment might provide a mechanism for someone to cripple us early on than I am about high difficulty variance.
I think the proper mechanism for effecting this would be to get the community involved in testing it (on a testnet or one-off coin), then introduce it to an already-released and growing Freicoin through a checkpoint/proof-of-stake system.
What this does---
The filter takes the time difference between blocks generated, from 21.167 hours to 0 hours ago and convolves (mathematical operation) them with the filter coefficients.
The output of this filter is delayed by a total of 12 hours (72 blocks). This is the result of 10.6666 + 1.3333. 10.66666 (64 blocks) is the delay built into the filter output, and 1.3333 (8 blocks) is the length of a delay line to allow the network time to synchronize. I will have to change the length of the delay line in code from bs = ((M+1)/2)+9; to bs = 8; because I forgot what I was doing.
Each output of the delay buffer is subtracted from 600, the desired value, to produce an error signal. The error signal is stored in an error buffer that is chosen to be the same length as nInterval.
Its important to realize that the above operations occur for every block, not once every retargeting. Its very much a "sliding window," to use bitcointalk terminology, however we just aren't using every output to set difficulty. This is what is known as a zero order hold.
The difficulty output is chosen as the new difficulty once every 12 hours. The new difficulty setting uses information from as soon as 1.333 hours ago, and as far back as 22.5 hours ago. However as time advances past the difficulty readjustment these values are pushed back.
When difficulty is changed all of the values in the error buffer are added up and a threshold is set of 75000 "units." This output is then used to set the gain ratio, where the max gain per difficulty adjustment in either direction is 8%.
Added improved version of this filter in v0.0.2-2.
Thanks... excellent... can't wait for the FORK!
I've pushed the difficulty filter test branch for the original Bitcoin. So, if you ever have a lot of extra time and want to see and compare the output versus the original difficulty filter, you can. I've emailed you the coefficients file which you need to put in your bitcoin directory for this to work. Other than that I'm going to put this down for a while.
https://github.com/mhredmond21/freicoin/compare/difficulty