mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
style: apply clang-format
This commit is contained in:
parent
db9798f5e4
commit
74a5a9f984
@ -2,17 +2,17 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <evo/cbtx.h>
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <evo/simplifiedmns.h>
|
||||
#include <evo/specialtx.h>
|
||||
#include <llmq/blockprocessor.h>
|
||||
#include <llmq/chainlocks.h>
|
||||
#include <llmq/commitment.h>
|
||||
#include <llmq/options.h>
|
||||
#include <llmq/quorums.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <evo/simplifiedmns.h>
|
||||
#include <evo/specialtx.h>
|
||||
#include <consensus/validation.h>
|
||||
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
|
@ -2,10 +2,10 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <evo/evodb.h>
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <evo/dmn_types.h>
|
||||
#include <evo/dmnstate.h>
|
||||
#include <evo/evodb.h>
|
||||
#include <evo/providertx.h>
|
||||
#include <evo/specialtx.h>
|
||||
#include <llmq/commitment.h>
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include <crypto/common.h>
|
||||
#include <evo/dmn_types.h>
|
||||
#include <evo/providertx.h>
|
||||
#include <gsl/pointers.h>
|
||||
#include <saltedhasher.h>
|
||||
#include <scheduler.h>
|
||||
#include <sync.h>
|
||||
#include <gsl/pointers.h>
|
||||
|
||||
#include <immer/map.hpp>
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <evo/mnhftx.h>
|
||||
#include <evo/specialtx.h>
|
||||
#include <llmq/commitment.h>
|
||||
#include <llmq/signing.h>
|
||||
#include <llmq/quorums.h>
|
||||
#include <llmq/signing.h>
|
||||
#include <node/blockstorage.h>
|
||||
|
||||
#include <chain.h>
|
||||
|
@ -33,7 +33,10 @@ namespace llmq
|
||||
{
|
||||
|
||||
CDKGLogger::CDKGLogger(const CDKGSession& _quorumDkg, std::string_view _func, int source_line) :
|
||||
CBatchedLogger(BCLog::LLMQ_DKG, strprintf("QuorumDKG(type=%s, qIndex=%d, h=%d, member=%d)", _quorumDkg.params.name, _quorumDkg.quorumIndex, _quorumDkg.m_quorum_base_block_index->nHeight, _quorumDkg.AreWeMember()), __FILE__, source_line)
|
||||
CBatchedLogger(BCLog::LLMQ_DKG,
|
||||
strprintf("QuorumDKG(type=%s, qIndex=%d, h=%d, member=%d)", _quorumDkg.params.name, _quorumDkg.quorumIndex,
|
||||
_quorumDkg.m_quorum_base_block_index->nHeight, _quorumDkg.AreWeMember()),
|
||||
__FILE__, source_line)
|
||||
{
|
||||
}
|
||||
|
||||
@ -68,12 +71,21 @@ CDKGMember::CDKGMember(const CDeterministicMNCPtr& _dmn, size_t _idx) :
|
||||
|
||||
}
|
||||
|
||||
CDKGSession::CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman,
|
||||
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
|
||||
CDKGSession::CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params,
|
||||
CBLSWorker& _blsWorker, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||
CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
|
||||
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman) :
|
||||
params(_params), blsWorker(_blsWorker), cache(_blsWorker), connman(_connman), m_dmnman(dmnman), dkgManager(_dkgManager),
|
||||
dkgDebugManager(_dkgDebugManager), m_mn_metaman(mn_metaman), m_mn_activeman(mn_activeman), m_sporkman(sporkman),
|
||||
params(_params),
|
||||
blsWorker(_blsWorker),
|
||||
cache(_blsWorker),
|
||||
connman(_connman),
|
||||
m_dmnman(dmnman),
|
||||
dkgManager(_dkgManager),
|
||||
dkgDebugManager(_dkgDebugManager),
|
||||
m_mn_metaman(mn_metaman),
|
||||
m_mn_activeman(mn_activeman),
|
||||
m_sporkman(sporkman),
|
||||
m_quorum_base_block_index{pQuorumBaseBlockIndex}
|
||||
{
|
||||
}
|
||||
|
@ -326,10 +326,10 @@ private:
|
||||
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
||||
|
||||
public:
|
||||
CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman,
|
||||
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
|
||||
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman);
|
||||
CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker,
|
||||
CConnman& _connman, CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager,
|
||||
CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman,
|
||||
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman);
|
||||
|
||||
// TODO: remove Init completely
|
||||
bool Init(const uint256& _myProTxHash, int _quorumIndex);
|
||||
|
@ -24,28 +24,34 @@
|
||||
namespace llmq
|
||||
{
|
||||
|
||||
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
|
||||
CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman, const Consensus::LLMQParams& _params, int _quorumIndex) :
|
||||
blsWorker(_blsWorker),
|
||||
m_chainstate(chainstate),
|
||||
connman(_connman),
|
||||
m_dmnman(dmnman),
|
||||
dkgDebugManager(_dkgDebugManager),
|
||||
dkgManager(_dkgManager),
|
||||
m_mn_metaman(mn_metaman),
|
||||
quorumBlockProcessor(_quorumBlockProcessor),
|
||||
m_mn_activeman(mn_activeman),
|
||||
m_sporkman(sporkman),
|
||||
m_peerman(peerman),
|
||||
params(_params),
|
||||
quorumIndex(_quorumIndex),
|
||||
curSession(std::make_unique<CDKGSession>(nullptr, _params, _blsWorker, _connman, dmnman, _dkgManager, _dkgDebugManager, m_mn_metaman, 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)
|
||||
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
|
||||
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
|
||||
pendingPrematureCommitments((size_t)_params.size * 2, MSG_QUORUM_PREMATURE_COMMITMENT)
|
||||
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman,
|
||||
CDeterministicMNManager& dmnman, CDKGDebugManager& _dkgDebugManager,
|
||||
CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
|
||||
CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman,
|
||||
const Consensus::LLMQParams& _params, int _quorumIndex) :
|
||||
blsWorker(_blsWorker),
|
||||
m_chainstate(chainstate),
|
||||
connman(_connman),
|
||||
m_dmnman(dmnman),
|
||||
dkgDebugManager(_dkgDebugManager),
|
||||
dkgManager(_dkgManager),
|
||||
m_mn_metaman(mn_metaman),
|
||||
quorumBlockProcessor(_quorumBlockProcessor),
|
||||
m_mn_activeman(mn_activeman),
|
||||
m_sporkman(sporkman),
|
||||
m_peerman(peerman),
|
||||
params(_params),
|
||||
quorumIndex(_quorumIndex),
|
||||
curSession(std::make_unique<CDKGSession>(nullptr, _params, _blsWorker, _connman, dmnman, _dkgManager,
|
||||
_dkgDebugManager, m_mn_metaman, 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)
|
||||
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
|
||||
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
|
||||
pendingPrematureCommitments((size_t)_params.size * 2, MSG_QUORUM_PREMATURE_COMMITMENT)
|
||||
{
|
||||
if (params.type == Consensus::LLMQType::LLMQ_NONE) {
|
||||
throw std::runtime_error("Can't initialize CDKGSessionHandler with LLMQ_NONE type.");
|
||||
@ -194,10 +200,12 @@ bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
||||
return false;
|
||||
}
|
||||
|
||||
curSession = std::make_unique<CDKGSession>(pQuorumBaseBlockIndex, params, blsWorker, connman, m_dmnman, dkgManager, dkgDebugManager, m_mn_metaman, m_mn_activeman, m_sporkman);
|
||||
curSession = std::make_unique<CDKGSession>(pQuorumBaseBlockIndex, params, blsWorker, connman, m_dmnman, dkgManager,
|
||||
dkgDebugManager, m_mn_metaman, m_mn_activeman, m_sporkman);
|
||||
|
||||
if (!curSession->Init(m_mn_activeman->GetProTxHash(), quorumIndex)) {
|
||||
LogPrintf("CDKGSessionManager::%s -- height[%d] quorum initialization failed for %s qi[%d]\n", __func__, pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex);
|
||||
LogPrintf("CDKGSessionManager::%s -- height[%d] quorum initialization failed for %s qi[%d]\n", __func__,
|
||||
pQuorumBaseBlockIndex->nHeight, curSession->params.name, quorumIndex);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -445,37 +453,32 @@ static void RelayInvToParticipants(const CDKGSession& session, CConnman& connman
|
||||
for (const auto& r : relayMembers) {
|
||||
ss << r.ToString().substr(0, 4) << " | ";
|
||||
}
|
||||
logger.Batch("RelayInvToParticipants inv[%s] relayMembers[%d] GetNodeCount[%d] GetNetworkActive[%d] HasMasternodeQuorumNodes[%d] for quorumHash[%s] forMember[%s] relayMembers[%s]",
|
||||
inv.ToString(),
|
||||
relayMembers.size(),
|
||||
connman.GetNodeCount(ConnectionDirection::Both),
|
||||
logger.Batch("RelayInvToParticipants inv[%s] relayMembers[%d] GetNodeCount[%d] GetNetworkActive[%d] "
|
||||
"HasMasternodeQuorumNodes[%d] for quorumHash[%s] forMember[%s] relayMembers[%s]",
|
||||
inv.ToString(), relayMembers.size(), connman.GetNodeCount(ConnectionDirection::Both),
|
||||
connman.GetNetworkActive(),
|
||||
connman.HasMasternodeQuorumNodes(session.GetParams().type, session.BlockIndex()->GetBlockHash()),
|
||||
session.BlockIndex()->GetBlockHash().ToString(),
|
||||
session.ProTx().ToString().substr(0, 4), ss.str());
|
||||
session.BlockIndex()->GetBlockHash().ToString(), session.ProTx().ToString().substr(0, 4), ss.str());
|
||||
|
||||
std::stringstream ss2;
|
||||
connman.ForEachNode([&](const CNode* pnode) {
|
||||
if (pnode->qwatch ||
|
||||
(!pnode->GetVerifiedProRegTxHash().IsNull() && (relayMembers.count(pnode->GetVerifiedProRegTxHash()) != 0))) {
|
||||
(!pnode->GetVerifiedProRegTxHash().IsNull() && (relayMembers.count(pnode->GetVerifiedProRegTxHash()) != 0))) {
|
||||
peerman.PushInventory(pnode->GetId(), inv);
|
||||
}
|
||||
|
||||
if (pnode->GetVerifiedProRegTxHash().IsNull()) {
|
||||
logger.Batch("node[%d:%s] not mn",
|
||||
pnode->GetId(),
|
||||
pnode->m_addr_name);
|
||||
logger.Batch("node[%d:%s] not mn", pnode->GetId(), pnode->m_addr_name);
|
||||
} else if (relayMembers.count(pnode->GetVerifiedProRegTxHash()) == 0) {
|
||||
ss2 << pnode->GetVerifiedProRegTxHash().ToString().substr(0, 4) << " | ";
|
||||
}
|
||||
});
|
||||
logger.Batch("forMember[%s] NOTrelayMembers[%s]",
|
||||
session.ProTx().ToString().substr(0, 4),
|
||||
ss2.str());
|
||||
logger.Batch("forMember[%s] NOTrelayMembers[%s]", session.ProTx().ToString().substr(0, 4), ss2.str());
|
||||
logger.Flush();
|
||||
}
|
||||
template<typename Message, int MessageType>
|
||||
bool ProcessPendingMessageBatch(CConnman& connman, PeerManager* peerman, CDKGSession& session, CDKGPendingMessages& pendingMessages, size_t maxCount)
|
||||
template <typename Message, int MessageType>
|
||||
bool ProcessPendingMessageBatch(CConnman& connman, PeerManager* peerman, CDKGSession& session,
|
||||
CDKGPendingMessages& pendingMessages, size_t maxCount)
|
||||
{
|
||||
auto msgs = pendingMessages.PopAndDeserializeMessages<Message>(maxCount);
|
||||
if (msgs.empty()) {
|
||||
@ -571,7 +574,8 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
curSession->Contribute(pendingContributions);
|
||||
};
|
||||
auto fContributeWait = [this] {
|
||||
return ProcessPendingMessageBatch<CDKGContribution, MSG_QUORUM_CONTRIB>(connman, m_peerman.get(), *curSession, pendingContributions, 8);
|
||||
return ProcessPendingMessageBatch<CDKGContribution, MSG_QUORUM_CONTRIB>(connman, m_peerman.get(), *curSession,
|
||||
pendingContributions, 8);
|
||||
};
|
||||
HandlePhase(QuorumPhase::Contribute, QuorumPhase::Complain, curQuorumHash, 0.05, fContributeStart, fContributeWait);
|
||||
|
||||
@ -580,7 +584,8 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
curSession->VerifyAndComplain(pendingComplaints);
|
||||
};
|
||||
auto fComplainWait = [this] {
|
||||
return ProcessPendingMessageBatch<CDKGComplaint, MSG_QUORUM_COMPLAINT>(connman, m_peerman.get(), *curSession, pendingComplaints, 8);
|
||||
return ProcessPendingMessageBatch<CDKGComplaint, MSG_QUORUM_COMPLAINT>(connman, m_peerman.get(), *curSession,
|
||||
pendingComplaints, 8);
|
||||
};
|
||||
HandlePhase(QuorumPhase::Complain, QuorumPhase::Justify, curQuorumHash, 0.05, fComplainStart, fComplainWait);
|
||||
|
||||
@ -589,7 +594,9 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
curSession->VerifyAndJustify(pendingJustifications);
|
||||
};
|
||||
auto fJustifyWait = [this] {
|
||||
return ProcessPendingMessageBatch<CDKGJustification, MSG_QUORUM_JUSTIFICATION>(connman, m_peerman.get(), *curSession, pendingJustifications, 8);
|
||||
return ProcessPendingMessageBatch<CDKGJustification, MSG_QUORUM_JUSTIFICATION>(connman, m_peerman.get(),
|
||||
*curSession,
|
||||
pendingJustifications, 8);
|
||||
};
|
||||
HandlePhase(QuorumPhase::Justify, QuorumPhase::Commit, curQuorumHash, 0.05, fJustifyStart, fJustifyWait);
|
||||
|
||||
@ -598,7 +605,8 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
curSession->VerifyAndCommit(pendingPrematureCommitments);
|
||||
};
|
||||
auto fCommitWait = [this] {
|
||||
return ProcessPendingMessageBatch<CDKGPrematureCommitment, MSG_QUORUM_PREMATURE_COMMITMENT>(connman, m_peerman.get(), *curSession, pendingPrematureCommitments, 8);
|
||||
return ProcessPendingMessageBatch<CDKGPrematureCommitment, MSG_QUORUM_PREMATURE_COMMITMENT>(
|
||||
connman, m_peerman.get(), *curSession, pendingPrematureCommitments, 8);
|
||||
};
|
||||
HandlePhase(QuorumPhase::Commit, QuorumPhase::Finalize, curQuorumHash, 0.1, fCommitStart, fCommitWait);
|
||||
|
||||
|
@ -5,10 +5,10 @@
|
||||
#ifndef BITCOIN_LLMQ_DKGSESSIONMGR_H
|
||||
#define BITCOIN_LLMQ_DKGSESSIONMGR_H
|
||||
|
||||
#include <llmq/dkgsessionhandler.h>
|
||||
#include <bls/bls.h>
|
||||
#include <bls/bls_ies.h>
|
||||
#include <bls/bls_worker.h>
|
||||
#include <llmq/dkgsessionhandler.h>
|
||||
#include <net_types.h>
|
||||
|
||||
#include <map>
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include <llmq/params.h>
|
||||
#include <llmq/utils.h>
|
||||
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <evo/evodb.h>
|
||||
#include <evo/specialtx.h>
|
||||
#include <evo/deterministicmns.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <dbwrapper.h>
|
||||
@ -232,10 +232,7 @@ CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate,
|
||||
MigrateOldQuorumDB(_evoDb);
|
||||
}
|
||||
|
||||
CQuorumManager::~CQuorumManager()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
CQuorumManager::~CQuorumManager() { Stop(); }
|
||||
|
||||
void CQuorumManager::Start()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user