diff --git a/src/connectivity_tool/conn_tool.cpp b/src/connectivity_tool/conn_tool.cpp index ac0586c6..98f2a53f 100644 --- a/src/connectivity_tool/conn_tool.cpp +++ b/src/connectivity_tool/conn_tool.cpp @@ -793,6 +793,7 @@ bool handle_increment_build_no(po::variables_map& vm) //--------------------------------------------------------------------------------------------------------------- bool handle_update_maintainers_info(po::variables_map& vm) { + log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); if(!command_line::has_arg(vm, arg_rpc_port)) { std::cout << "ERROR: rpc port not set" << ENDL; diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 1b111ae3..3db594ca 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -902,9 +902,10 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con return DIFFICULTY_STARTER; //skip genesis timestamp TIME_MEASURE_START_PD(target_calculating_enum_blocks); + CRITICAL_REGION_BEGIN(m_targetdata_cache_lock); std::list>& targetdata_cache = pos ? m_pos_targetdata_cache : m_pow_targetdata_cache; - if (targetdata_cache.empty()) - load_targetdata_cache(pos); + //if (targetdata_cache.empty()) + load_targetdata_cache(pos); size_t count = 0; for (auto it = targetdata_cache.rbegin(); it != targetdata_cache.rend() && count < DIFFICULTY_WINDOW; it++) @@ -913,6 +914,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con commulative_difficulties.push_back(it->first); ++count; } + CRITICAL_REGION_END(); wide_difficulty_type& dif = pos ? m_cached_next_pos_difficulty : m_cached_next_pow_difficulty; TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks); @@ -4259,8 +4261,6 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt return false; } - get_block_height(bl); - if(!check_block_timestamp_main(bl)) { LOG_PRINT_L0("Block with id: " << id << ENDL @@ -4596,6 +4596,7 @@ void blockchain_storage::on_block_removed(const block_extended_info& bei) //------------------------------------------------------------------ void blockchain_storage::update_targetdata_cache_on_block_added(const block_extended_info& bei) { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); if (bei.height == 0) return; //skip genesis std::list>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache; @@ -4606,6 +4607,7 @@ void blockchain_storage::update_targetdata_cache_on_block_added(const block_exte //------------------------------------------------------------------ void blockchain_storage::update_targetdata_cache_on_block_removed(const block_extended_info& bei) { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); std::list>& targetdata_cache = is_pos_block(bei.bl) ? m_pos_targetdata_cache : m_pow_targetdata_cache; if (targetdata_cache.size()) targetdata_cache.pop_back(); @@ -4615,6 +4617,7 @@ void blockchain_storage::update_targetdata_cache_on_block_removed(const block_ex //------------------------------------------------------------------ void blockchain_storage::load_targetdata_cache(bool is_pos)const { + CRITICAL_REGION_LOCAL(m_targetdata_cache_lock); std::list>& targetdata_cache = is_pos? m_pos_targetdata_cache: m_pow_targetdata_cache; targetdata_cache.clear(); uint64_t stop_ind = 0; diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index eaa12740..580afe81 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -511,6 +511,7 @@ namespace currency mutable wide_difficulty_type m_cached_next_pow_difficulty; mutable wide_difficulty_type m_cached_next_pos_difficulty; + mutable critical_section m_targetdata_cache_lock; mutable std::list > m_pos_targetdata_cache; mutable std::list > m_pow_targetdata_cache; //work like a cache to avoid recalculation on read operations diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index a5488380..2e4e9303 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -205,7 +205,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 + 4 +#define BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION CURRENCY_FORMATION_VERSION + 7 #define BLOCKCHAIN_STORAGE_MINOR_COMPATIBILITY_VERSION 1 diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index b281e5c3..e4eebf74 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -258,6 +258,11 @@ namespace currency } //pre-validate block here, and propagate it to network asap to avoid latency of handling big block (tx flood) + //######################################################## + /* + problem with prevalidation: in case of pre_validate_block() is passed but handle_incoming_tx() is failed + network got spammed with notifications about this broken block and then connections got closed. + temporary disabled to more investigation bool prevalidate_relayed = false; if (m_core.pre_validate_block(b, bvc, block_id) && bvc.m_added_to_main_chain) { @@ -266,6 +271,8 @@ namespace currency relay_block(arg, context); prevalidate_relayed = true; } + */ + //######################################################## //now actually process block for(auto tx_blob_it = arg.b.txs.begin(); tx_blob_it!=arg.b.txs.end();tx_blob_it++) @@ -291,13 +298,13 @@ namespace currency } LOG_PRINT_GREEN("[HANDLE]NOTIFY_NEW_BLOCK EXTRA: id: " << block_id << ",bvc.m_added_to_main_chain " << bvc.m_added_to_main_chain - << ",prevalidate_result " << prevalidate_relayed + //<< ",prevalidate_result " << prevalidate_relayed << ",bvc.added_to_altchain " << bvc.added_to_altchain << ",bvc.m_marked_as_orphaned " << bvc.m_marked_as_orphaned, LOG_LEVEL_2); if (bvc.m_added_to_main_chain || (bvc.added_to_altchain && bvc.height_difference < 2)) { - if (!prevalidate_relayed) + if (true/*!prevalidate_relayed*/) { // pre-validation failed prevoiusly, but complete check was success, not an alternative block ++arg.hop; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index c7e18dac..2d3a9fc4 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -402,14 +402,14 @@ namespace nodetool template bool node_server::on_maintainers_entry_update() { - LOG_PRINT_MAGENTA("Fresh maintainers info recieved(timestamp: " << m_maintainers_info_local.timestamp << ")", LOG_LEVEL_0); + LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "Fresh maintainers info recieved(timestamp: " << m_maintainers_info_local.timestamp << ")", LOG_LEVEL_0, epee::log_space::console_color_magenta); if(PROJECT_VERSION_BUILD_NO < m_maintainers_info_local.build_no) { - LOG_PRINT_MAGENTA("Newer version avaliable: " << static_cast(m_maintainers_info_local.ver_major) << + LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "Newer version avaliable: " << static_cast(m_maintainers_info_local.ver_major) << "." << static_cast(m_maintainers_info_local.ver_minor) << "." << static_cast(m_maintainers_info_local.ver_revision) << "." << static_cast(m_maintainers_info_local.build_no) << - ", current version: " << PROJECT_VERSION_LONG, LOG_LEVEL_0); + ", current version: " << PROJECT_VERSION_LONG, LOG_LEVEL_0, epee::log_space::console_color_magenta); } handle_alert_conditions(); @@ -893,7 +893,7 @@ namespace nodetool if(m_alert_mode != ALERT_TYPE_CALM) return true; - LOG_PRINT_L0("This software is old, please update."); + LOG_PRINT_CHANNEL2(NULL, NULL, "This software is outdated, please update.", LOG_LEVEL_0); return true; } //----------------------------------------------------------------------------------- @@ -903,7 +903,7 @@ namespace nodetool if(m_alert_mode != ALERT_TYPE_URGENT) return true; - LOG_PRINT_CYAN("[URGENT]:This software is old, please update.", LOG_LEVEL_0); + LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "[URGENT]:This software is dramatically outdated, please update to latest version.", LOG_LEVEL_0, epee::log_space::console_color_cyan); return true; } //----------------------------------------------------------------------------------- @@ -913,7 +913,7 @@ namespace nodetool if(m_alert_mode != ALERT_TYPE_CRITICAL) return true; - LOG_PRINT_RED("[CRITICAL]:This software is old, please update.", LOG_LEVEL_0); + LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "[CRITICAL]:This software is critically outdated, please update to latest version.", LOG_LEVEL_0, epee::log_space::console_color_red); return true; } //----------------------------------------------------------------------------------- diff --git a/src/version.h.in b/src/version.h.in index 205690a7..e523598c 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -2,6 +2,6 @@ #define BUILD_COMMIT_ID "@VERSION@" #define PROJECT_VERSION "1.0" -#define PROJECT_VERSION_BUILD_NO 25 +#define PROJECT_VERSION_BUILD_NO 29 #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 "]" diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index debe1300..ede30932 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -226,6 +226,13 @@ namespace tools m_wallet.get_payments(payment_id, payment_list); for (auto payment : payment_list) { + if (payment.m_unlock_time && !req.allow_locked_transactions) + { + //check that transaction don't have locking for time longer then 10 blocks ahead + //TODO: add code for "unlock_time" set as timestamp, now it's all being filtered + if (payment.m_unlock_time > payment.m_block_height + WALLET_DEFAULT_TX_SPENDABLE_AGE) + continue; + } wallet_rpc::payment_details rpc_payment; rpc_payment.payment_id = req.payment_id; rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash); @@ -257,6 +264,14 @@ namespace tools for (auto & payment : payment_list) { + if (payment.m_unlock_time && !req.allow_locked_transactions) + { + //check that transaction don't have locking for time longer then 10 blocks ahead + //TODO: add code for "unlock_time" set as timestamp, now it's all being filtered + if (payment.m_unlock_time > payment.m_block_height + WALLET_DEFAULT_TX_SPENDABLE_AGE) + continue; + } + wallet_rpc::payment_details rpc_payment; rpc_payment.payment_id = payment_id_str; rpc_payment.tx_hash = epee::string_tools::pod_to_hex(payment.m_tx_hash); diff --git a/src/wallet/wallet_rpc_server_commans_defs.h b/src/wallet/wallet_rpc_server_commans_defs.h index 2c4ef2ba..79beae2c 100644 --- a/src/wallet/wallet_rpc_server_commans_defs.h +++ b/src/wallet/wallet_rpc_server_commans_defs.h @@ -277,9 +277,11 @@ namespace wallet_rpc struct request { std::string payment_id; // hex-encoded + bool allow_locked_transactions; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(payment_id) + KV_SERIALIZE(allow_locked_transactions) END_KV_SERIALIZE_MAP() }; @@ -299,10 +301,12 @@ namespace wallet_rpc { std::vector payment_ids; uint64_t min_block_height; + bool allow_locked_transactions; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(payment_ids) KV_SERIALIZE(min_block_height) + KV_SERIALIZE(allow_locked_transactions) END_KV_SERIALIZE_MAP() }; diff --git a/utils/munin_plugins/sequense_factor b/utils/munin_plugins/sequence_factor old mode 100755 new mode 100644 similarity index 53% rename from utils/munin_plugins/sequense_factor rename to utils/munin_plugins/sequence_factor index 0db780ed..561f6ab9 --- a/utils/munin_plugins/sequense_factor +++ b/utils/munin_plugins/sequence_factor @@ -3,16 +3,16 @@ case $1 in config) cat <<'EOM' -graph_title sequense -graph_vlabel sequense +graph_title sequence +graph_vlabel sequence graph_category daemon -pos_sequense_factor.label pos_sequense_factor -pow_sequense_factor.label pow_sequense_factor +pos_sequence_factor.label pos_sequence_factor +pow_sequence_factor.label pow_sequence_factor EOM exit 0;; esac -printf "pos_sequense_factor.value " -connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000002000" | grep pos_sequense_factor | cut -d ' ' -f2 -printf "pow_sequense_factor.value " -connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000004000" | grep pow_sequense_factor | cut -d ' ' -f2 +printf "pos_sequence_factor.value " +connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000002000" | grep pos_sequence_factor | cut -d ' ' -f2 +printf "pow_sequence_factor.value " +connectivity_tool --ip=127.0.0.1 --rpc-port=$ZANO_RPC_PORT --timeout=1000 --rpc-get-daemon-info --getinfo-flags-hex="0x0000000000004000" | grep pow_sequence_factor | cut -d ' ' -f2 diff --git a/utils/update_alert.json b/utils/update_alert.json index 57641f30..6766e765 100644 --- a/utils/update_alert.json +++ b/utils/update_alert.json @@ -2,10 +2,10 @@ "maj":1, "min":0, "rev":0, - "build":8, + "build":26, "cs":[ { - "build":7, + "build":28, "mode":3 } ]