From 104d496e776ccc873254a63388abd747558590de Mon Sep 17 00:00:00 2001 From: Sami Ahmed Date: Sun, 22 Mar 2026 17:59:18 -0700 Subject: [PATCH] Bump version to 5.3.5 - fix out-of-sync display for PoS chains Remove time-based sync check that showed "out of sync" when blocks were >6 hours old. For PoS chains with few stakers, blocks can be hours apart - that's idle, not out of sync. Now uses block count only. Also adds periodic UI refresh every 30s and switches cached stake weight from volatile to std::atomic. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build-all.yml | 2 +- src/clientversion.h | 2 +- src/qt/clientmodel.cpp | 14 +++++++++++--- src/qt/trianglesgui.cpp | 7 ++++--- src/version.h | 2 +- src/wallet.h | 6 +++--- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 992d493..a80f70e 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: env: - VERSION: "5.3.4" + VERSION: "5.3.5" jobs: build-windows-qt: diff --git a/src/clientversion.h b/src/clientversion.h index a6554d1..5782cf6 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -8,7 +8,7 @@ // These need to be macros, as version.cpp's and triangles-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 5 #define CLIENT_VERSION_MINOR 3 -#define CLIENT_VERSION_REVISION 4 +#define CLIENT_VERSION_REVISION 5 #define CLIENT_VERSION_BUILD 0 // Converts the parameter X to a string after macro replacement on X has been performed. diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index f67f51c..8a8ffe8 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -70,12 +70,20 @@ void ClientModel::updateTimer() int newNumBlocks = getNumBlocks(); int newNumBlocksOfPeers = getNumBlocksOfPeers(); - // Always emit during IBD so the speed/ETA display stays live - if(cachedNumBlocks != newNumBlocks || cachedNumBlocksOfPeers != newNumBlocksOfPeers - || newNumBlocks < newNumBlocksOfPeers) + // Always emit when values change or during IBD. + // Also emit every ~30 seconds even when idle so setNumBlocks() can + // re-evaluate sync status (e.g. when a new block arrives after a long gap). + static int64_t nLastEmit = 0; + int64_t nNow = GetTime(); + bool fChanged = (cachedNumBlocks != newNumBlocks || cachedNumBlocksOfPeers != newNumBlocksOfPeers); + bool fCatchingUp = (newNumBlocks < newNumBlocksOfPeers); + bool fPeriodicRefresh = (nNow - nLastEmit >= 30); + + if(fChanged || fCatchingUp || fPeriodicRefresh) { cachedNumBlocks = newNumBlocks; cachedNumBlocksOfPeers = newNumBlocksOfPeers; + nLastEmit = nNow; emit numBlocksChanged(newNumBlocks, newNumBlocksOfPeers); } diff --git a/src/qt/trianglesgui.cpp b/src/qt/trianglesgui.cpp index 01ef56d..065d2ec 100644 --- a/src/qt/trianglesgui.cpp +++ b/src/qt/trianglesgui.cpp @@ -904,9 +904,10 @@ void TrianglesGUI::setNumBlocks(int count, int nTotalBlocks) } // Set icon state: spinning if catching up, tick otherwise. - // Use a generous threshold (6 hours) for PoS chains where block intervals - // can be long during difficulty adjustment with few stakers. - if(secs < 6*60*60 && count >= nTotalBlocks) + // For PoS chains with few stakers, blocks can be hours or days apart. + // Sync status is based purely on block count - NOT block timestamp. + // A stale chain (no recent blocks) is still "synced" if we have all blocks. + if(count >= nTotalBlocks) { tooltip = tr("Up to date") + QString(".
") + tooltip; labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); diff --git a/src/version.h b/src/version.h index b124feb..79d9b55 100644 --- a/src/version.h +++ b/src/version.h @@ -53,7 +53,7 @@ static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 5 #define DISPLAY_VERSION_MINOR 3 -#define DISPLAY_VERSION_REVISION 4 +#define DISPLAY_VERSION_REVISION 5 #define DISPLAY_VERSION_BUILD 0 #endif diff --git a/src/wallet.h b/src/wallet.h index fa2dab4..f7bcf75 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -7,6 +7,7 @@ #include #include +#include #include @@ -204,9 +205,8 @@ public: bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, int64_t nFees, CTransaction& txNew, CKey& key); // Cached staking info - updated by the staking thread, read by the UI thread. - // Access is safe without locks: written atomically by the miner, read by UI for display only. - volatile uint64_t nCachedStakeWeight; - volatile int64_t nCachedStakeWeightTime; // GetTime() when last updated + std::atomic nCachedStakeWeight; + std::atomic nCachedStakeWeightTime; // GetTime() when last updated std::string SendMoney(CScript scriptPubKey, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false); std::string SendMoneyToDestination(const CTxDestination& address, int64_t nValue, std::string& sNarr, CWalletTx& wtxNew, bool fAskFee=false);