Remove dummy DKG

This commit is contained in:
Alexander Block 2018-11-21 09:32:34 +01:00
parent 55f205eba1
commit 0df3871d14
8 changed files with 3 additions and 808 deletions

View File

@ -141,7 +141,6 @@ BITCOIN_CORE_H = \
limitedmap.h \
llmq/quorums_commitment.h \
llmq/quorums_blockprocessor.h \
llmq/quorums_dummydkg.h \
llmq/quorums_utils.h \
llmq/quorums_init.h \
masternode-meta.h \
@ -249,7 +248,6 @@ libdash_server_a_SOURCES = \
governance-votedb.cpp \
llmq/quorums_commitment.cpp \
llmq/quorums_blockprocessor.cpp \
llmq/quorums_dummydkg.cpp \
llmq/quorums_utils.cpp \
llmq/quorums_init.cpp \
masternode-meta.cpp \

View File

@ -16,8 +16,6 @@
#include "evo/deterministicmns.h"
#include "llmq/quorums_dummydkg.h"
void CDSNotificationInterface::InitializeCurrentBlockTip()
{
LOCK(cs_main);
@ -40,7 +38,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
return;
deterministicMNManager->UpdatedBlockTip(pindexNew);
llmq::quorumDummyDKG->UpdatedBlockTip(pindexNew, fInitialDownload);
masternodeSync.UpdatedBlockTip(pindexNew, fInitialDownload, connman);

View File

@ -1,608 +0,0 @@
// Copyright (c) 2018 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "quorums_dummydkg.h"
#include "quorums_blockprocessor.h"
#include "quorums_commitment.h"
#include "quorums_utils.h"
#include "evo/specialtx.h"
#include "activemasternode.h"
#include "chain.h"
#include "chainparams.h"
#include "consensus/validation.h"
#include "net.h"
#include "net_processing.h"
#include "primitives/block.h"
#include "spork.h"
#include "validation.h"
namespace llmq
{
CDummyDKG* quorumDummyDKG;
void CDummyDKG::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
{
if (strCommand == NetMsgType::QCONTRIB) {
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED)) {
return;
}
CDummyContribution qc;
try {
vRecv >> qc;
} catch (...) {
// When we switch to the real DKG, non-upgraded nodes will get to this point. Let them just ignore the
// incompatible messages
return;
}
uint256 hash = ::SerializeHash(qc);
{
LOCK(cs_main);
connman.RemoveAskFor(hash);
}
ProcessDummyContribution(pfrom->id, qc);
} else if (strCommand == NetMsgType::QDCOMMITMENT) {
if (!Params().GetConsensus().fLLMQAllowDummyCommitments) {
Misbehaving(pfrom->id, 100);
return;
}
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED)) {
return;
}
CDummyCommitment qc;
vRecv >> qc;
uint256 hash = ::SerializeHash(qc);
{
LOCK(cs_main);
connman.RemoveAskFor(hash);
}
ProcessDummyCommitment(pfrom->id, qc);
}
}
void CDummyDKG::ProcessDummyContribution(NodeId from, const llmq::CDummyContribution& qc)
{
if (!Params().GetConsensus().llmqs.count((Consensus::LLMQType)qc.llmqType)) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid commitment type %d, peer=%d\n", __func__,
qc.llmqType, from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
auto type = (Consensus::LLMQType)qc.llmqType;
const auto& params = Params().GetConsensus().llmqs.at(type);
int curQuorumHeight;
const CBlockIndex* quorumIndex;
{
LOCK(cs_main);
curQuorumHeight = chainActive.Height() - (chainActive.Height() % params.dkgInterval);
quorumIndex = chainActive[curQuorumHeight];
}
uint256 quorumHash = quorumIndex->GetBlockHash();
if (qc.quorumHash != quorumHash) {
LogPrintf("CDummyDKG::%s -- dummy contrinution for wrong quorum, peer=%d\n", __func__,
from);
return;
}
auto members = CLLMQUtils::GetAllQuorumMembers(type, qc.quorumHash);
if (members.size() != params.size) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid members count %d, peer=%d\n", __func__,
members.size(), from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
if (qc.signer >= members.size()) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid signer %d, peer=%d\n", __func__,
qc.signer, from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
auto signer = members[qc.signer];
{
LOCK(sessionCs);
if (curSessions[type].dummyContributionsFromMembers.count(signer->proTxHash)) {
return;
}
}
// verify member sig
if (!qc.sig.VerifyInsecure(signer->pdmnState->pubKeyOperator, qc.GetSignHash())) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid memberSig, peer=%d\n", __func__,
from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
LogPrintf("CDummyDKG::%s -- processed dummy contribution for quorum %s:%d, signer=%d, peer=%d\n", __func__,
qc.quorumHash.ToString(), qc.llmqType, qc.signer, from);
uint256 hash = ::SerializeHash(qc);
{
LOCK(sessionCs);
curSessions[type].dummyContributions[hash] = qc;
curSessions[type].dummyContributionsFromMembers[signer->proTxHash] = hash;
}
CInv inv(MSG_QUORUM_DUMMY_CONTRIBUTION, hash);
g_connman->RelayInv(inv, DMN_PROTO_VERSION);
}
void CDummyDKG::ProcessDummyCommitment(NodeId from, const llmq::CDummyCommitment& qc)
{
if (!Params().GetConsensus().llmqs.count((Consensus::LLMQType)qc.llmqType)) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid commitment type %d, peer=%d\n", __func__,
qc.llmqType, from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
auto type = (Consensus::LLMQType)qc.llmqType;
const auto& params = Params().GetConsensus().llmqs.at(type);
if (qc.validMembers.size() != params.size) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid validMembers size %d, peer=%d\n", __func__,
qc.validMembers.size(), from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
int curQuorumHeight;
const CBlockIndex* quorumIndex;
{
LOCK(cs_main);
curQuorumHeight = chainActive.Height() - (chainActive.Height() % params.dkgInterval);
quorumIndex = chainActive[curQuorumHeight];
}
uint256 quorumHash = quorumIndex->GetBlockHash();
if (qc.quorumHash != quorumHash) {
LogPrintf("CDummyDKG::%s -- dummy commitment for wrong quorum, peer=%d\n", __func__,
from);
return;
}
auto members = CLLMQUtils::GetAllQuorumMembers(type, qc.quorumHash);
if (members.size() != params.size) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid members count %d, peer=%d\n", __func__,
members.size(), from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
if (qc.signer >= members.size()) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid signer %d, peer=%d\n", __func__,
qc.signer, from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
if (qc.CountValidMembers() < params.minSize) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid validMembers count %d, peer=%d\n", __func__,
qc.CountValidMembers(), from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
auto signer = members[qc.signer];
{
LOCK(sessionCs);
for (const auto& p : curSessions[type].dummyCommitmentsFromMembers) {
if (p.second.count(signer->proTxHash)) {
return;
}
}
}
auto svec = BuildDeterministicSvec(type, qc.quorumHash);
auto vvec = BuildVvec(svec);
auto vvecHash = ::SerializeHash(vvec);
auto commitmentHash = CLLMQUtils::BuildCommitmentHash((uint8_t)type, qc.quorumHash, qc.validMembers, vvec[0], vvecHash);
// verify member sig
if (!qc.membersSig.VerifyInsecure(signer->pdmnState->pubKeyOperator, commitmentHash)) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid memberSig, peer=%d\n", __func__,
from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
// recover public key share
CBLSPublicKey sharePk;
if (!sharePk.PublicKeyShare(vvec, CBLSId::FromHash(signer->proTxHash))) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- failed to recover public key share, peer=%d\n", __func__,
from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
// verify sig share
if (!qc.quorumSig.VerifyInsecure(sharePk, commitmentHash)) {
LOCK(cs_main);
LogPrintf("CDummyDKG::%s -- invalid quorumSig, peer=%d\n", __func__,
from);
if (from != -1) {
Misbehaving(from, 100);
}
return;
}
LogPrintf("CDummyDKG::%s -- processed dummy commitment for quorum %s:%d, validMembers=%d, signer=%d, peer=%d\n", __func__,
qc.quorumHash.ToString(), qc.llmqType, qc.CountValidMembers(), qc.signer, from);
uint256 hash = ::SerializeHash(qc);
{
LOCK(sessionCs);
curSessions[type].dummyCommitments[hash] = qc;
curSessions[type].dummyCommitmentsFromMembers[commitmentHash][signer->proTxHash] = hash;
}
CInv inv(MSG_QUORUM_DUMMY_COMMITMENT, hash);
g_connman->RelayInv(inv, DMN_PROTO_VERSION);
}
void CDummyDKG::UpdatedBlockTip(const CBlockIndex* pindex, bool fInitialDownload)
{
if (fInitialDownload) {
return;
}
if (!fMasternodeMode) {
return;
}
bool fDIP0003Active = VersionBitsState(chainActive.Tip(), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0003, versionbitscache) == THRESHOLD_ACTIVE;
if (!fDIP0003Active) {
return;
}
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED)) {
return;
}
for (const auto& p : Params().GetConsensus().llmqs) {
const auto& params = p.second;
int phaseIndex = pindex->nHeight % params.dkgInterval;
if (phaseIndex == 0) {
CreateDummyContribution(params.type, pindex);
} else if (phaseIndex == params.dkgPhaseBlocks * 2) {
CreateDummyCommitment(params.type, pindex);
} else if (phaseIndex == params.dkgPhaseBlocks * 4) {
CreateFinalCommitment(params.type, pindex);
}
}
}
void CDummyDKG::CreateDummyContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindex)
{
const auto& params = Params().GetConsensus().llmqs.at(llmqType);
int quorumHeight = pindex->nHeight - (pindex->nHeight % params.dkgInterval);
const CBlockIndex* quorumIndex;
{
LOCK(cs_main);
quorumIndex = chainActive[quorumHeight];
}
uint256 quorumHash = quorumIndex->GetBlockHash();
auto members = CLLMQUtils::GetAllQuorumMembers(llmqType, quorumHash);
if (members.size() != params.size) {
return;
}
int myIdx = -1;
for (size_t i = 0; i < members.size(); i++) {
if (members[i]->collateralOutpoint == activeMasternodeInfo.outpoint) {
myIdx = (int)i;
break;
}
}
if (myIdx == -1) {
return;
}
auto signer = members[myIdx];
CDummyContribution qc;
qc.llmqType = (uint8_t)llmqType;
qc.quorumHash = quorumHash;
qc.signer = (uint16_t)myIdx;
qc.sig = activeMasternodeInfo.blsKeyOperator->Sign(qc.GetSignHash());
ProcessDummyContribution(-1, qc);
}
void CDummyDKG::CreateDummyCommitment(Consensus::LLMQType llmqType, const CBlockIndex* pindex)
{
const auto& params = Params().GetConsensus().llmqs.at(llmqType);
int quorumHeight = pindex->nHeight - (pindex->nHeight % params.dkgInterval);
const CBlockIndex* quorumIndex;
{
LOCK(cs_main);
quorumIndex = chainActive[quorumHeight];
}
uint256 quorumHash = quorumIndex->GetBlockHash();
auto members = CLLMQUtils::GetAllQuorumMembers(llmqType, quorumHash);
if (members.size() != params.size) {
return;
}
int myIdx = -1;
for (size_t i = 0; i < members.size(); i++) {
if (members[i]->collateralOutpoint == activeMasternodeInfo.outpoint) {
myIdx = (int)i;
break;
}
}
if (myIdx == -1) {
return;
}
auto signer = members[myIdx];
auto svec = BuildDeterministicSvec(llmqType, quorumHash);
auto vvec = BuildVvec(svec);
auto vvecHash = ::SerializeHash(vvec);
auto validMembers = GetValidMembers(llmqType, members);
if (std::count(validMembers.begin(), validMembers.end(), true) < params.minSize) {
return;
}
auto commitmentHash = CLLMQUtils::BuildCommitmentHash((uint8_t)llmqType, quorumHash, validMembers, vvec[0], vvecHash);
CDummyCommitment qc;
qc.llmqType = (uint8_t)llmqType;
qc.quorumHash = quorumHash;
qc.signer = (uint16_t)myIdx;
qc.validMembers = validMembers;
qc.membersSig = activeMasternodeInfo.blsKeyOperator->Sign(commitmentHash);
CBLSSecretKey skShare;
if (!skShare.SecretKeyShare(svec, CBLSId::FromHash(signer->proTxHash))) {
return;
}
qc.quorumSig = skShare.Sign(commitmentHash);
ProcessDummyCommitment(-1, qc);
}
void CDummyDKG::CreateFinalCommitment(Consensus::LLMQType llmqType, const CBlockIndex* pindex)
{
const auto& params = Params().GetConsensus().llmqs.at(llmqType);
int quorumHeight = pindex->nHeight - (pindex->nHeight % params.dkgInterval);
const CBlockIndex* quorumIndex;
{
LOCK(cs_main);
quorumIndex = chainActive[quorumHeight];
}
uint256 quorumHash = quorumIndex->GetBlockHash();
auto members = CLLMQUtils::GetAllQuorumMembers(llmqType, quorumHash);
if (members.size() != params.size) {
return;
}
auto svec = BuildDeterministicSvec(llmqType, quorumHash);
auto vvec = BuildVvec(svec);
auto vvecHash = ::SerializeHash(vvec);
LOCK(sessionCs);
auto& session = curSessions[llmqType];
for (const auto& p : session.dummyCommitmentsFromMembers) {
const auto& commitmentHash = p.first;
if (p.second.size() < params.minSize) {
continue;
}
const auto& firstQc = session.dummyCommitments[p.second.begin()->second];
CFinalCommitment fqc(params, quorumHash);
fqc.validMembers = firstQc.validMembers;
fqc.quorumPublicKey = vvec[0];
fqc.quorumVvecHash = vvecHash;
std::vector<CBLSSignature> quorumSigs;
std::vector<CBLSId> quorumSigIds;
std::vector<CBLSSignature> memberSigs;
std::vector<CBLSPublicKey> memberPubKeys;
for (const auto& p2 : p.second) {
const auto& proTxHash = p2.first;
const auto& qc = session.dummyCommitments[p2.second];
int signerIdx = -1;
for (size_t i = 0; i < members.size(); i++) {
if (members[i]->proTxHash == proTxHash) {
signerIdx = (int)i;
break;
}
}
if (signerIdx == -1) {
break;
}
fqc.signers[signerIdx] = true;
if (quorumSigs.size() < params.threshold) {
quorumSigs.emplace_back(qc.quorumSig);
quorumSigIds.emplace_back(CBLSId::FromHash(proTxHash));
}
memberSigs.emplace_back(qc.membersSig);
memberPubKeys.emplace_back(members[signerIdx]->pdmnState->pubKeyOperator);
}
if (!fqc.quorumSig.Recover(quorumSigs, quorumSigIds)) {
LogPrintf("CDummyDKG::%s -- recovery failed for quorum %s:%d, validMembers=%d, signers=%d\n", __func__,
fqc.quorumHash.ToString(), fqc.llmqType, fqc.CountValidMembers(), fqc.CountSigners());
continue;
}
fqc.membersSig = CBLSSignature::AggregateSecure(memberSigs, memberPubKeys, commitmentHash);
if (!fqc.Verify(members, true)) {
LogPrintf("CDummyDKG::%s -- self created final commitment is invalid for quorum %s:%d, validMembers=%d, signers=%d\n", __func__,
fqc.quorumHash.ToString(), fqc.llmqType, fqc.CountValidMembers(), fqc.CountSigners());
continue;
}
LogPrintf("CDummyDKG::%s -- self created final commitment for quorum %s:%d, validMembers=%d, signers=%d\n", __func__,
fqc.quorumHash.ToString(), fqc.llmqType, fqc.CountValidMembers(), fqc.CountSigners());
quorumBlockProcessor->AddMinableCommitment(fqc);
}
// reset for next round
curSessions[llmqType] = CDummyDKGSession();
}
std::vector<bool> CDummyDKG::GetValidMembers(Consensus::LLMQType llmqType, const std::vector<CDeterministicMNCPtr>& members)
{
const auto& params = Params().GetConsensus().llmqs.at(llmqType);
std::vector<bool> ret(params.size, false);
LOCK(sessionCs);
// Valid members are members that sent us a dummy contribution in this session
for (size_t i = 0; i < params.size; i++) {
if (curSessions[llmqType].dummyContributionsFromMembers.count(members[i]->proTxHash)) {
ret[i] = true;
}
}
return ret;
}
// The returned secret key vector is NOT SECURE AT ALL!!
// It is known by everyone. This is only for testnet/devnet/regtest, so this is fine. Also, we won't do any meaningful
// things with the commitments. This is only needed to make the final commitments validate
BLSSecretKeyVector CDummyDKG::BuildDeterministicSvec(Consensus::LLMQType llmqType, const uint256& quorumHash)
{
const auto& params = Params().GetConsensus().llmqs.at(llmqType);
CHash256 seed_;
seed_.Write((unsigned char*)&llmqType, 1);
seed_.Write(quorumHash.begin(), quorumHash.size());
uint256 seed;
seed_.Finalize(seed.begin());
BLSSecretKeyVector svec;
svec.reserve(params.size);
for (size_t i = 0; i < params.threshold; i++) {
CBLSSecretKey sk;
while (true) {
seed = ::SerializeHash(seed);
sk.SetBuf(seed.begin(), seed.size());
if (sk.IsValid()) {
break;
}
}
svec.emplace_back(sk);
}
return svec;
}
BLSPublicKeyVector CDummyDKG::BuildVvec(const BLSSecretKeyVector& svec)
{
BLSPublicKeyVector vvec;
vvec.reserve(svec.size());
for (size_t i = 0; i < svec.size(); i++) {
vvec.emplace_back(svec[i].GetPublicKey());
}
return vvec;
}
bool CDummyDKG::HasDummyContribution(const uint256& hash)
{
LOCK(sessionCs);
for (const auto& p : curSessions) {
auto it = p.second.dummyContributions.find(hash);
if (it != p.second.dummyContributions.end()) {
return true;
}
}
return false;
}
bool CDummyDKG::GetDummyContribution(const uint256& hash, CDummyContribution& ret)
{
LOCK(sessionCs);
for (const auto& p : curSessions) {
auto it = p.second.dummyContributions.find(hash);
if (it != p.second.dummyContributions.end()) {
ret = it->second;
return true;
}
}
return false;
}
bool CDummyDKG::HasDummyCommitment(const uint256& hash)
{
LOCK(sessionCs);
for (const auto& p : curSessions) {
auto it = p.second.dummyCommitments.find(hash);
if (it != p.second.dummyCommitments.end()) {
return true;
}
}
return false;
}
bool CDummyDKG::GetDummyCommitment(const uint256& hash, CDummyCommitment& ret)
{
LOCK(sessionCs);
for (const auto& p : curSessions) {
auto it = p.second.dummyCommitments.find(hash);
if (it != p.second.dummyCommitments.end()) {
ret = it->second;
return true;
}
}
return false;
}
}

