diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 72331964d1780..6bde05b680fa4 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -190,6 +190,7 @@ class CMainParams : public CChainParams { consensus.BRRHeight = 1374912; // 000000000000000c5a124f3eccfbe6e17876dca79cec9e63dfa70d269113c926 consensus.DIP0020Height = 1516032; // 000000000000000f64ed3bd9af1078177ac026f6aa2677aa4d8beeae43be56cc consensus.DIP0024Height = 1737792; // 0000000000000001342be9c0b75ad40c276beaad91616423c4d9cb101b3db438 + consensus.DIP0024QuorumsHeight = 1738698; // 000000000000001aa25181e4c466e593992c98f9eb21c69ee757b8bb0af50244 consensus.V19Height = 1899072; // 0000000000000015e32e73052d663626327004c81c5c22cb8b42c361015c0eae consensus.MinBIP9WarningHeight = 1899072 + 2016; // V19 activation height + miner confirmation window consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20 @@ -388,6 +389,7 @@ class CTestNetParams : public CChainParams { consensus.BRRHeight = 387500; // 0000001537dbfd09dea69f61c1f8b2afa27c8dc91c934e144797761c9f10367b consensus.DIP0020Height = 414100; // 000000cf961868662fbfbb5d1af6f1caa1809f6a4e390efe5f8cd3031adea668 consensus.DIP0024Height = 769700; // 0000008d84e4efd890ae95c70a7a6126a70a80e5c19e4cb264a5b3469aeef172 + consensus.DIP0024QuorumsHeight = 770730; // 0000003c43b3ae7fffe61278ca5537a0e256ebf4d709d45f0ab040271074d51e consensus.V19Height = 850100; // 000004728b8ff2a16b9d4eebb0fd61eeffadc9c7fe4b0ec0b5a739869401ab5b consensus.MinBIP9WarningHeight = 850100 + 2016; // v19 activation height + miner confirmation window consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20 @@ -559,6 +561,7 @@ class CDevNetParams : public CChainParams { consensus.BRRHeight = 300; consensus.DIP0020Height = 300; consensus.DIP0024Height = 300; + consensus.DIP0024QuorumsHeight = 300; consensus.V19Height = 300; consensus.MinBIP9WarningHeight = 300 + 2016; // v19 activation height + miner confirmation window consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1 @@ -797,6 +800,7 @@ class CRegTestParams : public CChainParams { consensus.BRRHeight = 2500; // see block_reward_reallocation_tests consensus.DIP0020Height = 300; consensus.DIP0024Height = 900; + consensus.DIP0024QuorumsHeight = 900; consensus.V19Height = 900; consensus.MinBIP9WarningHeight = 0; consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1 diff --git a/src/consensus/params.h b/src/consensus/params.h index 74c148ef5be05..caf17bac3f67a 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -125,6 +125,8 @@ struct Params { int DIP0020Height; /** Block height at which DIP0024 (Quorum Rotation) and decreased governance proposal fee becomes active */ int DIP0024Height; + /** Block height at which the first DIP0024 quorum was mined */ + int DIP0024QuorumsHeight; /** Block height at which V19 (Basic BLS and EvoNodes) becomes active */ int V19Height; /** Don't warn about unknown BIP 9 activations below this height. diff --git a/src/llmq/options.cpp b/src/llmq/options.cpp index db0b883b803ba..34d9067c8bb11 100644 --- a/src/llmq/options.cpp +++ b/src/llmq/options.cpp @@ -116,28 +116,26 @@ std::map GetEnabledQuorumVvecSyncEntries() bool IsQuorumTypeEnabled(Consensus::LLMQType llmqType, gsl::not_null pindexPrev) { - return IsQuorumTypeEnabledInternal(llmqType, pindexPrev, std::nullopt); + return IsQuorumTypeEnabledInternal(llmqType, pindexPrev, std::nullopt, std::nullopt); } bool IsQuorumTypeEnabledInternal(Consensus::LLMQType llmqType, gsl::not_null pindexPrev, - std::optional optDIP0024IsActive) + std::optional optDIP0024IsActive, std::optional optHaveDIP0024Quorums) { const Consensus::Params& consensusParams = Params().GetConsensus(); const bool fDIP0024IsActive{optDIP0024IsActive.value_or(DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_DIP0024))}; + const bool fHaveDIP0024Quorums{optHaveDIP0024Quorums.value_or(pindexPrev->nHeight >= consensusParams.DIP0024QuorumsHeight)}; switch (llmqType) { case Consensus::LLMQType::LLMQ_DEVNET: return true; case Consensus::LLMQType::LLMQ_50_60: - if (Params().NetworkIDString() == CBaseChainParams::TESTNET) return true; - return !fDIP0024IsActive; - + return !fDIP0024IsActive || !fHaveDIP0024Quorums || + Params().NetworkIDString() == CBaseChainParams::TESTNET; case Consensus::LLMQType::LLMQ_TEST_INSTANTSEND: - if (!fDIP0024IsActive) return true; - - return consensusParams.llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_TEST_INSTANTSEND; - + return !fDIP0024IsActive || !fHaveDIP0024Quorums || + consensusParams.llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_TEST_INSTANTSEND; case Consensus::LLMQType::LLMQ_TEST: case Consensus::LLMQType::LLMQ_TEST_PLATFORM: case Consensus::LLMQType::LLMQ_400_60: diff --git a/src/llmq/options.h b/src/llmq/options.h index 17e85dc0f1139..db207a99cbb95 100644 --- a/src/llmq/options.h +++ b/src/llmq/options.h @@ -43,7 +43,7 @@ bool IsWatchQuorumsEnabled(); std::map GetEnabledQuorumVvecSyncEntries(); bool IsQuorumTypeEnabled(Consensus::LLMQType llmqType, gsl::not_null pindexPrev); -bool IsQuorumTypeEnabledInternal(Consensus::LLMQType llmqType, gsl::not_null pindexPrev, std::optional optDIP0024IsActive); +bool IsQuorumTypeEnabledInternal(Consensus::LLMQType llmqType, gsl::not_null pindexPrev, std::optional optDIP0024IsActive, std::optional optHaveDIP0024Quorums); std::vector GetEnabledQuorumTypes(gsl::not_null pindex); std::vector> GetEnabledQuorumParams(gsl::not_null pindex); diff --git a/src/test/evo_utils_tests.cpp b/src/test/evo_utils_tests.cpp index 1810f5aef14e4..ce5de7a3fca94 100644 --- a/src/test/evo_utils_tests.cpp +++ b/src/test/evo_utils_tests.cpp @@ -21,14 +21,18 @@ void Test(NodeContext& node) using namespace llmq; auto tip = node.chainman->ActiveTip(); const auto& consensus_params = Params().GetConsensus(); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, tip, false), false); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, tip, true), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, tip, false ), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, tip, true), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, tip, false), Params().IsTestChain()); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, tip, true), Params().IsTestChain()); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, tip, false), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, tip, true), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, tip, false, false), false); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, tip, true, false), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, tip, true, true), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, tip, false, false), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, tip, true, false), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, tip, true, true), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, tip, false, false), Params().IsTestChain()); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, tip, true, false), Params().IsTestChain()); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, tip, true, true), Params().IsTestChain()); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, tip, false, false), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, tip, true, false), true); + BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, tip, true, true), true); } BOOST_FIXTURE_TEST_CASE(utils_IsQuorumTypeEnabled_tests_regtest, RegTestingSetup)