Add configurable devnet quorums (#3348)

* add new quorum type LLMQ_EVONET

* add params for new quorum type LLMQ_EVONET

* add LLMQ_EVONET to devnet llmqs

* allow modifying of LLMQ_EVONET params on startup

* rename LLMQ_EVONET to LLMQ_DEVNET

* Update src/chainparams.cpp

Co-Authored-By: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

* Update src/chainparams.cpp

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
Cofresi 2020-02-25 12:06:10 -04:00 committed by GitHub
parent 8b7b4be804
commit 2521970a50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 0 deletions

View File

@ -124,6 +124,14 @@ void CChainParams::UpdateLLMQTestParams(int size, int threshold) {
params.threshold = threshold; params.threshold = threshold;
} }
void CChainParams::UpdateLLMQDevnetParams(int size, int threshold)
{
auto& params = consensus.llmqs.at(Consensus::LLMQ_DEVNET);
params.size = size;
params.minSize = threshold;
params.threshold = threshold;
}
static CBlock FindDevNetGenesisBlock(const Consensus::Params& params, const CBlock &prevBlock, const CAmount& reward) static CBlock FindDevNetGenesisBlock(const Consensus::Params& params, const CBlock &prevBlock, const CAmount& reward)
{ {
std::string devNetName = GetDevNetName(); std::string devNetName = GetDevNetName();
@ -167,6 +175,25 @@ static Consensus::LLMQParams llmq_test = {
.keepOldConnections = 3, .keepOldConnections = 3,
}; };
// this one is for devnets only
static Consensus::LLMQParams llmq_devnet = {
.type = Consensus::LLMQ_DEVNET,
.name = "llmq_devnet",
.size = 10,
.minSize = 7,
.threshold = 6,
.dkgInterval = 24, // one DKG per hour
.dkgPhaseBlocks = 2,
.dkgMiningWindowStart = 10, // dkgPhaseBlocks * 5 = after finalization
.dkgMiningWindowEnd = 18,
.dkgBadVotesThreshold = 7,
.signingActiveQuorumCount = 3, // just a few ones to allow easier testing
.keepOldConnections = 4,
};
static Consensus::LLMQParams llmq50_60 = { static Consensus::LLMQParams llmq50_60 = {
.type = Consensus::LLMQ_50_60, .type = Consensus::LLMQ_50_60,
.name = "llmq_50_60", .name = "llmq_50_60",
@ -688,6 +715,7 @@ public:
nExtCoinType = 1; nExtCoinType = 1;
// long living quorum params // long living quorum params
consensus.llmqs[Consensus::LLMQ_DEVNET] = llmq_devnet;
consensus.llmqs[Consensus::LLMQ_50_60] = llmq50_60; consensus.llmqs[Consensus::LLMQ_50_60] = llmq50_60;
consensus.llmqs[Consensus::LLMQ_400_60] = llmq400_60; consensus.llmqs[Consensus::LLMQ_400_60] = llmq400_60;
consensus.llmqs[Consensus::LLMQ_400_85] = llmq400_85; consensus.llmqs[Consensus::LLMQ_400_85] = llmq400_85;
@ -909,3 +937,8 @@ void UpdateLLMQTestParams(int size, int threshold)
{ {
globalChainParams->UpdateLLMQTestParams(size, threshold); globalChainParams->UpdateLLMQTestParams(size, threshold);
} }
void UpdateLLMQDevnetParams(int size, int threshold)
{
globalChainParams->UpdateLLMQDevnetParams(size, threshold);
}

View File

@ -85,6 +85,7 @@ public:
void UpdateSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor); void UpdateSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor);
void UpdateLLMQChainLocks(Consensus::LLMQType llmqType); void UpdateLLMQChainLocks(Consensus::LLMQType llmqType);
void UpdateLLMQTestParams(int size, int threshold); void UpdateLLMQTestParams(int size, int threshold);
void UpdateLLMQDevnetParams(int size, int threshold);
int PoolMinParticipants() const { return nPoolMinParticipants; } int PoolMinParticipants() const { return nPoolMinParticipants; }
int PoolMaxParticipants() const { return nPoolMaxParticipants; } int PoolMaxParticipants() const { return nPoolMaxParticipants; }
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; } int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
@ -170,4 +171,9 @@ void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType);
*/ */
void UpdateLLMQTestParams(int size, int threshold); void UpdateLLMQTestParams(int size, int threshold);
/**
* Allows modifying parameters of the devnet LLMQ
*/
void UpdateLLMQDevnetParams(int size, int threshold);
#endif // BITCOIN_CHAINPARAMS_H #endif // BITCOIN_CHAINPARAMS_H

View File

@ -50,6 +50,9 @@ enum LLMQType : uint8_t
// for testing only // for testing only
LLMQ_TEST = 100, // 3 members, 2 (66%) threshold, one per hour. Params might differ when -llmqtestparams is used LLMQ_TEST = 100, // 3 members, 2 (66%) threshold, one per hour. Params might differ when -llmqtestparams is used
// for devnets only
LLMQ_DEVNET = 101, // 10 members, 6 (60%) threshold, one per hour. Params might differ when -llmqdevnetparams is used
}; };
// Configures a LLMQ and its DKG // Configures a LLMQ and its DKG

View File

@ -1425,6 +1425,21 @@ bool AppInitParameterInteraction()
return InitError("LLMQ type for ChainLocks can only be overridden on devnet."); return InitError("LLMQ type for ChainLocks can only be overridden on devnet.");
} }
if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) {
if (gArgs.IsArgSet("-llmqdevnetparams")) {
std::string s = gArgs.GetArg("-llmqdevnetparams", "");
std::vector<std::string> v;
boost::split(v, s, boost::is_any_of(":"));
int size, threshold;
if (v.size() != 2 || !ParseInt32(v[0], &size) || !ParseInt32(v[1], &threshold)) {
return InitError("Invalid -llmqdevnetparams specified");
}
UpdateLLMQDevnetParams(size, threshold);
}
} else if (gArgs.IsArgSet("-llmqdevnetparams")) {
return InitError("LLMQ devnet params can only be overridden on devnet.");
}
if (chainparams.NetworkIDString() == CBaseChainParams::REGTEST) { if (chainparams.NetworkIDString() == CBaseChainParams::REGTEST) {
if (gArgs.IsArgSet("-llmqtestparams")) { if (gArgs.IsArgSet("-llmqtestparams")) {
std::string s = gArgs.GetArg("-llmqtestparams", ""); std::string s = gArgs.GetArg("-llmqtestparams", "");