Moving threshold function on to work_thresholds class where it belongs.

This commit is contained in:
clemahieu 2021-08-08 21:53:46 +01:00
commit 49aaac7d02
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
16 changed files with 64 additions and 57 deletions

View file

@ -135,16 +135,16 @@ TEST (difficulty, network_constants)
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold_entry (version, nano::block_type::receive));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold_entry (version, nano::block_type::open));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold_entry (version, nano::block_type::change));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_0, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_1, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_1, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_0, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_1, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_1, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_1, false, false, false)));
// Send [+ change]
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_2, true, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_2, true, false, false)));
// Change
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_2, false, false, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_2, false, false, false)));
// Receive [+ change] / Open
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2_receive, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_2, false, true, false)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2_receive, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_2, false, true, false)));
// Epoch
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2_receive, nano::work_threshold (version, nano::block_details (nano::epoch::epoch_2, false, false, true)));
ASSERT_EQ (nano::dev::network_params.network.publish_thresholds.epoch_2_receive, nano::dev::network_params.network.publish_thresholds.threshold (version, nano::block_details (nano::epoch::epoch_2, false, false, true)));
}

View file

@ -2893,7 +2893,7 @@ TEST (ledger, work_validation)
// With random work the block doesn't pass, then modifies the block with sufficient work and ensures a correct result
auto process_block = [&store, &ledger, &pool] (nano::block & block_a, nano::block_details const details_a) {
auto threshold = nano::work_threshold (block_a.work_version (), details_a);
auto threshold = nano::dev::network_params.network.publish_thresholds.threshold (block_a.work_version (), details_a);
// Rarely failed with random work, so modify until it doesn't have enough difficulty
while (block_a.difficulty () >= threshold)
{

View file

@ -822,7 +822,7 @@ TEST (wallet, no_work)
auto block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), false));
ASSERT_NE (nullptr, block);
ASSERT_NE (0, block->block_work ());
ASSERT_GE (block->difficulty (), nano::work_threshold (block->work_version (), block->sideband ().details));
ASSERT_GE (block->difficulty (), nano::dev::network_params.network.publish_thresholds.threshold (block->work_version (), block->sideband ().details));
auto transaction (system.wallet (0)->wallets.tx_begin_read ());
uint64_t cached_work (0);
system.wallet (0)->store.work_get (transaction, nano::dev::genesis_key.pub, cached_work);

View file

@ -108,6 +108,21 @@ uint64_t nano::work_thresholds::threshold (nano::block_details const & details_a
return result;
}
uint64_t nano::work_thresholds::threshold (nano::work_version const version_a, nano::block_details const details_a)
{
static nano::network_constants network_constants;
uint64_t result{ std::numeric_limits<uint64_t>::max () };
switch (version_a)
{
case nano::work_version::work_1:
result = network_constants.publish_thresholds.threshold (details_a);
break;
default:
debug_assert (false && "Invalid version specified to ledger work_threshold");
}
return result;
}
namespace nano
{
const char * network_constants::active_network_err_msg = "Invalid network. Valid values are live, test, beta and dev.";

View file

@ -113,6 +113,8 @@ public:
uint64_t threshold_entry (nano::work_version const, nano::block_type const);
uint64_t value (nano::root const & root_a, uint64_t work_a);
uint64_t threshold (nano::block_details const &);
// Ledger threshold
uint64_t threshold (nano::work_version const, nano::block_details const);
/** Network work thresholds. Define these inline as constexpr when moving to cpp17. */
static const nano::work_thresholds publish_full;

View file

@ -64,21 +64,6 @@ uint64_t nano::work_threshold_base (nano::work_version const version_a)
return result;
}
uint64_t nano::work_threshold (nano::work_version const version_a, nano::block_details const details_a)
{
static nano::network_constants network_constants;
uint64_t result{ std::numeric_limits<uint64_t>::max () };
switch (version_a)
{
case nano::work_version::work_1:
result = network_constants.publish_thresholds.threshold (details_a);
break;
default:
debug_assert (false && "Invalid version specified to ledger work_threshold");
}
return result;
}
double nano::normalized_multiplier (double const multiplier_a, uint64_t const threshold_a)
{
static nano::network_constants network_constants;

View file

@ -24,8 +24,6 @@ bool work_validate_entry (nano::work_version const, nano::root const &, uint64_t
uint64_t work_difficulty (nano::work_version const, nano::root const &, uint64_t const);
uint64_t work_threshold_base (nano::work_version const);
// Ledger threshold
uint64_t work_threshold (nano::work_version const, nano::block_details const);
double normalized_multiplier (double const, uint64_t const);
double denormalized_multiplier (double const, uint64_t const);

View file

@ -1567,7 +1567,7 @@ int main (int argc, char * const * argv)
}
}
// Check if block work value is correct
if (block->difficulty () < nano::work_threshold (block->work_version (), block->sideband ().details))
if (block->difficulty () < node->network_params.network.publish_thresholds.threshold (block->work_version (), block->sideband ().details))
{
print_error_message (boost::str (boost::format ("Invalid work for block %1% value: %2%\n") % hash.to_string () % nano::to_string_hex (block->block_work ())));
}

