diff --git a/src/consensus/activation.h b/src/consensus/activation.h --- a/src/consensus/activation.h +++ b/src/consensus/activation.h @@ -39,4 +39,8 @@ bool IsAxionEnabled(const Consensus::Params ¶ms, const CBlockIndex *pindexPrev); +/** Check if May 15th, 2022 protocol upgrade has activated. */ +bool IsGluonEnabled(const Consensus::Params ¶ms, + const CBlockIndex *pindexPrev); + #endif // BITCOIN_CONSENSUS_ACTIVATION_H diff --git a/src/consensus/activation.cpp b/src/consensus/activation.cpp --- a/src/consensus/activation.cpp +++ b/src/consensus/activation.cpp @@ -84,3 +84,13 @@ return pindexPrev->GetMedianTimePast() >= gArgs.GetArg("-axionactivationtime", params.axionActivationTime); } + +bool IsGluonEnabled(const Consensus::Params ¶ms, + const CBlockIndex *pindexPrev) { + if (pindexPrev == nullptr) { + return false; + } + + return pindexPrev->GetMedianTimePast() >= + gArgs.GetArg("-gluonactivationtime", params.gluonActivationTime); +} diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -409,15 +409,27 @@ // Hidden Options std::vector hidden_args = { - "-dbcrashratio", "-forcecompactdb", "-maxaddrtosend", "-parkdeepreorg", - "-automaticunparking", "-replayprotectionactivationtime", + "-dbcrashratio", + "-forcecompactdb", + "-maxaddrtosend", + "-parkdeepreorg", + "-automaticunparking", + "-replayprotectionactivationtime", "-enableminerfund", // GUI args. These will be overwritten by SetupUIArgs for the GUI - "-allowselfsignedrootcertificates", "-choosedatadir", "-lang=", - "-min", "-resetguisettings", "-rootcertificates=", "-splash", + "-allowselfsignedrootcertificates", + "-choosedatadir", + "-lang=", + "-min", + "-resetguisettings", + "-rootcertificates=", + "-splash", "-uiplatform", // TODO remove after the November 2020 upgrade - "-axionactivationtime"}; + "-axionactivationtime", + // TODO remove after the May 2022 upgrade + "-gluonactivationtime", + }; // Set all of the args and their help // When adding new options to the categories, please keep and ensure diff --git a/src/test/activation_tests.cpp b/src/test/activation_tests.cpp --- a/src/test/activation_tests.cpp +++ b/src/test/activation_tests.cpp @@ -73,4 +73,28 @@ BOOST_CHECK(IsAxionEnabled(params, &blocks.back())); } +BOOST_AUTO_TEST_CASE(isgluonenabled) { + const Consensus::Params ¶ms = Params().GetConsensus(); + const auto activation = + gArgs.GetArg("-gluonactivationtime", params.gluonActivationTime); + SetMockTime(activation - 1000000); + + BOOST_CHECK(!IsGluonEnabled(params, nullptr)); + + std::array blocks; + for (size_t i = 1; i < blocks.size(); ++i) { + blocks[i].pprev = &blocks[i - 1]; + } + BOOST_CHECK(!IsGluonEnabled(params, &blocks.back())); + + SetMTP(blocks, activation - 1); + BOOST_CHECK(!IsGluonEnabled(params, &blocks.back())); + + SetMTP(blocks, activation); + BOOST_CHECK(IsGluonEnabled(params, &blocks.back())); + + SetMTP(blocks, activation + 1); + BOOST_CHECK(IsGluonEnabled(params, &blocks.back())); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -55,6 +55,8 @@ '-zapwallettxes', # Remove after November 2020 upgrade '-axionactivationtime', + # Remove after May 2022 upgrade + '-gluonactivationtime', '-replayprotectionactivationtime', ])