From 5f56d146c25c6db4cc7ef6a1b20dd3590f9c9c23 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 24 Mar 2025 01:32:01 +0300 Subject: [PATCH 1/8] fixed an issue in pop_asset_info() with deregistering asset after HF5 during chain switching --- src/currency_core/blockchain_storage.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 31b607ca..a033e3de 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -4232,7 +4232,6 @@ bool blockchain_storage::pop_asset_info(const asset_descriptor_operation& ado, c if (is_hardfork_active_for_height(ZANO_HARDFORK_05, height)) { // NEW HF5 handling - assets_container::t_value_type local_asset_hist = *asset_history_ptr; asset_descriptor_operation& last_ado = local_asset_hist.back(); // above we made sure that the history isn't empty CHECK_AND_ASSERT_MES(last_ado.opt_descriptor.has_value(), false, "opt_descriptor is missing during asset pop, op: " << (int)ado.operation_type); asset_descriptor_base& last_adb = last_ado.opt_descriptor.get(); From dc5b5f72a31bfdc8d89693ad4276e5ddf60d3c6f Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 24 Mar 2025 03:09:29 +0400 Subject: [PATCH 2/8] moved to v3 db --- src/common/db_backend_selector.cpp | 13 ++++++++++++ src/common/db_backend_selector.h | 3 +++ src/currency_core/blockchain_storage.cpp | 27 ++++++++++++++++++------ src/currency_core/blockchain_storage.h | 2 +- src/currency_core/currency_config.h | 6 +++++- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/common/db_backend_selector.cpp b/src/common/db_backend_selector.cpp index 9c7917ca..33f1382f 100644 --- a/src/common/db_backend_selector.cpp +++ b/src/common/db_backend_selector.cpp @@ -67,6 +67,19 @@ namespace db return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX; } + std::string db_backend_selector::get_db_folder_path_old_1() const + { + //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); + return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1; + } + + std::string db_backend_selector::get_db_folder_path_old_2() const + { + //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); + return m_config_folder + ("/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX) + get_engine_name() + CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2; + } + + std::string db_backend_selector::get_temp_db_folder_path() const { //CHECK_AND_ASSERT_THROW_MES(m_engine_type != db_none, "db_backend_selector was no inited"); diff --git a/src/common/db_backend_selector.h b/src/common/db_backend_selector.h index b9d811b8..54c4a10a 100644 --- a/src/common/db_backend_selector.h +++ b/src/common/db_backend_selector.h @@ -34,6 +34,9 @@ namespace tools std::shared_ptr create_backend(); + std::string get_db_folder_path_old_1() const; + std::string get_db_folder_path_old_2() const; + private: db_engine_type m_engine_type; std::string m_config_folder; diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index a033e3de..6c541583 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -220,6 +220,23 @@ void blockchain_storage::set_db_l2_cache_size(uint64_t ceched_elements) const m_db_assets.set_cache_size(ceched_elements); m_db_addr_to_alias.set_cache_size(ceched_elements); } + +void remove_old_db(const std::string old_db_folder_path) +{ + try { + if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path))) + { + LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0); + boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path)); + } + } + catch (...) + { + + } +} + + bool blockchain_storage::init(const std::string& config_folder, const boost::program_options::variables_map& vm) { // CRITICAL_REGION_LOCAL(m_read_lock); @@ -251,12 +268,10 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro m_config_folder = config_folder; // remove old incompatible DB - const std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD; - if (boost::filesystem::exists(epee::string_encoding::utf8_to_wstring(old_db_folder_path))) - { - LOG_PRINT_YELLOW("Removing old DB in " << old_db_folder_path << "...", LOG_LEVEL_0); - boost::filesystem::remove_all(epee::string_encoding::utf8_to_wstring(old_db_folder_path)); - } + std::string old_db_folder_path = m_config_folder + "/" CURRENCY_BLOCKCHAINDATA_FOLDERNAME_OLD; + remove_old_db(old_db_folder_path); + remove_old_db(dbbs.get_db_folder_path_old_1()); + remove_old_db(dbbs.get_db_folder_path_old_2()); const std::string db_folder_path = dbbs.get_db_folder_path(); LOG_PRINT_L0("Loading blockchain from " << db_folder_path); diff --git a/src/currency_core/blockchain_storage.h b/src/currency_core/blockchain_storage.h index 40860074..035fd400 100644 --- a/src/currency_core/blockchain_storage.h +++ b/src/currency_core/blockchain_storage.h @@ -722,7 +722,7 @@ namespace currency bool is_output_allowed_for_input(const txout_to_key& out_v, const txin_v& in_v) const; bool is_output_allowed_for_input(const txout_htlc& out_v, const txin_v& in_v, uint64_t top_minus_source_height) const; bool is_output_allowed_for_input(const tx_out_zarcanum& out, const txin_v& in_v) const; - + void remove_old_dbs(); //POS diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index bf0b901b..5ab8c014 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -232,7 +232,11 @@ #define CURRENCY_POOLDATA_FOLDERNAME_PREFIX "poolstate_" #define CURRENCY_POOLDATA_FOLDERNAME_SUFFIX "_v1" #define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_PREFIX "blockchain_" -#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v2" +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX "_v3" + +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_1 "_v1" +#define CURRENCY_BLOCKCHAINDATA_FOLDERNAME_SUFFIX_OLD_2 "_v2" + #define P2P_NET_DATA_FILENAME "p2pstate.bin" #define MINER_CONFIG_FILENAME "miner_conf.json" From 5984b47ad97c92ed0aacedf944fde075008dc104 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 24 Mar 2025 02:27:57 +0300 Subject: [PATCH 3/8] === version bump: 2.1.2.394 -> 2.1.3.395 === --- 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 5c997eae..8caa9a13 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "2" #define PROJECT_MINOR_VERSION "1" -#define PROJECT_REVISION "2" +#define PROJECT_REVISION "3" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 394 +#define PROJECT_VERSION_BUILD_NO 395 #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 ef9a0ab5fd2ce62ca8e5b1b78ab4133970f2fea4 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 24 Mar 2025 07:21:52 +0400 Subject: [PATCH 4/8] added ip blacklisting on unexpected block id --- 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 94b77505..02e126e9 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -561,6 +561,7 @@ namespace currency LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_GET_OBJECTS: block with id=" << epst::pod_to_hex(get_blob_hash(block_entry.block)) << " wasn't requested, dropping connection"); m_p2p->drop_connection(context); + m_p2p->add_ip_fail(context.m_remote_ip); return 1; } if(b.tx_hashes.size() != block_entry.txs.size()) From 695fc1dd4e988812bb986abb21152f8c5238d8a2 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 24 Mar 2025 07:05:25 +0300 Subject: [PATCH 5/8] predownload updated to height 3083770 --- 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 c44649a0..3a973917 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_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3030303.pak", "937c80a2a212e70f0b5c9001159f983db72dd0cf7a6d55d72bcd9d6998874ffb", 7809031729, 12347842560 }; - static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3030303.pak", "227f20b3998a8622363ebd4b7189e73caac21cfc17fa8544a3fa9d593e41709d", 9450752666, 12102598656 }; + static constexpr pre_download_entry c_pre_download_mdbx = { "https://f005.backblazeb2.com/file/zano-predownload/zano_mdbx_95_3083770.pak", "e7cb7b5e1560c3a7615604880feda9df37636be83264a5afff01f44b5f824cc8", 8357805798, 12884705280 }; + static constexpr pre_download_entry c_pre_download_lmdb = { "https://f005.backblazeb2.com/file/zano-predownload/zano_lmdb_95_3083770.pak", "685db01e1a4c827d20e777563009f771be593fe80cc32b8a4dfe2711e6a2b2f8", 10070627937, 12842385408 }; #else static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 }; static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 }; From f0f54efe1734004e674903983ca18fa4d43afdc2 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 24 Mar 2025 07:07:18 +0300 Subject: [PATCH 6/8] === version bump: 2.1.3.395 -> 2.1.4.396 === --- 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 8caa9a13..d36830c9 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "2" #define PROJECT_MINOR_VERSION "1" -#define PROJECT_REVISION "3" +#define PROJECT_REVISION "4" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 395 +#define PROJECT_VERSION_BUILD_NO 396 #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 39e36cf8c8dc50c697f0f164bb93c94325f52189 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 24 Mar 2025 08:52:14 +0400 Subject: [PATCH 7/8] p2pstate reset --- src/p2p/net_node.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index a238f63f..6cb58abb 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -34,7 +34,8 @@ using namespace epee; #define LOG_DEFAULT_CHANNEL "p2p" ENABLE_CHANNEL_BY_DEFAULT(LOG_DEFAULT_CHANNEL); -#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+13) + +#define CURRENT_P2P_STORAGE_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+14) #define P2P_SERVER_DEFAULT_THREADS_NUM 10 From 3917d95019f89c3681667d809754536834ab1a03 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 24 Mar 2025 19:58:16 +0300 Subject: [PATCH 8/8] === version bump: 2.1.4.396 -> 2.1.5.397 === --- 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 d36830c9..90aeb815 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "2" #define PROJECT_MINOR_VERSION "1" -#define PROJECT_REVISION "4" +#define PROJECT_REVISION "5" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 396 +#define PROJECT_VERSION_BUILD_NO 397 #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 "]"