View file

@ -414,7 +414,7 @@ uint64_t nano::json_handler::difficulty_ledger (nano::block const & block_a)
details_found = true;
}
}
return details_found ? nano::work_threshold (block_a.work_version (), details) : node.default_difficulty (block_a.work_version ());
return details_found ? node.network_params.network.publish_thresholds.threshold (block_a.work_version (), details) : node.default_difficulty (block_a.work_version ());
}
double nano::json_handler::multiplier_optional_impl (nano::work_version const version_a, uint64_t & difficulty)
@ -829,7 +829,7 @@ void nano::json_handler::account_representative_set ()
if (!rpc_l->ec)
{
nano::block_details details (info.epoch (), false, false, false);
if (nano::work_difficulty (nano::work_version::work_1, info.head, work) < nano::work_threshold (nano::work_version::work_1, details))
if (nano::work_difficulty (nano::work_version::work_1, info.head, work) < rpc_l->node.network_params.network.publish_thresholds.threshold (nano::work_version::work_1, details))
{
rpc_l->ec = nano::error_common::invalid_work;
}
@ -3284,7 +3284,7 @@ void nano::json_handler::receive ()
head = account;
}
nano::block_details details (epoch, false, true, false);
if (nano::work_difficulty (nano::work_version::work_1, head, work) < nano::work_threshold (nano::work_version::work_1, details))
if (nano::work_difficulty (nano::work_version::work_1, head, work) < node.network_params.network.publish_thresholds.threshold (nano::work_version::work_1, details))
{
ec = nano::error_common::invalid_work;
}
@ -3628,7 +3628,7 @@ void nano::json_handler::send ()
if (!ec && work)
{
nano::block_details details (info.epoch (), true, false, false);
if (nano::work_difficulty (nano::work_version::work_1, info.head, work) < nano::work_threshold (nano::work_version::work_1, details))
if (nano::work_difficulty (nano::work_version::work_1, info.head, work) < node.network_params.network.publish_thresholds.threshold (nano::work_version::work_1, details))
{
ec = nano::error_common::invalid_work;
}
@ -5051,7 +5051,7 @@ void nano::json_handler::work_validate ()
response_l.put ("valid", (result_difficulty >= difficulty) ? "1" : "0");
}
response_l.put ("valid_all", (result_difficulty >= node.default_difficulty (work_version)) ? "1" : "0");
response_l.put ("valid_receive", (result_difficulty >= nano::work_threshold (work_version, nano::block_details (nano::epoch::epoch_2, false, true, false))) ? "1" : "0");
response_l.put ("valid_receive", (result_difficulty >= node.network_params.network.publish_thresholds.threshold (work_version, nano::block_details (nano::epoch::epoch_2, false, true, false))) ? "1" : "0");
response_l.put ("difficulty", nano::to_string_hex (result_difficulty));
auto result_multiplier = nano::difficulty::to_multiplier (result_difficulty, node.default_difficulty (work_version));
response_l.put ("multiplier", nano::to_string (result_multiplier));

View file

@ -1546,7 +1546,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e
if (!store.account.get (transaction, account, info) && info.epoch () < epoch_a)
{
++attempts;
auto difficulty (nano::work_threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true)));
auto difficulty (network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true)));
nano::root const & root (info.head);
std::shared_ptr<nano::block> epoch = builder.state ()
.account (account)
@ -1624,7 +1624,7 @@ void nano::node::epoch_upgrader_impl (nano::raw_key const & prv_a, nano::epoch e
{
++attempts;
release_assert (nano::epochs::is_sequential (info.epoch, epoch_a));
auto difficulty (nano::work_threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true)));
auto difficulty (network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true)));
nano::root const & root (key.account);
nano::account const & account (key.account);
std::shared_ptr<nano::block> epoch = builder.state ()

View file

@ -1043,7 +1043,7 @@ bool nano::wallet::action_complete (std::shared_ptr<nano::block> const & block_a
wallets.delayed_work->erase (account_a);
if (block_a != nullptr)
{
auto required_difficulty{ nano::work_threshold (block_a->work_version (), details_a) };
auto required_difficulty{ wallets.node.network_params.network.publish_thresholds.threshold (block_a->work_version (), details_a) };
if (block_a->difficulty () < required_difficulty)
{
wallets.node.logger.try_log (boost::str (boost::format ("Cached or provided work for block %1% account %2% is invalid, regenerating") % block_a->hash ().to_string () % account_a.to_account ()));

View file

@ -2241,7 +2241,7 @@ void nano_qt::block_creation::create_send ()
nano::block_details details;
details.is_send = true;
details.epoch = info.epoch ();
auto const required_difficulty{ nano::work_threshold (send.work_version (), details) };
auto const required_difficulty{ wallet.node.network_params.network.publish_thresholds.threshold (send.work_version (), details) };
if (wallet.node.work_generate_blocking (send, required_difficulty).is_initialized ())
{
std::string block_l;
@ -2325,7 +2325,7 @@ void nano_qt::block_creation::create_receive ()
nano::block_details details;
details.is_receive = true;
details.epoch = std::max (info.epoch (), pending.epoch);
auto required_difficulty{ nano::work_threshold (receive.work_version (), details) };
auto required_difficulty{ wallet.node.network_params.network.publish_thresholds.threshold (receive.work_version (), details) };
if (wallet.node.work_generate_blocking (receive, required_difficulty).is_initialized ())
{
std::string block_l;
@ -2408,7 +2408,7 @@ void nano_qt::block_creation::create_change ()
nano::state_block change (account_l, info.head, representative_l, info.balance, 0, key, account_l, 0);
nano::block_details details;
details.epoch = info.epoch ();
auto const required_difficulty{ nano::work_threshold (change.work_version (), details) };
auto const required_difficulty{ wallet.node.network_params.network.publish_thresholds.threshold (change.work_version (), details) };
if (wallet.node.work_generate_blocking (change, required_difficulty).is_initialized ())
{
std::string block_l;
@ -2490,7 +2490,7 @@ void nano_qt::block_creation::create_open ()
nano::block_details details;
details.is_receive = true;
details.epoch = pending.epoch;
auto const required_difficulty{ nano::work_threshold (open.work_version (), details) };
auto const required_difficulty{ wallet.node.network_params.network.publish_thresholds.threshold (open.work_version (), details) };
if (wallet.node.work_generate_blocking (open, required_difficulty).is_initialized ())
{
std::string block_l;

View file

@ -524,7 +524,7 @@ TEST (rpc, send_epoch_2)
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv, false);
auto target_difficulty = nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, true, false, false));
auto target_difficulty = nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, true, false, false));
ASSERT_LT (node->network_params.network.publish_thresholds.entry, target_difficulty);
auto min_difficulty = node->network_params.network.publish_thresholds.entry;
@ -2147,7 +2147,7 @@ TEST (rpc, work_generate_block_ledger_epoch_2)
auto send_block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key.pub, nano::Gxrb_ratio));
ASSERT_NE (nullptr, send_block);
nano::state_block block (key.pub, 0, nano::dev::genesis_key.pub, nano::Gxrb_ratio, send_block->hash (), key.prv, key.pub, 0);
auto threshold (nano::work_threshold (block.work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
auto threshold (nano::dev::network_params.network.publish_thresholds.threshold (block.work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
block.block_work_set (system.work_generate_limited (block.root ().as_block_hash (), 1, threshold - 1));
nano::block_hash hash (block.root ().as_block_hash ());
auto [rpc, rpc_ctx] = add_rpc (system, node);
@ -2542,7 +2542,7 @@ TEST (rpc, account_representative_set_epoch_2)
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv, false);
auto target_difficulty = nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, false, false, false));
auto target_difficulty = nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, false, false, false));
ASSERT_LT (node->network_params.network.publish_thresholds.entry, target_difficulty);
auto min_difficulty = node->network_params.network.publish_thresholds.entry;
@ -4361,7 +4361,7 @@ TEST (rpc, block_create_state_open)
ASSERT_EQ (nano::block_type::state, state_block->type ());
ASSERT_EQ (state_hash, state_block->hash ().to_string ());
auto difficulty (state_block->difficulty ());
ASSERT_GT (difficulty, nano::work_threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_0, false, true, false)));
ASSERT_GT (difficulty, nano::dev::network_params.network.publish_thresholds.threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_0, false, true, false)));
ASSERT_TRUE (node->latest (key.pub).is_zero ());
rpc_ctx->io_scope->reset ();
auto process_result (node->process (*state_block));
@ -4441,7 +4441,7 @@ TEST (rpc, block_create_open_epoch_v2)
ASSERT_EQ (nano::block_type::state, state_block->type ());
ASSERT_EQ (state_hash, state_block->hash ().to_string ());
auto difficulty (state_block->difficulty ());
ASSERT_GT (difficulty, nano::work_threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
ASSERT_GT (difficulty, nano::dev::network_params.network.publish_thresholds.threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
ASSERT_TRUE (node->latest (key.pub).is_zero ());
rpc_ctx->io_scope->reset ();
auto process_result (node->process (*state_block));
@ -4485,7 +4485,7 @@ TEST (rpc, block_create_receive_epoch_v2)
ASSERT_EQ (nano::block_type::state, state_block->type ());
ASSERT_EQ (state_hash, state_block->hash ().to_string ());
auto difficulty (state_block->difficulty ());
ASSERT_GT (difficulty, nano::work_threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
ASSERT_GT (difficulty, nano::dev::network_params.network.publish_thresholds.threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, false, true, false)));
rpc_ctx->io_scope->reset ();
auto process_result (node->process (*state_block));
ASSERT_EQ (nano::process_result::progress, process_result.code);
@ -4527,7 +4527,7 @@ TEST (rpc, block_create_send_epoch_v2)
ASSERT_EQ (nano::block_type::state, state_block->type ());
ASSERT_EQ (state_hash, state_block->hash ().to_string ());
auto difficulty (state_block->difficulty ());
ASSERT_GT (difficulty, nano::work_threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, true, false, false)));
ASSERT_GT (difficulty, nano::dev::network_params.network.publish_thresholds.threshold (state_block->work_version (), nano::block_details (nano::epoch::epoch_2, true, false, false)));
rpc_ctx->io_scope->reset ();
auto process_result (node->process (*state_block));
ASSERT_EQ (nano::process_result::progress, process_result.code);

