refactor: more LLMQ params related refactoring (#4517)

* refactor: Turn LLMQType into `enum class`

* refactor: Simplify/make LLMQ additions safer

* refactor: Move `is_serializable_enum<Consensus::LLMQType>` to `src/llmq/params.h`

* refactor: Add missing include

* refactor: Add missing comment

* Use `static_cast`

* make available_llmqs constexpr array

Signed-off-by: pasta <pasta@dashboost.org>

* cleanup/fixes

Co-authored-by: pasta <pasta@dashboost.org>
This commit is contained in:
UdjinM6 2021-10-15 13:28:19 +03:00 committed by GitHub
parent 38dee8b361
commit ea8d4c26b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 159 additions and 139 deletions

View File

@ -108,6 +108,19 @@ static CBlock FindDevNetGenesisBlock(const CBlock &prevBlock, const CAmount& rew
assert(false);
}
void CChainParams::AddLLMQ(Consensus::LLMQType llmqType)
{
assert(consensus.llmqs.count(llmqType) == 0);
for (const auto& llmq_param : Consensus::available_llmqs) {
if (llmq_param.type == llmqType) {
consensus.llmqs[llmqType] = llmq_param;
return;
}
}
error("CChainParams::%s: unknown LLMQ type %d", __func__, static_cast<uint8_t>(llmqType));
assert(false);
}
/**
* Main network
*/
@ -253,13 +266,13 @@ public:
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
// long living quorum params
consensus.llmqs[Consensus::LLMQ_50_60] = Consensus::llmq50_60;
consensus.llmqs[Consensus::LLMQ_400_60] = Consensus::llmq400_60;
consensus.llmqs[Consensus::LLMQ_400_85] = Consensus::llmq400_85;
consensus.llmqs[Consensus::LLMQ_100_67] = Consensus::llmq100_67;
consensus.llmqTypeChainLocks = Consensus::LLMQ_400_60;
consensus.llmqTypeInstantSend = Consensus::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQ_100_67;
AddLLMQ(Consensus::LLMQType::LLMQ_50_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_85);
AddLLMQ(Consensus::LLMQType::LLMQ_100_67);
consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_400_60;
consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
@ -455,13 +468,13 @@ public:
nExtCoinType = 1;
// long living quorum params
consensus.llmqs[Consensus::LLMQ_50_60] = Consensus::llmq50_60;
consensus.llmqs[Consensus::LLMQ_400_60] = Consensus::llmq400_60;
consensus.llmqs[Consensus::LLMQ_400_85] = Consensus::llmq400_85;
consensus.llmqs[Consensus::LLMQ_100_67] = Consensus::llmq100_67;
consensus.llmqTypeChainLocks = Consensus::LLMQ_50_60;
consensus.llmqTypeInstantSend = Consensus::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQ_100_67;
AddLLMQ(Consensus::LLMQType::LLMQ_50_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_85);
AddLLMQ(Consensus::LLMQType::LLMQ_100_67);
consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67;
fDefaultConsistencyChecks = false;
fRequireStandard = false;
@ -638,14 +651,14 @@ public:
nExtCoinType = 1;
// long living quorum params
consensus.llmqs[Consensus::LLMQ_DEVNET] = Consensus::llmq_devnet;
consensus.llmqs[Consensus::LLMQ_50_60] = Consensus::llmq50_60;
consensus.llmqs[Consensus::LLMQ_400_60] = Consensus::llmq400_60;
consensus.llmqs[Consensus::LLMQ_400_85] = Consensus::llmq400_85;
consensus.llmqs[Consensus::LLMQ_100_67] = Consensus::llmq100_67;
consensus.llmqTypeChainLocks = Consensus::LLMQ_50_60;
consensus.llmqTypeInstantSend = Consensus::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQ_100_67;
AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET);
AddLLMQ(Consensus::LLMQType::LLMQ_50_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_60);
AddLLMQ(Consensus::LLMQType::LLMQ_400_85);
AddLLMQ(Consensus::LLMQType::LLMQ_100_67);
consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_50_60;
consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67;
UpdateDevnetLLMQChainLocksFromArgs(args);
UpdateDevnetLLMQInstantSendFromArgs(args);
@ -716,7 +729,7 @@ public:
*/
void UpdateLLMQDevnetParameters(int size, int threshold)
{
auto& params = consensus.llmqs.at(Consensus::LLMQ_DEVNET);
auto& params = consensus.llmqs.at(Consensus::LLMQType::LLMQ_DEVNET);
params.size = size;
params.minSize = threshold;
params.threshold = threshold;
@ -871,11 +884,11 @@ public:
nExtCoinType = 1;
// long living quorum params
consensus.llmqs[Consensus::LLMQ_TEST] = Consensus::llmq_test;
consensus.llmqs[Consensus::LLMQ_TEST_V17] = Consensus::llmq_test_v17;
consensus.llmqTypeChainLocks = Consensus::LLMQ_TEST;
consensus.llmqTypeInstantSend = Consensus::LLMQ_TEST;
consensus.llmqTypePlatform = Consensus::LLMQ_TEST;
AddLLMQ(Consensus::LLMQType::LLMQ_TEST);
AddLLMQ(Consensus::LLMQType::LLMQ_TEST_V17);
consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_TEST;
consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_TEST;
consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_TEST;
UpdateLLMQTestParametersFromArgs(args);
}
@ -937,7 +950,7 @@ public:
*/
void UpdateLLMQTestParameters(int size, int threshold)
{
auto& params = consensus.llmqs.at(Consensus::LLMQ_TEST);
auto& params = consensus.llmqs.at(Consensus::LLMQType::LLMQ_TEST);
params.size = size;
params.minSize = threshold;
params.threshold = threshold;
@ -1098,16 +1111,16 @@ void CDevNetParams::UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args)
if (!args.IsArgSet("-llmqchainlocks")) return;
std::string strLLMQType = gArgs.GetArg("-llmqchainlocks", std::string(consensus.llmqs.at(consensus.llmqTypeChainLocks).name));
Consensus::LLMQType llmqType = Consensus::LLMQ_NONE;
Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE;
for (const auto& p : consensus.llmqs) {
if (p.second.name == strLLMQType) {
llmqType = p.first;
}
}
if (llmqType == Consensus::LLMQ_NONE) {
if (llmqType == Consensus::LLMQType::LLMQ_NONE) {
throw std::runtime_error("Invalid LLMQ type specified for -llmqchainlocks.");
}
LogPrintf("Setting llmqchainlocks to size=%ld\n", llmqType);
LogPrintf("Setting llmqchainlocks to size=%ld\n", static_cast<uint8_t>(llmqType));
UpdateDevnetLLMQChainLocks(llmqType);
}
@ -1116,16 +1129,16 @@ void CDevNetParams::UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args)
if (!args.IsArgSet("-llmqinstantsend")) return;
std::string strLLMQType = gArgs.GetArg("-llmqinstantsend", std::string(consensus.llmqs.at(consensus.llmqTypeInstantSend).name));
Consensus::LLMQType llmqType = Consensus::LLMQ_NONE;
Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE;
for (const auto& p : consensus.llmqs) {
if (p.second.name == strLLMQType) {
llmqType = p.first;
}
}
if (llmqType == Consensus::LLMQ_NONE) {
if (llmqType == Consensus::LLMQType::LLMQ_NONE) {
throw std::runtime_error("Invalid LLMQ type specified for -llmqinstantsend.");
}
LogPrintf("Setting llmqinstantsend to size=%ld\n", llmqType);
LogPrintf("Setting llmqinstantsend to size=%ld\n", static_cast<uint8_t>(llmqType));
UpdateDevnetLLMQInstantSend(llmqType);
}

