style: apply clang-format

This commit is contained in:
Konstantin Akimov 2024-09-24 01:15:27 +07:00
parent db9798f5e4
commit 74a5a9f984
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
9 changed files with 81 additions and 64 deletions

View File

@ -2,17 +2,17 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <consensus/validation.h>
#include <evo/cbtx.h> #include <evo/cbtx.h>
#include <evo/deterministicmns.h> #include <evo/deterministicmns.h>
#include <evo/simplifiedmns.h>
#include <evo/specialtx.h>
#include <llmq/blockprocessor.h> #include <llmq/blockprocessor.h>
#include <llmq/chainlocks.h> #include <llmq/chainlocks.h>
#include <llmq/commitment.h> #include <llmq/commitment.h>
#include <llmq/options.h> #include <llmq/options.h>
#include <llmq/quorums.h> #include <llmq/quorums.h>
#include <node/blockstorage.h> #include <node/blockstorage.h>
#include <evo/simplifiedmns.h>
#include <evo/specialtx.h>
#include <consensus/validation.h>
#include <chain.h> #include <chain.h>
#include <chainparams.h> #include <chainparams.h>

View File

@ -2,10 +2,10 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <evo/evodb.h>
#include <evo/deterministicmns.h> #include <evo/deterministicmns.h>
#include <evo/dmn_types.h> #include <evo/dmn_types.h>
#include <evo/dmnstate.h> #include <evo/dmnstate.h>
#include <evo/evodb.h>
#include <evo/providertx.h> #include <evo/providertx.h>
#include <evo/specialtx.h> #include <evo/specialtx.h>
#include <llmq/commitment.h> #include <llmq/commitment.h>

View File

@ -13,10 +13,10 @@
#include <crypto/common.h> #include <crypto/common.h>
#include <evo/dmn_types.h> #include <evo/dmn_types.h>
#include <evo/providertx.h> #include <evo/providertx.h>
#include <gsl/pointers.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <scheduler.h> #include <scheduler.h>
#include <sync.h> #include <sync.h>
#include <gsl/pointers.h>
#include <immer/map.hpp> #include <immer/map.hpp>

View File

@ -8,8 +8,8 @@
#include <evo/mnhftx.h> #include <evo/mnhftx.h>
#include <evo/specialtx.h> #include <evo/specialtx.h>
#include <llmq/commitment.h> #include <llmq/commitment.h>
#include <llmq/signing.h>
#include <llmq/quorums.h> #include <llmq/quorums.h>
#include <llmq/signing.h>
#include <node/blockstorage.h> #include <node/blockstorage.h>
#include <chain.h> #include <chain.h>

View File

@ -33,7 +33,10 @@ namespace llmq
{ {
CDKGLogger::CDKGLogger(const CDKGSession& _quorumDkg, std::string_view _func, int source_line) : 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, CDKGSession::CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params,
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CBLSWorker& _blsWorker, CConnman& _connman, CDeterministicMNManager& dmnman,
CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
const CSporkManager& sporkman) : const CSporkManager& sporkman) :
params(_params), blsWorker(_blsWorker), cache(_blsWorker), connman(_connman), m_dmnman(dmnman), dkgManager(_dkgManager), params(_params),
dkgDebugManager(_dkgDebugManager), m_mn_metaman(mn_metaman), m_mn_activeman(mn_activeman), m_sporkman(sporkman), 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} m_quorum_base_block_index{pQuorumBaseBlockIndex}
{ {
} }

View File

@ -326,10 +326,10 @@ private:
std::set<uint256> validCommitments GUARDED_BY(invCs); std::set<uint256> validCommitments GUARDED_BY(invCs);
public: public:
CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman, CDKGSession(const CBlockIndex* pQuorumBaseBlockIndex, const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker,
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman, CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager,
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman, CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman,
const CSporkManager& sporkman); const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman);
// TODO: remove Init completely // TODO: remove Init completely
bool Init(const uint256& _myProTxHash, int _quorumIndex); bool Init(const uint256& _myProTxHash, int _quorumIndex);

View File

