Skip to content
2 changes: 1 addition & 1 deletion src/active/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman
m_isman{isman},
m_qman{qman},
nodeman{std::make_unique<CActiveMasternodeManager>(connman, dmnman, operator_sk)},
dkgdbgman{std::make_unique<llmq::CDKGDebugManager>()},
dkgdbgman{std::make_unique<llmq::CDKGDebugManager>(dmnman, qsnapman, chainman)},
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(dmnman, qsnapman, chainman, sporkman, db_params, quorums_watch)},
shareman{std::make_unique<llmq::CSigSharesManager>(connman, chainman.ActiveChainstate(), sigman, peerman, *nodeman,
qman, sporkman)},
Expand Down
8 changes: 4 additions & 4 deletions src/active/dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ ActiveDKGSession::~ActiveDKGSession() = default;

void ActiveDKGSession::Contribute(CDKGPendingMessages& pendingMessages, PeerManager& peerman)
{
CDKGLogger logger(*this, __func__, __LINE__);

if (!AreWeMember()) {
return;
}

assert(params.threshold > 1); // we should not get there with single-node-quorums

CDKGLogger logger(*this, __func__, __LINE__);

cxxtimer::Timer t1(true);
logger.Batch("generating contributions");
if (!blsWorker.GenerateContributions(params.threshold, memberIds, vvecContribution, m_sk_contributions)) {
Expand Down Expand Up @@ -304,7 +304,7 @@ void ActiveDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages, Pe

CDKGLogger logger(*this, __func__, __LINE__);

std::set<uint256> justifyFor;
Uint256HashSet justifyFor;

for (const auto& m : members) {
if (m->bad) {
Expand Down Expand Up @@ -338,7 +338,7 @@ void ActiveDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages, Pe
}

void ActiveDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, PeerManager& peerman,
const std::set<uint256>& forMembers)
const Uint256HashSet& forMembers)
{
CDKGLogger logger(*this, __func__, __LINE__);

Expand Down
2 changes: 1 addition & 1 deletion src/active/dkgsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ActiveDKGSession final : public llmq::CDKGSession
void VerifyAndJustify(CDKGPendingMessages& pendingMessages, PeerManager& peerman) override
EXCLUSIVE_LOCKS_REQUIRED(!invCs);
void SendJustification(CDKGPendingMessages& pendingMessages, PeerManager& peerman,
const std::set<uint256>& forMembers) override;
const Uint256HashSet& forMembers) override;

// Phase 4: commit
void VerifyAndCommit(CDKGPendingMessages& pendingMessages, PeerManager& peerman) override;
Expand Down
6 changes: 3 additions & 3 deletions src/active/dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,19 @@ void ActiveDKGSessionHandler::HandlePhase(QuorumPhase curPhase, QuorumPhase next

// returns a set of NodeIds which sent invalid messages
template<typename Message>
std::set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<std::pair<NodeId, std::shared_ptr<Message>>>& messages)
std::unordered_set<NodeId> BatchVerifyMessageSigs(CDKGSession& session, const std::vector<std::pair<NodeId, std::shared_ptr<Message>>>& messages)
{
if (messages.empty()) {
return {};
}

std::set<NodeId> ret;
std::unordered_set<NodeId> ret;
bool revertToSingleVerification = false;

CBLSSignature aggSig;
std::vector<CBLSPublicKey> pubKeys;
std::vector<uint256> messageHashes;
std::set<uint256> messageHashesSet;
Uint256HashSet messageHashesSet;
pubKeys.reserve(messages.size());
messageHashes.reserve(messages.size());
bool first = true;
Expand Down
4 changes: 2 additions & 2 deletions src/llmq/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ RPCResult CDKGDebugSessionStatus::GetJsonHelp(const std::string& key, bool optio
}};
}