View File

@ -8,6 +8,7 @@
#include <chainparamsbase.h>
#include <consensus/params.h>
#include <llmq/params.h>
#include <primitives/block.h>
#include <protocol.h>
@ -136,6 +137,8 @@ protected:
std::vector<std::string> vSporkAddresses;
int nMinSporkKeys;
bool fBIP9CheckMasternodesUpgraded;
void AddLLMQ(Consensus::LLMQType llmqType);
};
/**

View File

@ -113,14 +113,9 @@ struct Params {
std::map<LLMQType, LLMQParams> llmqs;
LLMQType llmqTypeChainLocks;
LLMQType llmqTypeInstantSend{LLMQ_NONE};
LLMQType llmqTypePlatform{LLMQ_NONE};
LLMQType llmqTypeInstantSend{LLMQType::LLMQ_NONE};
LLMQType llmqTypePlatform{LLMQType::LLMQ_NONE};
};
} // namespace Consensus
// This must be outside of all namespaces. We must also duplicate the forward declaration of is_serializable_enum to
// avoid inclusion of serialize.h here.
template<typename T> struct is_serializable_enum;
template<> struct is_serializable_enum<Consensus::LLMQType> : std::true_type {};
#endif // BITCOIN_CONSENSUS_PARAMS_H

View File

@ -59,7 +59,7 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& strC
if (!Params().GetConsensus().llmqs.count(qc.llmqType)) {
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- invalid commitment type %d from peer=%d\n", __func__,
qc.llmqType, pfrom->GetId());
static_cast<uint8_t>(qc.llmqType), pfrom->GetId());
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 100);
return;
@ -109,14 +109,14 @@ void CQuorumBlockProcessor::ProcessMessage(CNode* pfrom, const std::string& strC
if (!qc.Verify(pquorumIndex, true)) {
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- commitment for quorum %s:%d is not valid, peer=%d\n", __func__,
qc.quorumHash.ToString(), qc.llmqType, pfrom->GetId());
qc.quorumHash.ToString(), static_cast<uint8_t>(qc.llmqType), pfrom->GetId());
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 100);
return;
}
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- received commitment for quorum %s:%d, validMembers=%d, signers=%d, peer=%d\n", __func__,
qc.quorumHash.ToString(), qc.llmqType, qc.CountValidMembers(), qc.CountSigners(), pfrom->GetId());
qc.quorumHash.ToString(), static_cast<uint8_t>(qc.llmqType), qc.CountValidMembers(), qc.CountSigners(), pfrom->GetId());
AddMineableCommitment(qc);
}
@ -245,7 +245,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
}
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- processed commitment from block. type=%d, quorumHash=%s, signers=%s, validMembers=%d, quorumPublicKey=%s\n", __func__,
qc.llmqType, quorumHash.ToString(), qc.CountSigners(), qc.CountValidMembers(), qc.quorumPublicKey.ToString());
static_cast<uint8_t>(qc.llmqType), quorumHash.ToString(), qc.CountSigners(), qc.CountValidMembers(), qc.quorumPublicKey.ToString());
return true;
}

View File

@ -34,7 +34,7 @@ bool CFinalCommitment::Verify(const CBlockIndex* pQuorumIndex, bool checkSigs) c
}
if (!Params().GetConsensus().llmqs.count(llmqType)) {
LogPrintfFinalCommitment("invalid llmqType=%d\n", llmqType);
LogPrintfFinalCommitment("invalid llmqType=%d\n", static_cast<uint8_t>(llmqType));
return false;
}
const auto& llmq_params = GetLLMQParams(llmqType);
@ -109,7 +109,7 @@ bool CFinalCommitment::Verify(const CBlockIndex* pQuorumIndex, bool checkSigs) c
bool CFinalCommitment::VerifyNull() const
{
if (!Params().GetConsensus().llmqs.count(llmqType)) {
LogPrintfFinalCommitment("invalid llmqType=%d\n", llmqType);
LogPrintfFinalCommitment("invalid llmqType=%d\n", static_cast<uint8_t>(llmqType));
return false;
}

View File

@ -25,7 +25,7 @@ public:
public:
uint16_t nVersion{CURRENT_VERSION};
Consensus::LLMQType llmqType{Consensus::LLMQ_NONE};
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
uint256 quorumHash;
std::vector<bool> signers;
std::vector<bool> validMembers;

View File

@ -31,7 +31,7 @@ UniValue CDKGDebugSessionStatus::ToJson(int detailLevel) const
}
}
ret.pushKV("llmqType", llmqType);
ret.pushKV("llmqType", static_cast<uint8_t>(llmqType));
ret.pushKV("quorumHash", quorumHash.ToString());
ret.pushKV("quorumHeight", (int)quorumHeight);
ret.pushKV("phase", (int)phase);

View File

@ -48,7 +48,7 @@ public:
class CDKGDebugSessionStatus
{
public:
Consensus::LLMQType llmqType{Consensus::LLMQ_NONE};
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
uint256 quorumHash;
uint32_t quorumHeight{0};
uint8_t phase{0};

View File

@ -84,7 +84,7 @@ public:
class CDKGComplaint
{
public:
Consensus::LLMQType llmqType{Consensus::LLMQ_NONE};
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
uint256 quorumHash;
uint256 proTxHash;
std::vector<bool> badMembers;
@ -145,7 +145,7 @@ public:
class CDKGPrematureCommitment
{
public:
Consensus::LLMQType llmqType{Consensus::LLMQ_NONE};
Consensus::LLMQType llmqType{Consensus::LLMQType::LLMQ_NONE};
uint256 quorumHash;
uint256 proTxHash;
std::vector<bool> validMembers;

View File

@ -96,7 +96,7 @@ CDKGSessionHandler::CDKGSessionHandler(const Consensus::LLMQParams& _params, CBL
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
pendingPrematureCommitments((size_t)_params.size * 2, MSG_QUORUM_PREMATURE_COMMITMENT)
{
if (params.type == Consensus::LLMQ_NONE) {
if (params.type == Consensus::LLMQType::LLMQ_NONE) {
throw std::runtime_error("Can't initialize CDKGSessionHandler with LLMQ_NONE type.");
}
}

View File

@ -487,7 +487,7 @@ void CInstantSendManager::ProcessTx(const CTransaction& tx, bool fRetroactive, c
}
auto llmqType = params.llmqTypeInstantSend;
if (llmqType == Consensus::LLMQ_NONE) {
if (llmqType == Consensus::LLMQType::LLMQ_NONE) {
return;
}
@ -642,7 +642,7 @@ void CInstantSendManager::HandleNewRecoveredSig(const CRecoveredSig& recoveredSi
}
auto llmqType = Params().GetConsensus().llmqTypeInstantSend;
if (llmqType == Consensus::LLMQ_NONE) {
if (llmqType == Consensus::LLMQType::LLMQ_NONE) {
return;
}

View File

@ -5,12 +5,13 @@
#ifndef BITCOIN_LLMQ_PARAMS_H
#define BITCOIN_LLMQ_PARAMS_H
#include <array>
#include <cstdint>
#include <string_view>
namespace Consensus {
enum LLMQType : uint8_t
enum class LLMQType : uint8_t
{
LLMQ_NONE = 0xff,
@ -94,13 +95,15 @@ struct LLMQParams {
};
/**
* llmq_test
* This quorum is only used for testing
*
*/
static constexpr LLMQParams llmq_test = {
.type = LLMQ_TEST,
static constexpr std::array<LLMQParams, 7> available_llmqs = {
/**
* llmq_test
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST,
.name = "llmq_test",
.size = 3,
.minSize = 2,
@ -116,15 +119,15 @@ static constexpr LLMQParams llmq_test = {
.keepOldConnections = 3,
.recoveryMembers = 3,
};
},
/**
* llmq_test (Dash Core 0.17) aka llmq_test_v17
* This quorum is only used for testing
*
*/
static constexpr LLMQParams llmq_test_v17 = {
.type = LLMQ_TEST_V17,
/**
* llmq_test (Dash Core 0.17) aka llmq_test_v17
* This quorum is only used for testing
*
*/
LLMQParams{
.type = LLMQType::LLMQ_TEST_V17,
.name = "llmq_test_v17",
.size = 3,
.minSize = 2,
@ -140,15 +143,15 @@ static constexpr LLMQParams llmq_test_v17 = {
.keepOldConnections = 3,
.recoveryMembers = 3,
};
},
/**
* llmq_devnet
* This quorum is only used for testing on devnets
*
*/
static constexpr LLMQParams llmq_devnet = {
.type = LLMQ_DEVNET,
/**
* llmq_devnet
* This quorum is only used for testing on devnets
*
*/
LLMQParams{
.type = LLMQType::LLMQ_DEVNET,
.name = "llmq_devnet",
.size = 10,
.minSize = 7,
@ -164,16 +167,16 @@ static constexpr LLMQParams llmq_devnet = {
.keepOldConnections = 4,
.recoveryMembers = 6,
};
},
/**
* llmq50_60
* This quorum is deployed on mainnet and requires
* 40 - 50 participants
*
*/
static constexpr LLMQParams llmq50_60 = {
.type = LLMQ_50_60,
* llmq_50_60
* This quorum is deployed on mainnet and requires
* 40 - 50 participants
*
*/
LLMQParams{
.type = LLMQType::LLMQ_50_60,
.name = "llmq_50_60",
.size = 50,
.minSize = 40,
@ -186,19 +189,18 @@ static constexpr LLMQParams llmq50_60 = {
.dkgBadVotesThreshold = 40,
.signingActiveQuorumCount = 24, // a full day worth of LLMQs
.keepOldConnections = 25,
.recoveryMembers = 25,
};
},
/**
* llmq400_60
* This quorum is deployed on mainnet and requires
* 300 - 400 participants
*
*/
static constexpr LLMQParams llmq400_60 = {
.type = LLMQ_400_60,
/**
* llmq_400_60
* This quorum is deployed on mainnet and requires
* 300 - 400 participants
*
*/
LLMQParams{
.type = LLMQType::LLMQ_400_60,
.name = "llmq_400_60",
.size = 400,
.minSize = 300,
@ -214,17 +216,17 @@ static constexpr LLMQParams llmq400_60 = {
.keepOldConnections = 5,
.recoveryMembers = 100,
};
},
/**
* llmq400_85
* This quorum is deployed on mainnet and requires
* 300 - 400 participants _with_ a supermajority
*
* Used for deployment and min-proto-version signalling
*/
static constexpr LLMQParams llmq400_85 = {
.type = LLMQ_400_85,
/**
* llmq_400_85
* This quorum is deployed on mainnet and requires
* 300 - 400 participants _with_ a supermajority
*
* Used for deployment and min-proto-version signalling
*/
LLMQParams{
.type = LLMQType::LLMQ_400_85,
.name = "llmq_400_85",
.size = 400,
.minSize = 350,
@ -240,17 +242,17 @@ static constexpr LLMQParams llmq400_85 = {
.keepOldConnections = 5,
.recoveryMembers = 100,
};
},
/**
* llmq100_67
* This quorum is deployed on mainnet and requires
* 80 - 100 participants
*
* Used by Dash Platform
*/
static constexpr LLMQParams llmq100_67 = {
.type = LLMQ_100_67,
/**
* llmq_100_67
* This quorum is deployed on mainnet and requires
* 80 - 100 participants
*
* Used by Dash Platform
*/
LLMQParams{
.type = LLMQType::LLMQ_100_67,
.name = "llmq_100_67",
.size = 100,
.minSize = 80,
@ -266,8 +268,15 @@ static constexpr LLMQParams llmq100_67 = {
.keepOldConnections = 25,
.recoveryMembers = 50,
};
},
}
}; // available_llmqs
} // namespace Consensus
// This must be outside of all namespaces. We must also duplicate the forward declaration of is_serializable_enum to
// avoid inclusion of serialize.h here.
template<typename T> struct is_serializable_enum;
template<> struct is_serializable_enum<Consensus::LLMQType> : std::true_type {};
#endif // BITCOIN_LLMQ_PARAMS_H

View File

@ -240,7 +240,7 @@ void CQuorumManager::TriggerQuorumDataRecoveryThreads(const CBlockIndex* pIndex)
if (nDataMask == 0) {
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- No data needed from (%d, %s) at height %d\n",
__func__, pQuorum->qc->llmqType, pQuorum->qc->quorumHash.ToString(), pIndex->nHeight);
__func__, static_cast<uint8_t>(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), pIndex->nHeight);
continue;
}
@ -394,7 +394,7 @@ bool CQuorumManager::RequestQuorumData(CNode* pFrom, Consensus::LLMQType llmqTyp
return false;
}
if (Params().GetConsensus().llmqs.count(llmqType) == 0) {
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Invalid llmqType: %d\n", __func__, llmqType);
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Invalid llmqType: %d\n", __func__, static_cast<uint8_t>(llmqType));
return false;
}
if (pQuorumIndex == nullptr) {
@ -402,7 +402,7 @@ bool CQuorumManager::RequestQuorumData(CNode* pFrom, Consensus::LLMQType llmqTyp
return false;
}
if (GetQuorum(llmqType, pQuorumIndex) == nullptr) {
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Quorum not found: %s, %d\n", __func__, pQuorumIndex->GetBlockHash().ToString(), llmqType);
LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- Quorum not found: %s, %d\n", __func__, pQuorumIndex->GetBlockHash().ToString(), static_cast<uint8_t>(llmqType));
return false;
}
@ -766,7 +766,7 @@ void CQuorumManager::StartQuorumDataRecoveryThread(const CQuorumCPtr pQuorum, co
auto printLog = [&](const std::string& strMessage) {
const std::string strMember{pCurrentMemberHash == nullptr ? "nullptr" : pCurrentMemberHash->ToString()};
LogPrint(BCLog::LLMQ, "CQuorumManager::StartQuorumDataRecoveryThread -- %s - for llmqType %d, quorumHash %s, nDataMask (%d/%d), pCurrentMemberHash %s, nTries %d\n",
strMessage, pQuorum->qc->llmqType, pQuorum->qc->quorumHash.ToString(), nDataMask, nDataMaskIn, strMember, nTries);
strMessage, static_cast<uint8_t>(pQuorum->qc->llmqType), pQuorum->qc->quorumHash.ToString(), nDataMask, nDataMaskIn, strMember, nTries);
};
printLog("Start");

View File

@ -33,7 +33,7 @@ void CSigShare::UpdateKey()
std::string CSigSesAnn::ToString() const
{
return strprintf("sessionId=%d, llmqType=%d, quorumHash=%s, id=%s, msgHash=%s",
sessionId, llmqType, quorumHash.ToString(), id.ToString(), msgHash.ToString());
sessionId, static_cast<uint8_t>(llmqType), quorumHash.ToString(), id.ToString(), msgHash.ToString());
}
void CSigSharesInv::Merge(const CSigSharesInv& inv2)
@ -1599,7 +1599,7 @@ CSigShare CSigSharesManager::CreateSigShare(const CQuorumCPtr& quorum, const uin
sigShare.UpdateKey();
LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::%s -- created sigShare. signHash=%s, id=%s, msgHash=%s, llmqType=%d, quorum=%s, time=%s\n", __func__,
signHash.ToString(), sigShare.id.ToString(), sigShare.msgHash.ToString(), quorum->params.type, quorum->qc->quorumHash.ToString(), t.count());
signHash.ToString(), sigShare.id.ToString(), sigShare.msgHash.ToString(), static_cast<uint8_t>(quorum->params.type), quorum->qc->quorumHash.ToString(), t.count());
return sigShare;
}

View File

@ -76,7 +76,7 @@ static bool EvalSpork(Consensus::LLMQType llmqType, int64_t spork_value)
if (spork_value == 0) {
return true;
}
if (spork_value == 1 && llmqType != Consensus::LLMQ_100_67 && llmqType != Consensus::LLMQ_400_60 && llmqType != Consensus::LLMQ_400_85) {
if (spork_value == 1 && llmqType != Consensus::LLMQType::LLMQ_100_67 && llmqType != Consensus::LLMQType::LLMQ_400_60 && llmqType != Consensus::LLMQType::LLMQ_400_85) {
return true;
}
return false;
@ -306,21 +306,21 @@ bool CLLMQUtils::IsQuorumTypeEnabled(Consensus::LLMQType llmqType, const CBlockI
switch (llmqType)
{
case Consensus::LLMQ_50_60:
case Consensus::LLMQ_400_60:
case Consensus::LLMQ_400_85:
case Consensus::LLMQType::LLMQ_50_60:
case Consensus::LLMQType::LLMQ_400_60:
case Consensus::LLMQType::LLMQ_400_85:
break;
case Consensus::LLMQ_100_67:
case Consensus::LLMQ_TEST_V17:
case Consensus::LLMQType::LLMQ_100_67:
case Consensus::LLMQType::LLMQ_TEST_V17:
if (!f_dip0020_Active) {
return false;
}
break;
case Consensus::LLMQ_TEST:
case Consensus::LLMQ_DEVNET:
case Consensus::LLMQType::LLMQ_TEST:
case Consensus::LLMQType::LLMQ_DEVNET:
break;
default:
throw std::runtime_error(strprintf("%s: Unknown LLMQ type %d", __func__, llmqType));
throw std::runtime_error(strprintf("%s: Unknown LLMQ type %d", __func__, static_cast<uint8_t>(llmqType)));
}
return true;
@ -352,7 +352,7 @@ std::map<Consensus::LLMQType, QvvecSyncMode> CLLMQUtils::GetEnabledQuorumVvecSyn
{
std::map<Consensus::LLMQType, QvvecSyncMode> mapQuorumVvecSyncEntries;
for (const auto& strEntry : gArgs.GetArgs("-llmq-qvvec-sync")) {
Consensus::LLMQType llmqType = Consensus::LLMQ_NONE;
Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE;
QvvecSyncMode mode{QvvecSyncMode::Invalid};
std::istringstream ssEntry(strEntry);
std::string strLLMQType, strMode, strTest;
@ -368,7 +368,7 @@ std::map<Consensus::LLMQType, QvvecSyncMode> CLLMQUtils::GetEnabledQuorumVvecSyn
break;
}
}
if (llmqType == Consensus::LLMQ_NONE) {
if (llmqType == Consensus::LLMQType::LLMQ_NONE) {
throw std::invalid_argument(strprintf("Invalid llmqType in -llmq-qvvec-sync: %s", strEntry));
}
if (mapQuorumVvecSyncEntries.count(llmqType) > 0) {

View File

@ -476,7 +476,7 @@ static UniValue quorum_sigs_cmd(const JSONRPCRequest& request)
}
UniValue obj(UniValue::VOBJ);
obj.pushKV("llmqType", llmqType);
obj.pushKV("llmqType", static_cast<uint8_t>(llmqType));
obj.pushKV("quorumHash", sigShare.quorumHash.ToString());
obj.pushKV("quorumMember", sigShare.quorumMember);
obj.pushKV("id", id.ToString());

View File

@ -266,7 +266,7 @@ void CRPCTable::InitPlatformRestrictions()
{"getblockhash", {}},
{"getblockcount", {}},
{"getbestchainlock", {}},
{"quorum", {"sign", Params().GetConsensus().llmqTypePlatform}},
{"quorum", {"sign", static_cast<uint8_t>(Params().GetConsensus().llmqTypePlatform)}},
{"quorum", {"verify"}},
{"verifyislock", {}},
};