refactor: move activeMasternodeInfo{Cs} into CActiveMasternodeManager

This commit is contained in:
Kittywhiskers Van Gogh 2024-03-16 19:19:24 +00:00
parent b8c1f010e7
commit e5295dec1f
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
15 changed files with 97 additions and 101 deletions

View File

@ -52,7 +52,7 @@ bool CCoinJoinQueue::Sign()
if (!fMasternodeMode) return false; if (!fMasternodeMode) return false;
uint256 hash = GetSignatureHash(); uint256 hash = GetSignatureHash();
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash, false)); CBLSSignature sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->Sign(hash, false));
if (!sig.IsValid()) { if (!sig.IsValid()) {
return false; return false;
} }
@ -104,7 +104,7 @@ bool CCoinJoinBroadcastTx::Sign()
if (!fMasternodeMode) return false; if (!fMasternodeMode) return false;
uint256 hash = GetSignatureHash(); uint256 hash = GetSignatureHash();
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash, false)); CBLSSignature sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->Sign(hash, false));
if (!sig.IsValid()) { if (!sig.IsValid()) {
return false; return false;
} }

View File

@ -56,7 +56,7 @@ void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
LogPrint(BCLog::COINJOIN, "DSACCEPT -- nDenom %d (%s) txCollateral %s", dsa.nDenom, CoinJoin::DenominationToString(dsa.nDenom), dsa.txCollateral.ToString()); /* Continued */ LogPrint(BCLog::COINJOIN, "DSACCEPT -- nDenom %d (%s) txCollateral %s", dsa.nDenom, CoinJoin::DenominationToString(dsa.nDenom), dsa.txCollateral.ToString()); /* Continued */
auto mnList = m_dmnman.GetListAtChainTip(); auto mnList = m_dmnman.GetListAtChainTip();
auto dmn = WITH_LOCK(activeMasternodeInfoCs, return mnList.GetValidMNByCollateral(activeMasternodeInfo.outpoint)); auto dmn = WITH_LOCK(::activeMasternodeManager->cs, return mnList.GetValidMNByCollateral(::activeMasternodeManager->m_info.outpoint));
if (!dmn) { if (!dmn) {
PushStatus(peer, STATUS_REJECTED, ERR_MN_LIST); PushStatus(peer, STATUS_REJECTED, ERR_MN_LIST);
return; return;
@ -67,7 +67,7 @@ void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
TRY_LOCK(cs_vecqueue, lockRecv); TRY_LOCK(cs_vecqueue, lockRecv);
if (!lockRecv) return; if (!lockRecv) return;
auto mnOutpoint = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint); auto mnOutpoint = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint);
if (ranges::any_of(vecCoinJoinQueue, if (ranges::any_of(vecCoinJoinQueue,
[&mnOutpoint](const auto& q){return q.masternodeOutpoint == mnOutpoint;})) { [&mnOutpoint](const auto& q){return q.masternodeOutpoint == mnOutpoint;})) {
@ -331,8 +331,8 @@ void CCoinJoinServer::CommitFinalTransaction()
// create and sign masternode dstx transaction // create and sign masternode dstx transaction
if (!m_dstxman.GetDSTX(hashTx)) { if (!m_dstxman.GetDSTX(hashTx)) {
CCoinJoinBroadcastTx dstxNew(finalTransaction, CCoinJoinBroadcastTx dstxNew(finalTransaction,
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint),
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash),
GetAdjustedTime()); GetAdjustedTime());
dstxNew.Sign(); dstxNew.Sign();
m_dstxman.AddDSTX(dstxNew); m_dstxman.AddDSTX(dstxNew);
@ -499,8 +499,8 @@ void CCoinJoinServer::CheckForCompleteQueue()
SetState(POOL_STATE_ACCEPTING_ENTRIES); SetState(POOL_STATE_ACCEPTING_ENTRIES);
CCoinJoinQueue dsq(nSessionDenom, CCoinJoinQueue dsq(nSessionDenom,
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint),
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash),
GetAdjustedTime(), true); GetAdjustedTime(), true);
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */ LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */
"with %d participants\n", dsq.ToString(), vecSessionCollaterals.size()); "with %d participants\n", dsq.ToString(), vecSessionCollaterals.size());
@ -713,8 +713,8 @@ bool CCoinJoinServer::CreateNewSession(const CCoinJoinAccept& dsa, PoolMessage&
if (!fUnitTest) { if (!fUnitTest) {
//broadcast that I'm accepting entries, only if it's the first entry through //broadcast that I'm accepting entries, only if it's the first entry through
CCoinJoinQueue dsq(nSessionDenom, CCoinJoinQueue dsq(nSessionDenom,
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint),
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash), WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash),
GetAdjustedTime(), false); GetAdjustedTime(), false);
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString()); LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CreateNewSession -- signing and relaying new queue: %s\n", dsq.ToString());
dsq.Sign(); dsq.Sign();