@ -24,28 +24,34 @@
namespace llmq namespace llmq
{ {
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman, CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman,
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman, CDeterministicMNManager& dmnman, CDKGDebugManager& _dkgDebugManager,
CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman, const Consensus::LLMQParams& _params, int _quorumIndex) : CQuorumBlockProcessor& _quorumBlockProcessor,
blsWorker(_blsWorker), const CActiveMasternodeManager* const mn_activeman,
m_chainstate(chainstate), const CSporkManager& sporkman, const std::unique_ptr<PeerManager>& peerman,
connman(_connman), const Consensus::LLMQParams& _params, int _quorumIndex) :
m_dmnman(dmnman), blsWorker(_blsWorker),
dkgDebugManager(_dkgDebugManager), m_chainstate(chainstate),
dkgManager(_dkgManager), connman(_connman),
m_mn_metaman(mn_metaman), m_dmnman(dmnman),
quorumBlockProcessor(_quorumBlockProcessor), dkgDebugManager(_dkgDebugManager),
m_mn_activeman(mn_activeman), dkgManager(_dkgManager),
m_sporkman(sporkman), m_mn_metaman(mn_metaman),
m_peerman(peerman), quorumBlockProcessor(_quorumBlockProcessor),
params(_params), m_mn_activeman(mn_activeman),
quorumIndex(_quorumIndex), m_sporkman(sporkman),
curSession(std::make_unique<CDKGSession>(nullptr, _params, _blsWorker, _connman, dmnman, _dkgManager, _dkgDebugManager, m_mn_metaman, m_mn_activeman, sporkman)), m_peerman(peerman),
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) params(_params),
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT), quorumIndex(_quorumIndex),
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION), curSession(std::make_unique<CDKGSession>(nullptr, _params, _blsWorker, _connman, dmnman, _dkgManager,
pendingPrematureCommitments((size_t)_params.size * 2, MSG_QUORUM_PREMATURE_COMMITMENT) _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) { if (params.type == Consensus::LLMQType::LLMQ_NONE) {
throw std::runtime_error("Can't initialize CDKGSessionHandler with LLMQ_NONE type."); throw std::runtime_error("Can't initialize CDKGSessionHandler with LLMQ_NONE type.");
@ -194,10 +200,12 @@ bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
return false; 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)) { 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; return false;
} }
@ -445,37 +453,32 @@ static void RelayInvToParticipants(const CDKGSession& session, CConnman& connman
for (const auto& r : relayMembers) { for (const auto& r : relayMembers) {
ss << r.ToString().substr(0, 4) << " | "; 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]", logger.Batch("RelayInvToParticipants inv[%s] relayMembers[%d] GetNodeCount[%d] GetNetworkActive[%d] "
inv.ToString(), "HasMasternodeQuorumNodes[%d] for quorumHash[%s] forMember[%s] relayMembers[%s]",
relayMembers.size(), inv.ToString(), relayMembers.size(), connman.GetNodeCount(ConnectionDirection::Both),
connman.GetNodeCount(ConnectionDirection::Both),
connman.GetNetworkActive(), connman.GetNetworkActive(),
connman.HasMasternodeQuorumNodes(session.GetParams().type, session.BlockIndex()->GetBlockHash()), connman.HasMasternodeQuorumNodes(session.GetParams().type, session.BlockIndex()->GetBlockHash()),
session.BlockIndex()->GetBlockHash().ToString(), session.BlockIndex()->GetBlockHash().ToString(), session.ProTx().ToString().substr(0, 4), ss.str());
session.ProTx().ToString().substr(0, 4), ss.str());
std::stringstream ss2; std::stringstream ss2;
connman.ForEachNode([&](const CNode* pnode) { connman.ForEachNode([&](const CNode* pnode) {
if (pnode->qwatch || if (pnode->qwatch ||
(!pnode->GetVerifiedProRegTxHash().IsNull() && (relayMembers.count(pnode->GetVerifiedProRegTxHash()) != 0))) { (!pnode->GetVerifiedProRegTxHash().IsNull() && (relayMembers.count(pnode->GetVerifiedProRegTxHash()) != 0))) {
peerman.PushInventory(pnode->GetId(), inv); peerman.PushInventory(pnode->GetId(), inv);
} }
if (pnode->GetVerifiedProRegTxHash().IsNull()) { if (pnode->GetVerifiedProRegTxHash().IsNull()) {
logger.Batch("node[%d:%s] not mn", logger.Batch("node[%d:%s] not mn", pnode->GetId(), pnode->m_addr_name);
pnode->GetId(),
pnode->m_addr_name);
} else if (relayMembers.count(pnode->GetVerifiedProRegTxHash()) == 0) { } else if (relayMembers.count(pnode->GetVerifiedProRegTxHash()) == 0) {
ss2 << pnode->GetVerifiedProRegTxHash().ToString().substr(0, 4) << " | "; ss2 << pnode->GetVerifiedProRegTxHash().ToString().substr(0, 4) << " | ";
} }
}); });
logger.Batch("forMember[%s] NOTrelayMembers[%s]", logger.Batch("forMember[%s] NOTrelayMembers[%s]", session.ProTx().ToString().substr(0, 4), ss2.str());
session.ProTx().ToString().substr(0, 4),
ss2.str());
logger.Flush(); logger.Flush();
} }
template<typename Message, int MessageType> template <typename Message, int MessageType>
bool ProcessPendingMessageBatch(CConnman& connman, PeerManager* peerman, CDKGSession& session, CDKGPendingMessages& pendingMessages, size_t maxCount) bool ProcessPendingMessageBatch(CConnman& connman, PeerManager* peerman, CDKGSession& session,
CDKGPendingMessages& pendingMessages, size_t maxCount)
{ {
auto msgs = pendingMessages.PopAndDeserializeMessages<Message>(maxCount); auto msgs = pendingMessages.PopAndDeserializeMessages<Message>(maxCount);
if (msgs.empty()) { if (msgs.empty()) {
@ -571,7 +574,8 @@ void CDKGSessionHandler::HandleDKGRound()
curSession->Contribute(pendingContributions); curSession->Contribute(pendingContributions);
}; };
auto fContributeWait = [this] { 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); HandlePhase(QuorumPhase::Contribute, QuorumPhase::Complain, curQuorumHash, 0.05, fContributeStart, fContributeWait);
@ -580,7 +584,8 @@ void CDKGSessionHandler::HandleDKGRound()
curSession->VerifyAndComplain(pendingComplaints); curSession->VerifyAndComplain(pendingComplaints);
}; };
auto fComplainWait = [this] { 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); HandlePhase(QuorumPhase::Complain, QuorumPhase::Justify, curQuorumHash, 0.05, fComplainStart, fComplainWait);
@ -589,7 +594,9 @@ void CDKGSessionHandler::HandleDKGRound()
curSession->VerifyAndJustify(pendingJustifications); curSession->VerifyAndJustify(pendingJustifications);
}; };
auto fJustifyWait = [this] { 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); HandlePhase(QuorumPhase::Justify, QuorumPhase::Commit, curQuorumHash, 0.05, fJustifyStart, fJustifyWait);
@ -598,7 +605,8 @@ void CDKGSessionHandler::HandleDKGRound()
curSession->VerifyAndCommit(pendingPrematureCommitments); curSession->VerifyAndCommit(pendingPrematureCommitments);
}; };
auto fCommitWait = [this] { 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); HandlePhase(QuorumPhase::Commit, QuorumPhase::Finalize, curQuorumHash, 0.1, fCommitStart, fCommitWait);

