From dac549f0b610525f50b7395d9002708b0824f70a Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 2 Dec 2022 18:14:19 +0100 Subject: [PATCH] minor improvements and compilation fixes --- src/connectivity_tool/conn_tool.cpp | 2 +- src/currency_core/pos_mining.cpp | 9 +++++++-- tests/functional_tests/difficulty_analysis.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index f4daeacc..b4364d04 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -408,7 +408,7 @@ bool generate_genesis(const std::string& path_config, uint64_t premine_split_amo ss.str(""); ss.clear(); std::cout << ENDL << "PROOF PHRASE: " << gcp.proof_string << ENDL; - construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS); + // construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, TRANSACTION_VERSION_PRE_HF4, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS); <-- temporarily commented out; this overload needs to be re-implemented -- sowle currency::blobdata txb = tx_to_blob(bl.miner_tx); //self validate block diff --git a/src/currency_core/pos_mining.cpp b/src/currency_core/pos_mining.cpp index e0096ea3..a2b6237b 100644 --- a/src/currency_core/pos_mining.cpp +++ b/src/currency_core/pos_mining.cpp @@ -67,13 +67,18 @@ namespace currency if (found) { found = true; + const boost::multiprecision::uint256_t d_mp = lhs / (crypto::c_zarcanum_z_coeff_mp * this->stake_amount) + 1; + const boost::multiprecision::uint256_t ba = d_mp * crypto::c_zarcanum_z_coeff_mp * this->stake_amount - lhs; + const boost::multiprecision::uint256_t l_div_z_D = this->z_l_div_z_D / crypto::c_zarcanum_z_coeff_mp; LOG_PRINT_GREEN("Found Zarcanum kernel: amount: " << currency::print_money_brief(this->stake_amount) << /* ", gindex: " << td.m_global_output_index << */ ENDL << "difficulty: " << this->basic_diff << ENDL << "kernel info: " << ENDL << print_stake_kernel_info(this->sk) << "kernel_hash: " << this->kernel_hash << ENDL - << "lhs: " << crypto::scalar_t(lhs) << ENDL - << "rhs: " << crypto::scalar_t(rhs) + << "lhs: 0x" << crypto::scalar_t(lhs).to_string_as_hex_number() << " = 0x" << std::hex << d_mp << " * 2^64 * " << this->stake_amount << " - 0x" << std::hex << ba << ENDL + << "rhs: 0x" << crypto::scalar_t(rhs).to_string_as_hex_number() << ENDL + << "d: 0x" << std::hex << d_mp << ENDL + << "l / floor(z * D): 0x" << std::hex << l_div_z_D , LOG_LEVEL_0); } diff --git a/tests/functional_tests/difficulty_analysis.cpp b/tests/functional_tests/difficulty_analysis.cpp index 0af4d4d8..3df52f21 100644 --- a/tests/functional_tests/difficulty_analysis.cpp +++ b/tests/functional_tests/difficulty_analysis.cpp @@ -306,7 +306,7 @@ void run_emulation(const std::string& path) perform_simulation_for_function(timestamp_to_hashrate, current_index, blocks, result_blocks, \ [&](std::vector& timestamps, std::vector& cumulative_difficulties, size_t target_seconds) \ { \ - return func_name(timestamps, cumulative_difficulties, target_seconds); \ + return func_name(timestamps, cumulative_difficulties, target_seconds, DIFFICULTY_POW_STARTER); \ }); \ current_index+=2;