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

Turn staking requirement into integer math variant #877

Merged
merged 4 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ using namespace epee;
#include "ringct/rctSigs.h"
#include "multisig/multisig.h"
#include "int-util.h"
#include <cfenv>

using namespace crypto;

Expand Down Expand Up @@ -981,6 +982,7 @@ namespace cryptonote
{
blobdata bd = get_block_hashing_blob(b);
rx_slow_hash(main_height, seed_height, seed_hash.data, bd.data(), bd.size(), res.data, 0, 1);
std::fesetround(FE_TONEAREST);
}

bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners)
Expand All @@ -993,7 +995,8 @@ namespace cryptonote
const_cast<int &>(miners) = 0;
#endif

if (hf_version >= network_version_12_checkpointing) {
if (hf_version >= network_version_12_checkpointing)
{
uint64_t seed_height, main_height;
crypto::hash hash;
if (pbc != NULL)
Expand All @@ -1008,6 +1011,7 @@ namespace cryptonote
main_height = 0;
}
rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, miners, 0);
std::fesetround(FE_TONEAREST);
return true;
}

Expand Down
3 changes: 0 additions & 3 deletions src/cryptonote_core/service_node_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

@jagerman jagerman Oct 9, 2019

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And updated.

base = 15000 * COIN;
variable = (25007.0 * COIN) / loki::exp2(height_adjusted/129600.0);
std::fesetround(round_method);
}
else
{
Expand Down