Fixing dynamic re-work and trend from elections#1968
Merged
zhyatt merged 24 commits intonanocurrency:masterfrom May 13, 2019
Merged
Fixing dynamic re-work and trend from elections#1968zhyatt merged 24 commits intonanocurrency:masterfrom
zhyatt merged 24 commits intonanocurrency:masterfrom
Conversation
added 12 commits
May 7, 2019 22:14
…now tested elsewhere
clemahieu
approved these changes
May 8, 2019
Contributor
clemahieu
left a comment
There was a problem hiding this comment.
Nice I like the concept, that'll be a lot easier to manage and the precision loss is immaterial.
guilhermelawless
commented
May 9, 2019
argakiig
approved these changes
May 9, 2019
… the extreme one-off difficulties
Contributor
Author
|
So fad8c68 fixed the issues observed on beta where the active difficulty was extremely high. Since the max multiplier can easily be up in the tens of thousands even while computing work at base threshold, the average was biased towards these values. Median is correct here and fixed the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1963 . It's been cherry picked in this PR.
Discussion
nano::difficulty::to/from_multiplieruse the network threshold as the second argument. Where could we provide these methods using a default for that argument?Explanation of PR
nano::difficultynamespace in lib/numbersDifficulty arithmetic is a pain, it must be done under the "multiplier space", that is, must first transform the difficulty to a multiplier, and only then we're able to perform sums/divisions/etc.
To get a difficulty into multiplier space:
multiplier = ((1<<64) - base_difficulty) / ((1<<64) - difficulty). In C++,(1<<64) - valueis the same as(-value)if value is unsigned int 64 by abusing underflow.Note that the
difficultybeing in the denominator is what makes it not trivial to perform arithmetic in the value space. The expression(a/x + a/y + a/z)cannot be simplified further.Once in multiplier space, we can perform averages / trend analysis (like active difficulty trend), and at the end go back to a difficulty by inverting the previous operation. Precision loss in going back and forth is minimal and irrelevant in most (all?) use cases.