View File

@ -5,10 +5,10 @@
#ifndef BITCOIN_LLMQ_DKGSESSIONMGR_H #ifndef BITCOIN_LLMQ_DKGSESSIONMGR_H
#define BITCOIN_LLMQ_DKGSESSIONMGR_H #define BITCOIN_LLMQ_DKGSESSIONMGR_H
#include <llmq/dkgsessionhandler.h>
#include <bls/bls.h> #include <bls/bls.h>
#include <bls/bls_ies.h> #include <bls/bls_ies.h>
#include <bls/bls_worker.h> #include <bls/bls_worker.h>
#include <llmq/dkgsessionhandler.h>
#include <net_types.h> #include <net_types.h>
#include <map> #include <map>

View File

@ -11,9 +11,9 @@
#include <llmq/params.h> #include <llmq/params.h>
#include <llmq/utils.h> #include <llmq/utils.h>
#include <evo/deterministicmns.h>
#include <evo/evodb.h> #include <evo/evodb.h>
#include <evo/specialtx.h> #include <evo/specialtx.h>
#include <evo/deterministicmns.h>
#include <chainparams.h> #include <chainparams.h>
#include <dbwrapper.h> #include <dbwrapper.h>
@ -232,10 +232,7 @@ CQuorumManager::CQuorumManager(CBLSWorker& _blsWorker, CChainState& chainstate,
MigrateOldQuorumDB(_evoDb); MigrateOldQuorumDB(_evoDb);
} }
CQuorumManager::~CQuorumManager() CQuorumManager::~CQuorumManager() { Stop(); }
{
Stop();
}
void CQuorumManager::Start() void CQuorumManager::Start()
{ {