From 7384485fe1e8d7a0fb84ec2c28bf3b6c569ef1ad Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 5 Sep 2022 20:18:27 +0200 Subject: [PATCH 1/2] minting refactoring: in progress --- src/currency_core/blockchain_storage.cpp | 14 ++++++++- src/currency_core/currency_basic.h | 4 +-- src/rpc/core_rpc_server.cpp | 4 ++- src/rpc/core_rpc_server_commands_defs.h | 10 +++++-- src/wallet/wallet2.cpp | 37 +++++++++++++----------- src/wallet/wallet2.h | 20 +++++++++---- 6 files changed, 60 insertions(+), 29 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index ae488699..6eb446dd 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1424,7 +1424,8 @@ bool blockchain_storage::create_block_template(const create_block_template_param const account_public_address& stakeholder_address = params.stakeholder_address; const blobdata& ex_nonce = params.ex_nonce; bool pos = params.pos; - const pos_entry& pe = params.pe; + const pos_entry& pe = params.pe; + fill_block_template_func_t* pcustom_fill_block_template_func = params.pcustom_fill_block_template_func; uint64_t& height = resp.height; @@ -1435,6 +1436,17 @@ bool blockchain_storage::create_block_template(const create_block_template_param size_t median_size; boost::multiprecision::uint128_t already_generated_coins; CRITICAL_REGION_BEGIN(m_read_lock); + if (pe.g_index == WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED) + { + std::vector indexs; + if (!get_tx_outputs_gindexs(pe.tx_id, indexs) || pe.tx_out_index >= indexs.size()) + { + CHECK_AND_ASSERT_MES(false, false, "Failed to get_tx_outputs_gindexs() for tx_id " << pe.tx_id); + } + pe.g_index = indexs[pe.tx_out_index]; + } + + height = m_db_blocks.size(); b.major_version = m_core_runtime_config.hard_forks.get_block_major_version_by_height(height); diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index c45b1954..f7cb6271 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -964,7 +964,7 @@ namespace currency struct pos_entry { uint64_t amount; - uint64_t index; // global output index. TODO: remove, use tx_id + tx_out_index to get gindex in construct_miner_tx + uint64_t g_index; // global output index. (could be WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED) crypto::key_image keyimage; uint64_t block_timestamp; uint64_t stake_unlock_time; @@ -977,7 +977,7 @@ namespace currency BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amount) - KV_SERIALIZE(index) + KV_SERIALIZE(g_index) KV_SERIALIZE(stake_unlock_time) KV_SERIALIZE(block_timestamp) KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(keyimage) diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 1a099a0d..a96db023 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -831,7 +831,9 @@ namespace currency params.ex_nonce = req.extra_text; params.pos = req.pos_block; params.pe.amount = req.pos_amount; - params.pe.index = req.pos_index; + params.pe.g_index = req.pos_g_index; + params.pe.tx_id = req.tx_id; + params.pe.tx_out_index = req.tx_out_index; params.pe.stake_unlock_time = req.stake_unlock_time; //params.pe.keyimage key image will be set in the wallet //params.pe.wallet_index is not included in serialization map, TODO: refactoring here diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index 12874e9f..12a0911f 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -804,8 +804,10 @@ namespace currency std::string wallet_address; std::string stakeholder_address; bool pos_block; //is pos block - uint64_t pos_amount; // - uint64_t pos_index; // + uint64_t pos_amount; //do we still need it? + uint64_t pos_g_index; // + crypto::hash tx_id; + uint64_t tx_out_index; uint64_t stake_unlock_time; BEGIN_KV_SERIALIZE_MAP() @@ -815,7 +817,9 @@ namespace currency KV_SERIALIZE(stakeholder_address); KV_SERIALIZE(pos_block) KV_SERIALIZE(pos_amount) - KV_SERIALIZE(pos_index) + KV_SERIALIZE(pos_g_index) + KV_SERIALIZE_POD_AS_HEX_STRING(tx_id) + KV_SERIALIZE(tx_out_index) KV_SERIALIZE(stake_unlock_time) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 60f7cc0d..d60cc476 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3545,7 +3545,7 @@ bool wallet2::get_pos_entries(std::vector& entries) pos_entry pe = AUTO_VAL_INIT(pe); pe.amount = tr.amount(); - pe.index = tr.m_global_output_index; + //pe.index = tr.m_global_output_index; pe.keyimage = tr.m_key_image; pe.wallet_index = i; pe.stake_unlock_time = stake_unlock_time; @@ -3633,8 +3633,8 @@ bool wallet2::build_kernel(const pos_entry& pe, const stake_modifier_type& stake //---------------------------------------------------------------------------------------------------- bool wallet2::fill_mining_context(mining_context& ctx) { - bool r = get_pos_entries(ctx.sp.pos_entries); // TODO: Remove this call. Transfers are filtered in scan_pos - WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to get_pos_entries()"); + //bool r = get_pos_entries(ctx.sp.pos_entries); // TODO: Remove this call. Transfers are filtered in scan_pos + //WLT_CHECK_AND_ASSERT_MES(r, false, "Failed to get_pos_entries()"); currency::COMMAND_RPC_GET_POS_MINING_DETAILS::request pos_details_req = AUTO_VAL_INIT(pos_details_req); currency::COMMAND_RPC_GET_POS_MINING_DETAILS::response pos_details_resp = AUTO_VAL_INIT(pos_details_resp); @@ -3675,9 +3675,9 @@ bool wallet2::try_mint_pos(const currency::account_public_address& miner_address return true; } - uint64_t pos_entries_amount = 0; - for (auto& ent : ctx.sp.pos_entries) - pos_entries_amount += ent.amount; + //uint64_t pos_entries_amount = 0; + //for (auto& ent : ctx.sp.pos_entries) + // pos_entries_amount += ent.amount; std::atomic stop(false); scan_pos(ctx, stop, [this](){ @@ -3696,7 +3696,7 @@ bool wallet2::try_mint_pos(const currency::account_public_address& miner_address build_minted_block(ctx, miner_address); } - WLT_LOG_L0("PoS mining: " << ctx.iterations_processed << " iterations finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << print_money_brief(pos_entries_amount)); + WLT_LOG_L0("PoS mining: " << ctx.iterations_processed << " iterations finished, status: " << ctx.rsp.status << ", " << ctx.total_items_checked << " entries with total amount: " << print_money_brief(ctx.total_amount_checked)); return true; } @@ -3788,22 +3788,25 @@ bool wallet2::build_minted_block(const mining_context& cxt, //found a block, construct it, sign and push to daemon WLT_LOG_GREEN("Found kernel, constructing block", LOG_LEVEL_0); - CHECK_AND_NO_ASSERT_MES(cxt.rsp.index < cxt.sp.pos_entries.size(), false, "call_COMMAND_RPC_SCAN_POS returned wrong index: " << cxt.rsp.index << ", expected less then " << cxt.sp.pos_entries.size()); + //CHECK_AND_NO_ASSERT_MES(cxt.rsp.index < cxt.sp.pos_entries.size(), false, "call_COMMAND_RPC_SCAN_POS returned wrong index: " << cxt.rsp.index << ", expected less then " << cxt.sp.pos_entries.size()); - const pos_entry& pe = cxt.sp.pos_entries[cxt.rsp.index]; + const pos_entry pe = AUTO_VAL_INIT(); + pe. currency::COMMAND_RPC_GETBLOCKTEMPLATE::request tmpl_req = AUTO_VAL_INIT(tmpl_req); currency::COMMAND_RPC_GETBLOCKTEMPLATE::response tmpl_rsp = AUTO_VAL_INIT(tmpl_rsp); tmpl_req.wallet_address = get_account_address_as_str(miner_address); tmpl_req.stakeholder_address = get_account_address_as_str(m_account.get_public_address()); tmpl_req.pos_block = true; - tmpl_req.pos_amount = pe.amount; - - tmpl_req.pos_index = pe.index; // gindex <--- this should be removed as soon as pos_entry::index is replaced with tx_id and tx_out_index + tmpl_req.pos_g_index = m_transfers[cxt.rsp.index].m_global_output_index; + tmpl_req.pos_amount = m_transfers[cxt.rsp.index].amount();// pe.amount; + tmpl_req.tx_id = m_transfers[cxt.rsp.index].tx_hash(); + tmpl_req.tx_out_index = m_transfers[cxt.rsp.index].m_internal_output_index; + //tmpl_req.pos_index = pe.index; // gindex <--- this should be removed as soon as pos_entry::index is replaced with tx_id and tx_out_index // TODO: also fill out tx_id and tx_out_index for mining tx creation tmpl_req.extra_text = m_miner_text_info; - tmpl_req.stake_unlock_time = pe.stake_unlock_time; + tmpl_req.stake_unlock_time = cxt.rsp.stake_unlock_time; //generate packing tx transaction pack_tx = AUTO_VAL_INIT(pack_tx); if (generate_packing_transaction_if_needed(pack_tx, 0)) @@ -3828,15 +3831,15 @@ bool wallet2::build_minted_block(const mining_context& cxt, } std::vector keys_ptrs; - WLT_CHECK_AND_ASSERT_MES(pe.wallet_index < m_transfers.size(), + WLT_CHECK_AND_ASSERT_MES(cxt.rsp.index < m_transfers.size(), false, "Wrong wallet_index at generating coinbase transacton"); - if (m_transfers[pe.wallet_index].m_ptx_wallet_info->m_tx.vout[m_transfers[pe.wallet_index].m_internal_output_index].type() != typeid(tx_out_bare)) + if (m_transfers[cxt.rsp.index].m_ptx_wallet_info->m_tx.vout[m_transfers[cxt.rsp.index].m_internal_output_index].type() != typeid(tx_out_bare)) { //@#@ review zarcanum here return false; } - const auto& target = boost::get(m_transfers[pe.wallet_index].m_ptx_wallet_info->m_tx.vout[m_transfers[pe.wallet_index].m_internal_output_index]).target; + const auto& target = boost::get(m_transfers[cxt.rsp.index].m_ptx_wallet_info->m_tx.vout[m_transfers[cxt.rsp.index].m_internal_output_index]).target; WLT_CHECK_AND_ASSERT_MES(target.type() == typeid(currency::txout_to_key), false, "wrong type_id in source transaction in coinbase tx"); const currency::txout_to_key& txtokey = boost::get(target); @@ -3852,7 +3855,7 @@ bool wallet2::build_minted_block(const mining_context& cxt, res = prepare_and_sign_pos_block(b, pe, get_tx_pub_key_from_extra(m_transfers[pe.wallet_index].m_ptx_wallet_info->m_tx), - m_transfers[pe.wallet_index].m_internal_output_index, + m_transfers[cxt.rsp.index].m_internal_output_index, keys_ptrs); WLT_CHECK_AND_ASSERT_MES(res, false, "Failed to prepare_and_sign_pos_block"); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 2cf09707..656439f3 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -447,7 +447,7 @@ namespace tools struct mining_context { // from struct COMMAND_RPC_SCAN_POS - struct request_t + /*struct request_t { std::vector pos_entries; @@ -455,11 +455,13 @@ namespace tools KV_SERIALIZE(pos_entries) END_KV_SERIALIZE_MAP() }; + */ struct response_t { std::string status; - uint64_t index; // index in pos_entries container + uint64_t index; // index in m_transfers + uint64_t stake_unlock_time; uint64_t block_timestamp; uint64_t height; uint64_t starter_timestamp; @@ -469,6 +471,7 @@ namespace tools BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(status) KV_SERIALIZE(index) + KV_SERIALIZE(stake_unlock_time) KV_SERIALIZE(block_timestamp) KV_SERIALIZE(height) KV_SERIALIZE(is_pos_allowed) @@ -477,7 +480,7 @@ namespace tools END_KV_SERIALIZE_MAP() }; - request_t sp; + //request_t sp; response_t rsp; currency::wide_difficulty_type basic_diff; @@ -486,7 +489,9 @@ namespace tools bool zarcanum; crypto::scalar_t last_pow_block_id_hashed; // Zarcanum notation: f' - uint64_t iterations_processed; + uint64_t iterations_processed = 0; + uint64_t total_items_checked = 0; + uint64_t total_amount_checked = 0; }; struct expiration_entry_info @@ -1364,6 +1369,7 @@ namespace tools if (!is_transfer_okay_for_pos(tr, stake_unlock_time)) continue; + bool go_past = true; uint64_t step = 0; @@ -1384,7 +1390,8 @@ namespace tools }; do_pos_mining_prepare_entry(cxt, transfer_index); - + ctx.total_items_checked++; + ctx.total_amount_checked += tr.amount(); while(step <= ts_window) { //check every WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL seconds wheither top block changed, if so - break the loop @@ -1410,8 +1417,11 @@ namespace tools if (stop) return false; + cxt.iterations_processed++; if (do_pos_mining_iteration(cxt, transfer_index, ts)) { + cxt.rsp.index = transfer_index; + cxt.rsp.stake_unlock_time = stake_unlock_time; cxt.rsp.status = API_RETURN_CODE_OK; return true; } From ec73527df992af4d180da9a42e59e7530d257d05 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 6 Sep 2022 19:41:20 +0200 Subject: [PATCH 2/2] compilation is ok, tests in progress --- src/currency_core/blockchain_storage.cpp | 2 +- src/currency_core/currency_format_utils.cpp | 2 +- src/wallet/wallet2.cpp | 19 +++++++++++-------- src/wallet/wallet2.h | 6 +++--- src/wallet/wallet_public_structs_defs.h | 2 ++ src/wallet/wallets_manager.cpp | 8 ++++---- tests/core_tests/block_reward.cpp | 2 +- tests/core_tests/chaingen.cpp | 6 +++--- tests/core_tests/chaingen_helpers.h | 4 ++-- 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 6eb446dd..bc2c8a2e 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1424,7 +1424,7 @@ bool blockchain_storage::create_block_template(const create_block_template_param const account_public_address& stakeholder_address = params.stakeholder_address; const blobdata& ex_nonce = params.ex_nonce; bool pos = params.pos; - const pos_entry& pe = params.pe; + pos_entry pe = params.pe; fill_block_template_func_t* pcustom_fill_block_template_func = params.pcustom_fill_block_template_func; diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 7efe2f23..54932aa3 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -283,7 +283,7 @@ namespace currency posin.amount = pe.amount; // TODO: using pe.index is deprecated, get input's global index by pe.tx_id and pe.tx_out_index - posin.key_offsets.push_back(pe.index); + posin.key_offsets.push_back(pe.g_index); posin.k_image = pe.keyimage; tx.vin.push_back(posin); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d60cc476..551e3685 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3790,23 +3790,26 @@ bool wallet2::build_minted_block(const mining_context& cxt, //CHECK_AND_NO_ASSERT_MES(cxt.rsp.index < cxt.sp.pos_entries.size(), false, "call_COMMAND_RPC_SCAN_POS returned wrong index: " << cxt.rsp.index << ", expected less then " << cxt.sp.pos_entries.size()); - const pos_entry pe = AUTO_VAL_INIT(); - pe. + pos_entry pe = AUTO_VAL_INIT(pe); + currency::COMMAND_RPC_GETBLOCKTEMPLATE::request tmpl_req = AUTO_VAL_INIT(tmpl_req); currency::COMMAND_RPC_GETBLOCKTEMPLATE::response tmpl_rsp = AUTO_VAL_INIT(tmpl_rsp); tmpl_req.wallet_address = get_account_address_as_str(miner_address); tmpl_req.stakeholder_address = get_account_address_as_str(m_account.get_public_address()); tmpl_req.pos_block = true; - tmpl_req.pos_g_index = m_transfers[cxt.rsp.index].m_global_output_index; - tmpl_req.pos_amount = m_transfers[cxt.rsp.index].amount();// pe.amount; - tmpl_req.tx_id = m_transfers[cxt.rsp.index].tx_hash(); - tmpl_req.tx_out_index = m_transfers[cxt.rsp.index].m_internal_output_index; + pe.g_index = tmpl_req.pos_g_index = m_transfers[cxt.rsp.index].m_global_output_index; + pe.amount = tmpl_req.pos_amount = m_transfers[cxt.rsp.index].amount();// pe.amount; + pe.keyimage = m_transfers[cxt.rsp.index].m_key_image; + pe.block_timestamp = m_transfers[cxt.rsp.index].m_ptx_wallet_info->m_block_timestamp; + pe.stake_unlock_time = tmpl_req.stake_unlock_time = cxt.rsp.stake_unlock_time; + pe.tx_id = tmpl_req.tx_id = m_transfers[cxt.rsp.index].tx_hash(); + pe.tx_out_index = tmpl_req.tx_out_index = m_transfers[cxt.rsp.index].m_internal_output_index; + pe.wallet_index = cxt.rsp.index; + //tmpl_req.pos_index = pe.index; // gindex <--- this should be removed as soon as pos_entry::index is replaced with tx_id and tx_out_index // TODO: also fill out tx_id and tx_out_index for mining tx creation - tmpl_req.extra_text = m_miner_text_info; - tmpl_req.stake_unlock_time = cxt.rsp.stake_unlock_time; //generate packing tx transaction pack_tx = AUTO_VAL_INIT(pack_tx); if (generate_packing_transaction_if_needed(pack_tx, 0)) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 656439f3..66c31d3c 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -58,7 +58,7 @@ const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std::numeric_limits::max(); -const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits::max(); + #undef LOG_DEFAULT_CHANNEL #define LOG_DEFAULT_CHANNEL "wallet" @@ -1390,8 +1390,8 @@ namespace tools }; do_pos_mining_prepare_entry(cxt, transfer_index); - ctx.total_items_checked++; - ctx.total_amount_checked += tr.amount(); + cxt.total_items_checked++; + cxt.total_amount_checked += tr.amount(); while(step <= ts_window) { //check every WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL seconds wheither top block changed, if so - break the loop diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index bde9d9f4..37fa3957 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -14,6 +14,8 @@ #include "currency_core/bc_escrow_service.h" #include "rpc/core_rpc_server_commands_defs.h" +const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits::max(); + namespace tools { namespace wallet_public diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 74e99899..12382be3 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1993,9 +1993,9 @@ void wallets_manager::wallet_vs_options::worker_func() return true; } - uint64_t pos_entries_amount = 0; - for (auto& ent : ctx.sp.pos_entries) - pos_entries_amount += ent.amount; + //uint64_t pos_entries_amount = 0; + //for (auto& ent : ctx.sp.pos_entries) + // pos_entries_amount += ent.amount; w->get()->scan_pos(ctx, break_mining_loop, [this](){ return *plast_daemon_network_state == currency::COMMAND_RPC_GET_INFO::daemon_network_state_online && *plast_daemon_height == last_wallet_synch_height; @@ -2005,7 +2005,7 @@ void wallets_manager::wallet_vs_options::worker_func() { w->get()->build_minted_block(ctx); } - LOG_PRINT_L1(get_log_prefix() << " PoS mining iteration finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << currency::print_money_brief(pos_entries_amount) << ", processed: " << ctx.iterations_processed << " iter."); + LOG_PRINT_L1(get_log_prefix() << " PoS mining iteration finished, status: " << ctx.rsp.status << ", used " << ctx.total_items_checked << " entries with total amount: " << currency::print_money_brief(ctx.total_amount_checked) << ", processed: " << ctx.iterations_processed << " iter."); return true; }); } diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index b2d4056a..e47b4bce 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -63,7 +63,7 @@ bool block_template_against_txs_size::c1(currency::core& c, size_t ev_index, con pos_entry pe = AUTO_VAL_INIT(pe); pe.amount = boost::get(blk_0.miner_tx.vout[0]).amount; pe.block_timestamp = UINT64_MAX; // doesn't matter - pe.index = 0; // global index + pe.g_index = 0; // global index pe.keyimage = ki; pe.wallet_index = UINT64_MAX; // doesn't matter diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 20d77516..812ec95b 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -366,7 +366,7 @@ bool test_generator::sign_block(currency::block& b, bool r = get_output_details_by_global_index(blocks, oi, pe.amount, - pe.index, + pe.g_index, h, pts, out_i, @@ -556,7 +556,7 @@ bool test_generator::find_kernel(const std::list& accs, stake_kernel sk = AUTO_VAL_INIT(sk); build_kernel(pos_entries[i].amount, - pos_entries[i].index, + pos_entries[i].g_index, pos_entries[i].keyimage, sk, blck_chain, @@ -582,7 +582,7 @@ bool test_generator::find_kernel(const std::list& accs, //found kernel LOG_PRINT_GREEN("Found kernel: amount=" << print_money(pos_entries[i].amount) - << ", index=" << pos_entries[i].index + << ", index=" << pos_entries[i].g_index << ", key_image" << pos_entries[i].keyimage << ", diff: " << this_coin_diff, LOG_LEVEL_0); pe = pos_entries[i]; diff --git a/tests/core_tests/chaingen_helpers.h b/tests/core_tests/chaingen_helpers.h index 6b481eb1..44c1ca1d 100644 --- a/tests/core_tests/chaingen_helpers.h +++ b/tests/core_tests/chaingen_helpers.h @@ -175,12 +175,12 @@ inline bool mine_next_pos_block_in_playtime_with_wallet(tools::wallet2& w, const w.fill_mining_context(ctx); if (!ctx.rsp.is_pos_allowed) return false; - - pos_entries_count = ctx.sp.pos_entries.size(); + std::atomic stop(false); w.scan_pos(ctx, stop, [&w](){size_t blocks_fetched; w.refresh(blocks_fetched); return blocks_fetched == 0; }, w.get_core_runtime_config()); + pos_entries_count = ctx.total_items_checked; if (ctx.rsp.status != API_RETURN_CODE_OK) return false;