refactor: remove CSporkManager global, move to NodeContext

This commit is contained in:
Kittywhiskers Van Gogh 2024-02-29 14:03:48 +00:00
parent 24ba2f027c
commit 60fd1aa774
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
25 changed files with 98 additions and 90 deletions

View File

@ -313,8 +313,7 @@ void PrepareShutdown(NodeContext& node)
::dstxManager.reset(); ::dstxManager.reset();
node.mn_sync = nullptr; node.mn_sync = nullptr;
::masternodeSync.reset(); ::masternodeSync.reset();
node.sporkman = nullptr; node.sporkman.reset();
::sporkManager.reset();
node.govman = nullptr; node.govman = nullptr;
::governance.reset(); ::governance.reset();
@ -1717,15 +1716,8 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
::governance = std::make_unique<CGovernanceManager>(); ::governance = std::make_unique<CGovernanceManager>();
node.govman = ::governance.get(); node.govman = ::governance.get();
assert(!node.peerman); assert(!node.sporkman);
node.peerman = PeerManager::make(chainparams, *node.connman, *node.addrman, node.banman.get(), node.sporkman = std::make_unique<CSporkManager>();
*node.scheduler, chainman, *node.mempool, *node.govman,
node.cj_ctx, node.llmq_ctx, ignores_incoming_txs);
RegisterValidationInterface(node.peerman.get());
assert(!::sporkManager);
::sporkManager = std::make_unique<CSporkManager>();
node.sporkman = ::sporkManager.get();
std::vector<std::string> vSporkAddresses; std::vector<std::string> vSporkAddresses;
if (args.IsArgSet("-sporkaddr")) { if (args.IsArgSet("-sporkaddr")) {
@ -1755,6 +1747,12 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
::masternodeSync = std::make_unique<CMasternodeSync>(*node.connman, *node.govman); ::masternodeSync = std::make_unique<CMasternodeSync>(*node.connman, *node.govman);
node.mn_sync = ::masternodeSync.get(); node.mn_sync = ::masternodeSync.get();
assert(!node.peerman);
node.peerman = PeerManager::make(chainparams, *node.connman, *node.addrman, node.banman.get(),
*node.scheduler, chainman, *node.mempool, *node.govman, *node.sporkman,
node.cj_ctx, node.llmq_ctx, ignores_incoming_txs);
RegisterValidationInterface(node.peerman.get());
// sanitize comments per BIP-0014, format user agent and check total size // sanitize comments per BIP-0014, format user agent and check total size
std::vector<std::string> uacomments; std::vector<std::string> uacomments;

View File

@ -31,11 +31,11 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CEvoDB& evo
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, *dkg_debugman, *quorum_block_processor, sporkman, unit_tests, wipe)}, qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, *dkg_debugman, *quorum_block_processor, sporkman, unit_tests, wipe)},
qman{[&]() -> llmq::CQuorumManager* const { qman{[&]() -> llmq::CQuorumManager* const {
assert(llmq::quorumManager == nullptr); assert(llmq::quorumManager == nullptr);
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, *qdkgsman, evo_db, *quorum_block_processor, ::masternodeSync); llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, *qdkgsman, evo_db, *quorum_block_processor, sporkman, ::masternodeSync);
return llmq::quorumManager.get(); return llmq::quorumManager.get();
}()}, }()},
sigman{std::make_unique<llmq::CSigningManager>(connman, *llmq::quorumManager, unit_tests, wipe)}, sigman{std::make_unique<llmq::CSigningManager>(connman, *llmq::quorumManager, unit_tests, wipe)},
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *llmq::quorumManager, *sigman, peerman)}, shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, *llmq::quorumManager, sporkman, peerman)},
clhandler{[&]() -> llmq::CChainLocksHandler* const { clhandler{[&]() -> llmq::CChainLocksHandler* const {
assert(llmq::chainLocksHandler == nullptr); assert(llmq::chainLocksHandler == nullptr);
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, connman, *::masternodeSync, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool); llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, connman, *::masternodeSync, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool);

View File

@ -450,7 +450,7 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
void CDKGSession::VerifyConnectionAndMinProtoVersions() const void CDKGSession::VerifyConnectionAndMinProtoVersions() const
{ {
if (!IsQuorumPoseEnabled(params.type)) { if (!IsQuorumPoseEnabled(params.type, m_sporkman)) {
return; return;
} }
@ -465,7 +465,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions() const
protoMap.emplace(verifiedProRegTxHash, pnode->nVersion); protoMap.emplace(verifiedProRegTxHash, pnode->nVersion);
}); });
bool fShouldAllMembersBeConnected = IsAllMembersConnectedEnabled(params.type); bool fShouldAllMembersBeConnected = IsAllMembersConnectedEnabled(params.type, m_sporkman);
for (const auto& m : members) { for (const auto& m : members) {
if (m->dmn->proTxHash == myProTxHash) { if (m->dmn->proTxHash == myProTxHash) {
continue; continue;

View File

@ -19,6 +19,7 @@ class UniValue;
class CInv; class CInv;
class CConnman; class CConnman;
class CDeterministicMN; class CDeterministicMN;
class CSporkManager;
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>; using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
namespace llmq namespace llmq
@ -271,6 +272,7 @@ private:
CBLSWorkerCache cache; CBLSWorkerCache cache;
CDKGSessionManager& dkgManager; CDKGSessionManager& dkgManager;
CDKGDebugManager& dkgDebugManager; CDKGDebugManager& dkgDebugManager;
const CSporkManager& m_sporkman;
const CBlockIndex* m_quorum_base_block_index{nullptr}; const CBlockIndex* m_quorum_base_block_index{nullptr};
int quorumIndex{0}; int quorumIndex{0};
@ -311,8 +313,8 @@ private:
std::set<uint256> validCommitments GUARDED_BY(invCs); std::set<uint256> validCommitments GUARDED_BY(invCs);
public: public:
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman) : CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman, const CSporkManager& sporkman) :
params(_params), blsWorker(_blsWorker), cache(_blsWorker), dkgManager(_dkgManager), dkgDebugManager(_dkgDebugManager), connman(_connman) {} params(_params), blsWorker(_blsWorker), cache(_blsWorker), dkgManager(_dkgManager), dkgDebugManager(_dkgDebugManager), m_sporkman(sporkman), connman(_connman) {}
bool Init(gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex); bool Init(gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex);

View File

@ -25,7 +25,7 @@ namespace llmq
{ {
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager, CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager,
CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman,
const Consensus::LLMQParams& _params, int _quorumIndex) : const Consensus::LLMQParams& _params, int _quorumIndex) :
blsWorker(_blsWorker), blsWorker(_blsWorker),
m_chainstate(chainstate), m_chainstate(chainstate),
@ -33,9 +33,10 @@ CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chai
dkgDebugManager(_dkgDebugManager), dkgDebugManager(_dkgDebugManager),
dkgManager(_dkgManager), dkgManager(_dkgManager),
quorumBlockProcessor(_quorumBlockProcessor), quorumBlockProcessor(_quorumBlockProcessor),
m_sporkman(sporkman),
params(_params), params(_params),
quorumIndex(_quorumIndex), quorumIndex(_quorumIndex),
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, _dkgManager, _dkgDebugManager, _connman)), curSession(std::make_unique<CDKGSession>(_params, _blsWorker, _dkgManager, _dkgDebugManager, _connman, sporkman)),
pendingContributions((size_t)_params.size * 2, MSG_QUORUM_CONTRIB), // we allow size*2 messages as we need to make sure we see bad behavior (double messages) pendingContributions((size_t)_params.size * 2, MSG_QUORUM_CONTRIB), // we allow size*2 messages as we need to make sure we see bad behavior (double messages)
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT), pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION), pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
@ -183,7 +184,7 @@ void CDKGSessionHandler::StopThread()
bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex) bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
{ {
curSession = std::make_unique<CDKGSession>(params, blsWorker, dkgManager, dkgDebugManager, connman); curSession = std::make_unique<CDKGSession>(params, blsWorker, dkgManager, dkgDebugManager, connman, m_sporkman);
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) { if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
return false; return false;
@ -526,9 +527,9 @@ void CDKGSessionHandler::HandleDKGRound()
return changed; return changed;
}); });
utils::EnsureQuorumConnections(params, pQuorumBaseBlockIndex, connman, curSession->myProTxHash); utils::EnsureQuorumConnections(params, connman, m_sporkman, pQuorumBaseBlockIndex, curSession->myProTxHash);
if (curSession->AreWeMember()) { if (curSession->AreWeMember()) {
utils::AddQuorumProbeConnections(params, pQuorumBaseBlockIndex, connman, curSession->myProTxHash); utils::AddQuorumProbeConnections(params, connman, m_sporkman, pQuorumBaseBlockIndex, curSession->myProTxHash);
} }
WaitForNextPhase(QuorumPhase::Initialized, QuorumPhase::Contribute, curQuorumHash); WaitForNextPhase(QuorumPhase::Initialized, QuorumPhase::Contribute, curQuorumHash);

View File

@ -17,6 +17,7 @@
class CBlockIndex; class CBlockIndex;
class CBLSWorker; class CBLSWorker;
class CChainState; class CChainState;
class CSporkManager;
class PeerManager; class PeerManager;
namespace llmq namespace llmq
@ -122,6 +123,7 @@ private:
CDKGDebugManager& dkgDebugManager; CDKGDebugManager& dkgDebugManager;
CDKGSessionManager& dkgManager; CDKGSessionManager& dkgManager;
CQuorumBlockProcessor& quorumBlockProcessor; CQuorumBlockProcessor& quorumBlockProcessor;
const CSporkManager& m_sporkman;
const Consensus::LLMQParams params; const Consensus::LLMQParams params;
const int quorumIndex; const int quorumIndex;
@ -141,7 +143,7 @@ private:
public: public:
CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager, CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager,
CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman,
const Consensus::LLMQParams& _params, int _quorumIndex); const Consensus::LLMQParams& _params, int _quorumIndex);
~CDKGSessionHandler() = default; ~CDKGSessionHandler() = default;

View File

@ -25,7 +25,7 @@ static const std::string DB_SKCONTRIB = "qdkg_S";
static const std::string DB_ENC_CONTRIB = "qdkg_E"; static const std::string DB_ENC_CONTRIB = "qdkg_E";
CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager, CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager,
CQuorumBlockProcessor& _quorumBlockProcessor, CSporkManager& sporkManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkManager,
bool unitTests, bool fWipe) : bool unitTests, bool fWipe) :
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)), db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
blsWorker(_blsWorker), blsWorker(_blsWorker),
@ -48,7 +48,7 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai
for (const auto i : irange::range(session_count)) { for (const auto i : irange::range(session_count)) {
dkgSessionHandlers.emplace(std::piecewise_construct, dkgSessionHandlers.emplace(std::piecewise_construct,
std::forward_as_tuple(params.type, i), std::forward_as_tuple(params.type, i),
std::forward_as_tuple(blsWorker, m_chainstate, connman, dkgDebugManager, *this, quorumBlockProcessor, params, i)); std::forward_as_tuple(blsWorker, m_chainstate, connman, dkgDebugManager, *this, quorumBlockProcessor, spork_manager, params, i));
} }
} }
} }