View File

@ -1,157 +0,0 @@
// Copyright (c) 2018 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef DASH_QUORUMS_DUMMYDKG_H
#define DASH_QUORUMS_DUMMYDKG_H
#include "llmq/quorums_commitment.h"
#include "consensus/params.h"
#include "net.h"
#include "primitives/transaction.h"
#include "sync.h"
#include "bls/bls.h"
#include <map>
class CNode;
class CConnman;
/**
* Implementation of an insecure dummy DKG
*
* This is only used on testnet/devnet/regtest and will NEVER be used on
* mainnet. It is NOT SECURE AT ALL! It will actually be removed later when the real DKG is introduced.
*
* It works by using a deterministic secure vector as the secure polynomial. Everyone can calculate this
* polynomial by himself, which makes it insecure by definition.
*
* The purpose of this dummy implementation is to test final LLMQ commitments and simple PoSe on-chain.
* The dummy DKG first creates dummy commitments and propagates these to all nodes. They can then create
* a valid LLMQ commitment from these, which validates with the normal commitment validation code.
*
* After these have been mined on-chain, they are indistinguishable from commitments created from the real
* DKG, making them good enough for testing.
*
* The validMembers bitset is created from information of past dummy DKG sessions. If nodes failed to provide
* the dummy commitments, they will be marked as bad in the next session. This might create some chaos and
* finalizable commitments, but this is ok and will sort itself out after some sessions.
*/
namespace llmq
{
// This is more like a PING than a contribution
// We will later replace this message (reusing same inv type) for the real contribution
// Deserialization will then be incompatible between peers, but that is fine (let them reject the messages)
class CDummyContribution
{
public:
uint8_t llmqType{Consensus::LLMQ_NONE};
uint256 quorumHash;
uint16_t signer{(uint16_t)-1};
CBLSSignature sig;
public:
ADD_SERIALIZE_METHODS
template<typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(llmqType);
READWRITE(quorumHash);
READWRITE(signer);
READWRITE(sig);
}
uint256 GetSignHash() const
{
CDummyContribution tmp(*this);
tmp.sig = CBLSSignature();
return ::SerializeHash(tmp);
}
};
// This message is only allowed on testnet/devnet/regtest
// If any peer tries to send this message on mainnet, it is banned immediately
// It is used to test commitments on testnet without actually running a full-blown DKG.
class CDummyCommitment
{
public:
uint8_t llmqType{Consensus::LLMQ_NONE};
uint256 quorumHash;
uint16_t signer{(uint16_t)-1};
std::vector<bool> validMembers;
CBLSSignature quorumSig;
CBLSSignature membersSig;
public:
int CountValidMembers() const
{
return (int)std::count(validMembers.begin(), validMembers.end(), true);
}
public:
ADD_SERIALIZE_METHODS
template<typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)
{
READWRITE(llmqType);
READWRITE(quorumHash);
READWRITE(signer);
READWRITE(DYNBITSET(validMembers));
READWRITE(quorumSig);
READWRITE(membersSig);
}
};
class CDummyDKGSession
{
public:
std::map<uint256, CDummyContribution> dummyContributions;
std::map<uint256, CDummyCommitment> dummyCommitments;
std::map<uint256, uint256> dummyContributionsFromMembers;
std::map<uint256, std::map<uint256, uint256>> dummyCommitmentsFromMembers;
};
// It simulates the result of a DKG session by deterministically calculating a secret/public key vector
// !!!THIS IS NOT SECURE AT ALL AND WILL NEVER BE USED ON MAINNET!!!
// The whole dummy DKG will be removed when we add the real DKG
class CDummyDKG
{
private:
CCriticalSection sessionCs;
std::map<Consensus::LLMQType, CDummyDKGSession> curSessions;
public:
void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
void ProcessDummyContribution(NodeId from, const CDummyContribution& qc);
void ProcessDummyCommitment(NodeId from, const CDummyCommitment& qc);
void UpdatedBlockTip(const CBlockIndex* pindex, bool fInitialDownload);
void CreateDummyContribution(Consensus::LLMQType llmqType, const CBlockIndex* pindex);
void CreateDummyCommitment(Consensus::LLMQType llmqType, const CBlockIndex* pindex);
void CreateFinalCommitment(Consensus::LLMQType llmqType, const CBlockIndex* pindex);
bool HasDummyContribution(const uint256& hash);
bool GetDummyContribution(const uint256& hash, CDummyContribution& ret);
bool HasDummyCommitment(const uint256& hash);
bool GetDummyCommitment(const uint256& hash, CDummyCommitment& ret);
private:
std::vector<bool> GetValidMembers(Consensus::LLMQType llmqType, const std::vector<CDeterministicMNCPtr>& members);
BLSSecretKeyVector BuildDeterministicSvec(Consensus::LLMQType llmqType, const uint256& quorumHash);
BLSPublicKeyVector BuildVvec(const BLSSecretKeyVector& svec);
};
extern CDummyDKG* quorumDummyDKG;
}
#endif//DASH_QUORUMS_DUMMYDKG_H