View file

@ -346,7 +346,8 @@ void ledger_processor::state_block_impl (nano::state_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (epoch, is_send, is_receive, false);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
ledger.stats.inc (nano::stat::type::ledger, nano::stat::detail::state_block);
@ -446,7 +447,8 @@ void ledger_processor::epoch_block_impl (nano::state_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (epoch, false, false, true);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
ledger.stats.inc (nano::stat::type::ledger, nano::stat::detail::epoch_block);
@ -498,7 +500,8 @@ void ledger_processor::change_block (nano::change_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
debug_assert (!validate_message (account, hash, block_a.signature));
@ -547,7 +550,8 @@ void ledger_processor::send_block (nano::send_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
debug_assert (!validate_message (account, hash, block_a.signature));
@ -624,7 +628,8 @@ void ledger_processor::receive_block (nano::receive_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
auto new_balance (info.balance.number () + pending.amount.number ());
@ -697,7 +702,8 @@ void ledger_processor::open_block (nano::open_block & block_a)
if (result.code == nano::process_result::progress)
{
nano::block_details block_details (nano::epoch::epoch_0, false /* unused */, false /* unused */, false /* unused */);
result.code = block_a.difficulty () >= nano::work_threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
nano::network_constants constants;
result.code = block_a.difficulty () >= constants.publish_thresholds.threshold (block_a.work_version (), block_details) ? nano::process_result::progress : nano::process_result::insufficient_work; // Does this block have sufficient work? (Malformed)
if (result.code == nano::process_result::progress)
{
#ifdef NDEBUG

View file

@ -1609,7 +1609,7 @@ TEST (node, mass_epoch_upgrader)
.link (info.key.pub)
.representative (nano::dev::genesis_key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*node.work_generate_blocking (latest, nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_0, false, false, false))))
.work (*node.work_generate_blocking (latest, nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_0, false, false, false))))
.build (ec);
ASSERT_FALSE (ec);
ASSERT_NE (nullptr, block);
@ -1633,7 +1633,7 @@ TEST (node, mass_epoch_upgrader)
.link (info.pending_hash)
.representative (info.key.pub)
.sign (info.key.prv, info.key.pub)
.work (*node.work_generate_blocking (info.key.pub, nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_0, false, false, false))))
.work (*node.work_generate_blocking (info.key.pub, nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_0, false, false, false))))
.build (ec);
ASSERT_FALSE (ec);
ASSERT_NE (nullptr, block);
@ -1723,7 +1723,7 @@ TEST (node, mass_block_new)
std::vector<nano::keypair> keys (num_blocks);
nano::state_block_builder builder;
std::vector<std::shared_ptr<nano::state_block>> send_blocks;
auto send_threshold (nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, true, false, false)));
auto send_threshold (nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, true, false, false)));
auto latest_genesis = node.latest (nano::dev::genesis_key.pub);
for (auto i = 0; i < num_blocks; ++i)
{
@ -1746,7 +1746,7 @@ TEST (node, mass_block_new)
std::cout << "Send blocks time: " << timer.stop ().count () << " " << timer.unit () << "\n\n";
std::vector<std::shared_ptr<nano::state_block>> open_blocks;
auto receive_threshold (nano::work_threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, false, true, false)));
auto receive_threshold (nano::dev::network_params.network.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (nano::epoch::epoch_2, false, true, false)));
for (auto i = 0; i < num_blocks; ++i)
{
auto const & key = keys[i];

View file

@ -219,6 +219,7 @@ std::unique_ptr<nano::state_block> nano::upgrade_epoch (nano::work_pool & pool_a
nano::state_block_builder builder;
std::error_code ec;
nano::network_constants constants;
auto epoch = builder
.account (dev_genesis_key.pub)
.previous (latest)
@ -226,7 +227,7 @@ std::unique_ptr<nano::state_block> nano::upgrade_epoch (nano::work_pool & pool_a
.link (ledger_a.epoch_link (epoch_a))
.representative (dev_genesis_key.pub)
.sign (dev_genesis_key.prv, dev_genesis_key.pub)
.work (*pool_a.generate (latest, nano::work_threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true))))
.work (*pool_a.generate (latest, constants.publish_thresholds.threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true))))
.build (ec);
bool error{ true };