View File

@ -38,7 +38,7 @@ private:
CConnman& connman; CConnman& connman;
CDKGDebugManager& dkgDebugManager; CDKGDebugManager& dkgDebugManager;
CQuorumBlockProcessor& quorumBlockProcessor; CQuorumBlockProcessor& quorumBlockProcessor;
CSporkManager& spork_manager; const CSporkManager& spork_manager;
//TODO name struct instead of std::pair //TODO name struct instead of std::pair
std::map<std::pair<Consensus::LLMQType, int>, CDKGSessionHandler> dkgSessionHandlers; std::map<std::pair<Consensus::LLMQType, int>, CDKGSessionHandler> dkgSessionHandlers;
@ -64,7 +64,7 @@ private:
public: public:
CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager, CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGDebugManager& _dkgDebugManager,
CQuorumBlockProcessor& _quorumBlockProcessor, CSporkManager& sporkManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkManager,
bool unitTests, bool fWipe); bool unitTests, bool fWipe);
~CDKGSessionManager() = default; ~CDKGSessionManager() = default;

View File

@ -20,7 +20,7 @@ static constexpr int TESTNET_LLMQ_25_67_ACTIVATION_HEIGHT = 847000;
namespace llmq namespace llmq
{ {
static bool EvalSpork(Consensus::LLMQType llmqType, int64_t spork_value) static bool EvalSpork(const Consensus::LLMQType llmqType, const int64_t spork_value)
{ {
if (spork_value == 0) { if (spork_value == 0) {
return true; return true;
@ -31,14 +31,14 @@ static bool EvalSpork(Consensus::LLMQType llmqType, int64_t spork_value)
return false; return false;
} }
bool IsAllMembersConnectedEnabled(Consensus::LLMQType llmqType) bool IsAllMembersConnectedEnabled(const Consensus::LLMQType llmqType, const CSporkManager& sporkman)
{ {
return EvalSpork(llmqType, sporkManager->GetSporkValue(SPORK_21_QUORUM_ALL_CONNECTED)); return EvalSpork(llmqType, sporkman.GetSporkValue(SPORK_21_QUORUM_ALL_CONNECTED));
} }
bool IsQuorumPoseEnabled(Consensus::LLMQType llmqType) bool IsQuorumPoseEnabled(const Consensus::LLMQType llmqType, const CSporkManager& sporkman)
{ {
return EvalSpork(llmqType, sporkManager->GetSporkValue(SPORK_23_QUORUM_POSE)); return EvalSpork(llmqType, sporkman.GetSporkValue(SPORK_23_QUORUM_POSE));
} }

View File

@ -13,6 +13,7 @@
#include <vector> #include <vector>
class CBlockIndex; class CBlockIndex;
class CSporkManager;
namespace llmq namespace llmq
{ {
@ -28,8 +29,8 @@ static constexpr bool DEFAULT_ENABLE_QUORUM_DATA_RECOVERY{true};
// If true, we will connect to all new quorums and watch their communication // If true, we will connect to all new quorums and watch their communication
static constexpr bool DEFAULT_WATCH_QUORUMS{false}; static constexpr bool DEFAULT_WATCH_QUORUMS{false};
bool IsAllMembersConnectedEnabled(Consensus::LLMQType llmqType); bool IsAllMembersConnectedEnabled(const Consensus::LLMQType llmqType, const CSporkManager& sporkman);
bool IsQuorumPoseEnabled(Consensus::LLMQType llmqType); bool IsQuorumPoseEnabled(const Consensus::LLMQType llmqType, const CSporkManager& sporkman);
bool IsQuorumRotationEnabled(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pindex); bool IsQuorumRotationEnabled(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pindex);

View File

@ -206,13 +206,14 @@ bool CQuorum::ReadContributions(CEvoDB& evoDb)
} }
CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGSessionManager& _dkgManager, CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGSessionManager& _dkgManager,
CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const std::unique_ptr<CMasternodeSync>& mn_sync) : CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman, const std::unique_ptr<CMasternodeSync>& mn_sync) :
blsWorker(_blsWorker), blsWorker(_blsWorker),
m_chainstate(chainstate), m_chainstate(chainstate),
connman(_connman), connman(_connman),
dkgManager(_dkgManager), dkgManager(_dkgManager),
m_evoDb(_evoDb), m_evoDb(_evoDb),
quorumBlockProcessor(_quorumBlockProcessor), quorumBlockProcessor(_quorumBlockProcessor),
m_sporkman(sporkman),
m_mn_sync(mn_sync) m_mn_sync(mn_sync)
{ {
utils::InitQuorumsCache(mapQuorumsCache, false); utils::InitQuorumsCache(mapQuorumsCache, false);
@ -348,7 +349,7 @@ void CQuorumManager::CheckQuorumConnections(const Consensus::LLMQParams& llmqPar
}); });
for (const auto& quorum : lastQuorums) { for (const auto& quorum : lastQuorums) {
if (utils::EnsureQuorumConnections(llmqParams, quorum->m_quorum_base_block_index, connman, myProTxHash)) { if (utils::EnsureQuorumConnections(llmqParams, connman, m_sporkman, quorum->m_quorum_base_block_index, myProTxHash)) {
if (connmanQuorumsToDelete.erase(quorum->qc->quorumHash) > 0) { if (connmanQuorumsToDelete.erase(quorum->qc->quorumHash) > 0) {
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString()); LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, quorum->m_quorum_base_block_index->nHeight, quorum->m_quorum_base_block_index->GetBlockHash().ToString());
} }

View File

@ -27,6 +27,7 @@ class CConnman;
class CDeterministicMN; class CDeterministicMN;
class CMasternodeSync; class CMasternodeSync;
class CNode; class CNode;
class CSporkManager;
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>; using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
@ -220,6 +221,7 @@ private:
CDKGSessionManager& dkgManager; CDKGSessionManager& dkgManager;
CEvoDB& m_evoDb; CEvoDB& m_evoDb;
CQuorumBlockProcessor& quorumBlockProcessor; CQuorumBlockProcessor& quorumBlockProcessor;
const CSporkManager& m_sporkman;
const std::unique_ptr<CMasternodeSync>& m_mn_sync; const std::unique_ptr<CMasternodeSync>& m_mn_sync;
mutable RecursiveMutex cs_map_quorums; mutable RecursiveMutex cs_map_quorums;
@ -234,7 +236,7 @@ private:
public: public:
CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGSessionManager& _dkgManager, CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDKGSessionManager& _dkgManager,
CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const std::unique_ptr<CMasternodeSync>& mn_sync); CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman, const std::unique_ptr<CMasternodeSync>& mn_sync);
~CQuorumManager() { Stop(); }; ~CQuorumManager() { Stop(); };
void Start(); void Start();

View File

@ -698,7 +698,7 @@ void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CConnma
// prepare node set for direct-push in case this is our sig share // prepare node set for direct-push in case this is our sig share
std::set<NodeId> quorumNodes; std::set<NodeId> quorumNodes;
if (!IsAllMembersConnectedEnabled(llmqType) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash))) { if (!IsAllMembersConnectedEnabled(llmqType, m_sporkman) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash))) {
quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash()); quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash());
} }
@ -712,7 +712,7 @@ void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CConnma
if (!sigShares.Add(sigShare.GetKey(), sigShare)) { if (!sigShares.Add(sigShare.GetKey(), sigShare)) {
return; return;
} }
if (!IsAllMembersConnectedEnabled(llmqType)) { if (!IsAllMembersConnectedEnabled(llmqType, m_sporkman)) {
sigSharesQueuedToAnnounce.Add(sigShare.GetKey(), true); sigSharesQueuedToAnnounce.Add(sigShare.GetKey(), true);
} }
@ -857,7 +857,7 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
decltype(sigSharesToRequest.begin()->second)* invMap = nullptr; decltype(sigSharesToRequest.begin()->second)* invMap = nullptr;
for (auto& [signHash, session] : nodeState.sessions) { for (auto& [signHash, session] : nodeState.sessions) {
if (IsAllMembersConnectedEnabled(session.llmqType)) { if (IsAllMembersConnectedEnabled(session.llmqType, m_sporkman)) {
continue; continue;
} }
@ -928,7 +928,7 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
decltype(sigSharesToSend.begin()->second)* sigSharesToSend2 = nullptr; decltype(sigSharesToSend.begin()->second)* sigSharesToSend2 = nullptr;
for (auto& [signHash, session] : nodeState.sessions) { for (auto& [signHash, session] : nodeState.sessions) {
if (IsAllMembersConnectedEnabled(session.llmqType)) { if (IsAllMembersConnectedEnabled(session.llmqType, m_sporkman)) {
continue; continue;
} }
@ -982,7 +982,7 @@ void CSigSharesManager::CollectSigSharesToSendConcentrated(std::unordered_map<No
auto curTime = GetTime<std::chrono::milliseconds>().count(); auto curTime = GetTime<std::chrono::milliseconds>().count();
for (auto& [_, signedSession] : signedSessions) { for (auto& [_, signedSession] : signedSessions) {
if (!IsAllMembersConnectedEnabled(signedSession.quorum->params.type)) { if (!IsAllMembersConnectedEnabled(signedSession.quorum->params.type, m_sporkman)) {
continue; continue;
} }
@ -1474,7 +1474,7 @@ void CSigSharesManager::SignPendingSigShares()
auto sigShare = *opt_sigShare; auto sigShare = *opt_sigShare;
ProcessSigShare(sigShare, connman, pQuorum); ProcessSigShare(sigShare, connman, pQuorum);
if (IsAllMembersConnectedEnabled(pQuorum->params.type)) { if (IsAllMembersConnectedEnabled(pQuorum->params.type, m_sporkman)) {
LOCK(cs); LOCK(cs);
auto& session = signedSessions[sigShare.GetSignHash()]; auto& session = signedSessions[sigShare.GetSignHash()];
session.sigShare = sigShare; session.sigShare = sigShare;
@ -1528,7 +1528,7 @@ std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorumCPtr& qu
// causes all known sigShares to be re-announced // causes all known sigShares to be re-announced
void CSigSharesManager::ForceReAnnouncement(const CQuorumCPtr& quorum, Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash) void CSigSharesManager::ForceReAnnouncement(const CQuorumCPtr& quorum, Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash)
{ {
if (IsAllMembersConnectedEnabled(llmqType)) { if (IsAllMembersConnectedEnabled(llmqType, m_sporkman)) {
return; return;
} }

View File

@ -400,8 +400,9 @@ private:
FastRandomContext rnd GUARDED_BY(cs); FastRandomContext rnd GUARDED_BY(cs);
CConnman& connman; CConnman& connman;
const CQuorumManager& qman;
CSigningManager& sigman; CSigningManager& sigman;
const CQuorumManager& qman;
const CSporkManager& m_sporkman;
const std::unique_ptr<PeerManager>& m_peerman; const std::unique_ptr<PeerManager>& m_peerman;
@ -409,8 +410,8 @@ private:
std::atomic<uint32_t> recoveredSigsCounter{0}; std::atomic<uint32_t> recoveredSigsCounter{0};
public: public:
explicit CSigSharesManager(CConnman& _connman, CQuorumManager& _qman, CSigningManager& _sigman, const std::unique_ptr<PeerManager>& peerman) : explicit CSigSharesManager(CConnman& _connman, CSigningManager& _sigman, const CQuorumManager& _qman, const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman) :
connman(_connman), qman(_qman), sigman(_sigman), m_peerman(peerman) connman(_connman), sigman(_sigman), qman(_qman), m_sporkman(sporkman), m_peerman(peerman)
{ {
workInterrupt.reset(); workInterrupt.reset();
}; };

View File

@ -649,10 +649,10 @@ uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256
return proTxHash2; return proTxHash2;
} }
std::set<uint256> GetQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, std::set<uint256> GetQuorumConnections(const Consensus::LLMQParams& llmqParams, const CSporkManager& sporkman,
const uint256& forMember, bool onlyOutbound) gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound)
{ {
if (IsAllMembersConnectedEnabled(llmqParams.type)) { if (IsAllMembersConnectedEnabled(llmqParams.type, sporkman)) {
auto mns = GetAllQuorumMembers(llmqParams.type, pQuorumBaseBlockIndex); auto mns = GetAllQuorumMembers(llmqParams.type, pQuorumBaseBlockIndex);
std::set<uint256> result; std::set<uint256> result;
@ -749,8 +749,8 @@ std::set<size_t> CalcDeterministicWatchConnections(Consensus::LLMQType llmqType,
return result; return result;
} }
bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, const CSporkManager& sporkman,
CConnman& connman, const uint256& myProTxHash) gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& myProTxHash)
{ {
if (!fMasternodeMode && !IsWatchQuorumsEnabled()) { if (!fMasternodeMode && !IsWatchQuorumsEnabled()) {
return false; return false;
@ -773,7 +773,7 @@ bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_n
std::set<uint256> connections; std::set<uint256> connections;
std::set<uint256> relayMembers; std::set<uint256> relayMembers;
if (isMember) { if (isMember) {
connections = GetQuorumConnections(llmqParams, pQuorumBaseBlockIndex, myProTxHash, true); connections = GetQuorumConnections(llmqParams, sporkman, pQuorumBaseBlockIndex, myProTxHash, true);
relayMembers = GetQuorumRelayMembers(llmqParams, pQuorumBaseBlockIndex, myProTxHash, true); relayMembers = GetQuorumRelayMembers(llmqParams, pQuorumBaseBlockIndex, myProTxHash, true);
} else { } else {
auto cindexes = CalcDeterministicWatchConnections(llmqParams.type, pQuorumBaseBlockIndex, members.size(), 1); auto cindexes = CalcDeterministicWatchConnections(llmqParams.type, pQuorumBaseBlockIndex, members.size(), 1);
@ -804,10 +804,10 @@ bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_n
return true; return true;
} }
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, const CSporkManager& sporkman,
CConnman& connman, const uint256 &myProTxHash) gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256 &myProTxHash)
{ {
if (!IsQuorumPoseEnabled(llmqParams.type)) { if (!IsQuorumPoseEnabled(llmqParams.type, sporkman)) {
return; return;
} }

View File

@ -19,6 +19,7 @@ class CBlockIndex;
class CDeterministicMN; class CDeterministicMN;
class CDeterministicMNList; class CDeterministicMNList;
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>; using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
class CSporkManager;
namespace llmq namespace llmq
{ {
@ -30,12 +31,12 @@ namespace utils
std::vector<CDeterministicMNCPtr> GetAllQuorumMembers(Consensus::LLMQType llmqType, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, bool reset_cache = false); std::vector<CDeterministicMNCPtr> GetAllQuorumMembers(Consensus::LLMQType llmqType, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, bool reset_cache = false);
uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2); uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2);
std::set<uint256> GetQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound); std::set<uint256> GetQuorumConnections(const Consensus::LLMQParams& llmqParams, const CSporkManager& sporkman, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound);
std::set<uint256> GetQuorumRelayMembers(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound); std::set<uint256> GetQuorumRelayMembers(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& forMember, bool onlyOutbound);
std::set<size_t> CalcDeterministicWatchConnections(Consensus::LLMQType llmqType, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, size_t memberCount, size_t connectionCount); std::set<size_t> CalcDeterministicWatchConnections(Consensus::LLMQType llmqType, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, size_t memberCount, size_t connectionCount);
bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, CConnman& connman, const uint256& myProTxHash); bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, const CSporkManager& sporkman, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& myProTxHash);
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, CConnman& connman, const uint256& myProTxHash); void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, const CSporkManager& sporkman, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& myProTxHash);
template <typename CacheType> template <typename CacheType>
void InitQuorumsCache(CacheType& cache, bool limit_by_connections = true); void InitQuorumsCache(CacheType& cache, bool limit_by_connections = true);

View File

@ -238,7 +238,8 @@ class PeerManagerImpl final : public PeerManager
public: public:
PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman,
BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman, BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman,
CTxMemPool& pool, CGovernanceManager& govman, const std::unique_ptr<CJContext>& cj_ctx, CTxMemPool& pool, CGovernanceManager& govman, CSporkManager& sporkman,
const std::unique_ptr<CJContext>& cj_ctx,
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs); const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
/** Overridden from CValidationInterface. */ /** Overridden from CValidationInterface. */
@ -335,6 +336,7 @@ private:
const std::unique_ptr<CJContext>& m_cj_ctx; const std::unique_ptr<CJContext>& m_cj_ctx;
const std::unique_ptr<LLMQContext>& m_llmq_ctx; const std::unique_ptr<LLMQContext>& m_llmq_ctx;
CGovernanceManager& m_govman; CGovernanceManager& m_govman;
CSporkManager& m_sporkman;
/** The height of the best chain */ /** The height of the best chain */
std::atomic<int> m_best_height{-1}; std::atomic<int> m_best_height{-1};
@ -1587,15 +1589,16 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex, const Conse
std::unique_ptr<PeerManager> PeerManager::make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman, std::unique_ptr<PeerManager> PeerManager::make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman,
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool, CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
CGovernanceManager& govman, const std::unique_ptr<CJContext>& cj_ctx, CGovernanceManager& govman, CSporkManager& sporkman,
const std::unique_ptr<CJContext>& cj_ctx,
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs) const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
{ {
return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, scheduler, chainman, pool, govman, cj_ctx, llmq_ctx, ignore_incoming_txs); return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, scheduler, chainman, pool, govman, sporkman, cj_ctx, llmq_ctx, ignore_incoming_txs);
} }
PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman, PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman,
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool, CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
CGovernanceManager& govman, const std::unique_ptr<CJContext>& cj_ctx, CGovernanceManager& govman, CSporkManager& sporkman, const std::unique_ptr<CJContext>& cj_ctx,
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs) const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
: m_chainparams(chainparams), : m_chainparams(chainparams),
m_connman(connman), m_connman(connman),
@ -1606,6 +1609,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
m_cj_ctx(cj_ctx), m_cj_ctx(cj_ctx),
m_llmq_ctx(llmq_ctx), m_llmq_ctx(llmq_ctx),
m_govman(govman), m_govman(govman),
m_sporkman(sporkman),
m_ignore_incoming_txs(ignore_incoming_txs) m_ignore_incoming_txs(ignore_incoming_txs)
{ {
assert(std::addressof(g_chainman) == std::addressof(m_chainman)); assert(std::addressof(g_chainman) == std::addressof(m_chainman));
@ -1884,7 +1888,7 @@ bool PeerManagerImpl::AlreadyHave(const CInv& inv)
case MSG_SPORK: case MSG_SPORK:
{ {
return sporkManager->GetSporkByHash(inv.hash).has_value(); return m_sporkman.GetSporkByHash(inv.hash).has_value();
} }
case MSG_GOVERNANCE_OBJECT: case MSG_GOVERNANCE_OBJECT:
@ -2220,7 +2224,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
} }
if (!push && inv.type == MSG_SPORK) { if (!push && inv.type == MSG_SPORK) {
if (auto opt_spork = sporkManager->GetSporkByHash(inv.hash)) { if (auto opt_spork = m_sporkman.GetSporkByHash(inv.hash)) {
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SPORK, *opt_spork)); m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SPORK, *opt_spork));
push = true; push = true;
} }
@ -4429,14 +4433,14 @@ void PeerManagerImpl::ProcessMessage(
} }
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
ProcessPeerMsgRet(m_cj_ctx->server->ProcessMessage(pfrom, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_cj_ctx->server->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(sporkManager->ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
::masternodeSync->ProcessMessage(pfrom, msg_type, vRecv); ::masternodeSync->ProcessMessage(pfrom, msg_type, vRecv);
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom); ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
m_llmq_ctx->shareman->ProcessMessage(pfrom, *sporkManager, msg_type, vRecv); m_llmq_ctx->shareman->ProcessMessage(pfrom, m_sporkman, msg_type, vRecv);
ProcessPeerMsgRet(m_llmq_ctx->sigman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->sigman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(m_llmq_ctx->clhandler->ProcessMessage(pfrom, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->clhandler->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
ProcessPeerMsgRet(m_llmq_ctx->isman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom); ProcessPeerMsgRet(m_llmq_ctx->isman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom);

View File

@ -16,9 +16,10 @@ class CAddrMan;
class CTxMemPool; class CTxMemPool;
class ChainstateManager; class ChainstateManager;
class CCoinJoinServer; class CCoinJoinServer;
class CGovernanceManager;
class CSporkManager;
struct CJContext; struct CJContext;
struct LLMQContext; struct LLMQContext;
class CGovernanceManager;
extern RecursiveMutex cs_main; extern RecursiveMutex cs_main;
extern RecursiveMutex g_cs_orphans; extern RecursiveMutex g_cs_orphans;
@ -42,7 +43,8 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
public: public:
static std::unique_ptr<PeerManager> make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, static std::unique_ptr<PeerManager> make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman,
BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman, BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman,
CTxMemPool& pool, CGovernanceManager& govman, const std::unique_ptr<CJContext>& cj_ctx, CTxMemPool& pool, CGovernanceManager& govman, CSporkManager& sporkman,
const std::unique_ptr<CJContext>& cj_ctx,
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs); const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
virtual ~PeerManager() { } virtual ~PeerManager() { }

View File

@ -18,6 +18,7 @@
#include <net_processing.h> #include <net_processing.h>
#include <policy/fees.h> #include <policy/fees.h>
#include <scheduler.h> #include <scheduler.h>
#include <spork.h>
#include <txmempool.h> #include <txmempool.h>
NodeContext::NodeContext() {} NodeContext::NodeContext() {}

View File

@ -75,6 +75,7 @@ struct NodeContext {
std::unique_ptr<CChainstateHelper> chain_helper; std::unique_ptr<CChainstateHelper> chain_helper;
std::unique_ptr<CJContext> cj_ctx; std::unique_ptr<CJContext> cj_ctx;
std::unique_ptr<CMNHFManager> mnhf_manager; std::unique_ptr<CMNHFManager> mnhf_manager;
std::unique_ptr<CSporkManager> sporkman;
std::unique_ptr<LLMQContext> llmq_ctx; std::unique_ptr<LLMQContext> llmq_ctx;
CCreditPoolManager* cpoolman{nullptr}; CCreditPoolManager* cpoolman{nullptr};
CDeterministicMNManager* dmnman{nullptr}; CDeterministicMNManager* dmnman{nullptr};
@ -83,7 +84,6 @@ struct NodeContext {
CMasternodeMetaMan* mn_metaman{nullptr}; CMasternodeMetaMan* mn_metaman{nullptr};
CMasternodeSync* mn_sync{nullptr}; CMasternodeSync* mn_sync{nullptr};
CNetFulfilledRequestManager* netfulfilledman{nullptr}; CNetFulfilledRequestManager* netfulfilledman{nullptr};
CSporkManager* sporkman{nullptr};
//! Declare default constructor and destructor that are not inline, so code //! Declare default constructor and destructor that are not inline, so code
//! instantiating the NodeContext struct doesn't need to #include class //! instantiating the NodeContext struct doesn't need to #include class

View File

@ -275,7 +275,7 @@ static void quorum_dkgstatus_help(const JSONRPCRequest& request)
}.Check(request); }.Check(request);
} }
static UniValue quorum_dkgstatus(const JSONRPCRequest& request, const ChainstateManager& chainman, const LLMQContext& llmq_ctx) static UniValue quorum_dkgstatus(const JSONRPCRequest& request, const ChainstateManager& chainman, const CSporkManager& sporkman, const LLMQContext& llmq_ctx)
{ {
quorum_dkgstatus_help(request); quorum_dkgstatus_help(request);
@ -319,11 +319,8 @@ static UniValue quorum_dkgstatus(const JSONRPCRequest& request, const Chainstate
obj.pushKV("quorumHash", pQuorumBaseBlockIndex->GetBlockHash().ToString()); obj.pushKV("quorumHash", pQuorumBaseBlockIndex->GetBlockHash().ToString());
obj.pushKV("pindexTip", pindexTip->nHeight); obj.pushKV("pindexTip", pindexTip->nHeight);
auto allConnections = llmq::utils::GetQuorumConnections(llmq_params, pQuorumBaseBlockIndex, auto allConnections = llmq::utils::GetQuorumConnections(llmq_params, sporkman, pQuorumBaseBlockIndex, proTxHash, false);
proTxHash, false); auto outboundConnections = llmq::utils::GetQuorumConnections(llmq_params, sporkman, pQuorumBaseBlockIndex, proTxHash, true);
auto outboundConnections = llmq::utils::GetQuorumConnections(llmq_params,
pQuorumBaseBlockIndex, proTxHash,
true);
std::map<uint256, CAddress> foundConnections; std::map<uint256, CAddress> foundConnections;
const NodeContext& node = EnsureAnyNodeContext(request.context); const NodeContext& node = EnsureAnyNodeContext(request.context);
node.connman->ForEachNode([&](const CNode* pnode) { node.connman->ForEachNode([&](const CNode* pnode) {
@ -882,7 +879,7 @@ static UniValue _quorum(const JSONRPCRequest& request)
} else if (command == "quorumdkginfo") { } else if (command == "quorumdkginfo") {
return quorum_dkginfo(new_request, llmq_ctx, chainman); return quorum_dkginfo(new_request, llmq_ctx, chainman);
} else if (command == "quorumdkgstatus") { } else if (command == "quorumdkgstatus") {
return quorum_dkgstatus(new_request, chainman, llmq_ctx); return quorum_dkgstatus(new_request, chainman, *node.sporkman, llmq_ctx);
} else if (command == "quorummemberof") { } else if (command == "quorummemberof") {
return quorum_memberof(new_request, chainman, node, llmq_ctx); return quorum_memberof(new_request, chainman, node, llmq_ctx);
} else if (command == "quorumsign" || command == "quorumverify" || command == "quorumhasrecsig" || command == "quorumgetrecsig" || command == "quorumisconflicting") { } else if (command == "quorumsign" || command == "quorumverify" || command == "quorumhasrecsig" || command == "quorumgetrecsig" || command == "quorumisconflicting") {

View File

@ -23,8 +23,6 @@
#include <string> #include <string>
std::unique_ptr<CSporkManager> sporkManager;
const std::string SporkStore::SERIALIZATION_VERSION_STRING = "CSporkManager-Version-2"; const std::string SporkStore::SERIALIZATION_VERSION_STRING = "CSporkManager-Version-2";
std::optional<SporkValue> CSporkManager::SporkValueIfActive(SporkId nSporkID) const std::optional<SporkValue> CSporkManager::SporkValueIfActive(SporkId nSporkID) const

View File

@ -78,7 +78,6 @@ struct CSporkDef
MAKE_SPORK_DEF(SPORK_24_TEST_EHF, 4070908800ULL), // OFF MAKE_SPORK_DEF(SPORK_24_TEST_EHF, 4070908800ULL), // OFF
}; };
#undef MAKE_SPORK_DEF #undef MAKE_SPORK_DEF
extern std::unique_ptr<CSporkManager> sporkManager;
/** /**
* Sporks are network parameters used primarily to prevent forking and turn * Sporks are network parameters used primarily to prevent forking and turn

View File

@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler, auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *m_node.govman, m_node.cj_ctx, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.sporkman, m_node.cj_ctx,
m_node.llmq_ctx, false); m_node.llmq_ctx, false);
// Mock an outbound peer // Mock an outbound peer
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman); auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler, auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *m_node.govman, m_node.cj_ctx, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.sporkman, m_node.cj_ctx,
m_node.llmq_ctx, false); m_node.llmq_ctx, false);
constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS; constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS;
@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler, auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *m_node.govman, m_node.cj_ctx, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.sporkman, m_node.cj_ctx,
m_node.llmq_ctx, false); m_node.llmq_ctx, false);
banman->ClearBanned(); banman->ClearBanned();
@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler, auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *m_node.govman, m_node.cj_ctx, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.sporkman, m_node.cj_ctx,
m_node.llmq_ctx, false); m_node.llmq_ctx, false);
banman->ClearBanned(); banman->ClearBanned();
@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); auto banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler, auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
*m_node.chainman, *m_node.mempool, *m_node.govman, m_node.cj_ctx, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.sporkman, m_node.cj_ctx,
m_node.llmq_ctx, false); m_node.llmq_ctx, false);
banman->ClearBanned(); banman->ClearBanned();

View File

@ -222,8 +222,7 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests. m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
::sporkManager = std::make_unique<CSporkManager>(); m_node.sporkman = std::make_unique<CSporkManager>();
m_node.sporkman = ::sporkManager.get();
::governance = std::make_unique<CGovernanceManager>(); ::governance = std::make_unique<CGovernanceManager>();
m_node.govman = ::governance.get(); m_node.govman = ::governance.get();
::masternodeSync = std::make_unique<CMasternodeSync>(*m_node.connman, *m_node.govman); ::masternodeSync = std::make_unique<CMasternodeSync>(*m_node.connman, *m_node.govman);
@ -257,8 +256,7 @@ ChainTestingSetup::~ChainTestingSetup()
::masternodeSync.reset(); ::masternodeSync.reset();
m_node.govman = nullptr; m_node.govman = nullptr;
::governance.reset(); ::governance.reset();
m_node.sporkman = nullptr; m_node.sporkman.reset();
::sporkManager.reset();
m_node.connman.reset(); m_node.connman.reset();
m_node.addrman.reset(); m_node.addrman.reset();
m_node.args = nullptr; m_node.args = nullptr;
@ -291,7 +289,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
m_node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); m_node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(), m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(),
*m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.govman, *m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.govman,
m_node.cj_ctx, m_node.llmq_ctx, false); *m_node.sporkman, m_node.cj_ctx, m_node.llmq_ctx, false);
{ {
CConnman::Options options; CConnman::Options options;
options.m_msgproc = m_node.peerman.get(); options.m_msgproc = m_node.peerman.get();