2022-06-08 01:36:46 +02:00
|
|
|
// Copyright (c) 2018-2022 The Dash Core developers
|
2019-01-08 09:55:19 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2021-10-02 19:32:24 +02:00
|
|
|
#ifndef BITCOIN_LLMQ_DEBUG_H
|
|
|
|
#define BITCOIN_LLMQ_DEBUG_H
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <consensus/params.h>
|
|
|
|
#include <sync.h>
|
|
|
|
#include <univalue.h>
|
2019-05-02 01:20:06 +02:00
|
|
|
|
2020-02-27 22:33:44 +01:00
|
|
|
#include <functional>
|
2019-05-02 01:20:06 +02:00
|
|
|
#include <set>
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2023-02-20 11:12:12 +01:00
|
|
|
#include <llmq/dkgsessionhandler.h>
|
|
|
|
|
2019-01-08 09:55:19 +01:00
|
|
|
class CDataStream;
|
|
|
|
class CInv;
|
|
|
|
class CScheduler;
|
|
|
|
|
|
|
|
namespace llmq
|
|
|
|
{
|
|
|
|
|
|
|
|
class CDKGDebugMemberStatus
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
union {
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
// is it locally considered as bad (and thus removed from the validMembers set)
|
|
|
|
bool bad : 1;
|
|
|
|
// did we complain about this member
|
|
|
|
bool weComplain : 1;
|
|
|
|
|
|
|
|
// received message for DKG phases
|
|
|
|
bool receivedContribution : 1;
|
|
|
|
bool receivedComplaint : 1;
|
|
|
|
bool receivedJustification : 1;
|
|
|
|
bool receivedPrematureCommitment : 1;
|
|
|
|
};
|
2019-02-01 08:49:01 +01:00
|
|
|
uint8_t statusBitset;
|
2019-01-08 09:55:19 +01:00
|
|
|
};
|
|
|
|
|
2019-01-09 07:29:57 +01:00
|
|
|
std::set<uint16_t> complaintsFromMembers;
|
2019-01-08 09:55:19 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
CDKGDebugMemberStatus() : statusBitset(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class CDKGDebugSessionStatus
|
|
|
|
{
|
|
|
|
public:
|
2021-10-15 12:28:19 +02:00
|
|
|
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
|
2019-01-08 09:55:19 +01:00
|
|
|
uint256 quorumHash;
|
|
|
|
uint32_t quorumHeight{0};
|
2023-02-20 11:12:12 +01:00
|
|
|
QuorumPhase phase{0};
|
2019-01-08 09:55:19 +01:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
// sent messages for DKG phases
|
|
|
|
bool sentContributions : 1;
|
|
|
|
bool sentComplaint : 1;
|
|
|
|
bool sentJustification : 1;
|
|
|
|
bool sentPrematureCommitment : 1;
|
|
|
|
|
|
|
|
bool aborted : 1;
|
|
|
|
};
|
2019-02-01 08:49:01 +01:00
|
|
|
uint8_t statusBitset;
|
2019-01-08 09:55:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<CDKGDebugMemberStatus> members;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CDKGDebugSessionStatus() : statusBitset(0) {}
|
|
|
|
|
2022-04-16 16:46:04 +02:00
|
|
|
UniValue ToJson(int quorumIndex, int detailLevel) const;
|
2019-01-08 09:55:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CDKGDebugStatus
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int64_t nTime{0};
|
|
|
|
|
2022-04-16 16:46:04 +02:00
|
|
|
std::map<std::pair<Consensus::LLMQType, int>, CDKGDebugSessionStatus> sessions;
|
|
|
|
//std::map<Consensus::LLMQType, CDKGDebugSessionStatus> sessions;
|
2019-01-08 09:55:19 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
UniValue ToJson(int detailLevel) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CDKGDebugManager
|
|
|
|
{
|
|
|
|
private:
|
2023-04-25 13:51:26 +02:00
|
|
|
mutable RecursiveMutex cs;
|
2021-04-27 16:11:45 +02:00
|
|
|
CDKGDebugStatus localStatus GUARDED_BY(cs);
|
2019-01-08 09:55:19 +01:00
|
|
|
|
|
|
|
public:
|
2019-05-02 01:20:06 +02:00
|
|
|
CDKGDebugManager();
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2021-09-08 00:33:02 +02:00
|
|
|
void GetLocalDebugStatus(CDKGDebugStatus& ret) const;
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2022-04-16 16:46:04 +02:00
|
|
|
void ResetLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex);
|
|
|
|
void InitLocalSessionStatus(const Consensus::LLMQParams& llmqParams, int quorumIndex, const uint256& quorumHash, int quorumHeight);
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2022-04-16 16:46:04 +02:00
|
|
|
void UpdateLocalSessionStatus(Consensus::LLMQType llmqType, int quorumIndex, std::function<bool(CDKGDebugSessionStatus& status)>&& func);
|
|
|
|
void UpdateLocalMemberStatus(Consensus::LLMQType llmqType, int quorumIndex, size_t memberIdx, std::function<bool(CDKGDebugMemberStatus& status)>&& func);
|
2019-01-08 09:55:19 +01:00
|
|
|
};
|
|
|
|
|
2019-07-15 20:55:01 +02:00
|
|
|
} // namespace llmq
|
2019-01-08 09:55:19 +01:00
|
|
|
|
2021-10-02 19:32:24 +02:00
|
|
|
#endif // BITCOIN_LLMQ_DEBUG_H
|