diff --git a/README.md b/README.md index 2d2950cb..13558e5f 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ Be sure to clone the repository properly:\ ### Dependencies | component / version | minimum
(not recommended but may work) | recommended | most recent of what we have ever tested | |--|--|--|--| -| gcc (Linux) | 5.4.0 | 7.4.0 | 8.3.0 | +| gcc (Linux) | 5.4.0 | 7.5.0 | 8.3.0 | | llvm/clang (Linux) | UNKNOWN | 7.0.1 | 8.0.0 | -| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2015 (14.0 update 1) | 2017 (15.9.0) | 2019 | +| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2015 (14.0 update 1) | 2017 (15.9.0) | 2022 (17.4.2) | | [XCode](https://developer.apple.com/downloads/) (macOS) | 9.2 | 12.3 | 12.3 | -| [CMake](https://cmake.org/download/) | 2.8.6 | 3.15.5 | 3.20 | +| [CMake](https://cmake.org/download/) | 2.8.6 | 3.15.5 | 3.26.3 | | [Boost](https://www.boost.org/users/download/) | 1.70 | 1.70 | 1.76 | | [OpenSSL](https://www.openssl.org/source/) [(win)](https://slproweb.com/products/Win32OpenSSL.html) | - | 1.1.1n | 1.1.1n | | [Qt](https://download.qt.io/archive/qt/) (*only for GUI*) | 5.8.0 | 5.11.2 | 5.15.2 | @@ -45,7 +45,7 @@ Recommended OS version: Ubuntu 18.04 LTS. 2. Download and build Boost curl -OL https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.bz2 - tar -xjf boost_1_70_0.tar.bz2 + echo "430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778 boost_1_70_0.tar.bz2" | shasum -c && tar -xjf boost_1_70_0.tar.bz2 cd boost_1_70_0 ./bootstrap.sh --with-libraries=system,filesystem,thread,date_time,chrono,regex,serialization,atomic,program_options,locale,timer,log ./b2 @@ -63,10 +63,10 @@ Recommended OS version: Ubuntu 18.04 LTS. 4. Install OpenSSL - We recommend installing OpenSSL v1.1.1n locally unless you would like to use the same version system-wide. + We recommend installing OpenSSL v1.1.1n locally unless you would like to use the same version system-wide. Adjust the local path `/home/user/openssl` in the commands below according to your needs. curl -OL https://www.openssl.org/source/openssl-1.1.1n.tar.gz - tar xaf openssl-1.1.1n.tar.gz + echo "40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a openssl-1.1.1n.tar.gz" | shasum -c && tar xaf openssl-1.1.1n.tar.gz cd openssl-1.1.1n/ ./config --prefix=/home/user/openssl --openssldir=/home/user/openssl shared zlib make diff --git a/src/common/pre_download.h b/src/common/pre_download.h index 3a3e8666..373c0bd4 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 = { "http://95.217.42.247/pre-download/zano_mdbx_95_1569000.pak", "c2aff6fb65c2d7a40492738c75d1d04f2f35388d3c1a664aeb77420f2d90d644", 1740147926, 3221176320 }; - static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.42.247/pre-download/zano_lmdb_95_1569000.pak", "f673636638b666b36c976168a3c64b2fd1fcf071c41b5d9cf01ed58a5924f80a", 2244905636, 3216977920 }; + static constexpr pre_download_entry c_pre_download_mdbx = { "http://95.217.42.247/pre-download/zano_mdbx_95_2200000.pak", "c3bd64c62495c3f266759750952519f13f32fc161b59547beaa8202b6e26d516", 2628767033, 5100195840 }; + static constexpr pre_download_entry c_pre_download_lmdb = { "http://95.217.42.247/pre-download/zano_lmdb_95_2200000.pak", "fcbf0ab3b23836e1a51fa675e719900fb94110cfb74790b3323cebce7fb9f5bd", 3426025872, 4954472448 }; #else static constexpr pre_download_entry c_pre_download_mdbx = { "", "", 0, 0 }; static constexpr pre_download_entry c_pre_download_lmdb = { "", "", 0, 0 }; diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 9ab636f5..dd22e385 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -3919,9 +3919,6 @@ bool blockchain_storage::add_transaction_from_block(const transaction& tx, const if (need_to_profile && mixins_count > 0) { m_performance_data.tx_mixin_count.push(mixins_count); -#ifdef _DEBUG - LOG_PRINT_L0("[TX_MIXINS]: " << mixins_count); -#endif } //check if there is already transaction with this hash diff --git a/src/currency_core/checkpoints_create.h b/src/currency_core/checkpoints_create.h index e0152685..49d10037 100644 --- a/src/currency_core/checkpoints_create.h +++ b/src/currency_core/checkpoints_create.h @@ -26,6 +26,7 @@ namespace currency ADD_CHECKPOINT(900000, "2205b73cd79d4937b087b02a8b001171b73c34464bc4a952834eaf7c2bd63e86"); ADD_CHECKPOINT(1161000, "96990d851b484e30190678756ba2a4d3a2f92b987e2470728ac1e38b2bf35908"); ADD_CHECKPOINT(1480000, "5dd3381eec35e8b4eba4518bfd8eec682a4292761d92218fd59b9f0ffedad3fe"); + ADD_CHECKPOINT(2000000, "7b6698a8cc279aa78d6263f01fef186bd16f5b1ea263a7f4714abc1d506b9cb3"); #endif return true; diff --git a/src/currency_core/currency_core.cpp b/src/currency_core/currency_core.cpp index cd0b5d85..fde150f9 100644 --- a/src/currency_core/currency_core.cpp +++ b/src/currency_core/currency_core.cpp @@ -499,23 +499,24 @@ namespace currency //----------------------------------------------------------------------------------------------- bool core::add_new_block(const block& b, block_verification_context& bvc) { + uint64_t h = m_blockchain_storage.get_top_block_height(); + if (m_stop_after_height != 0 && h >= m_stop_after_height) + { + LOG_PRINT_YELLOW("Blockchain top block height is " << h << ", the daemon will now stop as requested", LOG_LEVEL_0); + if (m_critical_error_handler) + return m_critical_error_handler->on_immediate_stop_requested(); + return false; + } + bool r = m_blockchain_storage.add_new_block(b, bvc); if (r && bvc.m_added_to_main_chain) { - uint64_t h = get_block_height(b); + h = get_block_height(b); auto& crc = m_blockchain_storage.get_core_runtime_config(); if (h == crc.hard_fork_01_starts_after_height + 1) { LOG_PRINT_GREEN("Hardfork 1 activated at height " << h, LOG_LEVEL_0); } else if (h == crc.hard_fork_02_starts_after_height + 1) { LOG_PRINT_GREEN("Hardfork 2 activated at height " << h, LOG_LEVEL_0); } - - if (h == m_stop_after_height) - { - LOG_PRINT_YELLOW("Reached block " << h << ", the daemon will now stop as requested", LOG_LEVEL_0); - if (m_critical_error_handler) - return m_critical_error_handler->on_immediate_stop_requested(); - return false; - } } return r; } diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index fe224894..047a4602 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit fe224894ddab077d94741a0062500b7306834959 +Subproject commit 047a4602748e0d3e40456f9d2fc2eeef1bc89b06 diff --git a/src/version.h.in b/src/version.h.in index 50c2fe88..9b0be01a 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -5,9 +5,9 @@ #define PROJECT_MAJOR_VERSION "1" #define PROJECT_MINOR_VERSION "5" -#define PROJECT_REVISION "0" +#define PROJECT_REVISION "2" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 144 +#define PROJECT_VERSION_BUILD_NO 150 #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/wallet2.cpp b/src/wallet/wallet2.cpp index 862b1022..9fe9323c 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3521,6 +3521,7 @@ bool wallet2::try_mint_pos() //------------------------------------------------------------------ bool wallet2::try_mint_pos(const currency::account_public_address& miner_address) { + TIME_MEASURE_START_MS(mining_duration_ms); mining_context ctx = AUTO_VAL_INIT(ctx); WLT_LOG_L1("Starting PoS mining iteration"); fill_mining_context(ctx); @@ -3550,8 +3551,9 @@ bool wallet2::try_mint_pos(const currency::account_public_address& miner_address { build_minted_block(ctx.sp, ctx.rsp, miner_address); } + TIME_MEASURE_FINISH_MS(mining_duration_ms); - WLT_LOG_L0("PoS mining: " << ctx.rsp.iterations_processed << " iterations finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << print_money_brief(pos_entries_amount)); + WLT_LOG_L0("PoS mining: " << ctx.rsp.iterations_processed << " iterations finished (" << std::fixed << std::setprecision(2) << (mining_duration_ms / 1000.0f) << "s), status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << print_money_brief(pos_entries_amount)); return true; } @@ -3594,6 +3596,16 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& tmpl_req.pos_index = req.pos_entries[rsp.index].index; tmpl_req.extra_text = m_miner_text_info; tmpl_req.stake_unlock_time = req.pos_entries[rsp.index].stake_unlock_time; + + // mark stake source as spent and make sure it will be restored in case of error + const std::vector stake_transfer_idx_vec{ req.pos_entries[rsp.index].wallet_index }; + mark_transfers_as_spent(stake_transfer_idx_vec, "stake source"); + bool gracefull_leaving = false; + auto stake_transfer_spent_flag_restorer = epee::misc_utils::create_scope_leave_handler([&](){ + if (!gracefull_leaving) + clear_transfers_from_flag(stake_transfer_idx_vec, WALLET_TRANSFER_DETAIL_FLAG_SPENT, "stake source"); + }); + //generate packing tx transaction pack_tx = AUTO_VAL_INIT(pack_tx); if (generate_packing_transaction_if_needed(pack_tx, 0)) @@ -3641,7 +3653,7 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& keys_ptrs); WLT_CHECK_AND_ASSERT_MES(res, false, "Failed to prepare_and_sign_pos_block"); - WLT_LOG_GREEN("Block constructed <" << get_block_hash(b) << ">, sending to core...", LOG_LEVEL_0); + WLT_LOG_GREEN("Block " << get_block_hash(b) << " @ " << get_block_height(b) << " has been constructed, sending to core...", LOG_LEVEL_0); currency::COMMAND_RPC_SUBMITBLOCK2::request subm_req = AUTO_VAL_INIT(subm_req); currency::COMMAND_RPC_SUBMITBLOCK2::response subm_rsp = AUTO_VAL_INIT(subm_rsp); @@ -3658,6 +3670,7 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request& WLT_LOG_GREEN("POS block generated and accepted, congrats!", LOG_LEVEL_0); m_wcallback->on_pos_block_found(b); + gracefull_leaving = true; // to prevent source transfer flags be cleared in scope leave handler return true; } //---------------------------------------------------------------------------------------------------- diff --git a/tests/core_tests/pos_validation.cpp b/tests/core_tests/pos_validation.cpp index 2fb6de17..1593d270 100644 --- a/tests/core_tests/pos_validation.cpp +++ b/tests/core_tests/pos_validation.cpp @@ -1029,6 +1029,12 @@ bool pos_minting_tx_packing::configure_core(currency::core& c, size_t ev_index, bool pos_minting_tx_packing::pos_minting_tx_packing::generate(std::vector& events) const { + // + // THIS TEST IS ONLY FOR PRE-ZARCANUM WALLET + // PLEASE, reject all changes made in master/release2/develop branches and use the version from cryptoassets/multiassets + // -- sowle + // + bool r = false; m_accounts.resize(TOTAL_ACCS_COUNT); account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate(); @@ -1039,12 +1045,12 @@ bool pos_minting_tx_packing::pos_minting_tx_packing::generate(std::vectorset_pos_mint_packing_size(m_pos_mint_packing_size); + alice_wlt->set_pos_mint_packing_size(100); // no coinbase tx outputs should be packed r = alice_wlt->try_mint_pos(); @@ -1096,7 +1102,7 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v m_alice_start_amount + CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 1), // total true, UINT64_MAX, - m_alice_start_amount // unlocked (one output with amount == CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size was spent as stake) + UINT64_MAX //m_alice_start_amount // unlocked (one output with amount == CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size was spent as stake) ), false, ""); r = mine_next_pow_blocks_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c, WALLET_DEFAULT_TX_SPENDABLE_AGE); @@ -1109,7 +1115,8 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v m_alice_start_amount + CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 1) // unlocked ), false, ""); - // coinbase tx outputs should be packed now, there's enough coinbase outputs (> m_pos_mint_packing_size) + // coinbase tx outputs still should NOT be packed now (it's only possible with the stake) + alice_wlt->set_pos_mint_packing_size(10); r = alice_wlt->try_mint_pos(); CHECK_AND_ASSERT_MES(r, false, "try_mint_pos failed"); @@ -1117,11 +1124,10 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v m_alice_start_amount + CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 2), // total (+1 one block reward) true, UINT64_MAX, - // CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size locked for stake - // CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 1) locked for packing tx - m_alice_start_amount + CURRENCY_BLOCK_REWARD - CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 1) // unlocked + m_alice_start_amount + CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 0) // unlocked ), false, ""); + alice_wlt->set_pos_mint_packing_size(8); r = alice_wlt->try_mint_pos(); CHECK_AND_ASSERT_MES(r, false, "try_mint_pos failed"); @@ -1129,8 +1135,7 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v m_alice_start_amount + CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 3), // total (+1 one block reward) true, UINT64_MAX, - // CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size locked for stake - m_alice_start_amount + CURRENCY_BLOCK_REWARD - CURRENCY_BLOCK_REWARD * (m_pos_mint_packing_size + 1) - CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size // unlocked + 0 // unlocked ), false, ""); return true; diff --git a/utils/build_mail.py b/utils/build_mail.py new file mode 100644 index 00000000..4b547204 --- /dev/null +++ b/utils/build_mail.py @@ -0,0 +1,36 @@ +import sys +import os +import smtplib +from email.message import EmailMessage + +def getenv(e): + t = os.getenv(e) + if t == None: + print("Error: environment variable " + e + " was not set") + exit(1) + return t + +zs_from = getenv("ZANO_SMTP_FROM") +zs_addr = getenv("ZANO_SMTP_ADDR") +zs_port = getenv("ZANO_SMTP_PORT") +zs_user = getenv("ZANO_SMTP_USER") +zs_pass = getenv("ZANO_SMTP_PASS") + +if len(sys.argv) != 4: + print("Usage: " + sys.argv[0] + " ") + exit(1) + +msg = EmailMessage() +msg['Subject'] = sys.argv[1] +msg['From'] = zs_from +msg['To'] = sys.argv[2] +msg.add_header('Content-Type','text/html') +msg.set_payload(sys.argv[3]) + +s = smtplib.SMTP(zs_addr, zs_port) +s.starttls() +s.login(zs_user, zs_pass) +s.send_message(msg) +s.quit() + +print("e-mail sent.") diff --git a/utils/build_script_linux.sh b/utils/build_script_linux.sh index ffc5914a..96bf6ea0 100755 --- a/utils/build_script_linux.sh +++ b/utils/build_script_linux.sh @@ -142,6 +142,6 @@ sha256: $checksum" echo "$mail_msg" -echo "$mail_msg" | mail -s "Zano linux-x64 ${build_prefix_label}${testnet_label}${copy_qt_dev_tools_label}build $version_str" ${emails} +python3 ../../utils/build_mail.py "Zano linux-x64 ${build_prefix_label}${testnet_label}${copy_qt_dev_tools_label}build $version_str" "${emails}" "$mail_msg" exit 0 diff --git a/utils/build_script_linux_appimage.sh b/utils/build_script_linux_appimage.sh index f6ee4a70..dad4b69e 100755 --- a/utils/build_script_linux_appimage.sh +++ b/utils/build_script_linux_appimage.sh @@ -154,6 +154,6 @@ sha256: $checksum" echo "$mail_msg" -echo "$mail_msg" | mail -s "Zano linux-x64 ${build_prefix_label}${testnet_label}${copy_qt_dev_tools_label}build $version_str" ${emails} +python3 ../../utils/build_mail.py "Zano linux-x64 ${build_prefix_label}${testnet_label}${copy_qt_dev_tools_label}build $version_str" "${emails}" "$mail_msg" -exit 0 \ No newline at end of file +exit 0 diff --git a/utils/build_script_mac_osx.sh b/utils/build_script_mac_osx.sh index 580a0914..c26b8da9 100755 --- a/utils/build_script_mac_osx.sh +++ b/utils/build_script_mac_osx.sh @@ -148,13 +148,17 @@ echo "Build success" echo "############### Uploading... ################" -package_filepath=$package_filename +package_filepath="$(pwd)/$package_filename" -scp $package_filepath zano_build_server:/var/www/html/builds/ +#scp $package_filepath zano_build_server:/var/www/html/builds/ +source ../../../utils/macosx_build_uploader.sh +pushd . +upload_build $package_filepath if [ $? -ne 0 ]; then echo "Failed to upload to remote server" exit 1 fi +popd read checksum <<< $( shasum -a 256 $package_filepath | awk '/^/ { print $1 }' ) @@ -165,8 +169,7 @@ sha256: $checksum" echo "$mail_msg" -echo "$mail_msg" | mail -s "Zano macOS-x64 ${build_prefix_label}${testnet_label}build $version_str" ${emails} - +python3 ../../../utils/build_mail.py "Zano macOS-x64 ${build_prefix_label}${testnet_label}build $version_str" "${emails}" "$mail_msg" ###################### # notarization diff --git a/utils/macosx_build_uploader.sh b/utils/macosx_build_uploader.sh new file mode 100644 index 00000000..acd23652 --- /dev/null +++ b/utils/macosx_build_uploader.sh @@ -0,0 +1,51 @@ +set +e +curr_path=${BASH_SOURCE%/*} + +function upload_build() # $1 - path to the file to be uploaded +{ + if [ -z "$1" ] + then + echo "ERROR: upload_build is called with no or invalid parameters" + return 1 + fi + + # check if the directory contains files + #if [ -n "$(ls -A "$ZANO_BLD_UPL_DIR" 2>/dev/null)" ] + #then + # echo "ERROR: uploading folder contains files" + # return 1 + #fi + + cd "$ZANO_BLD_UPL_DIR" || return 2 + rm -rf ./* || return 3 + #popd || return 4 + + touch WAIT || return 5 + cp $1 . || return 6 + rm WAIT || return 7 + + counter=0 + while [ ! -f DONE ] + do + if [ "$counter" -ge 150 ] + then + echo "ERROR: uploading is taking longer than expected" + touch STOP + return 8 + fi + sleep 2 + echo "waiting..." + counter=$((counter + 1)) + done + + rc=$(