-
Notifications
You must be signed in to change notification settings - Fork 120
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
Turn staking requirement into integer math variant #877
Conversation
Executing RandomX has side effects on the current rounding mode depending on the hash program it generates and doesn't reset the rounding mode after the fact. So explicitly set it after.
342e985
to
d39a144
Compare
@@ -77,11 +77,8 @@ uint64_t get_staking_requirement(cryptonote::network_type m_nettype, uint64_t he | |||
uint64_t base = 0, variable = 0; | |||
if (hf_version >= cryptonote::network_version_11_infinite_staking) | |||
{ | |||
auto round_method = std::fegetround(); | |||
std::fesetround(FE_TONEAREST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this fesetround
should stay: I don't think there's any particular guarantee as to what rounding mode the thread is in without an explicit call, and I'm assuming it's essentially a no-op if setting it to the mode it's already in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And updated.
Instead of implicitly relying on the mode we expect it to be
61f5369
to
049c2e8
Compare
Original comment and data points for the algorithm from @jagerman
This is a linear step-down approximation of the staking requirement to remove the use of floating point math.
Will write some unit tests- to verify later.