Skip to content
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

consensus: Implement 1E-8 relative tolerance in CheckReward() #1797

Conversation

jamescowens
Copy link
Member

While Fern code goes to great lengths to remove sources of rounding error from the research rewards accrual, some double math remains, and can in certain circumstances generate a very small amount of error in the calculations of the rewards between the staking machine and the calculating machine. This commit allows the claimed reward to exceed the computed award at a rate of 1 Halford per 1 GRC of the total computed award, which is a relative error of 1E-8. This is an extremely tight tolerance, but should be enough to avoid any rounding errors that could affect concensus, and is vastly superior to the old 25% + 1 GRC slop allowed in the pre-v11 code.

While Fern code goes to great lengths to remove sources
of rounding error from the research rewards accrual, some
double math remains, and can in certain circumstances
generate a very small amount of error in the calculations
of the rewards between the staking machine and the calculating
machine. This commit allows the claimed reward to exceed the
computed award at a rate of 1 Halford per 1 GRC of the total
computed award, which is a relative error of 1E-8.
@jamescowens jamescowens added this to the Fern milestone Jul 20, 2020
@jamescowens jamescowens self-assigned this Jul 20, 2020
@jamescowens
Copy link
Member Author

@cyrossignol and I have agreed to try and solve the problem by changing the offending code to integer math. I will retain this open until we prove that solution works, because we may end up have to use this.

@jamescowens
Copy link
Member Author

This was solved a different way in #1799 instead.

@jamescowens jamescowens deleted the double_epsilon_compare branch September 3, 2020 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant