From 88073e300336b728cc4c07ec24bb21b6f0da6882 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 23 Sep 2019 21:51:25 +0200 Subject: [PATCH 1/4] added more logs + fixed issue with forgotten cumulative_diff_precise_adjusted --- src/currency_core/blockchain_storage.cpp | 15 ++++++++++++--- src/currency_core/blockchain_storage_basic.h | 1 + src/currency_core/currency_config.h | 2 +- src/daemon/daemon_commands_handler.h | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 54b2e8f4..68937caa 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1820,10 +1820,19 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ wide_difficulty_type main_pow_diff_begin = get_last_alt_x_block_cumulative_precise_adj_difficulty(alt_chain_type(), connection_point.height - 1, false); main_cumul_diff.pow_diff = main_pow_diff_end - main_pow_diff_begin; - //TODO: measurment of precise cumulative difficult + //TODO: measurement of precise cumulative difficult wide_difficulty_type alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff); wide_difficulty_type main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff); - + LOG_PRINT_L1("[FORK_CHOICE]: " << ENDL + << "difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL + << "difficulty_pos_at_split_point:" << difficulty_pos_at_split_point << ENDL + << "alt_cumul_diff.pow_diff:" << alt_cumul_diff.pow_diff << ENDL + << "alt_cumul_diff.pos_diff:" << alt_cumul_diff.pos_diff << ENDL + << "main_cumul_diff.pow_diff:" << main_cumul_diff.pow_diff << ENDL + << "main_cumul_diff.pos_diff:" << main_cumul_diff.pos_diff << ENDL + << "alt:" << alt << ENDL + << "main:" << main << ENDL + ); if (main < alt) return true; else if (main > alt) @@ -1838,7 +1847,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_ if (std::memcmp(&main_chain_bei.stake_hash, &proof_alt, sizeof(main_chain_bei.stake_hash)) >= 0) return false; - LOG_PRINT_L2("[is_reorganize_required]:TRUE, \"by order of memcmp\" main_stake_hash:" << &main_chain_bei.stake_hash << ", alt_stake_hash" << proof_alt); + LOG_PRINT_L1("[is_reorganize_required]:TRUE, \"by order of memcmp\" main_stake_hash:" << &main_chain_bei.stake_hash << ", alt_stake_hash" << proof_alt); return true; } } diff --git a/src/currency_core/blockchain_storage_basic.h b/src/currency_core/blockchain_storage_basic.h index dd3cf354..7344f200 100644 --- a/src/currency_core/blockchain_storage_basic.h +++ b/src/currency_core/blockchain_storage_basic.h @@ -63,6 +63,7 @@ namespace currency FIELD(block_cumulative_size) FIELD(cumulative_diff_adjusted) FIELD(cumulative_diff_precise) + FIELD(cumulative_diff_precise_adjusted) FIELD(difficulty) FIELD(already_generated_coins) FIELD(stake_hash) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index af7ad918..fce54784 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -202,7 +202,7 @@ #define CURRENT_TRANSACTION_CHAIN_ENTRY_ARCHIVE_VER 3 #define CURRENT_BLOCK_EXTENDED_INFO_ARCHIVE_VER 1 -#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 8 +#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 9 #define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1 diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 391f16f4..593e9163 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -499,8 +499,15 @@ private: bool r = m_srv.get_payload_object().get_core().get_blockchain_storage().get_main_blocks_rpc_details(height, 1, false, blocks); if (r && blocks.size()) { + currency::block b = AUTO_VAL_INIT(b); + m_srv.get_payload_object().get_core().get_blockchain_storage().get_block_by_height(height, b); + currency::blobdata blob = block_to_blob(b); + std::string block_hex = epee::string_tools::buff_to_hex_nodelimer(blob); + currency::block_rpc_extended_info& rbei = blocks.back(); - LOG_PRINT_GREEN("------------------ block_id: " << rbei.id << " ------------------" << ENDL << epee::serialization::store_t_to_json(rbei), LOG_LEVEL_0); + LOG_PRINT_GREEN("------------------ block_id: " << rbei.id << " ------------------" << + ENDL << epee::serialization::store_t_to_json(rbei) << ENDL + << " ------------------ hex_blob: " << ENDL << block_hex, LOG_LEVEL_0); } else { @@ -523,8 +530,14 @@ private: if (r) { + currency::block b = AUTO_VAL_INIT(b); + m_srv.get_payload_object().get_core().get_blockchain_storage().get_block_by_hash(block_hash, b); + currency::blobdata blob = block_to_blob(b); + std::string block_hex = epee::string_tools::buff_to_hex_nodelimer(blob); // currency::block& block = bei.bl; - LOG_PRINT_GREEN("------------------ block_id: " << bei.id << " ------------------" << ENDL << epee::serialization::store_t_to_json(bei), LOG_LEVEL_0); + LOG_PRINT_GREEN("------------------ block_id: " << bei.id << " ------------------" << ENDL + << epee::serialization::store_t_to_json(bei) << ENDL + << " ------------------ hex_blob: " << ENDL << block_hex, LOG_LEVEL_0); } else { From 14bd668e9a3fcce22e86e8938ea2b9411748fd35 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 23 Sep 2019 23:12:44 +0300 Subject: [PATCH 2/4] === build number: 57 -> 58 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index b685d4a8..68442457 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -7,6 +7,6 @@ #define PROJECT_REVISION "0" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 57 +#define PROJECT_VERSION_BUILD_NO 58 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 20a81cbe6dd61a960cb7763816e3c61f1b49460a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 24 Sep 2019 17:19:43 +0200 Subject: [PATCH 3/4] fixed warnings --- contrib/CMakeLists.txt | 5 ++--- contrib/db/liblmdb/CMakeLists.txt | 2 +- contrib/epee/include/net/abstract_tcp_server2.inl | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index c1ea6bdd..f691d096 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -12,10 +12,9 @@ set_property(TARGET zlibstatic PROPERTY FOLDER "contrib") set_property(TARGET lmdb PROPERTY FOLDER "contrib") - - if(MSVC) set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267") else() - set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value") + set_property(TARGET upnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") + set_property(TARGET zlibstatic APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value -Wno-implicit-fallthrough -Wno-discarded-qualifiers ") endif() diff --git a/contrib/db/liblmdb/CMakeLists.txt b/contrib/db/liblmdb/CMakeLists.txt index 4a60e07c..8ec1a8d8 100644 --- a/contrib/db/liblmdb/CMakeLists.txt +++ b/contrib/db/liblmdb/CMakeLists.txt @@ -4,7 +4,7 @@ set (lmdb_sources mdb.c midl.c) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable") endif() if(FREEBSD) add_definitions(-DMDB_DSYNC=O_SYNC) diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl index e0fcc3b1..4953508d 100644 --- a/contrib/epee/include/net/abstract_tcp_server2.inl +++ b/contrib/epee/include/net/abstract_tcp_server2.inl @@ -475,7 +475,7 @@ bool boosted_tcp_server::init_server(uint32_t port, const st } //----------------------------------------------------------------------------- PUSH_WARNINGS -DISABLE_GCC_WARNING(maybe - uninitialized) +DISABLE_GCC_WARNING(maybe-uninitialized) template bool boosted_tcp_server::init_server(const std::string port, const std::string& address) { From d0ea59aebc4d12f8dab08cd7161e4821d61edb16 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 24 Sep 2019 18:30:25 +0200 Subject: [PATCH 4/4] removed more warnings, code cleanup --- contrib/db/liblmdb/CMakeLists.txt | 2 +- src/simplewallet/simplewallet.cpp | 5 ----- src/wallet/wallet2.cpp | 18 +++++++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/contrib/db/liblmdb/CMakeLists.txt b/contrib/db/liblmdb/CMakeLists.txt index 8ec1a8d8..dc491820 100644 --- a/contrib/db/liblmdb/CMakeLists.txt +++ b/contrib/db/liblmdb/CMakeLists.txt @@ -4,7 +4,7 @@ set (lmdb_sources mdb.c midl.c) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-missing-braces -Wno-aggregate-return -Wno-discarded-qualifiers -Wno-unused-but-set-variable -Wno-implicit-fallthrough -Wno-maybe-uninitialized ") endif() if(FREEBSD) add_definitions(-DMDB_DSYNC=O_SYNC) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 45c77b65..db6e604f 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -154,11 +154,6 @@ namespace return message_writer(color ? epee::log_space::console_color_green : epee::log_space::console_color_default, false, std::string(), LOG_LEVEL_2); } - message_writer success_msg_writer(epee::log_space::console_colors color) - { - return message_writer(color, true, std::string(), LOG_LEVEL_2); - } - message_writer fail_msg_writer() { return message_writer(epee::log_space::console_color_red, true, "Error: ", LOG_LEVEL_0); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 15a36e4d..3bb392c3 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1890,7 +1890,7 @@ void wallet2::load_keys2ki(bool create_if_not_exist, bool& need_to_resync) m_pending_key_images.clear(); for (size_t i = 0, size = m_pending_key_images_file_container.size(); i < size; ++i) { - out_key_to_ki item = AUTO_VAL_INIT(item); + out_key_to_ki item = AUTO_VAL_INIT_T(out_key_to_ki); ok = m_pending_key_images_file_container.get_item(i, item); WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(ok, "m_pending_key_images_file_container.get_item() failed for index " << i << ", size: " << m_pending_key_images_file_container.size()); ok = m_pending_key_images.insert(std::make_pair(item.out_key, item.key_image)).second; @@ -4002,7 +4002,7 @@ void wallet2::prepare_transaction(const construct_tx_param& ctp, finalize_tx_par //---------------------------------------------------------------------------------------------------- void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::transaction& tx, crypto::secret_key& tx_key, bool broadcast_tx) { - TIME_MEASURE_START_MS(construct_tx_time); + //TIME_MEASURE_START_MS(construct_tx_time); bool r = currency::construct_tx(m_account.get_keys(), ftp.sources, ftp.prepared_destinations, @@ -4016,10 +4016,10 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans ftp.tx_outs_attr, ftp.shuffle, ftp.flags); - TIME_MEASURE_FINISH_MS(construct_tx_time); + //TIME_MEASURE_FINISH_MS(construct_tx_time); THROW_IF_FALSE_WALLET_EX(r, error::tx_not_constructed, ftp.sources, ftp.prepared_destinations, ftp.unlock_time); - TIME_MEASURE_START_MS(sign_ms_input_time); + //TIME_MEASURE_START_MS(sign_ms_input_time); if (ftp.multisig_id != currency::null_hash) { // In case there's multisig input is used -- sign it partially with this wallet's keys (we don't have any others here). @@ -4031,21 +4031,21 @@ void wallet2::finalize_transaction(const finalize_tx_param& ftp, currency::trans r = sign_multisig_input_in_tx(tx, 0, m_account.get_keys(), ms_source_tx, &is_tx_input_fully_signed); // it's assumed that ms input is the first one (index 0) WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r && !is_tx_input_fully_signed, "sign_multisig_input_in_tx failed: r = " << r << ", is_tx_input_fully_signed = " << is_tx_input_fully_signed); } - TIME_MEASURE_FINISH_MS(sign_ms_input_time); + //TIME_MEASURE_FINISH_MS(sign_ms_input_time); m_tx_keys.insert(std::make_pair(get_transaction_hash(tx), tx_key)); THROW_IF_FALSE_WALLET_EX(get_object_blobsize(tx) < CURRENCY_MAX_TRANSACTION_BLOB_SIZE, error::tx_too_big, tx, m_upper_transaction_size_limit); - TIME_MEASURE_START(send_transaction_to_network_time); + //TIME_MEASURE_START(send_transaction_to_network_time); if (broadcast_tx) send_transaction_to_network(tx); - TIME_MEASURE_FINISH(send_transaction_to_network_time); + //TIME_MEASURE_FINISH(send_transaction_to_network_time); - TIME_MEASURE_START(add_sent_tx_detailed_info_time); + //TIME_MEASURE_START(add_sent_tx_detailed_info_time); if (broadcast_tx) add_sent_tx_detailed_info(tx, ftp.prepared_destinations, ftp.selected_transfers); - TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); + //TIME_MEASURE_FINISH(add_sent_tx_detailed_info_time); /* TODO WLT_LOG_GREEN("[prepare_transaction]: get_needed_money_time: " << get_needed_money_time << " ms"