View File

@ -6,7 +6,6 @@
#include "quorums_blockprocessor.h"
#include "quorums_commitment.h"
#include "quorums_dummydkg.h"
namespace llmq
{
@ -14,13 +13,10 @@ namespace llmq
void InitLLMQSystem(CEvoDB& evoDb)
{
quorumBlockProcessor = new CQuorumBlockProcessor(evoDb);
quorumDummyDKG = new CDummyDKG();
}
void DestroyLLMQSystem()
{
delete quorumDummyDKG;
quorumDummyDKG = nullptr;
delete quorumBlockProcessor;
quorumBlockProcessor = nullptr;
}

View File

@ -45,7 +45,6 @@
#include "evo/deterministicmns.h"
#include "evo/simplifiedmns.h"
#include "llmq/quorums_commitment.h"
#include "llmq/quorums_dummydkg.h"
#include "llmq/quorums_blockprocessor.h"
#include <boost/thread.hpp>
@ -950,10 +949,6 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
case MSG_QUORUM_FINAL_COMMITMENT:
return llmq::quorumBlockProcessor->HasMinableCommitment(inv.hash);
case MSG_QUORUM_DUMMY_COMMITMENT:
return llmq::quorumDummyDKG->HasDummyCommitment(inv.hash);
case MSG_QUORUM_DUMMY_CONTRIBUTION:
return llmq::quorumDummyDKG->HasDummyContribution(inv.hash);
}
// Don't know what it is, just say we already got one
@ -1223,28 +1218,6 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
}
}
if (!push && (inv.type == MSG_QUORUM_DUMMY_CONTRIBUTION)) {
llmq::CDummyContribution o;
if (llmq::quorumDummyDKG->GetDummyContribution(inv.hash, o)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QCONTRIB, o));
push = true;
}
}
if (!push && (inv.type == MSG_QUORUM_DUMMY_COMMITMENT)) {
if (!consensusParams.fLLMQAllowDummyCommitments) {
Misbehaving(pfrom->id, 100);
pfrom->fDisconnect = true;
return;
}
llmq::CDummyCommitment o;
if (llmq::quorumDummyDKG->GetDummyCommitment(inv.hash, o)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QDCOMMITMENT, o));
push = true;
}
}
if (!push)
vNotFound.push_back(inv);
}
@ -2897,7 +2870,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
masternodeSync.ProcessMessage(pfrom, strCommand, vRecv);
governance.ProcessMessage(pfrom, strCommand, vRecv, connman);
llmq::quorumBlockProcessor->ProcessMessage(pfrom, strCommand, vRecv, connman);
llmq::quorumDummyDKG->ProcessMessage(pfrom, strCommand, vRecv, connman);
}
else
{

View File

@ -59,7 +59,6 @@ const char *MNGOVERNANCEOBJECTVOTE="govobjvote";
const char *GETMNLISTDIFF="getmnlistd";
const char *MNLISTDIFF="mnlistdiff";
const char *QFCOMMITMENT="qfcommit";
const char *QDCOMMITMENT="qdcommit";
const char *QCONTRIB="qcontrib";
};
@ -89,7 +88,7 @@ static const char* ppszTypeName[] =
"unused inv type 19",
"compact block", // Should never occur
NetMsgType::QFCOMMITMENT,
NetMsgType::QDCOMMITMENT,
"qdcommit", // was only shortly used on testnet
NetMsgType::QCONTRIB,
};
@ -144,7 +143,6 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::GETMNLISTDIFF,
NetMsgType::MNLISTDIFF,
NetMsgType::QFCOMMITMENT,
NetMsgType::QDCOMMITMENT,
NetMsgType::QCONTRIB,
};
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));

View File

@ -265,7 +265,6 @@ extern const char *MNGOVERNANCEOBJECTVOTE;
extern const char *GETMNLISTDIFF;
extern const char *MNLISTDIFF;
extern const char *QFCOMMITMENT;
extern const char *QDCOMMITMENT;
extern const char *QCONTRIB;
};
@ -361,8 +360,8 @@ enum GetDataMsg {
// MSG_CMPCT_BLOCK should not appear in any invs except as a part of getdata.
MSG_CMPCT_BLOCK = 20, //!< Defined in BIP152
MSG_QUORUM_FINAL_COMMITMENT = 21,
MSG_QUORUM_DUMMY_COMMITMENT = 22, // only valid on testnet/devnet/regtest
MSG_QUORUM_DUMMY_CONTRIBUTION = 23, // not a valid contribution and only allowed on testnet/devnet/regtest. Will later be replaced with the real contribution
/* MSG_QUORUM_DUMMY_COMMITMENT = 22, */ // was shortly used on testnet/devnet/regtest
/* MSG_QUORUM_DUMMY_CONTRIBUTION = 23, */ // not a valid contribution and only allowed on testnet/devnet/regtest. Will later be replaced with the real contribution
};
/** inv message data */