View File

@ -23,8 +23,8 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
{ {
if (!fMasternodeMode) return; if (!fMasternodeMode) return;
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
if (activeMasternodeInfo.proTxHash.IsNull()) return; if (::activeMasternodeManager->m_info.proTxHash.IsNull()) return;
uint256 signHash; uint256 signHash;
const auto receivedMNAuthChallenge = peer.GetReceivedMNAuthChallenge(); const auto receivedMNAuthChallenge = peer.GetReceivedMNAuthChallenge();
@ -42,7 +42,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION); nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
} }
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)}; const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
const CBLSPublicKeyVersionWrapper pubKey(*activeMasternodeInfo.blsPubKeyOperator, !is_basic_scheme_active); const CBLSPublicKeyVersionWrapper pubKey(*::activeMasternodeManager->m_info.blsPubKeyOperator, !is_basic_scheme_active);
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) { if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
signHash = ::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn())); signHash = ::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn()));
} else { } else {
@ -50,8 +50,8 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
} }
CMNAuth mnauth; CMNAuth mnauth;
mnauth.proRegTxHash = activeMasternodeInfo.proTxHash; mnauth.proRegTxHash = ::activeMasternodeManager->m_info.proTxHash;
mnauth.sig = activeMasternodeInfo.blsKeyOperator->Sign(signHash); mnauth.sig = ::activeMasternodeManager->m_info.blsKeyOperator->Sign(signHash);
LogPrint(BCLog::NET_NETCONN, "CMNAuth::%s -- Sending MNAUTH, peer=%d\n", __func__, peer.GetId()); LogPrint(BCLog::NET_NETCONN, "CMNAuth::%s -- Sending MNAUTH, peer=%d\n", __func__, peer.GetId());
@ -128,7 +128,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CDeterm
} }
const uint256 myProTxHash = fMasternodeMode ? const uint256 myProTxHash = fMasternodeMode ?
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash) : WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash) :
uint256(); uint256();
connman.ForEachNode([&](CNode* pnode2) { connman.ForEachNode([&](CNode* pnode2) {

View File

@ -692,14 +692,14 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg
} }
{ {
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
if (mn_payees.front()->proTxHash != activeMasternodeInfo.proTxHash) { if (mn_payees.front()->proTxHash != ::activeMasternodeManager->m_info.proTxHash) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s we are not the payee, skipping\n", __func__); LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s we are not the payee, skipping\n", __func__);
return std::nullopt; return std::nullopt;
} }
gov_sb.SetMasternodeOutpoint(activeMasternodeInfo.outpoint); gov_sb.SetMasternodeOutpoint(::activeMasternodeManager->m_info.outpoint);
gov_sb.Sign( *activeMasternodeInfo.blsKeyOperator); gov_sb.Sign( *::activeMasternodeManager->m_info.blsKeyOperator);
} // activeMasternodeInfoCs } // ::activeMasternodeManager->cs
if (std::string strError; !gov_sb.IsValidLocally(m_dmnman->GetListAtChainTip(), strError, true)) { if (std::string strError; !gov_sb.IsValidLocally(m_dmnman->GetListAtChainTip(), strError, true)) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Created trigger is invalid:%s\n", __func__, strError); LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Created trigger is invalid:%s\n", __func__, strError);
@ -720,7 +720,7 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
{ {
// only active masternodes can vote on triggers // only active masternodes can vote on triggers
if (!fMasternodeMode) return; if (!fMasternodeMode) return;
if (WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash.IsNull())) return; if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash.IsNull())) return;
LOCK2(cs_main, cs); LOCK2(cs_main, cs);
@ -763,9 +763,9 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman) bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman)
{ {
CGovernanceVote vote(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.outpoint), nHash, VOTE_SIGNAL_FUNDING, outcome); CGovernanceVote vote(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.outpoint), nHash, VOTE_SIGNAL_FUNDING, outcome);
vote.SetTime(GetAdjustedTime()); vote.SetTime(GetAdjustedTime());
vote.Sign(WITH_LOCK(activeMasternodeInfoCs, return *activeMasternodeInfo.blsKeyOperator)); vote.Sign(WITH_LOCK(::activeMasternodeManager->cs, return *::activeMasternodeManager->m_info.blsKeyOperator));
CGovernanceException exception; CGovernanceException exception;
if (!ProcessVoteAndRelay(vote, exception, connman)) { if (!ProcessVoteAndRelay(vote, exception, connman)) {

View File

@ -369,14 +369,14 @@ void PrepareShutdown(NodeContext& node)
pdsNotificationInterface = nullptr; pdsNotificationInterface = nullptr;
} }
if (fMasternodeMode) { if (fMasternodeMode) {
UnregisterValidationInterface(activeMasternodeManager.get()); UnregisterValidationInterface(::activeMasternodeManager.get());
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
// make sure to clean up BLS keys before global destructors are called (they have allocated from the secure memory pool) // make sure to clean up BLS keys before global destructors are called (they have allocated from the secure memory pool)
activeMasternodeInfo.blsKeyOperator.reset(); ::activeMasternodeManager->m_info.blsKeyOperator.reset();
activeMasternodeInfo.blsPubKeyOperator.reset(); ::activeMasternodeManager->m_info.blsPubKeyOperator.reset();
activeMasternodeManager.reset(); ::activeMasternodeManager.reset();
} }
node.chain_clients.clear(); node.chain_clients.clear();
@ -1859,19 +1859,19 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
fMasternodeMode = true; fMasternodeMode = true;
{ {
// Create and register activeMasternodeManager, will init later in ThreadImport // Create and register activeMasternodeManager, will init later in ThreadImport
activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(*node.connman, ::deterministicMNManager); ::activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(*node.connman, ::deterministicMNManager);
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
assert(activeMasternodeInfo.blsKeyOperator == nullptr); assert(::activeMasternodeManager->m_info.blsKeyOperator == nullptr);
assert(activeMasternodeInfo.blsPubKeyOperator == nullptr); assert(::activeMasternodeManager->m_info.blsPubKeyOperator == nullptr);
activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator); ::activeMasternodeManager->m_info.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator);
activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(keyOperator.GetPublicKey()); ::activeMasternodeManager->m_info.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(keyOperator.GetPublicKey());
// We don't know the actual scheme at this point, print both // We don't know the actual scheme at this point, print both
LogPrintf("MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n", LogPrintf("MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n",
activeMasternodeInfo.blsPubKeyOperator->ToString(true), ::activeMasternodeManager->m_info.blsPubKeyOperator->ToString(true),
activeMasternodeInfo.blsPubKeyOperator->ToString(false)); ::activeMasternodeManager->m_info.blsPubKeyOperator->ToString(false));
RegisterValidationInterface(activeMasternodeManager.get()); RegisterValidationInterface(::activeMasternodeManager.get());
} }
} }

