diff --git a/src/init.cpp b/src/init.cpp index deaf8d237d9ca..39f5b1bcc59a3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -104,7 +104,6 @@ #include #include #include -#include #include #include @@ -333,8 +332,8 @@ void PrepareShutdown(NodeContext& node) chainstate->ResetCoinsViews(); } } - DashChainstateSetupClose(node.chain_helper, node.cpoolman, node.dmnman, node.mnhf_manager, - llmq::quorumSnapshotManager, node.llmq_ctx, Assert(node.mempool.get())); + DashChainstateSetupClose(node.chain_helper, node.cpoolman, node.dmnman, node.mnhf_manager, node.llmq_ctx, + Assert(node.mempool.get())); node.mnhf_manager.reset(); node.evodb.reset(); } @@ -1856,7 +1855,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) node.dmnman, node.evodb, node.mnhf_manager, - llmq::quorumSnapshotManager, node.llmq_ctx, Assert(node.mempool.get()), fPruneMode, diff --git a/src/llmq/context.cpp b/src/llmq/context.cpp index 7998475868cce..876c38334f177 100644 --- a/src/llmq/context.cpp +++ b/src/llmq/context.cpp @@ -26,14 +26,15 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CDeterministicMNManager& d is_masternode{mn_activeman != nullptr}, bls_worker{std::make_shared()}, dkg_debugman{std::make_unique()}, - quorum_block_processor{std::make_unique(chainman.ActiveChainstate(), dmnman, evo_db, - *llmq::quorumSnapshotManager)}, + qsnapman{std::make_unique(evo_db)}, + quorum_block_processor{ + std::make_unique(chainman.ActiveChainstate(), dmnman, evo_db, *qsnapman)}, qdkgsman{std::make_unique(*bls_worker, chainman.ActiveChainstate(), dmnman, *dkg_debugman, - mn_metaman, *quorum_block_processor, *llmq::quorumSnapshotManager, - mn_activeman, sporkman, unit_tests, wipe)}, + mn_metaman, *quorum_block_processor, *qsnapman, mn_activeman, + sporkman, unit_tests, wipe)}, qman{std::make_unique(*bls_worker, chainman.ActiveChainstate(), dmnman, *qdkgsman, evo_db, - *quorum_block_processor, *llmq::quorumSnapshotManager, mn_activeman, - mn_sync, sporkman, unit_tests, wipe)}, + *quorum_block_processor, *qsnapman, mn_activeman, mn_sync, sporkman, + unit_tests, wipe)}, sigman{std::make_unique(mn_activeman, chainman.ActiveChainstate(), *qman, unit_tests, wipe)}, shareman{std::make_unique(*sigman, mn_activeman, *qman, sporkman)}, clhandler{std::make_unique(chainman.ActiveChainstate(), *qman, *sigman, *shareman, diff --git a/src/llmq/context.h b/src/llmq/context.h index 865d525a36fcd..deb395dce3fdc 100644 --- a/src/llmq/context.h +++ b/src/llmq/context.h @@ -28,6 +28,7 @@ class CEHFSignalsHandler; class CInstantSendManager; class CQuorumBlockProcessor; class CQuorumManager; +class CQuorumSnapshotManager; class CSigSharesManager; class CSigningManager; } @@ -61,6 +62,7 @@ struct LLMQContext { */ const std::shared_ptr bls_worker; const std::unique_ptr dkg_debugman; + const std::unique_ptr qsnapman; const std::unique_ptr quorum_block_processor; const std::unique_ptr qdkgsman; const std::unique_ptr qman; diff --git a/src/llmq/snapshot.cpp b/src/llmq/snapshot.cpp index e56ca051267e8..932139f8442b3 100644 --- a/src/llmq/snapshot.cpp +++ b/src/llmq/snapshot.cpp @@ -21,8 +21,6 @@ namespace llmq { static const std::string DB_QUORUM_SNAPSHOT = "llmq_S"; -std::unique_ptr quorumSnapshotManager; - UniValue CQuorumSnapshot::ToJson() const { UniValue obj; diff --git a/src/llmq/snapshot.h b/src/llmq/snapshot.h index caade91ad6ebb..b268c6db6e75f 100644 --- a/src/llmq/snapshot.h +++ b/src/llmq/snapshot.h @@ -229,9 +229,6 @@ class CQuorumSnapshotManager std::optional GetSnapshotForBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex); void StoreSnapshotForBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, const CQuorumSnapshot& snapshot); }; - -extern std::unique_ptr quorumSnapshotManager; - } // namespace llmq #endif // BITCOIN_LLMQ_SNAPSHOT_H diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 87d1aa224b57a..2753f2a354ec1 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -5205,7 +5205,7 @@ void PeerManagerImpl::ProcessMessage( llmq::CQuorumRotationInfo quorumRotationInfoRet; std::string strError; - if (BuildQuorumRotationInfo(*m_dmnman, *llmq::quorumSnapshotManager, m_chainman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, cmd, quorumRotationInfoRet, strError)) { + if (BuildQuorumRotationInfo(*m_dmnman, *m_llmq_ctx->qsnapman, m_chainman, *m_llmq_ctx->qman, *m_llmq_ctx->quorum_block_processor, cmd, quorumRotationInfoRet, strError)) { m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::QUORUMROTATIONINFO, quorumRotationInfoRet)); } else { strError = strprintf("getquorumrotationinfo failed for size(baseBlockHashes)=%d, blockRequestHash=%s. error=%s", cmd.baseBlockHashes.size(), cmd.blockRequestHash.ToString(), strError); diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 37a3ed1986ef2..d379a0ee6531d 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -16,7 +16,6 @@ #include #include #include -#include std::optional LoadChainstate(bool fReset, ChainstateManager& chainman, @@ -30,7 +29,6 @@ std::optional LoadChainstate(bool fReset, std::unique_ptr& dmnman, std::unique_ptr& evodb, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool, bool fPruneMode, @@ -74,7 +72,7 @@ std::optional LoadChainstate(bool fReset, pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, block_tree_db_in_memory, fReset)); DashChainstateSetup(chainman, govman, mn_metaman, mn_sync, sporkman, mn_activeman, chain_helper, cpoolman, - dmnman, evodb, mnhf_manager, qsnapman, llmq_ctx, mempool, fReset, fReindexChainState, + dmnman, evodb, mnhf_manager, llmq_ctx, mempool, fReset, fReindexChainState, consensus_params); if (fReset) { @@ -210,7 +208,6 @@ void DashChainstateSetup(ChainstateManager& chainman, std::unique_ptr& dmnman, std::unique_ptr& evodb, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool, bool fReset, @@ -224,9 +221,6 @@ void DashChainstateSetup(ChainstateManager& chainman, cpoolman.reset(); cpoolman = std::make_unique(*evodb); - qsnapman.reset(); - qsnapman.reset(new llmq::CQuorumSnapshotManager(*evodb)); - if (llmq_ctx) { llmq_ctx->Interrupt(); llmq_ctx->Stop(); @@ -240,7 +234,7 @@ void DashChainstateSetup(ChainstateManager& chainman, chain_helper.reset(); chain_helper = std::make_unique(*cpoolman, *dmnman, *mnhf_manager, govman, *(llmq_ctx->isman), *(llmq_ctx->quorum_block_processor), - *llmq::quorumSnapshotManager, chainman, consensus_params, mn_sync, sporkman, *(llmq_ctx->clhandler), + *(llmq_ctx->qsnapman), chainman, consensus_params, mn_sync, sporkman, *(llmq_ctx->clhandler), *(llmq_ctx->qman)); } @@ -248,7 +242,6 @@ void DashChainstateSetupClose(std::unique_ptr& chain_helper, std::unique_ptr& cpoolman, std::unique_ptr& dmnman, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool) @@ -258,7 +251,6 @@ void DashChainstateSetupClose(std::unique_ptr& chain_helper, mnhf_manager->DisconnectManagers(); } llmq_ctx.reset(); - qsnapman.reset(); cpoolman.reset(); mempool->DisconnectManagers(); dmnman.reset(); diff --git a/src/node/chainstate.h b/src/node/chainstate.h index b2b3d98310811..c7b399177e412 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -25,10 +25,6 @@ class CSporkManager; class CTxMemPool; struct LLMQContext; -namespace llmq { -class CQuorumSnapshotManager; -} - namespace Consensus { struct Params; } @@ -91,7 +87,6 @@ std::optional LoadChainstate(bool fReset, std::unique_ptr& dmnman, std::unique_ptr& evodb, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool, bool fPruneMode, @@ -123,7 +118,6 @@ void DashChainstateSetup(ChainstateManager& chainman, std::unique_ptr& dmnman, std::unique_ptr& evodb, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool, bool fReset, @@ -134,7 +128,6 @@ void DashChainstateSetupClose(std::unique_ptr& chain_helper, std::unique_ptr& cpoolman, std::unique_ptr& dmnman, std::unique_ptr& mnhf_manager, - std::unique_ptr& qsnapman, std::unique_ptr& llmq_ctx, CTxMemPool* mempool); diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 697d2c0792909..46518ae8ef109 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -76,7 +76,7 @@ BlockAssembler::BlockAssembler(CChainState& chainstate, const NodeContext& node, m_mnhfman(*Assert(node.mnhf_manager)), m_clhandler(*Assert(Assert(node.llmq_ctx)->clhandler)), m_isman(*Assert(Assert(node.llmq_ctx)->isman)), - m_qsnapman(*llmq::quorumSnapshotManager), + m_qsnapman(*Assert(Assert(node.llmq_ctx)->qsnapman)), chainparams(params), m_mempool(mempool), m_quorum_block_processor(*Assert(Assert(node.llmq_ctx)->quorum_block_processor)), diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index ddf4d0dd93ab5..bd2a4c82ab874 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -296,7 +296,7 @@ static RPCHelpMan quorum_dkgstatus() llmq::CDKGDebugStatus status; llmq_ctx.dkg_debugman->GetLocalDebugStatus(status); - auto ret = status.ToJson(*CHECK_NONFATAL(node.dmnman), *llmq::quorumSnapshotManager, chainman, detailLevel); + auto ret = status.ToJson(*CHECK_NONFATAL(node.dmnman), *llmq_ctx.qsnapman, chainman, detailLevel); CBlockIndex* pindexTip = WITH_LOCK(cs_main, return chainman.ActiveChain().Tip()); int tipHeight = pindexTip->nHeight; @@ -325,12 +325,11 @@ static RPCHelpMan quorum_dkgstatus() obj.pushKV("pindexTip", pindexTip->nHeight); auto allConnections = llmq::utils::GetQuorumConnections(llmq_params, *node.dmnman, - *llmq::quorumSnapshotManager, *node.sporkman, + *llmq_ctx.qsnapman, *node.sporkman, pQuorumBaseBlockIndex, proTxHash, false); auto outboundConnections = llmq::utils::GetQuorumConnections(llmq_params, *node.dmnman, - *llmq::quorumSnapshotManager, - *node.sporkman, pQuorumBaseBlockIndex, - proTxHash, true); + *llmq_ctx.qsnapman, *node.sporkman, + pQuorumBaseBlockIndex, proTxHash, true); std::map foundConnections; connman.ForEachNode([&](const CNode* pnode) { auto verifiedProRegTxHash = pnode->GetVerifiedProRegTxHash(); @@ -864,7 +863,7 @@ static RPCHelpMan quorum_rotationinfo() LOCK(cs_main); - if (!BuildQuorumRotationInfo(*CHECK_NONFATAL(node.dmnman), *llmq::quorumSnapshotManager, chainman, *llmq_ctx.qman, + if (!BuildQuorumRotationInfo(*CHECK_NONFATAL(node.dmnman), *llmq_ctx.qsnapman, chainman, *llmq_ctx.qman, *llmq_ctx.quorum_block_processor, cmd, quorumRotationInfoRet, strError)) { throw JSONRPCError(RPC_INVALID_REQUEST, strError); } diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 046809a9f015c..54e911f1e5186 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -112,14 +111,14 @@ void DashChainstateSetup(ChainstateManager& chainman, { DashChainstateSetup(chainman, *Assert(node.govman.get()), *Assert(node.mn_metaman.get()), *Assert(node.mn_sync.get()), *Assert(node.sporkman.get()), node.mn_activeman, node.chain_helper, node.cpoolman, node.dmnman, - node.evodb, node.mnhf_manager, llmq::quorumSnapshotManager, node.llmq_ctx, - Assert(node.mempool.get()), fReset, fReindexChainState, consensus_params); + node.evodb, node.mnhf_manager, node.llmq_ctx, Assert(node.mempool.get()), fReset, fReindexChainState, + consensus_params); } void DashChainstateSetupClose(NodeContext& node) { - DashChainstateSetupClose(node.chain_helper, node.cpoolman, node.dmnman, node.mnhf_manager, - llmq::quorumSnapshotManager, node.llmq_ctx, Assert(node.mempool.get())); + DashChainstateSetupClose(node.chain_helper, node.cpoolman, node.dmnman, node.mnhf_manager, node.llmq_ctx, + Assert(node.mempool.get())); } void DashPostChainstateSetup(NodeContext& node) @@ -203,7 +202,6 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve fCheckBlockIndex = true; m_node.evodb = std::make_unique(1 << 20, true, true); m_node.mnhf_manager = std::make_unique(*m_node.evodb); - llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*m_node.evodb)); m_node.cpoolman = std::make_unique(*m_node.evodb); static bool noui_connected = false; if (!noui_connected) { @@ -217,7 +215,6 @@ BasicTestingSetup::~BasicTestingSetup() { SetMockTime(0s); // Reset mocktime for following tests m_node.cpoolman.reset(); - llmq::quorumSnapshotManager.reset(); m_node.mnhf_manager.reset(); m_node.evodb.reset(); m_node.connman.reset(); @@ -297,7 +294,6 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector(*block.vtx[0]); Assert(cbTx.has_value()); BlockValidationState state; - if (!CalcCbTxMerkleRootMNList(block, chainstate.m_chain.Tip(), cbTx->merkleRootMNList, state, *m_node.dmnman, *llmq::quorumSnapshotManager, chainstate.CoinsTip())) { + if (!CalcCbTxMerkleRootMNList(block, chainstate.m_chain.Tip(), cbTx->merkleRootMNList, state, *m_node.dmnman, *m_node.llmq_ctx->qsnapman, chainstate.CoinsTip())) { Assert(false); } if (!CalcCbTxMerkleRootQuorums(block, chainstate.m_chain.Tip(), *m_node.llmq_ctx->quorum_block_processor, cbTx->merkleRootQuorums, state)) {