From 5114824b02e0ab8ea9e7b1e1a0dff9dfbaac290f Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 5 May 2020 12:53:20 +0200 Subject: [PATCH 01/41] softened alt blocks purge validation due to new onboard_transactions concept --- src/currency_core/blockchain_storage.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 54b45be9..02f51e92 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1533,7 +1533,6 @@ bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, std::shared_ptr tx_ptr; if (!get_transaction_from_pool_or_db(tx_id, tx_ptr)) { - LOG_ERROR("failed to get alt block tx " << tx_id << " on block detach from alts"); continue; } transaction& tx = *tx_ptr; @@ -6006,7 +6005,11 @@ bool blockchain_storage::get_transaction_from_pool_or_db(const crypto::hash& tx_ if (!m_tx_pool.get_transaction(tx_id, *tx_ptr)) // first try to get from the pool { auto p = m_db_transactions.get(tx_id); // if not found in the pool -- get from the DB - CHECK_AND_ASSERT_MES(p != nullptr, false, "can't get tx " << tx_id << " neither from the pool, nor from db_transactions"); + if (p == nullptr) + { + return false; + } + //CHECK_AND_ASSERT_MES(p != nullptr, false, "can't get tx " << tx_id << " neither from the pool, nor from db_transactions"); CHECK_AND_ASSERT_MES(p->m_keeper_block_height >= min_allowed_block_height, false, "tx " << tx_id << " found in the main chain at height " << p->m_keeper_block_height << " while required min allowed height is " << min_allowed_block_height); *tx_ptr = p->tx; } From 2382e9717bb5122c773dd7841484fea95d85128a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 5 May 2020 17:47:09 +0200 Subject: [PATCH 02/41] Implemented debug mode for remote node --- .../currency_protocol_handler.h | 3 ++ .../currency_protocol_handler.inl | 30 +++++++++++++++++++ src/daemon/daemon_commands_handler.h | 21 ++++++++++++- src/p2p/net_node.h | 2 +- src/p2p/net_node.inl | 1 + 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/currency_protocol/currency_protocol_handler.h b/src/currency_protocol/currency_protocol_handler.h index 5b603ba7..eaf06bda 100644 --- a/src/currency_protocol/currency_protocol_handler.h +++ b/src/currency_protocol/currency_protocol_handler.h @@ -70,6 +70,8 @@ namespace currency int64_t get_net_time_delta_median(); bool add_time_delta_and_check_time_sync(int64_t delta); bool get_last_time_sync_difference(int64_t& last_median2local_time_difference, int64_t& last_ntp2local_time_difference); // returns true if differences in allowed bounds + //----------------------------------------------------------------------------------- + void set_to_debug_mode(uint32_t ip); private: //----------------- commands handlers ---------------------------------------------- @@ -114,6 +116,7 @@ namespace currency std::mutex m_time_deltas_lock; int64_t m_last_median2local_time_difference; int64_t m_last_ntp2local_time_difference; + uint32_t m_debug_ip_address; template bool post_notify(typename t_parametr::request& arg, currency_connection_context& context) diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 2598d837..166cdb80 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -22,6 +22,7 @@ namespace currency , m_want_stop(false) , m_last_median2local_time_difference(0) , m_last_ntp2local_time_difference(0) + , m_debug_ip_address(0) { if(!m_p2p) m_p2p = &m_p2p_stub; @@ -241,6 +242,10 @@ namespace currency template int t_currency_protocol_handler::handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + if(context.m_state != currency_connection_context::state_normal) return 1; @@ -363,6 +368,10 @@ namespace currency template int t_currency_protocol_handler::handle_notify_new_transactions(int command, NOTIFY_NEW_TRANSACTIONS::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + if(context.m_state != currency_connection_context::state_normal) return 1; uint64_t inital_tx_count = arg.txs.size(); @@ -400,6 +409,10 @@ namespace currency template int t_currency_protocol_handler::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + LOG_PRINT_L2("[HANDLE]NOTIFY_REQUEST_GET_OBJECTS: arg.blocks.size() = " << arg.blocks.size() << ", arg.txs.size()="<< arg.txs.size()); LOG_PRINT_L3("[HANDLE]NOTIFY_REQUEST_GET_OBJECTS: " << ENDL << currency::print_kv_structure(arg)); @@ -445,6 +458,10 @@ namespace currency template int t_currency_protocol_handler::handle_response_get_objects(int command, NOTIFY_RESPONSE_GET_OBJECTS::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + LOG_PRINT_L2("[HANDLE]NOTIFY_RESPONSE_GET_OBJECTS: arg.blocks.size()=" << arg.blocks.size() << ", arg.missed_ids.size()=" << arg.missed_ids.size() << ", arg.txs.size()=" << arg.txs.size()); LOG_PRINT_L3("[HANDLE]NOTIFY_RESPONSE_GET_OBJECTS: " << ENDL << currency::print_kv_structure(arg)); if(context.m_last_response_height > arg.current_blockchain_height) @@ -627,6 +644,10 @@ namespace currency template int t_currency_protocol_handler::handle_request_chain(int command, NOTIFY_REQUEST_CHAIN::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + LOG_PRINT_L2("[HANDLE]NOTIFY_REQUEST_CHAIN: block_ids.size()=" << arg.block_ids.size()); LOG_PRINT_L3("[HANDLE]NOTIFY_REQUEST_CHAIN: " << print_kv_structure(arg)); NOTIFY_RESPONSE_CHAIN_ENTRY::request r; @@ -851,10 +872,19 @@ namespace currency return !(std::abs(m_last_median2local_time_difference) > TIME_SYNC_DELTA_TO_LOCAL_MAX_DIFFERENCE && std::abs(m_last_ntp2local_time_difference) > TIME_SYNC_NTP_TO_LOCAL_MAX_DIFFERENCE); } + template + void t_currency_protocol_handler::set_to_debug_mode(uint32_t ip) + { + m_debug_ip_address = ip; + } //------------------------------------------------------------------------------------------------------------------------ template int t_currency_protocol_handler::handle_response_chain_entry(int command, NOTIFY_RESPONSE_CHAIN_ENTRY::request& arg, currency_connection_context& context) { + //do not process requests if it comes from node wich is debugged + if (m_debug_ip_address != 0 && context.m_remote_ip == m_debug_ip_address) + return 1; + LOG_PRINT_L2("[HANDLE]NOTIFY_RESPONSE_CHAIN_ENTRY: m_block_ids.size()=" << arg.m_block_ids.size() << ", m_start_height=" << arg.start_height << ", m_total_height=" << arg.total_height); LOG_PRINT_L3("[HANDLE]NOTIFY_RESPONSE_CHAIN_ENTRY: " << ENDL << currency::print_kv_structure(arg)); diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 532e35d1..32a5f404 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -16,6 +16,7 @@ #include "warnings.h" #include "currency_core/bc_offers_service.h" #include "serialization/binary_utils.h" +#include "simplewallet/password_container.h" PUSH_VS_WARNINGS DISABLE_VS_WARNINGS(4100) @@ -69,7 +70,7 @@ public: m_cmd_binder.set_handler("print_tx_from_hex_blob", boost::bind(&daemon_commands_handler::print_tx_from_hex_blob, this, _1), "Unserialize transaction from hex binary data to json-like representation"); m_cmd_binder.set_handler("print_tx_outputs_usage", boost::bind(&daemon_commands_handler::print_tx_outputs_usage, this, _1), "Analyse if tx outputs for involved in subsequent transactions"); m_cmd_binder.set_handler("print_difficulties_of_last_n_blocks", boost::bind(&daemon_commands_handler::print_difficulties_of_last_n_blocks, this, _1), "Print difficulties of last n blocks"); - + m_cmd_binder.set_handler("debug_remore_node_mode", boost::bind(&daemon_commands_handler::debug_remore_node_mode, this, _1), " - If node got connected put node into 'debug mode' i.e. no sync process of other communication except ping responses, maintenance secrete key will be requested"); #ifdef _DEBUG m_cmd_binder.set_handler("debug_set_time_adj", boost::bind(&daemon_commands_handler::debug_set_time_adj, this, _1), "DEBUG: set core time adjustment"); #endif @@ -734,6 +735,24 @@ private: return true; } //-------------------------------------------------------------------------------- + bool debug_remore_node_mode(const std::vector& args) + { + if (args.empty()) + { + std::cout << "expected: ip address" << std::endl; + return true; + } + uint32_t ip = AUTO_VAL_INIT(ip); + if (!string_tools::get_ip_int32_from_string(ip, args.front())) + { + std::cout << "expected: ip address" << std::endl; + return true; + } + m_srv.get_payload_object().set_to_debug_mode(ip); + + return true; + } + //-------------------------------------------------------------------------------- bool print_pool(const std::vector& args) { LOG_PRINT_L0("Pool state: " << ENDL << m_srv.get_payload_object().get_core().print_pool(false)); diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index c57fa524..301b4cda 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -82,7 +82,6 @@ namespace nodetool m_use_only_priority_peers(false), m_peer_livetime{}, m_debug_requests_enabled(false) - {} static void init_options(boost::program_options::options_description& desc); @@ -248,6 +247,7 @@ namespace nodetool bool m_debug_requests_enabled; uint64_t m_startup_time; + //critical_section m_connections_lock; //connections_indexed_container m_connections; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 7ea6c905..5042548d 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1442,6 +1442,7 @@ namespace nodetool std::string s = ss.str(); return s; } + //----------------------------------------------------------------------------------- template void node_server::on_connection_new(p2p_connection_context& context) From 36946e5d33e894290224eafc8cdbeb7f26b6bceb Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 5 May 2020 19:42:14 +0300 Subject: [PATCH 03/41] added p2p key for testnet (debugging) --- src/currency_core/currency_config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 8de1ee32..6f5f5f35 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -98,12 +98,14 @@ #define RPC_DEFAULT_PORT 11211 #define STRATUM_DEFAULT_PORT 11777 #define P2P_NETWORK_ID_TESTNET_FLAG 0 +#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607" #else #define P2P_DEFAULT_PORT (11112 + CURRENCY_FORMATION_VERSION) #define RPC_DEFAULT_PORT 12111 #define STRATUM_DEFAULT_PORT 11888 #define STRARUM_DEFAULT_PORT 51113 #define P2P_NETWORK_ID_TESTNET_FLAG 1 +#define P2P_MAINTAINERS_PUB_KEY "aaa2d7aabc8d383fd53a3ae898697b28f236ceade6bafc1eecff413a6a02272a" #endif #define P2P_NETWORK_ID_VER (CURRENCY_FORMATION_VERSION+0) @@ -121,7 +123,6 @@ #define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds #define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes #define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 10000 //10 seconds -#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607" #define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70 #define P2P_FAILED_ADDR_FORGET_SECONDS (60*5) //5 minutes From f1cefa818622254ab3403cb42511143dcfc90830 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 5 May 2020 20:05:07 +0300 Subject: [PATCH 04/41] BCS: DB testnet compatibility rule (95->96) --- src/currency_core/blockchain_storage.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 54b45be9..9d8767bf 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -296,11 +296,19 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro bool need_reinit = false; if (m_db_blocks.size() != 0) { +#ifndef TESTNET if (m_db_storage_major_compatibility_version == 93 && BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION == 94) { // do not reinit db if moving from version 93 to version 94 LOG_PRINT_MAGENTA("DB storage does not need reinit because moving from v93 to v94", LOG_LEVEL_0); } +#else + if (m_db_storage_major_compatibility_version == 95 && BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION == 96) + { + // do not reinit TESTNET db if moving from version 95 to version 96 + LOG_PRINT_MAGENTA("DB storage does not need reinit because moving from v95 to v96", LOG_LEVEL_0); + } +#endif else if (m_db_storage_major_compatibility_version != BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION) { need_reinit = true; From cf0fb86d9096fbf5117729615f6cd93c27f3a8ab Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 12 May 2020 13:02:06 +0300 Subject: [PATCH 05/41] GUI: fix unconditional backend stop when predownloading fails --- src/wallet/wallets_manager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 5583e073..f9c27a43 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -345,7 +345,10 @@ bool wallets_manager::init_local_daemon() return static_cast(m_stop_singal_sent); }); - CHECK_AND_ASSERT_AND_SET_GUI(res, "pre-downloading failed"); + if (!res) + { + LOG_PRINT_RED("pre-downloading failed, continue with normal network synchronization", LOG_LEVEL_0); + } } From f6d99e39bb575144308c884fdacfb99351d08e39 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 12 May 2020 18:47:43 +0300 Subject: [PATCH 06/41] === version bump: 1.1.5.82 -> 1.1.6.83 === --- src/version.h.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h.in b/src/version.h.in index 80308ff7..a5a8a26b 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "1" #define PROJECT_MINOR_VERSION "1" -#define PROJECT_REVISION "5" +#define PROJECT_REVISION "6" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 82 +#define PROJECT_VERSION_BUILD_NO 83 #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 e6616cd225e62ea2b7befbe5885427926bb36953 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 12 May 2020 21:11:54 +0200 Subject: [PATCH 07/41] Added error on opening same wallet file --- contrib/epee/include/syncobj.h | 3 ++- src/wallet/wallets_manager.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/contrib/epee/include/syncobj.h b/contrib/epee/include/syncobj.h index 457c5f37..3494194a 100644 --- a/contrib/epee/include/syncobj.h +++ b/contrib/epee/include/syncobj.h @@ -705,7 +705,8 @@ namespace epee #define EXCLUSIVE_CRITICAL_REGION_LOCAL(x) boost::unique_lock< boost::shared_mutex > critical_region_var(x) #define SHARED_CRITICAL_REGION_BEGIN(x) { SHARED_CRITICAL_REGION_LOCAL(x) +#define SHARED_CRITICAL_REGION_END() } #define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { EXCLUSIVE_CRITICAL_REGION_LOCAL(x) - +#define EXCLUSIVE_CRITICAL_REGION_END() } } diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 627ecabe..6bd89cde 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -732,6 +732,16 @@ std::string wallets_manager::get_my_offers(const bc_services::core_offers_filter std::string wallets_manager::open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr) { + // check if that file already opened + SHARED_CRITICAL_REGION_BEGIN(m_wallets_lock); + for (auto& wallet_entry : m_wallets) + { + if (wallet_entry.second.w.unlocked_get()->get_wallet_path() == path) + return API_RETURN_CODE_ALREADY_EXISTS; + } + SHARED_CRITICAL_REGION_END(); + + std::shared_ptr w(new tools::wallet2()); owr.wallet_id = m_wallet_id_counter++; @@ -784,6 +794,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st } } EXCLUSIVE_CRITICAL_REGION_LOCAL(m_wallets_lock); + wallet_vs_options& wo = m_wallets[owr.wallet_id]; **wo.w = w; get_wallet_info(wo, owr.wi); From b97065bebae73b0fb2c449b7acded6eda8db9478 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 12 May 2020 21:48:15 +0200 Subject: [PATCH 08/41] added wallet size to open/store api --- src/wallet/view_iface.h | 2 ++ src/wallet/wallet_public_structs_defs.h | 3 +++ src/wallet/wallet_rpc_server.cpp | 2 ++ src/wallet/wallets_manager.cpp | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index c8af4a5c..35b20d4f 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -432,6 +432,7 @@ public: std::string seed; bool recovered; uint64_t wallet_local_bc_size; + uint64_t wallet_file_size; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(wallet_id) @@ -440,6 +441,7 @@ public: KV_SERIALIZE(seed) KV_SERIALIZE(recovered) KV_SERIALIZE(wallet_local_bc_size) + KV_SERIALIZE(wallet_file_size) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 574a1ba6..da115c33 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -359,7 +359,10 @@ namespace wallet_public struct response { + uint64_t wallet_file_size; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(wallet_file_size) END_KV_SERIALIZE_MAP() }; }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 040ef071..c9fb111b 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -350,6 +350,8 @@ namespace tools { WALLET_RPC_BEGIN_TRY_ENTRY(); m_wallet.store(); + boost::system::error_code ec = AUTO_VAL_INIT(ec); + res.wallet_file_size = boost::filesystem::file_size(m_wallet.get_wallet_path(), ec); WALLET_RPC_CATCH_TRY_ENTRY(); return true; } diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 6bd89cde..79e979eb 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -794,7 +794,8 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st } } EXCLUSIVE_CRITICAL_REGION_LOCAL(m_wallets_lock); - + boost::system::error_code ec = AUTO_VAL_INIT(ec); + owr.wallet_file_size = boost::filesystem::file_size(path, ec); wallet_vs_options& wo = m_wallets[owr.wallet_id]; **wo.w = w; get_wallet_info(wo, owr.wi); From bc6b9510991d71741764a9c3ac86d27a1d329666 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 13 May 2020 10:27:04 +0300 Subject: [PATCH 09/41] pre-downloading: increase timeout and attempt count --- src/common/pre_download.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/pre_download.h b/src/common/pre_download.h index d4598207..3b5657c2 100644 --- a/src/common/pre_download.h +++ b/src/common/pre_download.h @@ -88,7 +88,7 @@ namespace tools }; tools::create_directories_if_necessary(working_folder); - r = cl.download_and_unzip(cb, downloading_file_path, url, 1000 /* timout */, "GET", std::string(), 3 /* fails count */); + r = cl.download_and_unzip(cb, downloading_file_path, url, 5000 /* timout */, "GET", std::string(), 30 /* fails count */); if (!r) { LOG_PRINT_RED("Download failed", LOG_LEVEL_0); From a1c5343c4b8a8ef0eeb47fd2e4b026bd665112e0 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 13 May 2020 10:29:14 +0300 Subject: [PATCH 10/41] http_client improved to stop on permanent HTTP error + logs --- contrib/epee/include/net/http_client.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index 3ca863b6..be81ba41 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -925,6 +925,7 @@ using namespace std; class interruptible_http_client : public http_simple_client { std::shared_ptr m_pcb; + bool m_permanent_error = false; virtual bool handle_target_data(std::string& piece_of_transfer) { @@ -943,6 +944,7 @@ using namespace std; if (p_hri && !(p_hri->m_response_code >= 200 && p_hri->m_response_code < 300)) { LOG_PRINT_L0("HTTP request to " << url << " failed with code: " << p_hri->m_response_code); + m_permanent_error = true; return false; } return r; @@ -1002,24 +1004,33 @@ using namespace std; }; uint64_t current_err_count = 0; bool r = false; - + m_permanent_error = false; while (!r && current_err_count < fails_count) { - LOG_PRINT_L0("Attempt to invoke http: " << url << " (offset:" << state_received_bytes_base << ")"); + LOG_PRINT_L0("Attempt " << current_err_count + 1 << "/" << fails_count << " to get " << url << " (offset:" << state_received_bytes_base << ")"); fields_list additional_params_local = additional_params; additional_params_local.push_back(std::make_pair("Range", std::string("bytes=") + std::to_string(state_received_bytes_base) + "-")); r = this->invoke_cb(local_cb, url, timeout, method, body, additional_params_local); if (!r) { - if (stopped) + if (stopped || m_permanent_error) break; current_err_count++; state_received_bytes_base += state_received_bytes_current; state_received_bytes_current = 0; - boost::this_thread::sleep_for(boost::chrono::milliseconds(500)); + boost::this_thread::sleep_for(boost::chrono::milliseconds(2000)); } } + if (current_err_count >= fails_count) + { + LOG_PRINT_YELLOW("Downloading from " << url << " FAILED as it's reached maximum (" << fails_count << ") number of attempts. Downloaded " << state_received_bytes_base << " bytes.", LOG_LEVEL_0); + } + else if (m_permanent_error) + { + LOG_PRINT_YELLOW("Downloading from " << url << " FAILED due to permanent HTTP error. Downloaded " << state_received_bytes_base << " bytes.", LOG_LEVEL_0); + } + fs.close(); return r; } From 9e983b70b2a94c2cc4b444dcabcfdae6ac93fb67 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 13 May 2020 22:01:40 +0200 Subject: [PATCH 11/41] plain_wallet api refactored due to ios app crash --- src/common/error_codes.h | 1 + src/wallet/plain_wallet_api.cpp | 141 ++++++++++++++++++++++++-------- 2 files changed, 108 insertions(+), 34 deletions(-) diff --git a/src/common/error_codes.h b/src/common/error_codes.h index 8feb9012..f8ad7898 100644 --- a/src/common/error_codes.h +++ b/src/common/error_codes.h @@ -34,5 +34,6 @@ #define API_RETURN_CODE_WRONG_SEED "WRONG_SEED" #define API_RETURN_CODE_GENESIS_MISMATCH "GENESIS_MISMATCH" #define API_RETURN_CODE_DISCONNECTED "DISCONNECTED" +#define API_RETURN_CODE_UNINITIALIZED "UNINITIALIZED" diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 0cc8d5e1..f6e0d9b8 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -27,21 +27,42 @@ #define GENERAL_INTERNAL_ERRROR_INIT "Failed to intialize library" //TODO: global objects, subject to refactoring -wallets_manager gwm; -std::atomic initialized(false); -std::atomic gjobs_counter(1); -std::map gjobs; -epee::critical_section gjobs_lock; -std::string gconfig_folder; +struct plain_wallet_instance +{ + plain_wallet_instance() :initialized(false), gjobs_counter(1) + {} + wallets_manager gwm; + std::atomic initialized; + + std::atomic gjobs_counter; + std::map gjobs; + epee::critical_section gjobs_lock; +}; + +std::shared_ptr ginstance_ptr; + +epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&]() +{ + std::cout << "[LEAVE HANDLER CALLED]" << ENDL; +}); namespace plain_wallet { typedef epee::json_rpc::response error_response; + + std::string get_set_working_dir(bool need_to_set = false, const std::string val = "") + { + static std::string working_dir; + if (need_to_set) + working_dir = val; + return working_dir; + } + std::string get_bundle_working_dir() { - return gconfig_folder; + return get_set_working_dir(); // #ifdef WIN32 // return boost::dll::program_location().parent_path().string(); // #elif IOS_BUILD @@ -56,7 +77,7 @@ namespace plain_wallet } void set_bundle_working_dir(const std::string& dir) { - gconfig_folder = dir; + get_set_working_dir(true, dir); } std::string get_wallets_folder() @@ -102,15 +123,33 @@ namespace plain_wallet return "{}"; } + void deinit() + { + auto local_ptr = std::atomic_load(&ginstance_ptr); + if (local_ptr) + { + std::atomic_store(&ginstance_ptr, std::shared_ptr()); + //wait other callers finish + local_ptr->gjobs_lock.lock(); + local_ptr->gjobs_lock.unlock(); + local_ptr.reset(); + } + } + std::string init(const std::string& ip, const std::string& port, const std::string& working_dir, int log_level) { - if (initialized) + auto local_ptr = std::atomic_load(&ginstance_ptr); + if (local_ptr) { LOG_ERROR("Double-initialization in plain_wallet detected."); epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); ok_response.result.return_code = API_RETURN_CODE_ALREADY_EXISTS; return epee::serialization::store_t_to_json(ok_response); } + + std::cout << "[INIT PLAIN_WALLET_INSTANCE]" << ENDL; + std::shared_ptr ptr(new plain_wallet_instance()); + set_bundle_working_dir(working_dir); initialize_logs(log_level); @@ -122,13 +161,13 @@ namespace plain_wallet args[1] = const_cast(argss_1.c_str()); args[2] = const_cast(argss_2.c_str()); args[3] = nullptr; - if (!gwm.init(3, args, nullptr)) + if (!ptr->gwm.init(3, args, nullptr)) { LOG_ERROR("Failed to init wallets_manager"); return GENERAL_INTERNAL_ERRROR_INIT; } - if(!gwm.start()) + if(!ptr->gwm.start()) { LOG_ERROR("Failed to start wallets_manager"); return GENERAL_INTERNAL_ERRROR_INIT; @@ -155,7 +194,7 @@ namespace plain_wallet return epee::serialization::store_t_to_json(err_result); } - initialized = true; + std::atomic_store(&ginstance_ptr, ptr); epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); ok_response.result.return_code = API_RETURN_CODE_OK; return epee::serialization::store_t_to_json(ok_response); @@ -213,9 +252,21 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } +#define GET_INSTANCE_PTR(ptr_name) \ + auto ptr_name = std::atomic_load(&ginstance_ptr); \ + if (!ptr_name) \ + { \ + LOG_ERROR("Core already deinitialised or not initialized yet."); \ + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); \ + ok_response.result.return_code = API_RETURN_CODE_UNINITIALIZED; \ + return epee::serialization::store_t_to_json(ok_response); \ + } + std::string get_connectivity_status() { - return gwm.get_connectivity_status(); + GET_INSTANCE_PTR(inst_ptr); + + return inst_ptr->gwm.get_connectivity_status(); } std::string get_version() @@ -254,16 +305,18 @@ namespace plain_wallet std::string open(const std::string& path, const std::string& password) { + GET_INSTANCE_PTR(inst_ptr); + std::string full_path = get_wallets_folder() + path; epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - std::string rsp = gwm.open_wallet(epee::string_encoding::convert_to_unicode(full_path), password, 20, ok_response.result); + std::string rsp = inst_ptr->gwm.open_wallet(epee::string_encoding::convert_to_unicode(full_path), password, 20, ok_response.result); if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED) { if (rsp == API_RETURN_CODE_FILE_RESTORED) { ok_response.result.recovered = true; } - gwm.run_wallet(ok_response.result.wallet_id); + inst_ptr->gwm.run_wallet(ok_response.result.wallet_id); return epee::serialization::store_t_to_json(ok_response); } @@ -271,18 +324,21 @@ namespace plain_wallet err_result.error.code = rsp; return epee::serialization::store_t_to_json(err_result); } + std::string restore(const std::string& seed, const std::string& path, const std::string& password) { + GET_INSTANCE_PTR(inst_ptr); + std::string full_path = get_wallets_folder() + path; epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - std::string rsp = gwm.restore_wallet(epee::string_encoding::convert_to_unicode(full_path), password, seed, ok_response.result); + std::string rsp = inst_ptr->gwm.restore_wallet(epee::string_encoding::convert_to_unicode(full_path), password, seed, ok_response.result); if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED) { if (rsp == API_RETURN_CODE_FILE_RESTORED) { ok_response.result.recovered = true; } - gwm.run_wallet(ok_response.result.wallet_id); + inst_ptr->gwm.run_wallet(ok_response.result.wallet_id); return epee::serialization::store_t_to_json(ok_response); } error_response err_result = AUTO_VAL_INIT(err_result); @@ -292,16 +348,18 @@ namespace plain_wallet std::string generate(const std::string& path, const std::string& password) { + GET_INSTANCE_PTR(inst_ptr); + std::string full_path = get_wallets_folder() + path; epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - std::string rsp = gwm.generate_wallet(epee::string_encoding::convert_to_unicode(full_path), password, ok_response.result); + std::string rsp = inst_ptr->gwm.generate_wallet(epee::string_encoding::convert_to_unicode(full_path), password, ok_response.result); if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED) { if (rsp == API_RETURN_CODE_FILE_RESTORED) { ok_response.result.recovered = true; } - gwm.run_wallet(ok_response.result.wallet_id); + inst_ptr->gwm.run_wallet(ok_response.result.wallet_id); return epee::serialization::store_t_to_json(ok_response); } error_response err_result = AUTO_VAL_INIT(err_result); @@ -311,34 +369,44 @@ namespace plain_wallet std::string close_wallet(hwallet h) { + GET_INSTANCE_PTR(inst_ptr); + std::string r = "{\"response\": \""; - r += gwm.close_wallet(h); + r += inst_ptr->gwm.close_wallet(h); r += "\"}"; return r; } std::string get_wallet_status(hwallet h) { - return gwm.get_wallet_status(h); + GET_INSTANCE_PTR(inst_ptr); + return inst_ptr->gwm.get_wallet_status(h); } + std::string invoke(hwallet h, const std::string& params) { - return gwm.invoke(h, params); + GET_INSTANCE_PTR(inst_ptr); + return inst_ptr->gwm.invoke(h, params); } void put_result(uint64_t job_id, const std::string& res) { - CRITICAL_REGION_LOCAL(gjobs_lock); - gjobs[job_id] = res; + auto inst_ptr = std::atomic_load(&ginstance_ptr); + if (!inst_ptr) + { + return; + } + CRITICAL_REGION_LOCAL(inst_ptr->gjobs_lock); + inst_ptr->gjobs[job_id] = res; LOG_PRINT_L2("[ASYNC_CALL]: Finished(result put), job id: " << job_id); } - std::string async_call(const std::string& method_name, uint64_t instance_id, const std::string& params) { + GET_INSTANCE_PTR(inst_ptr); std::function async_callback; - uint64_t job_id = gjobs_counter++; + uint64_t job_id = inst_ptr->gjobs_counter++; if (method_name == "close") { async_callback = [job_id, instance_id]() @@ -413,17 +481,22 @@ namespace plain_wallet std::string try_pull_result(uint64_t job_id) { - //TODO: need refactoring - CRITICAL_REGION_LOCAL(gjobs_lock); - auto it = gjobs.find(job_id); - if (it == gjobs.end()) - { - return "{\"delivered\": false}"; + auto inst_ptr = std::atomic_load(&ginstance_ptr); + if (!inst_ptr) + { + return "{\"status\": \"canceled\"}"; } - std::string res = "{\"delivered\": true, \"result\": "; + //TODO: need refactoring + CRITICAL_REGION_LOCAL(inst_ptr->gjobs_lock); + auto it = inst_ptr->gjobs.find(job_id); + if (it == inst_ptr->gjobs.end()) + { + return "{\"status\": \"idle\"}"; + } + std::string res = "{\"status\": \"delivered\", \"result\": "; res += it->second; res += " }"; - gjobs.erase(it); + inst_ptr->gjobs.erase(it); return res; } From 1af88622021509bb9b11ce9e288dfc14507215db Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 13 May 2020 22:11:58 +0200 Subject: [PATCH 12/41] fixed capture for lambda --- src/wallet/plain_wallet_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index f6e0d9b8..2fd82ad3 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -42,7 +42,7 @@ struct plain_wallet_instance std::shared_ptr ginstance_ptr; -epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&]() +epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([]() { std::cout << "[LEAVE HANDLER CALLED]" << ENDL; }); From 932f66bc00dd5e7f52885241f4b87b3a7c7c758c Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 14 May 2020 17:42:51 +0300 Subject: [PATCH 13/41] GUI: default mixin count set to 10 --- src/gui/qt-daemon/html/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/qt-daemon/html/main.js b/src/gui/qt-daemon/html/main.js index 33a5e4aa..dccb0a60 100644 --- a/src/gui/qt-daemon/html/main.js +++ b/src/gui/qt-daemon/html/main.js @@ -7214,7 +7214,7 @@ var SendComponent = /** @class */ (function () { return null; }]), comment: new _angular_forms__WEBPACK_IMPORTED_MODULE_1__["FormControl"](''), - mixin: new _angular_forms__WEBPACK_IMPORTED_MODULE_1__["FormControl"](0, _angular_forms__WEBPACK_IMPORTED_MODULE_1__["Validators"].required), + mixin: new _angular_forms__WEBPACK_IMPORTED_MODULE_1__["FormControl"](10, _angular_forms__WEBPACK_IMPORTED_MODULE_1__["Validators"].required), fee: new _angular_forms__WEBPACK_IMPORTED_MODULE_1__["FormControl"](this.variablesService.default_fee, [_angular_forms__WEBPACK_IMPORTED_MODULE_1__["Validators"].required, function (g) { if ((new bignumber_js__WEBPACK_IMPORTED_MODULE_6__["BigNumber"](g.value)).isLessThan(_this.variablesService.default_fee)) { return { 'less_min': true }; @@ -7246,7 +7246,7 @@ var SendComponent = /** @class */ (function () { address: _this.variablesService.currentWallet.send_data['address'], amount: _this.variablesService.currentWallet.send_data['amount'], comment: _this.variablesService.currentWallet.send_data['comment'], - mixin: _this.variablesService.currentWallet.send_data['mixin'] || 0, + mixin: _this.variablesService.currentWallet.send_data['mixin'] || 10, fee: _this.variablesService.currentWallet.send_data['fee'] || _this.variablesService.default_fee, hide: _this.variablesService.currentWallet.send_data['hide'] || false }); From ecea7545e9f80e7b3e367c15a38c167c49df0f1e Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 14 May 2020 17:50:14 +0300 Subject: [PATCH 14/41] === build number: 83 -> 84 === --- 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 a5a8a26b..2731075f 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "6" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 83 +#define PROJECT_VERSION_BUILD_NO 84 #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 5ca6c8077e04270f08182584f00b972d429aa5d9 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 14 May 2020 19:00:13 +0300 Subject: [PATCH 15/41] added checkpoint for height 525000 (mainnet) and height 350000 (testnet) --- src/currency_core/checkpoints_create.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/currency_core/checkpoints_create.h b/src/currency_core/checkpoints_create.h index 95eb6a08..ede0cb37 100644 --- a/src/currency_core/checkpoints_create.h +++ b/src/currency_core/checkpoints_create.h @@ -19,9 +19,11 @@ namespace currency #ifdef TESTNET ADD_CHECKPOINT(50000, "cb05a7bdc7f78c5cdb6ef1048f85b27c569f44879233903ce5f5a4e5bd590a3d"); ADD_CHECKPOINT(100000, "6b8b54356a9d44f6c1ebdacb8593d8f5ab2e2e2ca4493e7ae7baf4b3755c5e16"); + ADD_CHECKPOINT(350000, "885841f079e5a38f1921f4a5319f0d52fdbab64bb2026ca3cabad1c032d22db7"); #else // MAINNET ADD_CHECKPOINT(425000, "46a6c36d5dec2d484d5e4845a8525ca322aafc06915ed9c8da2a241b51b7d1e8"); + ADD_CHECKPOINT(525000, "8c1ac57e67448130207a224b2d6e33ccdc64d6dd1c59dbcf9ad2361dc0d07d51"); #endif return true; From 29aa2a25def1257a246fe22c621a6c3bfbf9718c Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 14 May 2020 19:23:17 +0200 Subject: [PATCH 16/41] added wallets_manager deinitialization before everyone dies --- src/wallet/plain_wallet_api.cpp | 29 ++++++++++++++++++----------- src/wallet/wallets_manager.cpp | 18 +++++++++++++----- src/wallet/wallets_manager.h | 3 ++- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 2fd82ad3..30413acc 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -42,9 +42,22 @@ struct plain_wallet_instance std::shared_ptr ginstance_ptr; +#define GET_INSTANCE_PTR(ptr_name) \ + auto ptr_name = std::atomic_load(&ginstance_ptr); \ + if (!ptr_name) \ + { \ + LOG_ERROR("Core already deinitialised or not initialized yet."); \ + epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); \ + ok_response.result.return_code = API_RETURN_CODE_UNINITIALIZED; \ + return epee::serialization::store_t_to_json(ok_response); \ + } + +void deinit(); epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([]() { - std::cout << "[LEAVE HANDLER CALLED]" << ENDL; + std::cout << "[BEFORE DEINIT]" << ENDL; + deinit(); + std::cout << "[AFTER DEINIT]" << ENDL; }); namespace plain_wallet @@ -132,7 +145,11 @@ namespace plain_wallet //wait other callers finish local_ptr->gjobs_lock.lock(); local_ptr->gjobs_lock.unlock(); + bool r = local_ptr->gwm.quick_stop_no_save(); + std::cout << "[QUICK_STOP_NO_SAVE] return " << r; + //let's prepare wallet manager for quick shutdown local_ptr.reset(); + } } @@ -252,16 +269,6 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } -#define GET_INSTANCE_PTR(ptr_name) \ - auto ptr_name = std::atomic_load(&ginstance_ptr); \ - if (!ptr_name) \ - { \ - LOG_ERROR("Core already deinitialised or not initialized yet."); \ - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); \ - ok_response.result.return_code = API_RETURN_CODE_UNINITIALIZED; \ - return epee::serialization::store_t_to_json(ok_response); \ - } - std::string get_connectivity_status() { GET_INSTANCE_PTR(inst_ptr); diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 79e979eb..3ab5ceb1 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -56,7 +56,8 @@ wallets_manager::wallets_manager():m_pview(&m_view_stub), m_ui_opt(AUTO_VAL_INIT(m_ui_opt)), m_remote_node_mode(false), m_is_pos_allowed(false), - m_qt_logs_enbaled(false) + m_qt_logs_enbaled(false), + dont_save_wallet_at_stop(false) { #ifndef MOBILE_WALLET_BUILD m_offers_service.set_disabled(true); @@ -87,6 +88,7 @@ wallets_manager::~wallets_manager() { TRY_ENTRY(); stop(); + LOG_LEVEL_0("[~WALLETS_MANAGER] destroyed"); CATCH_ENTRY_NO_RETURN(); } @@ -297,12 +299,17 @@ bool wallets_manager::stop() LOG_PRINT_L0("Waiting for backend main worker thread: " << m_main_worker_thread.get_id()); m_main_worker_thread.join(); } - - - + return true; } + +bool wallets_manager::quick_stop_no_save() //stop without storing wallets +{ + dont_save_wallet_at_stop = true; + return stop(); +} + std::string wallets_manager::get_config_folder() { return m_data_dir; @@ -508,7 +515,8 @@ void wallets_manager::main_worker(const po::variables_map& m_vm) wo.second.stop_for_refresh = true; wo.second.w.unlocked_get()->stop(); - wo.second.w->get()->store(); + if(!dont_save_wallet_at_stop) + wo.second.w->get()->store(); } catch (const std::exception& e) { diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index 34d55b00..aa900d93 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -71,7 +71,6 @@ public: std::atomic* plast_daemon_is_disconnected; std::atomic has_related_alias_in_unconfirmed; std::atomic need_to_update_wallet_info; - std::atomic long_refresh_in_progress; epee::critical_section long_refresh_in_progress_lock; //secure wallet state and prevent from long wait while long refresh is in work @@ -90,6 +89,7 @@ public: bool init(int argc, char* argv[], view::i_view* pview_handler); bool start(); bool stop(); + bool quick_stop_no_save(); //stop without storing wallets bool send_stop_signal(); std::string open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr); std::string generate_wallet(const std::wstring& path, const std::string& password, view::open_wallet_response& owr); @@ -184,6 +184,7 @@ private: std::atomic m_last_daemon_is_disconnected; // std::atomic m_last_wallet_synch_height; std::atomic m_wallet_id_counter; + std::atomic dont_save_wallet_at_stop; std::string m_data_dir; view::gui_options m_ui_opt; From a9f4c63fdd0552f03e10dcd5ec53cccdb2f6d597 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 14 May 2020 19:35:55 +0200 Subject: [PATCH 17/41] fixed typo --- src/wallet/wallets_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 3ab5ceb1..06adc3d6 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -88,7 +88,7 @@ wallets_manager::~wallets_manager() { TRY_ENTRY(); stop(); - LOG_LEVEL_0("[~WALLETS_MANAGER] destroyed"); + LOG_PRINT_L0("[~WALLETS_MANAGER] destroyed"); CATCH_ENTRY_NO_RETURN(); } From 4159a528ffd04cb47c92c7e9e4ab28ef603a5fbe Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 14 May 2020 20:05:52 +0200 Subject: [PATCH 18/41] wrapped deinit into plain_wallet namespace --- src/wallet/plain_wallet_api.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 30413acc..9667e7d2 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -51,12 +51,14 @@ std::shared_ptr ginstance_ptr; ok_response.result.return_code = API_RETURN_CODE_UNINITIALIZED; \ return epee::serialization::store_t_to_json(ok_response); \ } - -void deinit(); +namespace plain_wallet +{ + void deinit(); +} epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([]() { std::cout << "[BEFORE DEINIT]" << ENDL; - deinit(); + plain_wallet::deinit(); std::cout << "[AFTER DEINIT]" << ENDL; }); From f5df96f444dccf5f11ba883b67257e042bd065b0 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 14 May 2020 22:05:36 +0200 Subject: [PATCH 19/41] intentional memory leak just to prove concept on ios --- contrib/epee/include/reg_exp_definer.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/reg_exp_definer.h b/contrib/epee/include/reg_exp_definer.h index e2bed5c3..807e188e 100644 --- a/contrib/epee/include/reg_exp_definer.h +++ b/contrib/epee/include/reg_exp_definer.h @@ -44,12 +44,17 @@ namespace epee const static global_regexp_critical_section gregexplock; + inline const boost::regex* build_regexp(const char* p, boost::regex::flag_type f) + { + return new boost::regex(p, f); + } + #define STATIC_REGEXP_EXPR_1(var_name, xpr_text, reg_exp_flags) \ static volatile uint32_t regexp_initialized_1 = 0;\ volatile uint32_t local_is_initialized_1 = regexp_initialized_1;\ if(!local_is_initialized_1)\ gregexplock.get_lock().lock();\ - static const boost::regex var_name(xpr_text , reg_exp_flags);\ + static const boost::regex& var_name = *build_regexp(xpr_text, reg_exp_flags);\ if(!local_is_initialized_1)\ {\ boost::interprocess::ipcdetail::atomic_write32(®exp_initialized_1, 1);\ @@ -61,19 +66,32 @@ namespace epee volatile uint32_t local_is_initialized_2 = regexp_initialized_2;\ if(!local_is_initialized_2)\ gregexplock.get_lock().lock().lock();\ - static const boost::regex var_name(xpr_text , reg_exp_flags);\ + static const boost::regex& var_name = *build_regexp(xpr_text, reg_exp_flags);\ if(!local_is_initialized_2)\ {\ boost::interprocess::ipcdetail::atomic_write32(®exp_initialized_2, 1);\ gregexplock.get_lock().lock().unlock();\ } +// #define STATIC_REGEXP_EXPR_2(var_name, xpr_text, reg_exp_flags) \ +// static volatile uint32_t regexp_initialized_2 = 0;\ +// volatile uint32_t local_is_initialized_2 = regexp_initialized_2;\ +// if(!local_is_initialized_2)\ +// gregexplock.get_lock().lock().lock();\ +// static const boost::regex var_name(xpr_text , reg_exp_flags);\ +// if(!local_is_initialized_2)\ +// {\ +// boost::interprocess::ipcdetail::atomic_write32(®exp_initialized_2, 1);\ +// gregexplock.get_lock().lock().unlock();\ +// } + + #define STATIC_REGEXP_EXPR_3(var_name, xpr_text, reg_exp_flags) \ static volatile uint32_t regexp_initialized_3 = 0;\ volatile uint32_t local_is_initialized_3 = regexp_initialized_3;\ if(!local_is_initialized_3)\ gregexplock.get_lock().lock().lock();\ - static const boost::regex var_name(xpr_text , reg_exp_flags);\ + static const boost::regex& var_name = *build_regexp(xpr_text, reg_exp_flags);\ if(!local_is_initialized_3)\ {\ boost::interprocess::ipcdetail::atomic_write32(®exp_initialized_3, 1);\ From 19ec19e676d699feaa09c664aa7bae2f3fe1acfc Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 15 May 2020 11:56:42 +0300 Subject: [PATCH 20/41] pre-downloading links updated --- src/common/pre_download.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/pre_download.h b/src/common/pre_download.h index 3b5657c2..29c0a269 100644 --- a/src/common/pre_download.h +++ b/src/common/pre_download.h @@ -21,8 +21,8 @@ namespace tools }; #ifndef TESTNET - static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_lmdb_94_425000.pak", "e6ac69dcf8e7a7017d032cb4326d661c541a3b6a328e6299e6d61c3acde5d49f", 684683820, 1021865984 }; - static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_mdbx_94_425000.pak", "e1f50efba1149a349eb626037dda30052c0233091693a00a10dd5363d5de1206", 535268266, 1073725440 }; + static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_lmdb_94_524999.pak", "ac46a4932813e28fe11ec160a2be4e48c961dce701ecace5133184cff2754d3d", 747173581, 1087696896 }; + static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_mdbx_94_524999.pak", "b195fdc1bda7173469db0b313f2ead2dbda1788639ba0aedb7001a6cc640fc47", 561335640, 1342156800 }; #else static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.43.225/pre-download/zano_testnet_lmdb_96_99000.pak", "9e8522b287ac7637ca770970542e94702f9fbaa267633cfcaeee4383dfe15bd0", 83851119, 131493888 }; static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.43.225/pre-download/zano_testnet_mdbx_96_99000.pak", "de33646711f2276e5b22db5741d7b2bf6a8e4c4231d393b730f9a4fce1d7ec03", 63257747, 268431360 }; From 4f91adbd08da20ffb5df57583e7f2c49816cd6e1 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 15 May 2020 13:33:02 +0300 Subject: [PATCH 21/41] ethash: log full dataset size on epoch change --- contrib/ethereum/libethash/ethash.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ethereum/libethash/ethash.cpp b/contrib/ethereum/libethash/ethash.cpp index 10ee9c6d..b6315236 100644 --- a/contrib/ethereum/libethash/ethash.cpp +++ b/contrib/ethereum/libethash/ethash.cpp @@ -149,7 +149,7 @@ epoch_context_full* create_epoch_context( LOG_CUSTOM_WITH_CALLSTACK("CRITICAL: std::calloc(" << alloc_size << ") failed in create_epoch_context()", 0); return nullptr; // Signal out-of-memory by returning null pointer. } - LOG_CUSTOM("context for epoch " << epoch_number << " allocated, size: " << alloc_size << " bytes", 0); + LOG_CUSTOM("context for epoch " << epoch_number << " allocated, size: " << alloc_size << " bytes, full dataset size: " << full_dataset_size << " bytes", 0); hash512* const light_cache = reinterpret_cast(alloc_data + context_alloc_size); const hash256 epoch_seed = calculate_epoch_seed(epoch_number); From 15ea90c14ebc9183b384b7cd9d4f41f03277ed04 Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 15 May 2020 13:36:20 +0300 Subject: [PATCH 22/41] === build number: 84 -> 85 === --- 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 2731075f..91ce5031 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "6" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 84 +#define PROJECT_VERSION_BUILD_NO 85 #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 40f1e1a870c6c63974ef63988edc76ca008c61e7 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 15:12:34 +0200 Subject: [PATCH 23/41] attempt to fix mobile crash on exit --- src/wallet/plain_wallet_api.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 9667e7d2..94d5ae0a 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -28,6 +28,7 @@ //TODO: global objects, subject to refactoring + struct plain_wallet_instance { plain_wallet_instance() :initialized(false), gjobs_counter(1) @@ -55,12 +56,18 @@ namespace plain_wallet { void deinit(); } -epee::misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([]() -{ - std::cout << "[BEFORE DEINIT]" << ENDL; + + + + +#ifdef MOBILE_WALLET_BUILD +void on_lib_unload() __attribute__((destructor)); +void on_lib_unload() { + std::cout << "[ON_LIB_UNLOAD]-->>" << ENDL; plain_wallet::deinit(); - std::cout << "[AFTER DEINIT]" << ENDL; -}); + std::cout << "[ON_LIB_UNLOAD]<<--" << ENDL; +} +#endif namespace plain_wallet { From 30e400b2d0ee82d45d17edd3f93d4d30248a3cd9 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 18:20:02 +0200 Subject: [PATCH 24/41] fixed bug in wallet sync process --- src/wallet/wallet2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 6835a6d2..b3646a78 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1229,7 +1229,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop //TODO: get_block_hash is slow crypto::hash bl_id = get_block_hash(bl); - if (processed_blocks_count != 1 && height > processed_blocks_count) + if (processed_blocks_count != 1 && height > processed_blocks_count && height != m_minimum_height) {//internal error: WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, "height{" << height <<"} > processed_blocks_count{" << processed_blocks_count << "}"); From eb119d6a3b526c41aa12ee2cf1359206b0113679 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 18:50:40 +0200 Subject: [PATCH 25/41] handling of rare but possible situation with wallet sync rewound --- src/wallet/wallet2.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b3646a78..f0d1bcee 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1229,10 +1229,19 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop //TODO: get_block_hash is slow crypto::hash bl_id = get_block_hash(bl); - if (processed_blocks_count != 1 && height > processed_blocks_count && height != m_minimum_height) - {//internal error: - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, - "height{" << height <<"} > processed_blocks_count{" << processed_blocks_count << "}"); + if (processed_blocks_count != 1 && height > processed_blocks_count) + { + if (height != m_minimum_height) + { + //internal error: + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, + "height{" << height << "} > processed_blocks_count{" << processed_blocks_count << "}"); + } + else + { + //possible case, wallet rewound to m_minimum_height + m_chain.clear(); + } } else if (height == processed_blocks_count) { From c4149503d095d8f10ffbc137c7e6bfdd4ba3453b Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 19:16:48 +0200 Subject: [PATCH 26/41] fixed wrong condition for syn validation check --- src/wallet/wallet2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index f0d1bcee..f9e2eab5 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1070,7 +1070,8 @@ void wallet2::process_unconfirmed(const currency::transaction& tx, std::vector channels_err_stat_container_type; inline epee::locked_object_proxy get_channels_errors_stat_container() { - static std::recursive_mutex cs; - static channels_err_stat_container_type errors_by_channel; + static epee::static_helpers::wrapper cs; + static epee::static_helpers::wrapper errors_by_channel; epee::locked_object_proxy res(errors_by_channel, cs); return res; } @@ -1194,7 +1194,7 @@ namespace log_space class log_singletone { public: - friend class initializer; + friend class static_helpers::initializer; friend class logger; static int get_log_detalisation_level() { @@ -1611,7 +1611,7 @@ POP_GCC_WARNINGS //static int get_set_error_filter(bool is_need_set = false) }; - const static initializer log_initializer; + const static static_helpers::initializer log_initializer; /************************************************************************/ /* */ // /************************************************************************/ diff --git a/contrib/epee/include/static_initializer.h b/contrib/epee/include/static_helpers.h similarity index 50% rename from contrib/epee/include/static_initializer.h rename to contrib/epee/include/static_helpers.h index 43ccff60..1a3dce05 100644 --- a/contrib/epee/include/static_initializer.h +++ b/contrib/epee/include/static_helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net +// Copyright (c) 2006-2020, Andrey N. Sabelnikov, www.sabelnikov.net // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -26,59 +26,74 @@ -#ifndef _STATIC_INITIALIZER_H_ -#define _STATIC_INITIALIZER_H_ - - +#pragma once +#include +#include +#include +#include +#include "include_base_utils.h" +#include "auto_val_init.h" namespace epee { -/*********************************************************************** -class initializer - useful to initialize some static classes - which have init() and un_init() static members -************************************************************************/ + namespace static_helpers + { + template + class initializer + { + public: + initializer() + { + to_initialize::init(); + //get_set_is_initialized(true, true); + } + ~initializer() + { + to_initialize::un_init(); + //get_set_is_uninitialized(true, true); + } + }; + typedef void(*static_destroy_handler_type)(); -template -class initializer -{ -public: - initializer() - { - to_initialize::init(); - //get_set_is_initialized(true, true); - } - ~initializer() - { - to_initialize::un_init(); - //get_set_is_uninitialized(true, true); - } + inline + bool set_or_call_on_destruct(bool set = false, static_destroy_handler_type destr_ptr = nullptr) + { + volatile static bool deinit_called = false; + volatile static static_destroy_handler_type static_destroy_handler = nullptr; + + if (set) + { + static_destroy_handler = destr_ptr; + return true; + } + if (!deinit_called) + { + std::cout << "[ENTERING DESTROY CALLBACK]: " << std::endl; + if (static_destroy_handler) + static_destroy_handler(); + + deinit_called = true; + std::cout << "[DESTROY CALLBACK FINISHED]: " << std::endl; + } + + return true; + } + + template + struct wrapper : public t_base + { + ~wrapper() + { + std::cout << "[DESTROYING STATIC]: " << typeid(t_base).name() << std::endl; + set_or_call_on_destruct(); + } + + }; + + } + - /*static inline bool is_initialized() - { - return get_set_is_initialized(); - } - static inline bool is_uninitialized() - { - return get_set_is_uninitialized(); - } -private: - static inline bool get_set_is_initialized(bool need_to_set = false, bool val_to_set= false) - { - static bool val_is_initialized = false; - if(need_to_set) - val_is_initialized = val_to_set; - return val_is_initialized; - } - static inline bool get_set_is_uninitialized(bool need_to_set = false, bool val_to_set = false) - { - static bool val_is_uninitialized = false; - if(need_to_set) - val_is_uninitialized = val_to_set; - return val_is_uninitialized; - }*/ -}; } -#endif //_STATIC_INITIALIZER_H_ diff --git a/contrib/epee/include/syncobj.h b/contrib/epee/include/syncobj.h index 3494194a..c994241b 100644 --- a/contrib/epee/include/syncobj.h +++ b/contrib/epee/include/syncobj.h @@ -35,7 +35,7 @@ #include #include "singleton.h" -#include "static_initializer.h" +#include "static_helpers.h" #include "misc_helpers.h" //#define DISABLE_DEADLOCK_GUARD @@ -532,7 +532,7 @@ namespace epee } }; - const static initializer > singleton_initializer; + //const static initializer > singleton_initializer; /************************************************************************/ /* */ diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 94d5ae0a..82880631 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -12,6 +12,8 @@ #include "wallets_manager.h" #include "common/base58.h" #include "common/config_encrypt_helper.h" +#include "static_helpers.h" + #define ANDROID_PACKAGE_NAME "com.zano_mobile" @@ -57,17 +59,22 @@ namespace plain_wallet void deinit(); } - - - -#ifdef MOBILE_WALLET_BUILD -void on_lib_unload() __attribute__((destructor)); -void on_lib_unload() { - std::cout << "[ON_LIB_UNLOAD]-->>" << ENDL; +void static_destroy_handler() +{ + std::cout << "[DESTROY CALLBACK HANDLER STARTED]: " << std::endl; plain_wallet::deinit(); - std::cout << "[ON_LIB_UNLOAD]<<--" << ENDL; + std::cout << "[DESTROY CALLBACK HANDLER FINISHED]: " << std::endl; } -#endif + + +// #ifdef MOBILE_WALLET_BUILD +// void on_lib_unload() __attribute__((destructor)); +// void on_lib_unload() { +// std::cout << "[ON_LIB_UNLOAD]-->>" << ENDL; +// plain_wallet::deinit(); +// std::cout << "[ON_LIB_UNLOAD]<<--" << ENDL; +// } +// #endif namespace plain_wallet { @@ -173,6 +180,8 @@ namespace plain_wallet return epee::serialization::store_t_to_json(ok_response); } + epee::static_helpers::set_or_call_on_destruct(true, static_destroy_handler); + std::cout << "[INIT PLAIN_WALLET_INSTANCE]" << ENDL; std::shared_ptr ptr(new plain_wallet_instance()); From a4b5af479e374cabc52bc1e679e3239af54da96e Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 23:15:50 +0200 Subject: [PATCH 28/41] guarded other static objects whichg might lead to errors in deinitialization --- contrib/epee/include/misc_log_ex.h | 2 +- contrib/epee/include/singleton.h | 4 ++-- contrib/epee/include/static_helpers.h | 4 ++++ src/common/util.h | 4 ++-- src/wallet/plain_wallet_api.cpp | 2 +- src/wallet/wallets_manager.cpp | 9 +++++++-- src/wallet/wallets_manager.h | 1 + 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index f1d846ad..37b2400f 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -1205,7 +1205,7 @@ namespace log_space //get_enabled_channels not thread-safe, at the moment leave it like this because it's configured in main, before other threads started static std::set& get_enabled_channels() { - static std::set genabled_channels; + static epee::static_helpers::wrapper> genabled_channels; return genabled_channels; } diff --git a/contrib/epee/include/singleton.h b/contrib/epee/include/singleton.h index f510c9a6..a770ab28 100644 --- a/contrib/epee/include/singleton.h +++ b/contrib/epee/include/singleton.h @@ -31,7 +31,7 @@ #pragma once #include - +#include "static_helpers.h" template class abstract_singleton @@ -39,7 +39,7 @@ class abstract_singleton static std::shared_ptr get_set_instance_internal(bool is_need_set = false, owned_object_t* pnew_obj = nullptr) { - static std::shared_ptr val_pobj; + static epee::static_helpers::wrapper> val_pobj; if (is_need_set) val_pobj.reset(pnew_obj); diff --git a/contrib/epee/include/static_helpers.h b/contrib/epee/include/static_helpers.h index 1a3dce05..bba92d51 100644 --- a/contrib/epee/include/static_helpers.h +++ b/contrib/epee/include/static_helpers.h @@ -33,6 +33,10 @@ #include #include "include_base_utils.h" #include "auto_val_init.h" + +#define DEFINE_SECURE_STATIC_VAR(type, var) static epee::static_helpers::wrapper var##inst; \ + static type& var = var##inst; + namespace epee { namespace static_helpers diff --git a/src/common/util.h b/src/common/util.h index 87138ef0..1f31d263 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -259,14 +259,14 @@ namespace tools static void handle_signal() { - static std::mutex m_mutex; + static epee::static_helpers::wrapper m_mutex; std::unique_lock lock(m_mutex); m_handler(); } static void handle_fatal_signal(int sig_number, void* address) { - static std::mutex m_mutex_fatal; + static epee::static_helpers::wrapper m_mutex_fatal; std::unique_lock lock(m_mutex_fatal); m_fatal_handler(sig_number, address); uninstall_fatal(); diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 82880631..fbb1c477 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -83,7 +83,7 @@ namespace plain_wallet std::string get_set_working_dir(bool need_to_set = false, const std::string val = "") { - static std::string working_dir; + DEFINE_SECURE_STATIC_VAR(std::string, working_dir); if (need_to_set) working_dir = val; return working_dir; diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 06adc3d6..4db0a77c 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -513,7 +513,7 @@ void wallets_manager::main_worker(const po::variables_map& m_vm) { wo.second.major_stop = true; wo.second.stop_for_refresh = true; - wo.second.w.unlocked_get()->stop(); + wo.second.stop(); if(!dont_save_wallet_at_stop) wo.second.w->get()->store(); @@ -1824,8 +1824,9 @@ void wallets_manager::wallet_vs_options::worker_func() } LOG_PRINT_GREEN("[WALLET_HANDLER] Wallet thread thread stopped", LOG_LEVEL_0); } -wallets_manager::wallet_vs_options::~wallet_vs_options() +void wallets_manager::wallet_vs_options::stop() { + w.unlocked_get()->stop(); do_mining = false; major_stop = true; stop_for_refresh = true; @@ -1833,6 +1834,10 @@ wallets_manager::wallet_vs_options::~wallet_vs_options() if (miner_thread.joinable()) miner_thread.join(); } +wallets_manager::wallet_vs_options::~wallet_vs_options() +{ + stop(); +} std::string wallets_manager::get_wallet_log_prefix(size_t wallet_id) const { diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index aa900d93..0d75447c 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -80,6 +80,7 @@ public: std::thread miner_thread; void worker_func(); + void stop(); std::string get_log_prefix() const { return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":" + w->get()->get_log_prefix() + "]"; } ~wallet_vs_options(); }; From 7d73fb92bacb34326d87c574429396b92bb152a5 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 18 May 2020 18:01:11 +0300 Subject: [PATCH 29/41] enumerate_subimtes implemented in basic_key_to_array_accessor --- src/common/db_abstract_accessor.h | 44 +++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/common/db_abstract_accessor.h b/src/common/db_abstract_accessor.h index 774284bd..f52050fe 100644 --- a/src/common/db_abstract_accessor.h +++ b/src/common/db_abstract_accessor.h @@ -913,28 +913,48 @@ namespace tools { typedef basic_key_value_accessor, t_value, is_t_access_strategy> basic_accessor_type; -// template solo_db_value, uint64_t, basic_accessor_type> - get_counter_accessor(const t_key& container_id) + get_counter_accessor(const t_key& container_id) { - static_assert(std::is_pod::value, "t_pod_key must be a POD type."); composite_key cc = { container_id, const_counter_suffix}; return solo_db_value, uint64_t, basic_accessor_type >(cc, *this); } -// template const solo_db_value, uint64_t, basic_accessor_type > - get_counter_accessor(const t_key& container_id) const + get_counter_accessor(const t_key& container_id) const { + static_assert(std::is_pod::value, "t_pod_key must be a POD type."); + composite_key cc = { container_id, const_counter_suffix }; - static_assert(std::is_pod::value, "t_pod_key must be a POD type."); - composite_key cc = { container_id, const_counter_suffix }; + return solo_db_value, uint64_t, basic_accessor_type >(cc, const_cast(static_cast(*this))); + } - return solo_db_value, uint64_t, basic_accessor_type >(cc, const_cast(static_cast(*this))); + template + struct subitems_visitor : public i_db_callback + { + subitems_visitor(callback_t cb) + : m_callback(cb) + {} + + virtual bool on_enum_item(uint64_t i, const void* key_data, uint64_t key_size, const void* value_data, uint64_t value_size) override + { + if (key_size != sizeof(composite_key)) + return true; // skip solo values containing items size + + composite_key key = AUTO_VAL_INIT(key); + key_from_ptr(key, key_data, key_size); + + t_value value = AUTO_VAL_INIT(value); + access_strategy_selector::from_buff_to_obj(value_data, value_size, value); + + return m_callback(i, key.container_id, key.sufix, value); } + callback_t m_callback; + }; + public: basic_key_to_array_accessor(basic_db_accessor& db) : basic_key_value_accessor, t_value, is_t_access_strategy>(db) {} @@ -991,6 +1011,14 @@ namespace tools counter = 0; } + + template + void enumerate_subitems(callback_t callback) const + { + subitems_visitor visitor(callback); + basic_accessor_type::bdb.get_backend()->enumerate(basic_accessor_type::m_h, &visitor); + } + }; /************************************************************************/ From 23b7c3e1e0d8f4c890b4ef655d7f2d66b4845ff3 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 18 May 2020 22:06:59 +0300 Subject: [PATCH 30/41] cmd print_bc_outs_stat re-implemented --- src/currency_core/blockchain_storage.cpp | 104 +++++++++++++++-------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index b61dce7a..b367f85a 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -2836,43 +2836,73 @@ void blockchain_storage::print_last_n_difficulty_numbers(uint64_t n) const //------------------------------------------------------------------ void blockchain_storage::print_blockchain_outs_stat() const { - LOG_ERROR("NOT IMPLEMENTED YET"); -// std::stringstream ss; -// CRITICAL_REGION_LOCAL(m_blockchain_lock); -// BOOST_FOREACH(const outputs_container::value_type& v, m_db_outputs) -// { -// const std::vector >& vals = v.second; -// if (vals.size()) -// { -// ss << "amount: " << print_money(v.first); -// uint64_t total_count = vals.size(); -// uint64_t unused_count = 0; -// for (size_t i = 0; i != vals.size(); i++) -// { -// bool used = false; -// auto it_tx = m_db_transactions.find(vals[i].first); -// if (it_tx == m_db_transactions.end()) -// { -// LOG_ERROR("Tx with id not found " << vals[i].first); -// } -// else -// { -// if (vals[i].second >= it_tx->second.m_spent_flags.size()) -// { -// LOG_ERROR("Tx with id " << vals[i].first << " in global index have wrong entry in global index, offset in tx = " << vals[i].second -// << ", it_tx->second.m_spent_flags.size()=" << it_tx->second.m_spent_flags.size() -// << ", it_tx->second.tx.vin.size()=" << it_tx->second.tx.vin.size()); -// } -// used = it_tx->second.m_spent_flags[vals[i].second]; -// -// } -// if (!used) -// ++unused_count; -// } -// ss << "\t total: " << total_count << "\t unused: " << unused_count << ENDL; -// } -// } -// LOG_PRINT_L0("OUTS: " << ENDL << ss.str()); + std::stringstream ss; + CRITICAL_REGION_LOCAL(m_read_lock); + + struct output_stat_t + { + uint64_t total = 0; + uint64_t unspent = 0; + uint64_t mixable = 0; + }; + + std::map outputs_stats; + + const uint64_t subitems_cnt = m_db_outputs.size(); + uint64_t progress = 0; + + auto lambda_handler = [&](uint64_t i, uint64_t amount, uint64_t index, const currency::global_output_entry& output_entry) -> bool + { + uint64_t progress_current = 20 * i / subitems_cnt; + if (progress_current != progress) + { + progress = progress_current; + LOG_PRINT_L0(progress * 5 << "%"); + } + + auto p_tx = m_db_transactions.find(output_entry.tx_id); + if (!p_tx) + { + LOG_ERROR("tx " << output_entry.tx_id << " not found"); + return true; // continue + } + if (output_entry.out_no >= p_tx->m_spent_flags.size()) + { + LOG_ERROR("tx with id " << output_entry.tx_id << " has wrong entry in global index, out_no = " << output_entry.out_no + << ", p_tx->m_spent_flags.size() = " << p_tx->m_spent_flags.size() + << ", p_tx->tx.vin.size() = " << p_tx->tx.vin.size()); + return true; // continue + } + if (p_tx->tx.vout.size() != p_tx->m_spent_flags.size()) + { + LOG_ERROR("Tx with id " << output_entry.tx_id << " has wrong entry in global index, out_no = " << output_entry.out_no + << ", p_tx->tx.vout.size() = " << p_tx->tx.vout.size() + << ", p_tx->m_spent_flags.size() = " << p_tx->m_spent_flags.size()); + return true; // continue + } + + auto& stat = outputs_stats[amount]; + ++stat.total; + + bool spent = p_tx->m_spent_flags[output_entry.out_no]; + if (!spent) + ++stat.unspent; + + if (!spent && p_tx->tx.vout[output_entry.out_no].target.type() == typeid(txout_to_key)) + { + if (boost::get(p_tx->tx.vout[output_entry.out_no].target).mix_attr != CURRENCY_TO_KEY_OUT_FORCED_NO_MIX) + ++stat.mixable; + } + return true; + }; + + m_db_outputs.enumerate_subitems(lambda_handler); + + ss << std::right << std::setw(15) << "amount" << std::setw(10) << "total" << std::setw(10) << "unspent" << std::setw(10) << "mixable" << ENDL; + for(auto it = outputs_stats.begin(); it != outputs_stats.end(); ++it) + ss << std::setw(15) << print_money_brief(it->first) << std::setw(10) << it->second.total << std::setw(10) << it->second.unspent << std::setw(10) << it->second.mixable << ENDL; + + LOG_PRINT_L0("OUTS: " << ENDL << ss.str()); } //------------------------------------------------------------------ void blockchain_storage::print_blockchain_outs(const std::string& file) const From cefe2ef855bcaf8670156fa883e959df5f3a3518 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 18 May 2020 22:08:40 +0300 Subject: [PATCH 31/41] log message for IP debug mode --- src/currency_protocol/currency_protocol_handler.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 166cdb80..822159c3 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -876,6 +876,7 @@ namespace currency void t_currency_protocol_handler::set_to_debug_mode(uint32_t ip) { m_debug_ip_address = ip; + LOG_PRINT_L0("debug mode is set for IP " << epee:string_tools::get_ip_string_from_int32(m_debug_ip_address)); } //------------------------------------------------------------------------------------------------------------------------ template From cf4a54744bd8e1e1bb858ae660f29756425102c1 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 18 May 2020 22:10:14 +0300 Subject: [PATCH 32/41] typo fixed --- src/daemon/daemon_commands_handler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 32a5f404..87963635 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -70,7 +70,7 @@ public: m_cmd_binder.set_handler("print_tx_from_hex_blob", boost::bind(&daemon_commands_handler::print_tx_from_hex_blob, this, _1), "Unserialize transaction from hex binary data to json-like representation"); m_cmd_binder.set_handler("print_tx_outputs_usage", boost::bind(&daemon_commands_handler::print_tx_outputs_usage, this, _1), "Analyse if tx outputs for involved in subsequent transactions"); m_cmd_binder.set_handler("print_difficulties_of_last_n_blocks", boost::bind(&daemon_commands_handler::print_difficulties_of_last_n_blocks, this, _1), "Print difficulties of last n blocks"); - m_cmd_binder.set_handler("debug_remore_node_mode", boost::bind(&daemon_commands_handler::debug_remore_node_mode, this, _1), " - If node got connected put node into 'debug mode' i.e. no sync process of other communication except ping responses, maintenance secrete key will be requested"); + m_cmd_binder.set_handler("debug_remote_node_mode", boost::bind(&daemon_commands_handler::debug_remote_node_mode, this, _1), " - If node got connected put node into 'debug mode' i.e. no sync process of other communication except ping responses, maintenance secrete key will be requested"); #ifdef _DEBUG m_cmd_binder.set_handler("debug_set_time_adj", boost::bind(&daemon_commands_handler::debug_set_time_adj, this, _1), "DEBUG: set core time adjustment"); #endif @@ -735,7 +735,7 @@ private: return true; } //-------------------------------------------------------------------------------- - bool debug_remore_node_mode(const std::vector& args) + bool debug_remote_node_mode(const std::vector& args) { if (args.empty()) { From 07a1cde8f94c306921a26c312f581b3102f2ea7d Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 19 May 2020 16:28:50 +0200 Subject: [PATCH 33/41] optimized shutdown process for wallets manager --- src/wallet/wallets_manager.cpp | 74 +++++++++++++++++++++++++--------- src/wallet/wallets_manager.h | 6 ++- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 4db0a77c..26459184 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -4,7 +4,7 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. - +#include #include "wallets_manager.h" #include "currency_core/alias_helper.h" #ifndef MOBILE_WALLET_BUILD @@ -33,7 +33,12 @@ return API_RETURN_CODE_WALLET_WRONG_ID; \ auto& name = it->second.w; -#define DAEMON_IDLE_UPDATE_TIME_MS 2000 +#ifdef MOBILE_WALLET_BUILD + #define DAEMON_IDLE_UPDATE_TIME_MS 10000 +#else + #define DAEMON_IDLE_UPDATE_TIME_MS 2000 +#endif + #define HTTP_PROXY_TIMEOUT 2000 #define HTTP_PROXY_ATTEMPTS_COUNT 1 @@ -282,13 +287,6 @@ bool wallets_manager::start() CATCH_ENTRY_L0("main", false); } - - -bool wallets_manager::send_stop_signal() -{ - m_stop_singal_sent = true; - return true; -} bool wallets_manager::stop() @@ -504,6 +502,25 @@ void wallets_manager::main_worker(const po::variables_map& m_vm) SHARED_CRITICAL_REGION_BEGIN(m_wallets_lock); + //first send stop signal to all wallets + for (auto& wo : m_wallets) + { + try + { + wo.second.stop(false); + } + catch (const std::exception& e) + { + LOG_ERROR("Exception rised at storing wallet: " << e.what()); + continue; + } + catch (...) + { + LOG_ERROR("Exception rised at storing wallet"); + continue; + } + } + for (auto& wo : m_wallets) { LOG_PRINT_L0("Storing wallet data..."); @@ -511,10 +528,7 @@ void wallets_manager::main_worker(const po::variables_map& m_vm) //m_pview->update_daemon_status(dsi); try { - wo.second.major_stop = true; - wo.second.stop_for_refresh = true; wo.second.stop(); - if(!dont_save_wallet_at_stop) wo.second.w->get()->store(); } @@ -613,13 +627,34 @@ void wallets_manager::toggle_pos_mining() //update_wallets_info(); } +bool wallets_manager::send_stop_signal() +{ + m_stop_singal_sent = true; + m_stop_singal_sent_mutex_cv.notify_one(); + return true; +} + + void wallets_manager::loop() { - while(!m_stop_singal_sent) + + while (!m_stop_singal_sent) { - update_state_info(); - std::this_thread::sleep_for(std::chrono::milliseconds(DAEMON_IDLE_UPDATE_TIME_MS)); + { + std::unique_lock lk(m_stop_singal_sent_mutex); + m_stop_singal_sent_mutex_cv.wait_for(lk, std::chrono::microseconds(DAEMON_IDLE_UPDATE_TIME_MS), [&] {return m_stop_singal_sent.load(); }); + } + if (!m_stop_singal_sent) + { + update_state_info(); + } + } +// while(!m_stop_singal_sent) +// { +// update_state_info(); +// std::this_thread::sleep_for(std::chrono::milliseconds(DAEMON_IDLE_UPDATE_TIME_MS)); +// } } void wallets_manager::init_wallet_entry(wallet_vs_options& wo, uint64_t id) @@ -1824,15 +1859,18 @@ void wallets_manager::wallet_vs_options::worker_func() } LOG_PRINT_GREEN("[WALLET_HANDLER] Wallet thread thread stopped", LOG_LEVEL_0); } -void wallets_manager::wallet_vs_options::stop() +void wallets_manager::wallet_vs_options::stop(bool wait) { w.unlocked_get()->stop(); do_mining = false; major_stop = true; stop_for_refresh = true; break_mining_loop = true; - if (miner_thread.joinable()) - miner_thread.join(); + if (wait) + { + if (miner_thread.joinable()) + miner_thread.join(); + } } wallets_manager::wallet_vs_options::~wallet_vs_options() { diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index 0d75447c..5b545f32 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -80,7 +80,7 @@ public: std::thread miner_thread; void worker_func(); - void stop(); + void stop(bool wait = true); std::string get_log_prefix() const { return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":" + w->get()->get_log_prefix() + "]"; } ~wallet_vs_options(); }; @@ -174,7 +174,11 @@ private: virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti); std::thread m_main_worker_thread; + std::atomic m_stop_singal_sent; + std::mutex m_stop_singal_sent_mutex; + std::condition_variable m_stop_singal_sent_mutex_cv; + view::i_view m_view_stub; view::i_view* m_pview; std::shared_ptr m_rpc_proxy; From c9177ea8040d5e577c8ecf78f573b2415e9490c0 Mon Sep 17 00:00:00 2001 From: sowle Date: Tue, 19 May 2020 20:25:03 +0300 Subject: [PATCH 34/41] print_blockchain_outs_stat -> print_blockchain_outs_stats --- src/currency_core/blockchain_storage.cpp | 2 +- src/currency_core/blockchain_storage.h | 2 +- src/daemon/daemon_commands_handler.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index b367f85a..253d1f6e 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -2834,7 +2834,7 @@ void blockchain_storage::print_last_n_difficulty_numbers(uint64_t n) const LOG_PRINT_L0("LAST BLOCKS:" << ss.str()); } //------------------------------------------------------------------ -void blockchain_storage::print_blockchain_outs_stat() const +void blockchain_storage::print_blockchain_outs_stats() const { std::stringstream ss; CRITICAL_REGION_LOCAL(m_read_lock); diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index bc595256..c77a9b15 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -432,7 +432,7 @@ namespace currency void print_blockchain_with_tx(uint64_t start_index, uint64_t end_index) const; void print_blockchain_index() const; void print_blockchain_outs(const std::string& file) const; - void print_blockchain_outs_stat() const; + void print_blockchain_outs_stats() const; void print_db_cache_perfeormance_data() const; void print_last_n_difficulty_numbers(uint64_t n) const; bool calc_tx_cummulative_blob(const block& bl)const; diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 87963635..844da14f 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -39,7 +39,7 @@ public: //m_cmd_binder.set_handler("print_bci", boost::bind(&daemon_commands_handler::print_bci, this, _1)); m_cmd_binder.set_handler("print_bc_outs", boost::bind(&daemon_commands_handler::print_bc_outs, this, _1)); m_cmd_binder.set_handler("print_market", boost::bind(&daemon_commands_handler::print_market, this, _1)); - m_cmd_binder.set_handler("print_bc_outs_stat", boost::bind(&daemon_commands_handler::print_bc_outs_stat, this, _1)); + m_cmd_binder.set_handler("print_bc_outs_stats", boost::bind(&daemon_commands_handler::print_bc_outs_stats, this, _1)); m_cmd_binder.set_handler("print_block", boost::bind(&daemon_commands_handler::print_block, this, _1), "Print block, print_block | "); m_cmd_binder.set_handler("print_block_info", boost::bind(&daemon_commands_handler::print_block_info, this, _1), "Print block info, print_block | "); m_cmd_binder.set_handler("print_tx", boost::bind(&daemon_commands_handler::print_tx, this, _1), "Print transaction, print_tx "); @@ -218,9 +218,9 @@ private: return true; } //-------------------------------------------------------------------------------- - bool print_bc_outs_stat(const std::vector& args) + bool print_bc_outs_stats(const std::vector& args) { - m_srv.get_payload_object().get_core().get_blockchain_storage().print_blockchain_outs_stat(); + m_srv.get_payload_object().get_core().get_blockchain_storage().print_blockchain_outs_stats(); return true; } //-------------------------------------------------------------------------------- From dbf70494ba0e9fdf8588592d38a6e2a9af65d2a3 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 20 May 2020 18:34:37 +0300 Subject: [PATCH 35/41] gui: reset default mixin to 10 after sending a tx --- src/gui/qt-daemon/html/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/html/main.js b/src/gui/qt-daemon/html/main.js index dccb0a60..b410e1dc 100644 --- a/src/gui/qt-daemon/html/main.js +++ b/src/gui/qt-daemon/html/main.js @@ -7276,7 +7276,7 @@ var SendComponent = /** @class */ (function () { if (send_status) { _this.modalService.prepareModal('success', 'SEND.SUCCESS_SENT'); _this.variablesService.currentWallet.send_data = { address: null, amount: null, comment: null, mixin: null, fee: null, hide: null }; - _this.sendForm.reset({ address: null, amount: null, comment: null, mixin: 0, fee: _this.variablesService.default_fee, hide: false }); + _this.sendForm.reset({ address: null, amount: null, comment: null, mixin: 10, fee: _this.variablesService.default_fee, hide: false }); } }); } From a74dc3140a3666b40c9849a05946d7e0af9f0610 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 20 May 2020 18:35:40 +0300 Subject: [PATCH 36/41] === build number: 85 -> 86 === --- 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 91ce5031..c72c4910 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "6" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 85 +#define PROJECT_VERSION_BUILD_NO 86 #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 12ea93fef8940548edd3ba2a0dd8b833c137bc30 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 20 May 2020 18:40:01 +0300 Subject: [PATCH 37/41] fixed a typo --- src/currency_protocol/currency_protocol_handler.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 822159c3..65993062 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -876,7 +876,7 @@ namespace currency void t_currency_protocol_handler::set_to_debug_mode(uint32_t ip) { m_debug_ip_address = ip; - LOG_PRINT_L0("debug mode is set for IP " << epee:string_tools::get_ip_string_from_int32(m_debug_ip_address)); + LOG_PRINT_L0("debug mode is set for IP " << epee::string_tools::get_ip_string_from_int32(m_debug_ip_address)); } //------------------------------------------------------------------------------------------------------------------------ template From 05f15d55602be6c1260499c8078b9a716638942d Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 20 May 2020 21:04:03 +0300 Subject: [PATCH 38/41] gui: attempt to fix default mixin value for alias-targeted tx --- src/gui/qt-daemon/html/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/html/main.js b/src/gui/qt-daemon/html/main.js index b410e1dc..d59b34d3 100644 --- a/src/gui/qt-daemon/html/main.js +++ b/src/gui/qt-daemon/html/main.js @@ -7296,7 +7296,7 @@ var SendComponent = /** @class */ (function () { if (send_status) { _this.modalService.prepareModal('success', 'SEND.SUCCESS_SENT'); _this.variablesService.currentWallet.send_data = { address: null, amount: null, comment: null, mixin: null, fee: null, hide: null }; - _this.sendForm.reset({ address: null, amount: null, comment: null, mixin: 0, fee: _this.variablesService.default_fee, hide: false }); + _this.sendForm.reset({ address: null, amount: null, comment: null, mixin: 10, fee: _this.variablesService.default_fee, hide: false }); } }); } From 9d1a58887280864e0c2b1e4116cb26ebc007208b Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 20 May 2020 21:04:41 +0300 Subject: [PATCH 39/41] === build number: 86 -> 87 === --- 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 c72c4910..a6b10969 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "6" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 86 +#define PROJECT_VERSION_BUILD_NO 87 #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 034e4e029678f940504ae5e9836dc1c0a3305144 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 22 May 2020 14:36:25 +0200 Subject: [PATCH 40/41] got rid of console messages --- contrib/epee/include/static_helpers.h | 4 +--- src/wallet/wallets_manager.cpp | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/epee/include/static_helpers.h b/contrib/epee/include/static_helpers.h index bba92d51..d3c11c83 100644 --- a/contrib/epee/include/static_helpers.h +++ b/contrib/epee/include/static_helpers.h @@ -73,12 +73,11 @@ namespace epee } if (!deinit_called) { - std::cout << "[ENTERING DESTROY CALLBACK]: " << std::endl; + if (static_destroy_handler) static_destroy_handler(); deinit_called = true; - std::cout << "[DESTROY CALLBACK FINISHED]: " << std::endl; } return true; @@ -89,7 +88,6 @@ namespace epee { ~wrapper() { - std::cout << "[DESTROYING STATIC]: " << typeid(t_base).name() << std::endl; set_or_call_on_destruct(); } diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 26459184..48f7b5c0 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -891,7 +891,6 @@ std::string wallets_manager::generate_wallet(const std::wstring& path, const std #else LOG_ERROR("Unexpected location reached"); #endif - } try From 4369439fbc3df79448e0c00fd8bd67f48191804d Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 22 May 2020 16:30:34 +0300 Subject: [PATCH 41/41] get_callstack_win_x64() made thread-safe --- src/common/callstack_helper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/callstack_helper.cpp b/src/common/callstack_helper.cpp index eb1be7eb..49d8fd54 100644 --- a/src/common/callstack_helper.cpp +++ b/src/common/callstack_helper.cpp @@ -105,6 +105,11 @@ namespace tools std::string get_callstack_win_x64() { + // @TODO@ + // static epee::static_helpers::wrapper cs; + static std::recursive_mutex cs; + std::lock_guard lock(cs); + HANDLE h_process = GetCurrentProcess(); HANDLE h_thread = GetCurrentThread();