// CDKGDebugStatus::ToJson() defined in llmq/debug.cpp
RPCResult CDKGDebugStatus::GetJsonHelp(const std::string& key, bool optional, bool inner_optional)
// CDKGDebugManager::ToJson() defined in llmq/debug.cpp
RPCResult CDKGDebugManager::GetJsonHelp(const std::string& key, bool optional, bool inner_optional)
{
return {RPCResult::Type::OBJ, key, optional, key.empty() ? "" : "The state of the node's DKG sessions",
{
Expand Down
33 changes: 19 additions & 14 deletions src/llmq/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,40 @@ UniValue CDKGDebugSessionStatus::ToJson(CDeterministicMNManager& dmnman, CQuorum
return ret;
}

CDKGDebugManager::CDKGDebugManager() = default;
CDKGDebugManager::CDKGDebugManager(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
const ChainstateManager& chainman) :
m_dmnman{dmnman},
m_qsnapman{qsnapman},
m_chainman{chainman}
{
}

CDKGDebugManager::~CDKGDebugManager() = default;

UniValue CDKGDebugStatus::ToJson(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
const ChainstateManager& chainman, int detailLevel) const
size_t CDKGDebugManager::GetSessionCount() const
{
UniValue ret(UniValue::VOBJ);
return WITH_LOCK(cs_lockStatus, return localStatus.sessions.size());
}

UniValue CDKGDebugManager::ToJson(int detailLevel) const
{
LOCK(cs_lockStatus);

ret.pushKV("time", nTime);
ret.pushKV("timeStr", FormatISO8601DateTime(nTime));
UniValue ret(UniValue::VOBJ);
ret.pushKV("time", localStatus.nTime);
ret.pushKV("timeStr", FormatISO8601DateTime(localStatus.nTime));

// TODO Support array of sessions
UniValue sessionsArrJson(UniValue::VARR);
for (const auto& p : sessions) {
for (const auto& p : localStatus.sessions) {
const auto& llmq_params_opt = Params().GetLLMQ(p.first.first);
if (!llmq_params_opt.has_value()) {
continue;
}
UniValue s(UniValue::VOBJ);
s.pushKV("llmqType", std::string(llmq_params_opt->name));
s.pushKV("quorumIndex", p.first.second);
s.pushKV("status", p.second.ToJson(dmnman, qsnapman, chainman, p.first.second, detailLevel));
s.pushKV("status", p.second.ToJson(m_dmnman, m_qsnapman, m_chainman, p.first.second, detailLevel));

sessionsArrJson.push_back(s);
}
Expand All @@ -138,12 +149,6 @@ UniValue CDKGDebugStatus::ToJson(CDeterministicMNManager& dmnman, CQuorumSnapsho
return ret;
}

void CDKGDebugManager::GetLocalDebugStatus(llmq::CDKGDebugStatus& ret) const
{
LOCK(cs_lockStatus);
ret = localStatus;
}

void CDKGDebugManager::ResetLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex)
{
LOCK(cs_lockStatus);
Expand Down
31 changes: 15 additions & 16 deletions src/llmq/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <univalue.h>

#include <functional>
#include <set>
#include <unordered_set>

class CDataStream;
class CDeterministicMNManager;
Expand Down Expand Up @@ -45,7 +45,7 @@ class CDKGDebugMemberStatus
uint8_t statusBitset;
};

std::set<uint16_t> complaintsFromMembers;
std::unordered_set<uint16_t> complaintsFromMembers;

public:
CDKGDebugMemberStatus() : statusBitset(0) {}
Expand Down Expand Up @@ -83,34 +83,28 @@ class CDKGDebugSessionStatus
const ChainstateManager& chainman, int quorumIndex, int detailLevel) const;
};

class CDKGDebugStatus
{
public:
struct CDKGDebugStatus {
int64_t nTime{0};

std::map<std::pair<Consensus::LLMQType, int>, CDKGDebugSessionStatus> sessions;
//std::map<Consensus::LLMQType, CDKGDebugSessionStatus> sessions;

public:
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional, bool inner_optional = false);
[[nodiscard]] UniValue ToJson(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman,
const ChainstateManager& chainman, int detailLevel) const;
};

class CDKGDebugManager
{
private:
CDeterministicMNManager& m_dmnman;
CQuorumSnapshotManager& m_qsnapman;
const ChainstateManager& m_chainman;

private:
mutable Mutex cs_lockStatus;
CDKGDebugStatus localStatus GUARDED_BY(cs_lockStatus);

public:
CDKGDebugManager(const CDKGDebugManager&) = delete;
CDKGDebugManager& operator=(const CDKGDebugManager&) = delete;
CDKGDebugManager();
CDKGDebugManager(CDeterministicMNManager& dmnman, CQuorumSnapshotManager& qsnapman, const ChainstateManager& chainman);
~CDKGDebugManager();

void GetLocalDebugStatus(CDKGDebugStatus& ret) const EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);

void ResetLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
void InitLocalSessionStatus(const Consensus::LLMQParams& llmqParams, int quorumIndex, const uint256& quorumHash,
int quorumHeight) EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
Expand All @@ -121,8 +115,13 @@ class CDKGDebugManager
void UpdateLocalMemberStatus(Consensus::LLMQType llmqType, int quorumIndex, size_t memberIdx,
std::function<bool(CDKGDebugMemberStatus& status)>&& func)
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
};

size_t GetSessionCount() const
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional, bool inner_optional = false);
[[nodiscard]] UniValue ToJson(int detailLevel) const
EXCLUSIVE_LOCKS_REQUIRED(!cs_lockStatus);
};
} // namespace llmq

#endif // BITCOIN_LLMQ_DEBUG_H
Loading
Loading