View File

@ -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 = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(qc.GetSignHash())); qc.sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->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 (!qc.contributions->Decrypt(*myIdx, WITH_LOCK(activeMasternodeInfoCs, return *activeMasternodeInfo.blsKeyOperator), skContribution, PROTOCOL_VERSION)) { if (!qc.contributions->Decrypt(*myIdx, WITH_LOCK(::activeMasternodeManager->cs, return *::activeMasternodeManager->m_info.blsKeyOperator), 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 = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(qc.GetSignHash())); qc.sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->Sign(qc.GetSignHash()));
logger.Flush(); logger.Flush();
@ -711,7 +711,7 @@ void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const
return; return;
} }
qj.sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(qj.GetSignHash())); qj.sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->Sign(qj.GetSignHash()));
logger.Flush(); logger.Flush();
@ -1003,7 +1003,7 @@ void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
(*commitmentHash.begin())++; (*commitmentHash.begin())++;
} }
qc.sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(commitmentHash)); qc.sig = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.blsKeyOperator->Sign(commitmentHash));
qc.quorumSig = skShare.Sign(commitmentHash); qc.quorumSig = skShare.Sign(commitmentHash);
if (lieType == 3) { if (lieType == 3) {

View File

@ -192,7 +192,7 @@ bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
} }
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(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash), quorumIndex)) { if (!curSession->Init(pQuorumBaseBlockIndex, mns, WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash), 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;
} }

