From 05041a4572bf125325764dc11f04ce8efcc1388f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 28 Nov 2024 13:22:47 +0300 Subject: [PATCH] fix: force ehf signal db update --- src/evo/mnhftx.cpp | 19 +++++++++++++++++++ src/evo/mnhftx.h | 2 ++ src/init.cpp | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/src/evo/mnhftx.cpp b/src/evo/mnhftx.cpp index 0a381cd44b..618a5a640a 100644 --- a/src/evo/mnhftx.cpp +++ b/src/evo/mnhftx.cpp @@ -375,6 +375,25 @@ void CMNHFManager::ConnectManagers(gsl::not_null chainman, g m_qman = qman; } +bool CMNHFManager::ForceSignalDBUpdate() +{ + // force ehf signals db update + auto dbTx = m_evoDb.BeginTransaction(); + + const bool last_legacy = bls::bls_legacy_scheme.load(); + bls::bls_legacy_scheme.store(false); + GetSignalsStage(m_chainman->ActiveChainstate().m_chain.Tip()); + bls::bls_legacy_scheme.store(last_legacy); + + dbTx->Commit(); + // flush it to disk + if (!m_evoDb.CommitRootTransaction()) { + LogPrintf("CMNHFManager::%s -- failed to commit to evoDB\n", __func__); + return false; + } + return true; +} + std::string MNHFTx::ToString() const { return strprintf("MNHFTx(versionBit=%d, quorumHash=%s, sig=%s)", diff --git a/src/evo/mnhftx.h b/src/evo/mnhftx.h index eb92f1db82..4609d4d762 100644 --- a/src/evo/mnhftx.h +++ b/src/evo/mnhftx.h @@ -155,6 +155,8 @@ public: */ void DisconnectManagers() { m_chainman = nullptr; m_qman = nullptr; }; + bool ForceSignalDBUpdate(); + private: void AddToCache(const Signals& signals, const CBlockIndex* const pindex); diff --git a/src/init.cpp b/src/init.cpp index 8967159b7b..b193fc7211 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2058,6 +2058,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) strLoadError = _("Error upgrading evo database"); break; } + if (!node.mnhf_manager->ForceSignalDBUpdate()) { + strLoadError = _("Error upgrading evo database for EHF"); + break; + } for (CChainState* chainstate : chainman.GetAll()) { if (!is_coinsview_empty(chainstate)) {