New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT MERGE] Difficulty adjustment algorithm using LWMA #2887
base: master
Are you sure you want to change the base?
Conversation
There is a potential exploit in the above algorithm. Use this instead:
The following EMA is just as good and pretty much the same when N of EMA is 1/2 the N of WWHM. So the N=70 selected below will be a lot slower to respond than the N=60 above, but will be a lot smoother. A lot smoother invites hash attacks a lot less (because the price/difficulty ratio looks attractive when difficulty accidentally goes down). So you can't win for losing when selecting N. The the past I've wanted smaller N, but BCH DAA N=144 success is causing me to go to larger N. The WWHM N=60 on Masari coin is doing great, so it might be best for small coins.
HOWEVER, I am not yet sure what is the best N for either of the two algorithms above. If I make a change to the above I'll modify this blog post. |
9a80015
to
1d706e0
Compare
I've made adjustments to the implementation as recommended above - thanks! |
Algorithm design by @zawy12 kyuupichan/difficulty#28 Adjustments: - rolling window N=60 - Block future limit of 20 minutes - Timestamp check window of 12 blocks
Target solvetime/timespan has been 120 seconds since inception for Masari - it might look different in v2's algo compared to Sumo's because they have 4 minute blocks (WHM algorithm above is part of v3 hard fork for Masari) |
We've developed a new algorithm that's the best of the best and allows integer math on the target. |
1078136
to
ecfe57f
Compare
Commit 9d0c0b4 is a bit ugly but resolves overflow issue for when the Monero network hits 40x+ the current difficulty if this implementation is considered when compared to competing algorithms. |
I'm told by @zawy12 that this is "almost as good", but is a much simpler approximation of EMA and may be more preferred for integrating into Monero - zawy12/difficulty-algorithms#21 |
This LWMA implementation is a better than my implementation https://github.com/wowario/wownero/blob/master/src/cryptonote_basic/difficulty.cpp#L192 references: |
I've updated the description and revised the pull request to include LWMA as it is a better algorithm than WWHM. |
I've just included an FTL bound in Masari, which bounds a chain's timestamps by it's top block timestamp - FTL (masari-project/masari@0ad730e), which should work well with the -FTL minimum in the DAA proposed here. |
If the -FTL is not enforced in addition to the MTP for block validation and template creation, then the following line must be removed from the LWMA proposed: |
I've overridden my original Weighted-weigthed Harmonic Mean (WWHM) implementation (kyuupichan/difficulty#28) with a modified version of the newest Linearly Weighted Moving Average (LWMA) implementation (zawy12/difficulty-algorithms#3 (comment)).
-- a hard fork would be needed if we include this FTL minimum bound masari-project/masari@0ad730e
All connected copyrights have been retained.