View File

@ -103,7 +103,7 @@ bool CQuorum::SetVerificationVector(const std::vector<CBLSPublicKey>& quorumVecI
bool CQuorum::SetSecretKeyShare(const CBLSSecretKey& secretKeyShare) bool CQuorum::SetSecretKeyShare(const CBLSSecretKey& secretKeyShare)
{ {
if (!secretKeyShare.IsValid() || (secretKeyShare.GetPublicKey() != GetPubKeyShare(WITH_LOCK(activeMasternodeInfoCs, return GetMemberIndex(activeMasternodeInfo.proTxHash))))) { if (!secretKeyShare.IsValid() || (secretKeyShare.GetPublicKey() != GetPubKeyShare(WITH_LOCK(::activeMasternodeManager->cs, return GetMemberIndex(::activeMasternodeManager->m_info.proTxHash))))) {
return false; return false;
} }
LOCK(cs); LOCK(cs);
@ -251,7 +251,7 @@ void CQuorumManager::TriggerQuorumDataRecoveryThreads(const CBlockIndex* pIndex)
// 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 = fMasternodeMode ?
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash) : WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash) :
uint256(); uint256();
bool fWeAreQuorumTypeMember = ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) { bool fWeAreQuorumTypeMember = ranges::any_of(vecQuorums, [&proTxHash](const auto& pQuorum) {
@ -345,7 +345,7 @@ void CQuorumManager::CheckQuorumConnections(const Consensus::LLMQParams& llmqPar
} }
const uint256 myProTxHash = fMasternodeMode ? const uint256 myProTxHash = fMasternodeMode ?
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash) : WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash) :
uint256(); uint256();
bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend; bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend;
@ -655,10 +655,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(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
for (const auto i : irange::range(vecProTxHashes.size())) { for (const auto i : irange::range(vecProTxHashes.size())) {
// cppcheck-suppress useStlAlgorithm // cppcheck-suppress useStlAlgorithm
if (activeMasternodeInfo.proTxHash == vecProTxHashes[i]) { if (::activeMasternodeManager->m_info.proTxHash == vecProTxHashes[i]) {
nIndex = i; nIndex = i;
break; break;
} }
@ -834,7 +834,7 @@ 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());
auto secret = WITH_LOCK(activeMasternodeInfoCs, return *activeMasternodeInfo.blsKeyOperator); auto secret = WITH_LOCK(::activeMasternodeManager->cs, return *::activeMasternodeManager->m_info.blsKeyOperator);
for (const auto i : irange::range(vecEncrypted.size())) { for (const auto i : irange::range(vecEncrypted.size())) {
if (!vecEncrypted[i].Decrypt(memberIdx, secret, vecSecretKeys[i], PROTOCOL_VERSION)) { if (!vecEncrypted[i].Decrypt(memberIdx, secret, vecSecretKeys[i], PROTOCOL_VERSION)) {
return errorHandler("Failed to decrypt"); return errorHandler("Failed to decrypt");
@ -917,7 +917,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(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash)) { if (pQuorum->IsValidMember(member->proTxHash) && member->proTxHash != WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash)) {
vecMemberHashes.push_back(member->proTxHash); vecMemberHashes.push_back(member->proTxHash);
} }
} }
@ -966,7 +966,7 @@ void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, co
printLog("Connect"); printLog("Connect");
} }
auto proTxHash = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash); auto proTxHash = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash);
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) {

View File

@ -896,7 +896,7 @@ 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(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash.IsNull())) return false; if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash.IsNull())) return false;
const CQuorumCPtr quorum = [&]() { const CQuorumCPtr quorum = [&]() {
if (quorumHash.IsNull()) { if (quorumHash.IsNull()) {
@ -918,7 +918,7 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, CSigShares
return false; return false;
} }
if (!WITH_LOCK(activeMasternodeInfoCs, return quorum->IsValidMember(activeMasternodeInfo.proTxHash))) { if (!WITH_LOCK(::activeMasternodeManager->cs, return quorum->IsValidMember(::activeMasternodeManager->m_info.proTxHash))) {
return false; return false;
} }

View File

@ -219,7 +219,7 @@ 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(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash.IsNull())) return; if (WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash.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;
@ -464,7 +464,7 @@ void CSigSharesManager::ProcessMessageSigShare(NodeId fromId, const CSigShare& s
// quorum is too old // quorum is too old
return; return;
} }
if (!quorum->IsMember(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash))) { if (!quorum->IsMember(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash))) {
// 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;
} }
@ -513,7 +513,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(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash))) { if (!session.quorum->IsMember(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash))) {
// 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;
} }
@ -697,7 +697,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, m_sporkman) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash))) { if (!IsAllMembersConnectedEnabled(llmqType, m_sporkman) && sigShare.getQuorumMember() == quorum->GetMemberIndex(WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash))) {
quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash()); quorumNodes = connman.GetMasternodeQuorumNodes(sigShare.getLlmqType(), sigShare.getQuorumHash());
} }
@ -1488,7 +1488,7 @@ 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
{ {
cxxtimer::Timer t(true); cxxtimer::Timer t(true);
auto activeMasterNodeProTxHash = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash); auto activeMasterNodeProTxHash = WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash);
if (!quorum->IsValidMember(activeMasterNodeProTxHash)) { if (!quorum->IsValidMember(activeMasterNodeProTxHash)) {
return std::nullopt; return std::nullopt;

View File

@ -15,8 +15,6 @@
#include <warnings.h> #include <warnings.h>
// Keep track of the active Masternode // Keep track of the active Masternode
RecursiveMutex activeMasternodeInfoCs;
CActiveMasternodeInfo activeMasternodeInfo GUARDED_BY(activeMasternodeInfoCs);
std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager; std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
std::string CActiveMasternodeManager::GetStateString() const std::string CActiveMasternodeManager::GetStateString() const
@ -65,7 +63,7 @@ std::string CActiveMasternodeManager::GetStatus() const
void CActiveMasternodeManager::Init(const CBlockIndex* pindex) void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
{ {
LOCK2(cs_main, activeMasternodeInfoCs); LOCK2(::cs_main, cs);
if (!fMasternodeMode) return; if (!fMasternodeMode) return;
@ -80,14 +78,14 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
return; return;
} }
if (!GetLocalAddress(activeMasternodeInfo.service)) { if (!GetLocalAddress(m_info.service)) {
state = MASTERNODE_ERROR; state = MASTERNODE_ERROR;
return; return;
} }
CDeterministicMNList mnList = Assert(m_dmnman)->GetListForBlock(pindex); CDeterministicMNList mnList = Assert(m_dmnman)->GetListForBlock(pindex);
CDeterministicMNCPtr dmn = mnList.GetMNByOperatorKey(*activeMasternodeInfo.blsPubKeyOperator); CDeterministicMNCPtr dmn = mnList.GetMNByOperatorKey(*m_info.blsPubKeyOperator);
if (!dmn) { if (!dmn) {
// MN not appeared on the chain yet // MN not appeared on the chain yet
return; return;
@ -104,7 +102,7 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
LogPrintf("CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s\n", dmn->proTxHash.ToString(), dmn->ToString()); LogPrintf("CActiveMasternodeManager::Init -- proTxHash=%s, proTx=%s\n", dmn->proTxHash.ToString(), dmn->ToString());
if (activeMasternodeInfo.service != dmn->pdmnState->addr) { if (m_info.service != dmn->pdmnState->addr) {
state = MASTERNODE_ERROR; state = MASTERNODE_ERROR;
strError = "Local address does not match the address from ProTx"; strError = "Local address does not match the address from ProTx";
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError);
@ -112,33 +110,33 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
} }
// Check socket connectivity // Check socket connectivity
LogPrintf("CActiveMasternodeManager::Init -- Checking inbound connection to '%s'\n", activeMasternodeInfo.service.ToString()); LogPrintf("CActiveMasternodeManager::Init -- Checking inbound connection to '%s'\n", m_info.service.ToString());
std::unique_ptr<Sock> sock = CreateSock(activeMasternodeInfo.service); std::unique_ptr<Sock> sock = CreateSock(m_info.service);
if (!sock) { if (!sock) {
state = MASTERNODE_ERROR; state = MASTERNODE_ERROR;
strError = "Could not create socket to connect to " + activeMasternodeInfo.service.ToString(); strError = "Could not create socket to connect to " + m_info.service.ToString();
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError);
return; return;
} }
bool fConnected = ConnectSocketDirectly(activeMasternodeInfo.service, *sock, nConnectTimeout, true) && IsSelectableSocket(sock->Get()); bool fConnected = ConnectSocketDirectly(m_info.service, *sock, nConnectTimeout, true) && IsSelectableSocket(sock->Get());
sock->Reset(); sock->Reset();
if (!fConnected && Params().RequireRoutableExternalIP()) { if (!fConnected && Params().RequireRoutableExternalIP()) {
state = MASTERNODE_ERROR; state = MASTERNODE_ERROR;
strError = "Could not connect to " + activeMasternodeInfo.service.ToString(); strError = "Could not connect to " + m_info.service.ToString();
LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError); LogPrintf("CActiveMasternodeManager::Init -- ERROR: %s\n", strError);
return; return;
} }
activeMasternodeInfo.proTxHash = dmn->proTxHash; m_info.proTxHash = dmn->proTxHash;
activeMasternodeInfo.outpoint = dmn->collateralOutpoint; m_info.outpoint = dmn->collateralOutpoint;
activeMasternodeInfo.legacy = dmn->pdmnState->nVersion == CProRegTx::LEGACY_BLS_VERSION; m_info.legacy = dmn->pdmnState->nVersion == CProRegTx::LEGACY_BLS_VERSION;
state = MASTERNODE_READY; state = MASTERNODE_READY;
} }
void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
{ {
LOCK2(cs_main, activeMasternodeInfoCs); LOCK2(::cs_main, cs);
if (!fMasternodeMode) return; if (!fMasternodeMode) return;
@ -147,23 +145,23 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
if (state == MASTERNODE_READY) { if (state == MASTERNODE_READY) {
auto oldMNList = Assert(m_dmnman)->GetListForBlock(pindexNew->pprev); auto oldMNList = Assert(m_dmnman)->GetListForBlock(pindexNew->pprev);
auto newMNList = m_dmnman->GetListForBlock(pindexNew); auto newMNList = m_dmnman->GetListForBlock(pindexNew);
if (!newMNList.IsMNValid(activeMasternodeInfo.proTxHash)) { if (!newMNList.IsMNValid(m_info.proTxHash)) {
// MN disappeared from MN list // MN disappeared from MN list
state = MASTERNODE_REMOVED; state = MASTERNODE_REMOVED;
activeMasternodeInfo.proTxHash = uint256(); m_info.proTxHash = uint256();
activeMasternodeInfo.outpoint.SetNull(); m_info.outpoint.SetNull();
// MN might have reappeared in same block with a new ProTx // MN might have reappeared in same block with a new ProTx
Init(pindexNew); Init(pindexNew);
return; return;
} }
auto oldDmn = oldMNList.GetMN(activeMasternodeInfo.proTxHash); auto oldDmn = oldMNList.GetMN(m_info.proTxHash);
auto newDmn = newMNList.GetMN(activeMasternodeInfo.proTxHash); auto newDmn = newMNList.GetMN(m_info.proTxHash);
if (newDmn->pdmnState->pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) { if (newDmn->pdmnState->pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) {
// MN operator key changed or revoked // MN operator key changed or revoked
state = MASTERNODE_OPERATOR_KEY_CHANGED; state = MASTERNODE_OPERATOR_KEY_CHANGED;
activeMasternodeInfo.proTxHash = uint256(); m_info.proTxHash = uint256();
activeMasternodeInfo.outpoint.SetNull(); m_info.outpoint.SetNull();
// MN might have reappeared in same block with a new ProTx // MN might have reappeared in same block with a new ProTx
Init(pindexNew); Init(pindexNew);
return; return;
@ -172,8 +170,8 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
if (newDmn->pdmnState->addr != oldDmn->pdmnState->addr) { if (newDmn->pdmnState->addr != oldDmn->pdmnState->addr) {
// MN IP changed // MN IP changed
state = MASTERNODE_PROTX_IP_CHANGED; state = MASTERNODE_PROTX_IP_CHANGED;
activeMasternodeInfo.proTxHash = uint256(); m_info.proTxHash = uint256();
activeMasternodeInfo.outpoint.SetNull(); m_info.outpoint.SetNull();
Init(pindexNew); Init(pindexNew);
return; return;
} }
@ -203,7 +201,7 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
if (!fFoundLocal) { if (!fFoundLocal) {
bool empty = true; bool empty = true;
// If we have some peers, let's try to find our local address from one of them // If we have some peers, let's try to find our local address from one of them
auto service = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.service); auto service = WITH_LOCK(cs, return m_info.service);
connman.ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) { connman.ForEachNodeContinueIf(CConnman::AllNodes, [&](CNode* pnode) {
empty = false; empty = false;
if (pnode->addr.IsIPv4()) if (pnode->addr.IsIPv4())

View File

@ -7,19 +7,13 @@
#include <netaddress.h> #include <netaddress.h>
#include <primitives/transaction.h> #include <primitives/transaction.h>
#include <threadsafety.h>
#include <validationinterface.h> #include <validationinterface.h>
class CActiveMasternodeManager;
class CBLSPublicKey; class CBLSPublicKey;
class CBLSSecretKey; class CBLSSecretKey;
class CDeterministicMNManager; class CDeterministicMNManager;
struct CActiveMasternodeInfo;
extern CActiveMasternodeInfo activeMasternodeInfo;
extern RecursiveMutex activeMasternodeInfoCs;
extern std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
struct CActiveMasternodeInfo { struct CActiveMasternodeInfo {
// Keys for the active Masternode // Keys for the active Masternode
std::unique_ptr<CBLSPublicKey> blsPubKeyOperator; std::unique_ptr<CBLSPublicKey> blsPubKeyOperator;
@ -32,7 +26,6 @@ struct CActiveMasternodeInfo {
bool legacy{true}; bool legacy{true};
}; };
class CActiveMasternodeManager final : public CValidationInterface class CActiveMasternodeManager final : public CValidationInterface
{ {
public: public:
@ -46,6 +39,9 @@ public:
MASTERNODE_ERROR, MASTERNODE_ERROR,
}; };
mutable RecursiveMutex cs;
CActiveMasternodeInfo m_info GUARDED_BY(cs);
private: private:
masternode_state_t state{MASTERNODE_WAITING_FOR_PROTX}; masternode_state_t state{MASTERNODE_WAITING_FOR_PROTX};
std::string strError; std::string strError;
@ -70,4 +66,6 @@ private:
bool GetLocalAddress(CService& addrRet); bool GetLocalAddress(CService& addrRet);
}; };
extern std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
#endif // BITCOIN_MASTERNODE_NODE_H #endif // BITCOIN_MASTERNODE_NODE_H

View File

@ -318,12 +318,12 @@ static UniValue gobject_submit(const JSONRPCRequest& request)
bool fMnFound{false}; bool fMnFound{false};
if (fMasternodeMode) { if (fMasternodeMode) {
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
fMnFound = mnList.HasValidMNByCollateral(activeMasternodeInfo.outpoint); fMnFound = mnList.HasValidMNByCollateral(::activeMasternodeManager->m_info.outpoint);
LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = %s, outpoint = %s, params.size() = %lld, fMnFound = %d\n", LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = %s, outpoint = %s, params.size() = %lld, fMnFound = %d\n",
(activeMasternodeInfo.blsPubKeyOperator ? activeMasternodeInfo.blsPubKeyOperator->ToString(activeMasternodeInfo.legacy) : "N/A"), (::activeMasternodeManager->m_info.blsPubKeyOperator ? ::activeMasternodeManager->m_info.blsPubKeyOperator->ToString(::activeMasternodeManager->m_info.legacy) : "N/A"),
activeMasternodeInfo.outpoint.ToStringShort(), request.params.size(), fMnFound); ::activeMasternodeManager->m_info.outpoint.ToStringShort(), request.params.size(), fMnFound);
} else { } else {
LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = N/A, outpoint = N/A, params.size() = %lld, fMnFound = %d\n", LogPrint(BCLog::GOBJECT, "gobject_submit -- pubKeyOperator = N/A, outpoint = N/A, params.size() = %lld, fMnFound = %d\n",
request.params.size(), fMnFound); request.params.size(), fMnFound);

View File

@ -266,12 +266,12 @@ static UniValue masternode_status(const JSONRPCRequest& request)
UniValue mnObj(UniValue::VOBJ); UniValue mnObj(UniValue::VOBJ);
CDeterministicMNCPtr dmn; CDeterministicMNCPtr dmn;
{ {
LOCK(activeMasternodeInfoCs); LOCK(::activeMasternodeManager->cs);
// keep compatibility with legacy status for now (might get deprecated/removed later) // keep compatibility with legacy status for now (might get deprecated/removed later)
mnObj.pushKV("outpoint", activeMasternodeInfo.outpoint.ToStringShort()); mnObj.pushKV("outpoint", ::activeMasternodeManager->m_info.outpoint.ToStringShort());
mnObj.pushKV("service", activeMasternodeInfo.service.ToString()); mnObj.pushKV("service", ::activeMasternodeManager->m_info.service.ToString());
dmn = node.dmnman->GetListAtChainTip().GetMN(activeMasternodeInfo.proTxHash); dmn = node.dmnman->GetListAtChainTip().GetMN(::activeMasternodeManager->m_info.proTxHash);
} }
if (dmn) { if (dmn) {
mnObj.pushKV("proTxHash", dmn->proTxHash.ToString()); mnObj.pushKV("proTxHash", dmn->proTxHash.ToString());

View File

@ -296,7 +296,7 @@ static UniValue quorum_dkgstatus(const JSONRPCRequest& request, CDeterministicMN
int tipHeight = pindexTip->nHeight; int tipHeight = pindexTip->nHeight;
const uint256 proTxHash = fMasternodeMode ? const uint256 proTxHash = fMasternodeMode ?
WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash) : WITH_LOCK(::activeMasternodeManager->cs, return ::activeMasternodeManager->m_info.proTxHash) :
uint256(); uint256();
UniValue minableCommitments(UniValue::VARR); UniValue minableCommitments(UniValue::VARR);