mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: pass CActiveMasternodeManager as pointer arg to LLMQContext
This commit is contained in:
parent
5e0f77747a
commit
136e445abc
@ -1954,7 +1954,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
|||||||
node.llmq_ctx->Stop();
|
node.llmq_ctx->Stop();
|
||||||
}
|
}
|
||||||
node.llmq_ctx.reset();
|
node.llmq_ctx.reset();
|
||||||
node.llmq_ctx.reset(new LLMQContext(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman, *node.mempool, node.peerman, false, fReset || fReindexChainState));
|
node.llmq_ctx.reset(new LLMQContext(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman, *node.mempool, node.mn_activeman, node.peerman, false, fReset || fReindexChainState));
|
||||||
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||||
node.llmq_ctx->Start();
|
node.llmq_ctx->Start();
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <masternode/sync.h>
|
#include <masternode/sync.h>
|
||||||
|
|
||||||
LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||||
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool,
|
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool, const CActiveMasternodeManager* mn_activeman,
|
||||||
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe) :
|
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe) :
|
||||||
bls_worker{std::make_shared<CBLSWorker>()},
|
bls_worker{std::make_shared<CBLSWorker>()},
|
||||||
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
||||||
@ -29,14 +29,14 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
|||||||
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, connman, dmnman, evo_db);
|
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, connman, dmnman, evo_db);
|
||||||
return llmq::quorumBlockProcessor.get();
|
return llmq::quorumBlockProcessor.get();
|
||||||
}()},
|
}()},
|
||||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, *quorum_block_processor, sporkman, unit_tests, wipe)},
|
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, *quorum_block_processor, mn_activeman, 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, dmnman, *qdkgsman, evo_db, *quorum_block_processor, sporkman, ::masternodeSync);
|
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, 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, mn_activeman, *llmq::quorumManager, unit_tests, wipe)},
|
||||||
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, *llmq::quorumManager, sporkman, peerman)},
|
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, mn_activeman, *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);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
class CActiveMasternodeManager;
|
||||||
class CBLSWorker;
|
class CBLSWorker;
|
||||||
class CChainState;
|
class CChainState;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
@ -34,7 +35,7 @@ struct LLMQContext {
|
|||||||
LLMQContext() = delete;
|
LLMQContext() = delete;
|
||||||
LLMQContext(const LLMQContext&) = delete;
|
LLMQContext(const LLMQContext&) = delete;
|
||||||
LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||||
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool,
|
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool, const CActiveMasternodeManager* mn_activeman,
|
||||||
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe);
|
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe);
|
||||||
~LLMQContext();
|
~LLMQContext();
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void CDKGSession::SendContributions(CDKGPendingMessages& pendingMessages)
|
|||||||
|
|
||||||
logger.Batch("encrypted contributions. time=%d", t1.count());
|
logger.Batch("encrypted contributions. time=%d", t1.count());
|
||||||
|
|
||||||
qc.sig = ::activeMasternodeManager->Sign(qc.GetSignHash());
|
qc.sig = m_mn_activeman->Sign(qc.GetSignHash());
|
||||||
|
|
||||||
logger.Flush();
|
logger.Flush();
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan)
|
|||||||
|
|
||||||
bool complain = false;
|
bool complain = false;
|
||||||
CBLSSecretKey skContribution;
|
CBLSSecretKey skContribution;
|
||||||
if (!::activeMasternodeManager->Decrypt(*qc.contributions, *myIdx, skContribution, PROTOCOL_VERSION)) {
|
if (!m_mn_activeman->Decrypt(*qc.contributions, *myIdx, skContribution, PROTOCOL_VERSION)) {
|
||||||
logger.Batch("contribution from %s could not be decrypted", member->dmn->proTxHash.ToString());
|
logger.Batch("contribution from %s could not be decrypted", member->dmn->proTxHash.ToString());
|
||||||
complain = true;
|
complain = true;
|
||||||
} else if (member->idx != myIdx && ShouldSimulateError(DKGError::type::COMPLAIN_LIE)) {
|
} else if (member->idx != myIdx && ShouldSimulateError(DKGError::type::COMPLAIN_LIE)) {
|
||||||
@ -517,7 +517,7 @@ void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
|||||||
|
|
||||||
logger.Batch("sending complaint. badCount=%d, complaintCount=%d", badCount, complaintCount);
|
logger.Batch("sending complaint. badCount=%d, complaintCount=%d", badCount, complaintCount);
|
||||||
|
|
||||||
qc.sig = ::activeMasternodeManager->Sign(qc.GetSignHash());
|
qc.sig = m_mn_activeman->Sign(qc.GetSignHash());
|
||||||
|
|
||||||
logger.Flush();
|
logger.Flush();
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qj.sig = ::activeMasternodeManager->Sign(qj.GetSignHash());
|
qj.sig = m_mn_activeman->Sign(qj.GetSignHash());
|
||||||
|
|
||||||
logger.Flush();
|
logger.Flush();
|
||||||
|
|
||||||
@ -1003,7 +1003,7 @@ void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
|
|||||||
(*commitmentHash.begin())++;
|
(*commitmentHash.begin())++;
|
||||||
}
|
}
|
||||||
|
|
||||||
qc.sig = ::activeMasternodeManager->Sign(commitmentHash);
|
qc.sig = m_mn_activeman->Sign(commitmentHash);
|
||||||
qc.quorumSig = skShare.Sign(commitmentHash);
|
qc.quorumSig = skShare.Sign(commitmentHash);
|
||||||
|
|
||||||
if (lieType == 3) {
|
if (lieType == 3) {
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
class UniValue;
|
class CActiveMasternodeManager;
|
||||||
class CInv;
|
class CInv;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
|
class UniValue;
|
||||||
|
|
||||||
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
|
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
|
||||||
|
|
||||||
namespace llmq
|
namespace llmq
|
||||||
@ -273,6 +275,7 @@ private:
|
|||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
CDKGSessionManager& dkgManager;
|
CDKGSessionManager& dkgManager;
|
||||||
CDKGDebugManager& dkgDebugManager;
|
CDKGDebugManager& dkgDebugManager;
|
||||||
|
const CActiveMasternodeManager* m_mn_activeman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
|
|
||||||
const CBlockIndex* m_quorum_base_block_index{nullptr};
|
const CBlockIndex* m_quorum_base_block_index{nullptr};
|
||||||
@ -314,8 +317,11 @@ private:
|
|||||||
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman, const CSporkManager& sporkman) :
|
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDeterministicMNManager& dmnman,
|
||||||
params(_params), blsWorker(_blsWorker), cache(_blsWorker), m_dmnman(dmnman), dkgManager(_dkgManager), dkgDebugManager(_dkgDebugManager), m_sporkman(sporkman), connman(_connman) {}
|
CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman,
|
||||||
|
const CActiveMasternodeManager* mn_activeman, const CSporkManager& sporkman) :
|
||||||
|
params(_params), blsWorker(_blsWorker), cache(_blsWorker), m_dmnman(dmnman), dkgManager(_dkgManager),
|
||||||
|
dkgDebugManager(_dkgDebugManager), m_mn_activeman(mn_activeman), 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);
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ namespace llmq
|
|||||||
|
|
||||||
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CSporkManager& sporkman, const Consensus::LLMQParams& _params, int _quorumIndex) :
|
const CActiveMasternodeManager* mn_activeman, const CSporkManager& sporkman, const Consensus::LLMQParams& _params,
|
||||||
|
int _quorumIndex) :
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
@ -34,10 +35,11 @@ CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chai
|
|||||||
dkgDebugManager(_dkgDebugManager),
|
dkgDebugManager(_dkgDebugManager),
|
||||||
dkgManager(_dkgManager),
|
dkgManager(_dkgManager),
|
||||||
quorumBlockProcessor(_quorumBlockProcessor),
|
quorumBlockProcessor(_quorumBlockProcessor),
|
||||||
|
m_mn_activeman(mn_activeman),
|
||||||
m_sporkman(sporkman),
|
m_sporkman(sporkman),
|
||||||
params(_params),
|
params(_params),
|
||||||
quorumIndex(_quorumIndex),
|
quorumIndex(_quorumIndex),
|
||||||
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, dmnman, _dkgManager, _dkgDebugManager, _connman, sporkman)),
|
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, dmnman, _dkgManager, _dkgDebugManager, _connman, m_mn_activeman, 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),
|
||||||
@ -185,14 +187,14 @@ void CDKGSessionHandler::StopThread()
|
|||||||
|
|
||||||
bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
||||||
{
|
{
|
||||||
curSession = std::make_unique<CDKGSession>(params, blsWorker, m_dmnman, dkgManager, dkgDebugManager, connman, m_sporkman);
|
curSession = std::make_unique<CDKGSession>(params, blsWorker, m_dmnman, dkgManager, dkgDebugManager, connman, m_mn_activeman, m_sporkman);
|
||||||
|
|
||||||
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
|
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mns = utils::GetAllQuorumMembers(params.type, m_dmnman, pQuorumBaseBlockIndex);
|
auto mns = utils::GetAllQuorumMembers(params.type, m_dmnman, pQuorumBaseBlockIndex);
|
||||||
if (!curSession->Init(pQuorumBaseBlockIndex, mns, WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()), quorumIndex)) {
|
if (!curSession->Init(pQuorumBaseBlockIndex, mns, WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash()), quorumIndex)) {
|
||||||
LogPrintf("CDKGSessionManager::%s -- height[%d] quorum initialization failed for %s qi[%d] mns[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex, mns.size());
|
LogPrintf("CDKGSessionManager::%s -- height[%d] quorum initialization failed for %s qi[%d] mns[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex, mns.size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
class CActiveMasternodeManager;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CBLSWorker;
|
class CBLSWorker;
|
||||||
class CChainState;
|
class CChainState;
|
||||||
@ -125,6 +126,7 @@ private:
|
|||||||
CDKGDebugManager& dkgDebugManager;
|
CDKGDebugManager& dkgDebugManager;
|
||||||
CDKGSessionManager& dkgManager;
|
CDKGSessionManager& dkgManager;
|
||||||
CQuorumBlockProcessor& quorumBlockProcessor;
|
CQuorumBlockProcessor& quorumBlockProcessor;
|
||||||
|
const CActiveMasternodeManager* m_mn_activeman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
const Consensus::LLMQParams params;
|
const Consensus::LLMQParams params;
|
||||||
const int quorumIndex;
|
const int quorumIndex;
|
||||||
@ -146,7 +148,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CSporkManager& sporkman, const Consensus::LLMQParams& _params, int _quorumIndex);
|
const CActiveMasternodeManager* mn_activeman, const CSporkManager& sporkman, const Consensus::LLMQParams& _params,
|
||||||
|
int _quorumIndex);
|
||||||
~CDKGSessionHandler() = default;
|
~CDKGSessionHandler() = default;
|
||||||
|
|
||||||
void UpdatedBlockTip(const CBlockIndex *pindexNew);
|
void UpdatedBlockTip(const CBlockIndex *pindexNew);
|
||||||
|
@ -25,8 +25,8 @@ 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, CDeterministicMNManager& dmnman,
|
CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman,
|
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* mn_activeman,
|
||||||
bool unitTests, bool fWipe) :
|
const CSporkManager& sporkman, 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),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
@ -49,7 +49,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, dmnman, dkgDebugManager, *this, quorumBlockProcessor, spork_manager, params, i));
|
std::forward_as_tuple(blsWorker, m_chainstate, connman, dmnman, dkgDebugManager, *this, quorumBlockProcessor, mn_activeman, spork_manager, params, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
class CActiveMasternodeManager;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChainState;
|
class CChainState;
|
||||||
class CDBWrapper;
|
class CDBWrapper;
|
||||||
@ -66,8 +67,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman,
|
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* mn_activeman,
|
||||||
bool unitTests, bool fWipe);
|
const CSporkManager& sporkman, bool unitTests, bool fWipe);
|
||||||
~CDKGSessionManager() = default;
|
~CDKGSessionManager() = default;
|
||||||
|
|
||||||
void StartThreads();
|
void StartThreads();
|
||||||
|
@ -101,9 +101,9 @@ bool CQuorum::SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CQuorum::SetSecretKeyShare(const CBLSSecretKey& secretKeyShare)
|
bool CQuorum::SetSecretKeyShare(const CBLSSecretKey& secretKeyShare, const CActiveMasternodeManager& mn_activeman)
|
||||||
{
|
{
|
||||||
if (!secretKeyShare.IsValid() || (secretKeyShare.GetPublicKey() != GetPubKeyShare(WITH_LOCK(::activeMasternodeManager->cs, return GetMemberIndex(::activeMasternodeManager->GetProTxHash()))))) {
|
if (!secretKeyShare.IsValid() || (secretKeyShare.GetPublicKey() != GetPubKeyShare(WITH_LOCK(mn_activeman.cs, return GetMemberIndex(mn_activeman.GetProTxHash()))))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
@ -205,8 +205,10 @@ bool CQuorum::ReadContributions(CEvoDB& evoDb)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager,
|
CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman, const std::unique_ptr<CMasternodeSync>& mn_sync) :
|
CDKGSessionManager& _dkgManager, CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
|
const CActiveMasternodeManager* mn_activeman, const CSporkManager& sporkman,
|
||||||
|
const std::unique_ptr<CMasternodeSync>& mn_sync) :
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
@ -214,6 +216,7 @@ CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate,
|
|||||||
dkgManager(_dkgManager),
|
dkgManager(_dkgManager),
|
||||||
m_evoDb(_evoDb),
|
m_evoDb(_evoDb),
|
||||||
quorumBlockProcessor(_quorumBlockProcessor),
|
quorumBlockProcessor(_quorumBlockProcessor),
|
||||||
|
m_mn_activeman(mn_activeman),
|
||||||
m_sporkman(sporkman),
|
m_sporkman(sporkman),
|
||||||
m_mn_sync(mn_sync)
|
m_mn_sync(mn_sync)
|
||||||
{
|
{
|
||||||
@ -250,9 +253,11 @@ void CQuorumManager::TriggerQuorumDataRecoveryThreads(const CBlockIndex* pIndex)
|
|||||||
const auto vecQuorums = ScanQuorums(params.type, pIndex, params.keepOldConnections);
|
const auto vecQuorums = ScanQuorums(params.type, pIndex, params.keepOldConnections);
|
||||||
|
|
||||||
// First check if we are member of any quorum of this type
|
// First check if we are member of any quorum of this type
|
||||||
const uint256 proTxHash = fMasternodeMode ?
|
const uint256 proTxHash = [this]() {
|
||||||
WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()) :
|
if (!fMasternodeMode) return uint256();
|
||||||
uint256();
|
assert(m_mn_activeman);
|
||||||
|
return WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash());
|
||||||
|
}();
|
||||||
|
|
||||||
bool fWeAreQuorumTypeMember = ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
|
bool fWeAreQuorumTypeMember = ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
|
||||||
return pQuorum->IsValidMember(proTxHash);
|
return pQuorum->IsValidMember(proTxHash);
|
||||||
@ -344,9 +349,11 @@ void CQuorumManager::CheckQuorumConnections(const Consensus::LLMQParams& llmqPar
|
|||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- llmqType[%d] h[%d] keeping mn quorum connections for quorum: [%d:%s]\n", __func__, ToUnderlying(llmqParams.type), pindexNew->nHeight, curDkgHeight, curDkgBlock.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, curDkgHeight, curDkgBlock.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint256 myProTxHash = fMasternodeMode ?
|
const uint256 myProTxHash = [this]() {
|
||||||
WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()) :
|
if (!fMasternodeMode) return uint256();
|
||||||
uint256();
|
assert(m_mn_activeman);
|
||||||
|
return WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash());
|
||||||
|
}();
|
||||||
|
|
||||||
bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend;
|
bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend;
|
||||||
|
|
||||||
@ -646,6 +653,8 @@ CQuorumCPtr CQuorumManager::GetQuorum(Consensus::LLMQType llmqType, gsl::not_nul
|
|||||||
|
|
||||||
size_t CQuorumManager::GetQuorumRecoveryStartOffset(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex) const
|
size_t CQuorumManager::GetQuorumRecoveryStartOffset(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex) const
|
||||||
{
|
{
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
|
||||||
auto mns = m_dmnman.GetListForBlock(pIndex);
|
auto mns = m_dmnman.GetListForBlock(pIndex);
|
||||||
std::vector<uint256> vecProTxHashes;
|
std::vector<uint256> vecProTxHashes;
|
||||||
vecProTxHashes.reserve(mns.GetValidMNsCount());
|
vecProTxHashes.reserve(mns.GetValidMNsCount());
|
||||||
@ -655,10 +664,10 @@ size_t CQuorumManager::GetQuorumRecoveryStartOffset(const CQuorumCPtr pQuorum, c
|
|||||||
std::sort(vecProTxHashes.begin(), vecProTxHashes.end());
|
std::sort(vecProTxHashes.begin(), vecProTxHashes.end());
|
||||||
size_t nIndex{0};
|
size_t nIndex{0};
|
||||||
{
|
{
|
||||||
LOCK(::activeMasternodeManager->cs);
|
LOCK(m_mn_activeman->cs);
|
||||||
for (const auto i : irange::range(vecProTxHashes.size())) {
|
for (const auto i : irange::range(vecProTxHashes.size())) {
|
||||||
// cppcheck-suppress useStlAlgorithm
|
// cppcheck-suppress useStlAlgorithm
|
||||||
if (::activeMasternodeManager->GetProTxHash() == vecProTxHashes[i]) {
|
if (m_mn_activeman->GetProTxHash() == vecProTxHashes[i]) {
|
||||||
nIndex = i;
|
nIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -819,6 +828,7 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, const std::string& msg_t
|
|||||||
|
|
||||||
// Check if request has ENCRYPTED_CONTRIBUTIONS data
|
// Check if request has ENCRYPTED_CONTRIBUTIONS data
|
||||||
if (request.GetDataMask() & CQuorumDataRequest::ENCRYPTED_CONTRIBUTIONS) {
|
if (request.GetDataMask() & CQuorumDataRequest::ENCRYPTED_CONTRIBUTIONS) {
|
||||||
|
assert(fMasternodeMode);
|
||||||
|
|
||||||
if (WITH_LOCK(pQuorum->cs, return pQuorum->quorumVvec->size() != size_t(pQuorum->params.threshold))) {
|
if (WITH_LOCK(pQuorum->cs, return pQuorum->quorumVvec->size() != size_t(pQuorum->params.threshold))) {
|
||||||
return errorHandler("No valid quorum verification vector available", 0); // Don't bump score because we asked for it
|
return errorHandler("No valid quorum verification vector available", 0); // Don't bump score because we asked for it
|
||||||
@ -835,13 +845,13 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, const std::string& msg_t
|
|||||||
std::vector<CBLSSecretKey> vecSecretKeys;
|
std::vector<CBLSSecretKey> vecSecretKeys;
|
||||||
vecSecretKeys.resize(vecEncrypted.size());
|
vecSecretKeys.resize(vecEncrypted.size());
|
||||||
for (const auto i : irange::range(vecEncrypted.size())) {
|
for (const auto i : irange::range(vecEncrypted.size())) {
|
||||||
if (!::activeMasternodeManager->Decrypt(vecEncrypted[i], memberIdx, vecSecretKeys[i], PROTOCOL_VERSION)) {
|
if (!Assert(m_mn_activeman)->Decrypt(vecEncrypted[i], memberIdx, vecSecretKeys[i], PROTOCOL_VERSION)) {
|
||||||
return errorHandler("Failed to decrypt");
|
return errorHandler("Failed to decrypt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CBLSSecretKey secretKeyShare = blsWorker.AggregateSecretKeys(vecSecretKeys);
|
CBLSSecretKey secretKeyShare = blsWorker.AggregateSecretKeys(vecSecretKeys);
|
||||||
if (!pQuorum->SetSecretKeyShare(secretKeyShare)) {
|
if (!pQuorum->SetSecretKeyShare(secretKeyShare, *m_mn_activeman)) {
|
||||||
return errorHandler("Invalid secret key share received");
|
return errorHandler("Invalid secret key share received");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -883,6 +893,8 @@ void CQuorumManager::StartCachePopulatorThread(const CQuorumCPtr pQuorum) const
|
|||||||
|
|
||||||
void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, uint16_t nDataMaskIn) const
|
void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, const CBlockIndex* pIndex, uint16_t nDataMaskIn) const
|
||||||
{
|
{
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
|
||||||
if (pQuorum->fQuorumDataRecoveryThreadRunning) {
|
if (pQuorum->fQuorumDataRecoveryThreadRunning) {
|
||||||
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Already running\n", __func__);
|
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Already running\n", __func__);
|
||||||
return;
|
return;
|
||||||
@ -916,7 +928,7 @@ void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, co
|
|||||||
|
|
||||||
vecMemberHashes.reserve(pQuorum->qc->validMembers.size());
|
vecMemberHashes.reserve(pQuorum->qc->validMembers.size());
|
||||||
for (auto& member : pQuorum->members) {
|
for (auto& member : pQuorum->members) {
|
||||||
if (pQuorum->IsValidMember(member->proTxHash) && member->proTxHash != WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash())) {
|
if (pQuorum->IsValidMember(member->proTxHash) && member->proTxHash != WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash())) {
|
||||||
vecMemberHashes.push_back(member->proTxHash);
|
vecMemberHashes.push_back(member->proTxHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -965,7 +977,7 @@ void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, co
|
|||||||
printLog("Connect");
|
printLog("Connect");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto proTxHash = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash());
|
auto proTxHash = WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash());
|
||||||
connman.ForEachNode([&](CNode* pNode) {
|
connman.ForEachNode([&](CNode* pNode) {
|
||||||
auto verifiedProRegTxHash = pNode->GetVerifiedProRegTxHash();
|
auto verifiedProRegTxHash = pNode->GetVerifiedProRegTxHash();
|
||||||
if (pCurrentMemberHash == nullptr || verifiedProRegTxHash != *pCurrentMemberHash) {
|
if (pCurrentMemberHash == nullptr || verifiedProRegTxHash != *pCurrentMemberHash) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
class CActiveMasternodeManager;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CChainState;
|
class CChainState;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
@ -192,7 +193,7 @@ public:
|
|||||||
void Init(CFinalCommitmentPtr _qc, const CBlockIndex* _pQuorumBaseBlockIndex, const uint256& _minedBlockHash, Span<CDeterministicMNCPtr> _members);
|
void Init(CFinalCommitmentPtr _qc, const CBlockIndex* _pQuorumBaseBlockIndex, const uint256& _minedBlockHash, Span<CDeterministicMNCPtr> _members);
|
||||||
|
|
||||||
bool SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecIn);
|
bool SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecIn);
|
||||||
bool SetSecretKeyShare(const CBLSSecretKey& secretKeyShare);
|
bool SetSecretKeyShare(const CBLSSecretKey& secretKeyShare, const CActiveMasternodeManager& mn_activeman);
|
||||||
|
|
||||||
bool HasVerificationVector() const;
|
bool HasVerificationVector() const;
|
||||||
bool IsMember(const uint256& proTxHash) const;
|
bool IsMember(const uint256& proTxHash) const;
|
||||||
@ -223,6 +224,7 @@ private:
|
|||||||
CDKGSessionManager& dkgManager;
|
CDKGSessionManager& dkgManager;
|
||||||
CEvoDB& m_evoDb;
|
CEvoDB& m_evoDb;
|
||||||
CQuorumBlockProcessor& quorumBlockProcessor;
|
CQuorumBlockProcessor& quorumBlockProcessor;
|
||||||
|
const CActiveMasternodeManager* m_mn_activeman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
|
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
|
||||||
|
|
||||||
@ -237,8 +239,9 @@ private:
|
|||||||
mutable CThreadInterrupt quorumThreadInterrupt;
|
mutable CThreadInterrupt quorumThreadInterrupt;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager,
|
CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor, const CSporkManager& sporkman, const std::unique_ptr<CMasternodeSync>& mn_sync);
|
CDKGSessionManager& _dkgManager, CEvoDB& _evoDb, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
|
const CActiveMasternodeManager* mn_activeman, const CSporkManager& sporkman, const std::unique_ptr<CMasternodeSync>& mn_sync);
|
||||||
~CQuorumManager() { Stop(); };
|
~CQuorumManager() { Stop(); };
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
@ -539,9 +539,9 @@ void CRecoveredSigsDb::CleanupOldVotes(int64_t maxAge)
|
|||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
CSigningManager::CSigningManager(CConnman& _connman, const CQuorumManager& _qman,
|
CSigningManager::CSigningManager(CConnman& _connman, const CActiveMasternodeManager* mn_activeman, const CQuorumManager& _qman,
|
||||||
bool fMemory, bool fWipe) :
|
bool fMemory, bool fWipe) :
|
||||||
db(fMemory, fWipe), connman(_connman), qman(_qman)
|
db(fMemory, fWipe), connman(_connman), m_mn_activeman(mn_activeman), qman(_qman)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,7 +896,9 @@ void CSigningManager::UnregisterRecoveredSigsListener(CRecoveredSigsListener* l)
|
|||||||
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id, const uint256& msgHash, const uint256& quorumHash, bool allowReSign)
|
bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigSharesManager& shareman, const uint256& id, const uint256& msgHash, const uint256& quorumHash, bool allowReSign)
|
||||||
{
|
{
|
||||||
if (!fMasternodeMode) return false;
|
if (!fMasternodeMode) return false;
|
||||||
if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash().IsNull())) return false;
|
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
if (WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash().IsNull())) return false;
|
||||||
|
|
||||||
const CQuorumCPtr quorum = [&]() {
|
const CQuorumCPtr quorum = [&]() {
|
||||||
if (quorumHash.IsNull()) {
|
if (quorumHash.IsNull()) {
|
||||||
@ -918,7 +920,7 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigShares
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WITH_LOCK(::activeMasternodeManager->cs, return quorum->IsValidMember(::activeMasternodeManager->GetProTxHash()))) {
|
if (!WITH_LOCK(m_mn_activeman->cs, return quorum->IsValidMember(m_mn_activeman->GetProTxHash()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
class CActiveMasternodeManager;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CDataStream;
|
class CDataStream;
|
||||||
class CDBBatch;
|
class CDBBatch;
|
||||||
@ -162,6 +163,7 @@ private:
|
|||||||
|
|
||||||
CRecoveredSigsDb db;
|
CRecoveredSigsDb db;
|
||||||
CConnman& connman;
|
CConnman& connman;
|
||||||
|
const CActiveMasternodeManager* m_mn_activeman;
|
||||||
const CQuorumManager& qman;
|
const CQuorumManager& qman;
|
||||||
|
|
||||||
std::atomic<PeerManager*> m_peerman{nullptr};
|
std::atomic<PeerManager*> m_peerman{nullptr};
|
||||||
@ -177,7 +179,7 @@ private:
|
|||||||
std::vector<CRecoveredSigsListener*> recoveredSigsListeners GUARDED_BY(cs);
|
std::vector<CRecoveredSigsListener*> recoveredSigsListeners GUARDED_BY(cs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSigningManager(CConnman& _connman, const CQuorumManager& _qman, bool fMemory, bool fWipe);
|
CSigningManager(CConnman& _connman, const CActiveMasternodeManager* mn_activeman, const CQuorumManager& _qman, bool fMemory, bool fWipe);
|
||||||
|
|
||||||
bool AlreadyHave(const CInv& inv) const;
|
bool AlreadyHave(const CInv& inv) const;
|
||||||
bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret) const;
|
bool GetRecoveredSigForGetData(const uint256& hash, CRecoveredSig& ret) const;
|
||||||
|
@ -219,7 +219,9 @@ void CSigSharesManager::ProcessMessage(const CNode& pfrom, const CSporkManager&
|
|||||||
{
|
{
|
||||||
// non-masternodes are not interested in sigshares
|
// non-masternodes are not interested in sigshares
|
||||||
if (!fMasternodeMode) return;
|
if (!fMasternodeMode) return;
|
||||||
if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash().IsNull())) return;
|
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
if (WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash().IsNull())) return;
|
||||||
|
|
||||||
if (sporkman.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED) && msg_type == NetMsgType::QSIGSHARE) {
|
if (sporkman.IsSporkActive(SPORK_21_QUORUM_ALL_CONNECTED) && msg_type == NetMsgType::QSIGSHARE) {
|
||||||
std::vector<CSigShare> receivedSigShares;
|
std::vector<CSigShare> receivedSigShares;
|
||||||
@ -407,7 +409,7 @@ bool CSigSharesManager::ProcessMessageBatchedSigShares(const CNode& pfrom, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bool ban{false}; !PreVerifyBatchedSigShares(qman, sessionInfo, batchedSigShares, ban)) {
|
if (bool ban{false}; !PreVerifyBatchedSigShares(*Assert(m_mn_activeman), qman, sessionInfo, batchedSigShares, ban)) {
|
||||||
return !ban;
|
return !ban;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,6 +458,8 @@ bool CSigSharesManager::ProcessMessageBatchedSigShares(const CNode& pfrom, const
|
|||||||
|
|
||||||
void CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& sigShare)
|
void CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& sigShare)
|
||||||
{
|
{
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
|
||||||
auto quorum = qman.GetQuorum(sigShare.getLlmqType(), sigShare.getQuorumHash());
|
auto quorum = qman.GetQuorum(sigShare.getLlmqType(), sigShare.getQuorumHash());
|
||||||
if (!quorum) {
|
if (!quorum) {
|
||||||
return;
|
return;
|
||||||
@ -464,7 +468,7 @@ void CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& s
|
|||||||
// quorum is too old
|
// quorum is too old
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!quorum->IsMember(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()))) {
|
if (!quorum->IsMember(WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash()))) {
|
||||||
// we're not a member so we can't verify it (we actually shouldn't have received it)
|
// we're not a member so we can't verify it (we actually shouldn't have received it)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -505,7 +509,8 @@ void CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& s
|
|||||||
sigShare.GetSignHash().ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(), sigShare.getQuorumMember(), fromId);
|
sigShare.GetSignHash().ToString(), sigShare.getId().ToString(), sigShare.getMsgHash().ToString(), sigShare.getQuorumMember(), fromId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSigSharesManager::PreVerifyBatchedSigShares(const CQuorumManager& quorum_manager, const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, bool& retBan)
|
bool CSigSharesManager::PreVerifyBatchedSigShares(const CActiveMasternodeManager& mn_activeman, const CQuorumManager& quorum_manager,
|
||||||
|
const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, bool& retBan)
|
||||||
{
|
{
|
||||||
retBan = false;
|
retBan = false;
|
||||||
|
|
||||||
@ -513,7 +518,7 @@ bool CSigSharesManager::PreVerifyBatchedSigShares(const CQuorumManager& quorum_m
|
|||||||
// quorum is too old
|
// quorum is too old
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!session.quorum->IsMember(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()))) {
|
if (!session.quorum->IsMember(WITH_LOCK(mn_activeman.cs, return mn_activeman.GetProTxHash()))) {
|
||||||
// we're not a member so we can't verify it (we actually shouldn't have received it)
|
// we're not a member so we can't verify it (we actually shouldn't have received it)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -691,13 +696,14 @@ void CSigSharesManager::ProcessPendingSigShares(const std::vector<CSigShare>& si
|
|||||||
// sig shares are already verified when entering this method
|
// sig shares are already verified when entering this method
|
||||||
void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CConnman& connman, const CQuorumCPtr& quorum)
|
void CSigSharesManager::ProcessSigShare(const CSigShare& sigShare, const CConnman& connman, const CQuorumCPtr& quorum)
|
||||||
{
|
{
|
||||||
auto llmqType = quorum->params.type;
|
assert(m_mn_activeman);
|
||||||
|
|
||||||
|
auto llmqType = quorum->params.type;
|
||||||
bool canTryRecovery = false;
|
bool canTryRecovery = false;
|
||||||
|
|
||||||
// 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, m_sporkman) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash()))) {
|
if (!IsAllMembersConnectedEnabled(llmqType, m_sporkman) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash()))) {
|
||||||
quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash());
|
quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1487,8 +1493,10 @@ void CSigSharesManager::SignPendingSigShares()
|
|||||||
|
|
||||||
std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorumCPtr& quorum, const uint256& id, const uint256& msgHash) const
|
std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorumCPtr& quorum, const uint256& id, const uint256& msgHash) const
|
||||||
{
|
{
|
||||||
|
assert(m_mn_activeman);
|
||||||
|
|
||||||
cxxtimer::Timer t(true);
|
cxxtimer::Timer t(true);
|
||||||
auto activeMasterNodeProTxHash = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->GetProTxHash());
|
auto activeMasterNodeProTxHash = WITH_LOCK(m_mn_activeman->cs, return m_mn_activeman->GetProTxHash());
|
||||||
|
|
||||||
if (!quorum->IsValidMember(activeMasterNodeProTxHash)) {
|
if (!quorum->IsValidMember(activeMasterNodeProTxHash)) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -401,6 +401,7 @@ private:
|
|||||||
|
|
||||||
CConnman& connman;
|
CConnman& connman;
|
||||||
CSigningManager& sigman;
|
CSigningManager& sigman;
|
||||||
|
const CActiveMasternodeManager* m_mn_activeman;
|
||||||
const CQuorumManager& qman;
|
const CQuorumManager& qman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
|
|
||||||
@ -410,8 +411,9 @@ private:
|
|||||||
std::atomic<uint32_t> recoveredSigsCounter{0};
|
std::atomic<uint32_t> recoveredSigsCounter{0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSigSharesManager(CConnman& _connman, CSigningManager& _sigman, const CQuorumManager& _qman, const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman) :
|
explicit CSigSharesManager(CConnman& _connman, CSigningManager& _sigman, const CActiveMasternodeManager* mn_activeman,
|
||||||
connman(_connman), sigman(_sigman), qman(_qman), m_sporkman(sporkman), m_peerman(peerman)
|
const CQuorumManager& _qman, const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman) :
|
||||||
|
connman(_connman), sigman(_sigman), m_mn_activeman(mn_activeman), qman(_qman), m_sporkman(sporkman), m_peerman(peerman)
|
||||||
{
|
{
|
||||||
workInterrupt.reset();
|
workInterrupt.reset();
|
||||||
};
|
};
|
||||||
@ -443,7 +445,8 @@ private:
|
|||||||
void ProcessMessageSigShare(NodeId fromId, const CSigShare& sigShare);
|
void ProcessMessageSigShare(NodeId fromId, const CSigShare& sigShare);
|
||||||
|
|
||||||
static bool VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv);
|
static bool VerifySigSharesInv(Consensus::LLMQType llmqType, const CSigSharesInv& inv);
|
||||||
static bool PreVerifyBatchedSigShares(const CQuorumManager& quorum_manager, const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, bool& retBan);
|
static bool PreVerifyBatchedSigShares(const CActiveMasternodeManager& mn_activeman, const CQuorumManager& quorum_manager,
|
||||||
|
const CSigSharesNodeState::SessionInfo& session, const CBatchedSigShares& batchedSigShares, bool& retBan);
|
||||||
|
|
||||||
void CollectPendingSigSharesToVerify(size_t maxUniqueSessions,
|
void CollectPendingSigSharesToVerify(size_t maxUniqueSessions,
|
||||||
std::unordered_map<NodeId, std::vector<CSigShare>>& retSigShares,
|
std::unordered_map<NodeId, std::vector<CSigShare>>& retSigShares,
|
||||||
|
@ -115,7 +115,8 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman, *node.mempool, node.peerman, true, false);
|
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||||
|
/* mn_activeman = */ nullptr, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
||||||
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor),
|
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor),
|
||||||
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler));
|
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user