feat!: v19 BIP9 fork (#5070)

* Added v19 HF

* Refactoring

* Update src/consensus/params.h

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
Odysseas Gabrielides 2022-11-22 19:34:21 +02:00 committed by GitHub
parent 6ee156c69e
commit 85d6cadbfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 11 deletions

View File

@ -249,6 +249,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Deployment of Basic BLS, AssetLocks, EHF
consensus.vDeployments[Consensus::DEPLOYMENT_V19].bit = 8;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nStartTime = 19999999999; // TODO: To be determined later
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000079c96bdb79315818b358"); // 1756000
@ -474,6 +483,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Deployment of Basic BLS, AssetLocks, EHF
consensus.vDeployments[Consensus::DEPLOYMENT_V19].bit = 8;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nStartTime = 19999999999; // TODO: To be determined later
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdStart = 80; // 80% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000002d68c333d26a1b3"); // 817000
@ -670,6 +688,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Deployment of Basic BLS, AssetLocks, EHF
consensus.vDeployments[Consensus::DEPLOYMENT_V19].bit = 8;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nStartTime = 1661990400; // Sep 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdStart = 80; // 80% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000000000000");
@ -911,6 +938,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 180; // 60% of 300
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Deployment of Basic BLS, AssetLocks, EHF
consensus.vDeployments[Consensus::DEPLOYMENT_V19].bit = 8;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nWindowSize = 300;
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdStart = 240; // 80% of 300
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nThresholdMin = 180; // 60% of 300
consensus.vDeployments[Consensus::DEPLOYMENT_V19].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");

View File

@ -23,6 +23,7 @@ enum DeploymentPos {
DEPLOYMENT_REALLOC, // Deployment of Block Reward Reallocation
DEPLOYMENT_DIP0020, // Deployment of DIP0020, DIP0021 and LMQ_100_67 quorums
DEPLOYMENT_DIP0024, // Deployment of DIP0024 (Quorum Rotation) and decreased governance proposal fee
DEPLOYMENT_V19, // Deployment of Basic BLS, AssetLocks, EHF
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};

View File

@ -598,6 +598,14 @@ bool IsDIP0024Active(const CBlockIndex* pindex)
return VersionBitsState(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, llmq_versionbitscache) == ThresholdState::ACTIVE;
}
bool IsV19Active(const CBlockIndex* pindex)
{
assert(pindex);
LOCK(cs_llmq_vbc);
return VersionBitsState(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V19, llmq_versionbitscache) == ThresholdState::ACTIVE;
}
bool IsInstantSendLLMQTypeShared()
{
if (Params().GetConsensus().llmqTypeInstantSend == Params().GetConsensus().llmqTypeChainLocks ||

View File

@ -93,6 +93,7 @@ bool IsQuorumRotationEnabled(Consensus::LLMQType llmqType, const CBlockIndex* pi
Consensus::LLMQType GetInstantSendLLMQType(const CQuorumManager& qman, const CBlockIndex* pindex);
Consensus::LLMQType GetInstantSendLLMQType(bool deterministic);
bool IsDIP0024Active(const CBlockIndex* pindex);
bool IsV19Active(const CBlockIndex* pindex);
static bool IsInstantSendLLMQTypeShared();
/// Returns the state of `-llmq-data-recovery`

View File

@ -51,5 +51,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.name =*/"dip0024",
/*.gbt_force =*/true,
/*.check_mn_protocol =*/false,
},
{
/*.name =*/"v19",
/*.gbt_force =*/true,
/*.check_mn_protocol =*/false,
}
};

View File

@ -881,15 +881,8 @@ class DashTestFramework(BitcoinTestFramework):
self.sync_blocks()
self.sync_blocks()
def activate_dip0024(self, expected_activation_height=None):
self.log.info("Wait for dip0024 activation")
# disable spork17 while mining blocks to activate dip0024 to prevent accidental quorum formation
spork17_value = self.nodes[0].spork('show')['SPORK_17_QUORUM_DKG_ENABLED']
self.bump_mocktime(1)
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
self.wait_for_sporks_same()
def activate_by_name(self, name, expected_activation_height=None):
self.log.info("Wait for " + name + " activation")
# mine blocks in batches
batch_size = 10
if expected_activation_height is not None:
@ -904,19 +897,31 @@ class DashTestFramework(BitcoinTestFramework):
self.bump_mocktime(blocks_left)
self.nodes[0].generate(blocks_left)
self.sync_blocks()
assert self.nodes[0].getblockchaininfo()['bip9_softforks']['dip0024']['status'] != 'active'
assert self.nodes[0].getblockchaininfo()['bip9_softforks'][name]['status'] != 'active'
while self.nodes[0].getblockchaininfo()['bip9_softforks']['dip0024']['status'] != 'active':
while self.nodes[0].getblockchaininfo()['bip9_softforks'][name]['status'] != 'active':
self.bump_mocktime(batch_size)
self.nodes[0].generate(batch_size)
self.sync_blocks()
self.sync_blocks()
def activate_dip0024(self, expected_activation_height=None):
# disable spork17 while mining blocks to activate dip0024 to prevent accidental quorum formation
spork17_value = self.nodes[0].spork('show')['SPORK_17_QUORUM_DKG_ENABLED']
self.bump_mocktime(1)
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
self.wait_for_sporks_same()
self.activate_by_name('dip0024', expected_activation_height)
# revert spork17 changes
self.bump_mocktime(1)
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", spork17_value)
self.wait_for_sporks_same()
def activate_v19(self, expected_activation_height=None):
self.activate_by_name('v19', expected_activation_height)
def set_dash_llmq_test_params(self, llmq_size, llmq_threshold):
self.llmq_size = llmq_size
self.llmq_threshold = llmq_threshold