From 182161d916fadb8c90d4e1755a929b06eb292373 Mon Sep 17 00:00:00 2001 From: div72 <60045611+div72@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:28:50 +0300 Subject: [PATCH 1/6] banman: use GetPerformanceCounter instead of GetRandBytes Rationale: BanMan does a flush on shutdown which calls GetRandBytes in order to get a temporary filename to write to. Since this happens at shutdown the RNGState powering GetRandBytes could already be destructed which can lead to a segfault. --- src/addrdb.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/addrdb.cpp b/src/addrdb.cpp index c40d55a17c..c16078c41a 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -40,9 +40,7 @@ template bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data& data) { // Generate random temporary filename - unsigned short randv = 0; - GetRandBytes((unsigned char*)&randv, sizeof(randv)); - std::string tmpfn = strprintf("%s.%04x", prefix, randv); + std::string tmpfn = strprintf("%s.%" PRIx64, prefix, GetPerformanceCounter()); // open temp output file, and associate with CAutoFile fs::path pathTmp = GetDataDir() / tmpfn; From cc907eb4ac71a3cf9b7ca6d1b9d94ea8e7fd8a82 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Mon, 27 Mar 2023 18:24:14 -0400 Subject: [PATCH 2/6] Use std::filesystem for BackupConfigFile and BackupWallet when Boost ver = 1.74 Note that Boost 1.74 has a known bug that causes copy_file to misbehave when use across filesystem boundaries (i.e. if the walletbackups directory is actually a symlink to somewhere else). This commit is a workaround to use std::filesystem instead for this specific operation if the wallet is linked against Boost 1.74. This can be removed when we eventually migrate to std::filesystem from boost::filesystem. --- src/gridcoin/backup.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gridcoin/backup.cpp b/src/gridcoin/backup.cpp index c29b12d1db..de5456fb26 100644 --- a/src/gridcoin/backup.cpp +++ b/src/gridcoin/backup.cpp @@ -8,6 +8,7 @@ #include "wallet/wallet.h" #include "util.h" #include "util/time.h" +#include #include @@ -117,11 +118,16 @@ bool GRC::BackupConfigFile(const std::string& strDest) fs::create_directories(ConfigTarget.parent_path()); try { - #if BOOST_VERSION >= 107400 - fs::copy_file(ConfigSource, ConfigTarget, fs::copy_options::overwrite_existing); - #else - fs::copy_file(ConfigSource, ConfigTarget, fs::copy_option::overwrite_if_exists); - #endif +#if BOOST_VERSION > 107400 + fs::copy_file(ConfigSource, ConfigTarget, fs::copy_options::overwrite_existing); +#elif BOOST_VERSION == 107400 + // This is a workaround for Boost 1.74's problem with copy_file when the target is inside a symlink. + std::filesystem::path StdConfigSource = ConfigSource.wstring(); + std::filesystem::path StdConfigTarget = strDest; + std::filesystem::copy_file(StdConfigSource, StdConfigTarget, std::filesystem::copy_options::overwrite_existing); +#else + fs::copy_file(ConfigSource, ConfigTarget, fs::copy_option::overwrite_if_exists); +#endif LogPrintf("BackupConfigFile: Copied gridcoinresearch.conf to %s", ConfigTarget.string()); return true; } @@ -156,8 +162,13 @@ bool GRC::BackupWallet(const CWallet& wallet, const std::string& strDest) WalletTarget /= wallet.strWalletFile; try { -#if BOOST_VERSION >= 107400 +#if BOOST_VERSION > 107400 fs::copy_file(WalletSource, WalletTarget, fs::copy_options::overwrite_existing); +#elif BOOST_VERSION == 107400 + // This is a workaround for Boost 1.74's problem with copy_file when the target is inside a symlink. + std::filesystem::path StdWalletSource = WalletSource.wstring(); + std::filesystem::path StdWalletTarget = strDest; + std::filesystem::copy_file(StdWalletSource, StdWalletTarget, std::filesystem::copy_options::overwrite_existing); #else fs::copy_file(WalletSource, WalletTarget, fs::copy_option::overwrite_if_exists); #endif From c443072677b9581f36a8b75ce9e548dc27b7a0c6 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Thu, 30 Mar 2023 17:48:52 -0400 Subject: [PATCH 3/6] Add one minute QTimer to update beacon age/expiration in tooltip --- src/qt/bitcoingui.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 7a382f855d..becaeb4abd 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -828,6 +828,15 @@ void BitcoinGUI::setResearcherModel(ResearcherModel *researcherModel) updateBeaconIcon(); connect(researcherModel, &ResearcherModel::beaconChanged, this, &BitcoinGUI::updateBeaconIcon); + + QTimer *beacon_status_update_timer = new QTimer(this); + + // This timer trigger is to support updating the beacon age and time to expiration in the tooltip. + // Once a minute is sufficient. + connect(beacon_status_update_timer, &QTimer::timeout, this, &BitcoinGUI::updateBeaconIcon); + + // Check every minute + beacon_status_update_timer->start(1000 * 60); } void BitcoinGUI::setMRCModel(MRCModel *mrcModel) From 888e23f89c4ffc4440898da1bc62293837c2d78b Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Fri, 31 Mar 2023 16:54:47 -0400 Subject: [PATCH 4/6] Detect and prompt for shutdown of Gridcoin wallet during install for Windows This commit introduces the use of ExecWait in combination with tasklist and find to detect a running Gridcoin wallet, either GUI or daemon, and prompt to shut it down before installation proceeds. --- share/setup.nsi.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/share/setup.nsi.in b/share/setup.nsi.in index eef98f6810..a3f070dfca 100644 --- a/share/setup.nsi.in +++ b/share/setup.nsi.in @@ -168,6 +168,16 @@ Function .onInit Abort ${EndIf} !endif + loop: + ExpandEnvStrings $1 "%COMSPEC%" + ExecWait '$1 /C "$\"$SYSDIR\tasklist.exe$\" /NH /FI $\"IMAGENAME eq @GRIDCOIN_GUI_NAME@@EXEEXT@$\" | $\"$SYSDIR\find.exe$\" /I $\"@GRIDCOIN_GUI_NAME@@EXEEXT@$\""' $0 + StrCmp $0 0 0 notRunning_gui + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION 'The Gridcoin wallet (@GRIDCOIN_GUI_NAME@@EXEEXT@) is running. Please close before continuing.' IDOK loop IDCANCEL end + notRunning_gui: + ExecWait '$1 /C "$\"$SYSDIR\tasklist.exe$\" /NH /FI $\"IMAGENAME eq @GRIDCOIN_DAEMON_NAME@@EXEEXT@$\" | $\"$SYSDIR\find.exe$\" /I $\"@GRIDCOIN_DAEMON_NAME@@EXEEXT@$\""' $0 + StrCmp $0 0 0 notRunning_daemon + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION 'The Gridcoin wallet daemon (@GRIDCOIN_DAEMON_NAME@@EXEEXT@) is running. Please close before continuing.' IDOK loop IDCANCEL end + notRunning_daemon: ; Check for HKCU Path registry and prompt for uninstallation if found ReadRegStr $0 HKCU "${REGKEY}" "Path" ${IfThen} $0 == "" ${|} Return ${|} @@ -184,6 +194,8 @@ Function .onInit ${EndIf} ExecWait "$1 _?=$0" $0 ${IfThen} $0 != 0 ${|} Abort ${|} + end: + Abort FunctionEnd # Uninstaller functions From a65c8d8130d5d70d4b95d623b6fcffb41fbd9dcb Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Wed, 5 Apr 2023 17:11:16 -0400 Subject: [PATCH 5/6] Update changelog for 5.4.3.0 release. --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 979849b008..c353684138 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/). +## [5.4.3.0] 2023-04-05, leisure + +### Added + - install: Enhance windows installer - detect running gridcoinresearch(d).exe and ask to close before continuing #2672 (@jamescowens) + - gui: Add one minute QTimer to update beacon age/expiration in tooltip #2671 (@jamescowens) + +### Changed +none + +### Removed +none + +### Fixed + - util: Implement workaround for backupwallet to deal with Boost 1.74 regression on copy_file #2669 (@jamescowens) + - banman: use GetPerformanceCounter instead of GetRandBytes #2668 (@div72) + ## [5.4.2.0] 2023-03-26, leisure, "LaVerne" ### Added From a0a9ba896975faeb05f6032578e6fb6370eb7fd8 Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Wed, 5 Apr 2023 17:13:32 -0400 Subject: [PATCH 6/6] Increment version to 5.4.3.0 for release and update copyright year to 2023. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a91254db1a..5b123885ca 100755 --- a/configure.ac +++ b/configure.ac @@ -2,10 +2,10 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 5) define(_CLIENT_VERSION_MINOR, 4) -define(_CLIENT_VERSION_REVISION, 2) +define(_CLIENT_VERSION_REVISION, 3) define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2022) +define(_COPYRIGHT_YEAR, 2023) define(_COPYRIGHT_HOLDERS,[The %s developers]) define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Gridcoin]]) AC_INIT([Gridcoin],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/gridcoin/Gridcoin-Research/issues],[gridcoin],[https://gridcoin.us/])