diff --git a/src/chain.h b/src/chain.h index d2094ef0e1..40fcf8ecb5 100644 --- a/src/chain.h +++ b/src/chain.h @@ -330,7 +330,7 @@ class CBlockIndex std::sort(pbegin, pend); // Only after FC and when we have a full set of times. - if (nHeight >= Params().GetConsensus().FortCanningHeight && pend - pbegin == nMedianTimeSpan) { + if (nHeight >= Params().GetConsensus().DF11FortCanningHeight && pend - pbegin == nMedianTimeSpan) { // Take the median of the top five. return pbegin[8]; } diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c4878e7b7f..c53b91acb7 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -119,28 +119,28 @@ class CMainParams : public CChainParams { consensus.BIP34Hash = uint256(); consensus.BIP65Height = 0; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0 consensus.BIP66Height = 0; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931 - consensus.AMKHeight = 356500; // Oct 12th, 2020. - consensus.BayfrontHeight = 405000; // Nov 2nd, 2020. - consensus.BayfrontMarinaHeight = 465150; // Nov 28th, 2020. - consensus.BayfrontGardensHeight = 488300; // Dec 8th, 2020. - consensus.ClarkeQuayHeight = 595738; // Jan 24th, 2021. - consensus.DakotaHeight = 678000; // Mar 1st, 2021. - consensus.DakotaCrescentHeight = 733000; // Mar 25th, 2021. - consensus.EunosHeight = 894000; // Jun 3rd, 2021. - consensus.EunosKampungHeight = 895743; // Jun 4th, 2021. - consensus.EunosPayaHeight = 1072000; // Aug 5th, 2021. - consensus.FortCanningHeight = 1367000; // Nov 15th, 2021. - consensus.FortCanningMuseumHeight = 1430640; // Dec 7th, 2021. - consensus.FortCanningParkHeight = 1503143; // Jan 2nd, 2022. - consensus.FortCanningHillHeight = 1604999; // Feb 7th, 2022. - consensus.FortCanningRoadHeight = 1786000; // April 11th, 2022. - consensus.FortCanningCrunchHeight = 1936000; // June 2nd, 2022. - consensus.FortCanningSpringHeight = 2033000; // July 6th, 2022. - consensus.FortCanningGreatWorldHeight = 2212000; // Sep 7th, 2022. - consensus.FortCanningEpilogueHeight = 2257500; // Sep 22nd, 2022. - consensus.GrandCentralHeight = 2479000; // Dec 8th, 2022. - consensus.GrandCentralEpilogueHeight = 2574000; // Jan 10th, 2023. - consensus.NextNetworkUpgradeHeight = std::numeric_limits::max(); + consensus.DF1AMKHeight = 356500; // Oct 12th, 2020. + consensus.DF2BayfrontHeight = 405000; // Nov 2nd, 2020. + consensus.DF3BayfrontMarinaHeight = 465150; // Nov 28th, 2020. + consensus.DF4BayfrontGardensHeight = 488300; // Dec 8th, 2020. + consensus.DF5ClarkeQuayHeight = 595738; // Jan 24th, 2021. + consensus.DF6DakotaHeight = 678000; // Mar 1st, 2021. + consensus.DF7DakotaCrescentHeight = 733000; // Mar 25th, 2021. + consensus.DF8EunosHeight = 894000; // Jun 3rd, 2021. + consensus.DF9EunosKampungHeight = 895743; // Jun 4th, 2021. + consensus.DF10EunosPayaHeight = 1072000; // Aug 5th, 2021. + consensus.DF11FortCanningHeight = 1367000; // Nov 15th, 2021. + consensus.DF12FortCanningMuseumHeight = 1430640; // Dec 7th, 2021. + consensus.DF13FortCanningParkHeight = 1503143; // Jan 2nd, 2022. + consensus.DF14FortCanningHillHeight = 1604999; // Feb 7th, 2022. + consensus.DF15FortCanningRoadHeight = 1786000; // April 11th, 2022. + consensus.DF16FortCanningCrunchHeight = 1936000; // June 2nd, 2022. + consensus.DF17FortCanningSpringHeight = 2033000; // July 6th, 2022. + consensus.DF18FortCanningGreatWorldHeight = 2212000; // Sep 7th, 2022. + consensus.DF19FortCanningEpilogueHeight = 2257500; // Sep 22nd, 2022. + consensus.DF20GrandCentralHeight = 2479000; // Dec 8th, 2022. + consensus.DF21GrandCentralEpilogueHeight = 2574000; // Jan 10th, 2023. + consensus.DF22NextHeight = std::numeric_limits::max(); consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks @@ -394,28 +394,28 @@ class CTestNetParams : public CChainParams { consensus.BIP34Hash = uint256(); consensus.BIP65Height = 0; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6 consensus.BIP66Height = 0; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182 - consensus.AMKHeight = 150; - consensus.BayfrontHeight = 3000; - consensus.BayfrontMarinaHeight = 90470; - consensus.BayfrontGardensHeight = 101342; - consensus.ClarkeQuayHeight = 155000; - consensus.DakotaHeight = 220680; - consensus.DakotaCrescentHeight = 287700; - consensus.EunosHeight = 354950; - consensus.EunosKampungHeight = consensus.EunosHeight; - consensus.EunosPayaHeight = 463300; - consensus.FortCanningHeight = 686200; - consensus.FortCanningMuseumHeight = 724000; - consensus.FortCanningParkHeight = 828800; - consensus.FortCanningHillHeight = 828900; - consensus.FortCanningRoadHeight = 893700; - consensus.FortCanningCrunchHeight = 1011600; - consensus.FortCanningSpringHeight = 1086000; - consensus.FortCanningGreatWorldHeight = 1223000; - consensus.FortCanningEpilogueHeight = 1244000; - consensus.GrandCentralHeight = 1366000; - consensus.GrandCentralEpilogueHeight = 1438200; - consensus.NextNetworkUpgradeHeight = std::numeric_limits::max();; + consensus.DF1AMKHeight = 150; + consensus.DF2BayfrontHeight = 3000; + consensus.DF3BayfrontMarinaHeight = 90470; + consensus.DF4BayfrontGardensHeight = 101342; + consensus.DF5ClarkeQuayHeight = 155000; + consensus.DF6DakotaHeight = 220680; + consensus.DF7DakotaCrescentHeight = 287700; + consensus.DF8EunosHeight = 354950; + consensus.DF9EunosKampungHeight = consensus.DF8EunosHeight; + consensus.DF10EunosPayaHeight = 463300; + consensus.DF11FortCanningHeight = 686200; + consensus.DF12FortCanningMuseumHeight = 724000; + consensus.DF13FortCanningParkHeight = 828800; + consensus.DF14FortCanningHillHeight = 828900; + consensus.DF15FortCanningRoadHeight = 893700; + consensus.DF16FortCanningCrunchHeight = 1011600; + consensus.DF17FortCanningSpringHeight = 1086000; + consensus.DF18FortCanningGreatWorldHeight = 1223000; + consensus.DF19FortCanningEpilogueHeight = 1244000; + consensus.DF20GrandCentralHeight = 1366000; + consensus.DF21GrandCentralEpilogueHeight = 1438200; + consensus.DF22NextHeight = std::numeric_limits::max();; consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks @@ -612,28 +612,28 @@ class CChangiParams : public CChainParams { consensus.BIP34Hash = uint256(); consensus.BIP65Height = 0; consensus.BIP66Height = 0; - consensus.AMKHeight = 150; - consensus.BayfrontHeight = 3000; - consensus.BayfrontMarinaHeight = 90470; - consensus.BayfrontGardensHeight = 101342; - consensus.ClarkeQuayHeight = 155000; - consensus.DakotaHeight = 220680; - consensus.DakotaCrescentHeight = 287700; - consensus.EunosHeight = 354950; - consensus.EunosKampungHeight = consensus.EunosHeight; - consensus.EunosPayaHeight = 463300; - consensus.FortCanningHeight = 686200; - consensus.FortCanningMuseumHeight = 724000; - consensus.FortCanningParkHeight = 828800; - consensus.FortCanningHillHeight = 828900; - consensus.FortCanningRoadHeight = 893700; - consensus.FortCanningCrunchHeight = 1011600; - consensus.FortCanningSpringHeight = 1086000; - consensus.FortCanningGreatWorldHeight = 1223000; - consensus.FortCanningEpilogueHeight = 1244000; - consensus.GrandCentralHeight = 1366000; - consensus.GrandCentralEpilogueHeight = 1438200; - consensus.NextNetworkUpgradeHeight = 1586750; + consensus.DF1AMKHeight = 150; + consensus.DF2BayfrontHeight = 3000; + consensus.DF3BayfrontMarinaHeight = 90470; + consensus.DF4BayfrontGardensHeight = 101342; + consensus.DF5ClarkeQuayHeight = 155000; + consensus.DF6DakotaHeight = 220680; + consensus.DF7DakotaCrescentHeight = 287700; + consensus.DF8EunosHeight = 354950; + consensus.DF9EunosKampungHeight = consensus.DF8EunosHeight; + consensus.DF10EunosPayaHeight = 463300; + consensus.DF11FortCanningHeight = 686200; + consensus.DF12FortCanningMuseumHeight = 724000; + consensus.DF13FortCanningParkHeight = 828800; + consensus.DF14FortCanningHillHeight = 828900; + consensus.DF15FortCanningRoadHeight = 893700; + consensus.DF16FortCanningCrunchHeight = 1011600; + consensus.DF17FortCanningSpringHeight = 1086000; + consensus.DF18FortCanningGreatWorldHeight = 1223000; + consensus.DF19FortCanningEpilogueHeight = 1244000; + consensus.DF20GrandCentralHeight = 1366000; + consensus.DF21GrandCentralEpilogueHeight = 1438200; + consensus.DF22NextHeight = 1586750; consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks @@ -828,28 +828,28 @@ class CDevNetParams : public CChainParams { consensus.BIP34Hash = uint256(); consensus.BIP65Height = 0; consensus.BIP66Height = 0; - consensus.AMKHeight = 150; - consensus.BayfrontHeight = 3000; - consensus.BayfrontMarinaHeight = 90470; - consensus.BayfrontGardensHeight = 101342; - consensus.ClarkeQuayHeight = 155000; - consensus.DakotaHeight = 220680; - consensus.DakotaCrescentHeight = 287700; - consensus.EunosHeight = 354950; - consensus.EunosKampungHeight = consensus.EunosHeight; - consensus.EunosPayaHeight = 463300; - consensus.FortCanningHeight = 686200; - consensus.FortCanningMuseumHeight = 724000; - consensus.FortCanningParkHeight = 828800; - consensus.FortCanningHillHeight = 828900; - consensus.FortCanningRoadHeight = 893700; - consensus.FortCanningCrunchHeight = 1011600; - consensus.FortCanningSpringHeight = 1086000; - consensus.FortCanningGreatWorldHeight = 1223000; - consensus.FortCanningEpilogueHeight = 1244000; - consensus.GrandCentralHeight = 1366000; - consensus.GrandCentralEpilogueHeight = 1438200; - consensus.NextNetworkUpgradeHeight = 1586750; + consensus.DF1AMKHeight = 150; + consensus.DF2BayfrontHeight = 3000; + consensus.DF3BayfrontMarinaHeight = 90470; + consensus.DF4BayfrontGardensHeight = 101342; + consensus.DF5ClarkeQuayHeight = 155000; + consensus.DF6DakotaHeight = 220680; + consensus.DF7DakotaCrescentHeight = 287700; + consensus.DF8EunosHeight = 354950; + consensus.DF9EunosKampungHeight = consensus.DF8EunosHeight; + consensus.DF10EunosPayaHeight = 463300; + consensus.DF11FortCanningHeight = 686200; + consensus.DF12FortCanningMuseumHeight = 724000; + consensus.DF13FortCanningParkHeight = 828800; + consensus.DF14FortCanningHillHeight = 828900; + consensus.DF15FortCanningRoadHeight = 893700; + consensus.DF16FortCanningCrunchHeight = 1011600; + consensus.DF17FortCanningSpringHeight = 1086000; + consensus.DF18FortCanningGreatWorldHeight = 1223000; + consensus.DF19FortCanningEpilogueHeight = 1244000; + consensus.DF20GrandCentralHeight = 1366000; + consensus.DF21GrandCentralEpilogueHeight = 1438200; + consensus.DF22NextHeight = 1586750; consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks @@ -1047,28 +1047,28 @@ class CRegTestParams : public CChainParams { consensus.BIP34Hash = uint256(); consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests) consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests) - consensus.AMKHeight = 10000000; - consensus.BayfrontHeight = 10000000; - consensus.BayfrontMarinaHeight = 10000000; - consensus.BayfrontGardensHeight = 10000000; - consensus.ClarkeQuayHeight = 10000000; - consensus.DakotaHeight = 10000000; - consensus.DakotaCrescentHeight = 10000000; - consensus.EunosHeight = 10000000; - consensus.EunosKampungHeight = 10000000; - consensus.EunosPayaHeight = 10000000; - consensus.FortCanningHeight = 10000000; - consensus.FortCanningMuseumHeight = 10000000; - consensus.FortCanningParkHeight = 10000000; - consensus.FortCanningHillHeight = 10000000; - consensus.FortCanningRoadHeight = 10000000; - consensus.FortCanningCrunchHeight = 10000000; - consensus.FortCanningSpringHeight = 10000000; - consensus.FortCanningGreatWorldHeight = 10000000; - consensus.FortCanningEpilogueHeight = 10000000; - consensus.GrandCentralHeight = 10000000; - consensus.GrandCentralEpilogueHeight = 10000000; - consensus.NextNetworkUpgradeHeight = 10000000; + consensus.DF1AMKHeight = 10000000; + consensus.DF2BayfrontHeight = 10000000; + consensus.DF3BayfrontMarinaHeight = 10000000; + consensus.DF4BayfrontGardensHeight = 10000000; + consensus.DF5ClarkeQuayHeight = 10000000; + consensus.DF6DakotaHeight = 10000000; + consensus.DF7DakotaCrescentHeight = 10000000; + consensus.DF8EunosHeight = 10000000; + consensus.DF9EunosKampungHeight = 10000000; + consensus.DF10EunosPayaHeight = 10000000; + consensus.DF11FortCanningHeight = 10000000; + consensus.DF12FortCanningMuseumHeight = 10000000; + consensus.DF13FortCanningParkHeight = 10000000; + consensus.DF14FortCanningHillHeight = 10000000; + consensus.DF15FortCanningRoadHeight = 10000000; + consensus.DF16FortCanningCrunchHeight = 10000000; + consensus.DF17FortCanningSpringHeight = 10000000; + consensus.DF18FortCanningGreatWorldHeight = 10000000; + consensus.DF19FortCanningEpilogueHeight = 10000000; + consensus.DF20GrandCentralHeight = 10000000; + consensus.DF21GrandCentralEpilogueHeight = 10000000; + consensus.DF22NextHeight = 10000000; consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks @@ -1312,30 +1312,30 @@ std::optional UpdateHeightValidation(const std::string& argName, const std: void SetupCommonArgActivationParams(Consensus::Params &consensus) { UpdateHeightValidation("Segwit", "-segwitheight", consensus.SegwitHeight); - UpdateHeightValidation("AMK", "-amkheight", consensus.AMKHeight); - UpdateHeightValidation("Bayfront", "-bayfrontheight", consensus.BayfrontHeight); - UpdateHeightValidation("Bayfront Gardens", "-bayfrontgardensheight", consensus.BayfrontGardensHeight); - UpdateHeightValidation("Clarke Quay", "-clarkequayheight", consensus.ClarkeQuayHeight); - UpdateHeightValidation("Dakota", "-dakotaheight", consensus.DakotaHeight); - UpdateHeightValidation("Dakota Crescent", "-dakotacrescentheight", consensus.DakotaCrescentHeight); - auto eunosHeight = UpdateHeightValidation("Eunos", "-eunosheight", consensus.EunosHeight); + UpdateHeightValidation("AMK", "-amkheight", consensus.DF1AMKHeight); + UpdateHeightValidation("Bayfront", "-bayfrontheight", consensus.DF2BayfrontHeight); + UpdateHeightValidation("Bayfront Gardens", "-bayfrontgardensheight", consensus.DF4BayfrontGardensHeight); + UpdateHeightValidation("Clarke Quay", "-clarkequayheight", consensus.DF5ClarkeQuayHeight); + UpdateHeightValidation("Dakota", "-dakotaheight", consensus.DF6DakotaHeight); + UpdateHeightValidation("Dakota Crescent", "-dakotacrescentheight", consensus.DF7DakotaCrescentHeight); + auto eunosHeight = UpdateHeightValidation("Eunos", "-eunosheight", consensus.DF8EunosHeight); if (eunosHeight.has_value()){ - consensus.EunosKampungHeight = static_cast(eunosHeight.value()); + consensus.DF9EunosKampungHeight = static_cast(eunosHeight.value()); } - UpdateHeightValidation("Eunos Paya", "-eunospayaheight", consensus.EunosPayaHeight); - UpdateHeightValidation("Fort Canning", "-fortcanningheight", consensus.FortCanningHeight); - UpdateHeightValidation("Fort Canning Museum", "-fortcanningmuseumheight", consensus.FortCanningMuseumHeight); - UpdateHeightValidation("Fort Canning Park", "-fortcanningparkheight", consensus.FortCanningParkHeight); - UpdateHeightValidation("Fort Canning Hill", "-fortcanninghillheight", consensus.FortCanningHillHeight); - UpdateHeightValidation("Fort Canning Road", "-fortcanningroadheight", consensus.FortCanningRoadHeight); - UpdateHeightValidation("Fort Canning Crunch", "-fortcanningcrunchheight", consensus.FortCanningCrunchHeight); - UpdateHeightValidation("Fort Canning Spring", "-fortcanningspringheight", consensus.FortCanningSpringHeight); - UpdateHeightValidation("Fort Canning Great World", "-fortcanninggreatworldheight", consensus.FortCanningGreatWorldHeight); - UpdateHeightValidation("Fort Canning Great World", "-greatworldheight", consensus.FortCanningGreatWorldHeight); - UpdateHeightValidation("Fort Canning Epilogue", "-fortcanningepilogueheight", consensus.FortCanningEpilogueHeight); - UpdateHeightValidation("Grand Central", "-grandcentralheight", consensus.GrandCentralHeight); - UpdateHeightValidation("Grand Central Epilogue", "-grandcentralepilogueheight", consensus.GrandCentralEpilogueHeight); - UpdateHeightValidation("Next Network Upgrade", "-nextnetworkupgradeheight", consensus.NextNetworkUpgradeHeight); + UpdateHeightValidation("Eunos Paya", "-eunospayaheight", consensus.DF10EunosPayaHeight); + UpdateHeightValidation("Fort Canning", "-fortcanningheight", consensus.DF11FortCanningHeight); + UpdateHeightValidation("Fort Canning Museum", "-fortcanningmuseumheight", consensus.DF12FortCanningMuseumHeight); + UpdateHeightValidation("Fort Canning Park", "-fortcanningparkheight", consensus.DF13FortCanningParkHeight); + UpdateHeightValidation("Fort Canning Hill", "-fortcanninghillheight", consensus.DF14FortCanningHillHeight); + UpdateHeightValidation("Fort Canning Road", "-fortcanningroadheight", consensus.DF15FortCanningRoadHeight); + UpdateHeightValidation("Fort Canning Crunch", "-fortcanningcrunchheight", consensus.DF16FortCanningCrunchHeight); + UpdateHeightValidation("Fort Canning Spring", "-fortcanningspringheight", consensus.DF17FortCanningSpringHeight); + UpdateHeightValidation("Fort Canning Great World", "-fortcanninggreatworldheight", consensus.DF18FortCanningGreatWorldHeight); + UpdateHeightValidation("Fort Canning Great World", "-greatworldheight", consensus.DF18FortCanningGreatWorldHeight); + UpdateHeightValidation("Fort Canning Epilogue", "-fortcanningepilogueheight", consensus.DF19FortCanningEpilogueHeight); + UpdateHeightValidation("Grand Central", "-grandcentralheight", consensus.DF20GrandCentralHeight); + UpdateHeightValidation("Grand Central Epilogue", "-grandcentralepilogueheight", consensus.DF21GrandCentralEpilogueHeight); + UpdateHeightValidation("Next Network Upgrade", "-nextnetworkupgradeheight", consensus.DF22NextHeight); if (gArgs.GetBoolArg("-simulatemainnet", false)) { consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks diff --git a/src/consensus/params.h b/src/consensus/params.h index 5b21801430..ee93353570 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -76,32 +76,32 @@ struct Params { * BIP 16 exception blocks. */ int SegwitHeight; /** Block height at which tokens, liquidity pools and new block rewards becomes active */ - int AMKHeight; + int DF1AMKHeight; /** What exactly? Changes to mint DAT, new updatetokens? */ - int BayfrontHeight; - int BayfrontMarinaHeight; - int BayfrontGardensHeight; + int DF2BayfrontHeight; + int DF3BayfrontMarinaHeight; + int DF4BayfrontGardensHeight; /** Third major fork. */ - int ClarkeQuayHeight; + int DF5ClarkeQuayHeight; /** Fourth major fork **/ - int DakotaHeight; - int DakotaCrescentHeight; + int DF6DakotaHeight; + int DF7DakotaCrescentHeight; /** Fifth major fork **/ - int EunosHeight; - int EunosKampungHeight; - int EunosPayaHeight; - int FortCanningHeight; - int FortCanningMuseumHeight; - int FortCanningParkHeight; - int FortCanningHillHeight; - int FortCanningRoadHeight; - int FortCanningCrunchHeight; - int FortCanningSpringHeight; - int FortCanningGreatWorldHeight; - int FortCanningEpilogueHeight; - int GrandCentralHeight; - int GrandCentralEpilogueHeight; - int NextNetworkUpgradeHeight; + int DF8EunosHeight; + int DF9EunosKampungHeight; + int DF10EunosPayaHeight; + int DF11FortCanningHeight; + int DF12FortCanningMuseumHeight; + int DF13FortCanningParkHeight; + int DF14FortCanningHillHeight; + int DF15FortCanningRoadHeight; + int DF16FortCanningCrunchHeight; + int DF17FortCanningSpringHeight; + int DF18FortCanningGreatWorldHeight; + int DF19FortCanningEpilogueHeight; + int DF20GrandCentralHeight; + int DF21GrandCentralEpilogueHeight; + int DF22NextHeight; /** Foundation share after AMK, normalized to COIN = 100% */ CAmount foundationShareDFIP1; diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index bb02c5826b..49d457cb64 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -178,7 +178,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c std::vector dummy; const auto txType = GuessCustomTxType(tx, dummy); - if (NotAllowedToFail(txType, nSpendHeight) || (nSpendHeight >= chainparams.GetConsensus().GrandCentralHeight && txType == CustomTxType::UpdateMasternode)) { + if (NotAllowedToFail(txType, nSpendHeight) || (nSpendHeight >= chainparams.GetConsensus().DF20GrandCentralHeight && txType == CustomTxType::UpdateMasternode)) { CCustomCSView discardCache(mnview, nullptr, nullptr, nullptr); auto res = ApplyCustomTx(discardCache, inputs, tx, chainparams.GetConsensus(), nSpendHeight, 0, &canSpend); if (!res.ok && (res.code & CustomTxErrCodes::Fatal)) { diff --git a/src/masternodes/anchors.cpp b/src/masternodes/anchors.cpp index d600636e74..2c458e9bb9 100644 --- a/src/masternodes/anchors.cpp +++ b/src/masternodes/anchors.cpp @@ -759,14 +759,14 @@ bool ValidateAnchor(const CAnchor &anchor) { // Post-fork anchor, will be added to pending anchors to validate in chain context if (GetAnchorEmbeddedData(teamData, anchorCreationHeight, prefix)) { // Make sure anchor created after fork. - if (anchorCreationHeight >= static_cast(Params().GetConsensus().DakotaHeight)) { + if (anchorCreationHeight >= static_cast(Params().GetConsensus().DF6DakotaHeight)) { return true; } else { LogPrint(BCLog::ANCHORING, "%s: Post fork anchor created before fork height. Anchor %ld fork %d\n", __func__, anchorCreationHeight, - Params().GetConsensus().DakotaHeight); + Params().GetConsensus().DF6DakotaHeight); return false; } } @@ -875,7 +875,7 @@ bool ContextualValidateAnchor(const CAnchorData &anchor, CBlockIndex &anchorBloc } // Recreate deeper anchor depth - if (anchorCreationHeight >= static_cast(Params().GetConsensus().FortCanningHeight)) { + if (anchorCreationHeight >= static_cast(Params().GetConsensus().DF11FortCanningHeight)) { timeDepth += Params().GetConsensus().mn.anchoringAdditionalTimeDepth; while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > anchorCreationBlock->nTime) { --anchorHeight; @@ -1147,7 +1147,7 @@ const PendingOrderType PendingOrder = PendingOrderType([](const CAnchorIndex::AnchorRec &a, const CAnchorIndex::AnchorRec &b) { if (a.btcHeight == b.btcHeight) { if (a.anchor.height == b.anchor.height) { - if (a.anchor.height >= static_cast(Params().GetConsensus().EunosHeight)) { + if (a.anchor.height >= static_cast(Params().GetConsensus().DF8EunosHeight)) { const auto blockHash = panchors->ReadBlockHash(a.btcHeight); auto aHash = Hash(a.txHash.begin(), a.txHash.end(), blockHash.begin(), blockHash.end()); auto bHash = Hash(b.txHash.begin(), b.txHash.end(), blockHash.begin(), blockHash.end()); diff --git a/src/masternodes/errors.h b/src/masternodes/errors.h index 076ab8156a..3a46131b6e 100644 --- a/src/masternodes/errors.h +++ b/src/masternodes/errors.h @@ -307,7 +307,7 @@ class DeFiErrors { } static Res GovVarValidateFortCanningSpring() { - return Res::Err("Cannot be set before FortCanningSpringHeight"); + return Res::Err("Cannot be set before DF17FortCanningSpringHeight"); } static Res GovVarValidateToken(const uint32_t token) { diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index 3de66a8a78..1c548818f3 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -1637,7 +1637,7 @@ UniValue ATTRIBUTES::Export() const { } Res ATTRIBUTES::Validate(const CCustomCSView &view) const { - if (view.GetLastHeight() < Params().GetConsensus().FortCanningHillHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF14FortCanningHillHeight) { return DeFiErrors::GovVarValidateFortCanningHill(); } @@ -1650,7 +1650,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { case AttributeTypes::Token: switch (attrV0->key) { case TokenKeys::LoanPaybackCollateral: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningEpilogueHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF19FortCanningEpilogueHeight) { return DeFiErrors::GovVarValidateFortCanningEpilogue(); } @@ -1663,7 +1663,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case TokenKeys::LoanPayback: case TokenKeys::LoanPaybackFeePCT: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningRoadHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF15FortCanningRoadHeight) { return DeFiErrors::GovVarValidateFortCanningRoad(); } if (!view.GetLoanTokenByID({attrV0->typeId})) { @@ -1675,7 +1675,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case TokenKeys::DexInFeePct: case TokenKeys::DexOutFeePct: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningRoadHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF15FortCanningRoadHeight) { return DeFiErrors::GovVarValidateFortCanningRoad(); } if (!view.GetToken(DCT_ID{attrV0->typeId})) { @@ -1683,7 +1683,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { } break; case TokenKeys::LoanCollateralFactor: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningEpilogueHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF19FortCanningEpilogueHeight) { const auto amount = std::get_if(&value); if (amount) { if (*amount > COIN) { @@ -1693,7 +1693,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { } [[fallthrough]]; case TokenKeys::LoanMintingInterest: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningGreatWorldHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF18FortCanningGreatWorldHeight) { const auto amount = std::get_if(&value); if (amount) { if (*amount < 0) { @@ -1704,7 +1704,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { [[fallthrough]]; case TokenKeys::LoanCollateralEnabled: case TokenKeys::LoanMintingEnabled: { - if (view.GetLastHeight() < Params().GetConsensus().FortCanningCrunchHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF16FortCanningCrunchHeight) { return DeFiErrors::GovVarValidateFortCanningCrunch(); } if (!VerifyToken(view, attrV0->typeId)) { @@ -1718,7 +1718,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; } case TokenKeys::FixedIntervalPriceId: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningCrunchHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF16FortCanningCrunchHeight) { return DeFiErrors::GovVarValidateFortCanningCrunch(); } if (!VerifyToken(view, attrV0->typeId)) { @@ -1726,7 +1726,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { } break; case TokenKeys::DFIP2203Enabled: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningRoadHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF15FortCanningRoadHeight) { return DeFiErrors::GovVarValidateFortCanningRoad(); } if (!view.GetLoanTokenByID({attrV0->typeId})) { @@ -1745,7 +1745,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { case AttributeTypes::Consortium: switch (attrV0->key) { case ConsortiumKeys::MemberValues: { - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) + if (view.GetLastHeight() < Params().GetConsensus().DF20GrandCentralHeight) return Res::Err("Cannot be set before GrandCentral"); if (!view.GetToken(DCT_ID{attrV0->typeId})) @@ -1777,7 +1777,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { } case ConsortiumKeys::MintLimit: case ConsortiumKeys::DailyMintLimit: - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) + if (view.GetLastHeight() < Params().GetConsensus().DF20GrandCentralHeight) return Res::Err("Cannot be set before GrandCentral"); if (!view.GetToken(DCT_ID{attrV0->typeId})) @@ -1789,7 +1789,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case AttributeTypes::Oracles: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningCrunchHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF16FortCanningCrunchHeight) { return DeFiErrors::GovVarValidateFortCanningCrunch(); } if (attrV0->typeId == OracleIDs::Splits) { @@ -1831,7 +1831,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case PoolKeys::TokenAFeeDir: case PoolKeys::TokenBFeeDir: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningSpringHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF17FortCanningSpringHeight) { return DeFiErrors::GovVarValidateFortCanningSpring(); } if (!view.GetPoolPair({attrV0->typeId})) { @@ -1845,25 +1845,25 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { case AttributeTypes::Param: if (attrV0->typeId == ParamIDs::Feature && attrV0->key == DFIPKeys::MintTokens) { - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralEpilogueHeight) { - return Res::Err("Cannot be set before GrandCentralEpilogueHeight"); + if (view.GetLastHeight() < Params().GetConsensus().DF21GrandCentralEpilogueHeight) { + return Res::Err("Cannot be set before DF21GrandCentralEpilogueHeight"); } } else if (attrV0->typeId == ParamIDs::Feature || attrV0->typeId == ParamIDs::Foundation || attrV0->key == DFIPKeys::Members) { - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) { - return Res::Err("Cannot be set before GrandCentralHeight"); + if (view.GetLastHeight() < Params().GetConsensus().DF20GrandCentralHeight) { + return Res::Err("Cannot be set before DF20GrandCentralHeight"); } } else if (attrV0->typeId == ParamIDs::Foundation || attrV0->key == DFIPKeys::Members) { - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) { - return Res::Err("Cannot be set before GrandCentralHeight"); + if (view.GetLastHeight() < Params().GetConsensus().DF20GrandCentralHeight) { + return Res::Err("Cannot be set before DF20GrandCentralHeight"); } } else if (attrV0->typeId == ParamIDs::DFIP2206F || attrV0->key == DFIPKeys::StartBlock || attrV0->typeId == ParamIDs::DFIP2206A) { - if (view.GetLastHeight() < Params().GetConsensus().FortCanningSpringHeight) { - return Res::Err("Cannot be set before FortCanningSpringHeight"); + if (view.GetLastHeight() < Params().GetConsensus().DF17FortCanningSpringHeight) { + return Res::Err("Cannot be set before DF17FortCanningSpringHeight"); } } else if (attrV0->typeId == ParamIDs::DFIP2203) { - if (view.GetLastHeight() < Params().GetConsensus().FortCanningRoadHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF15FortCanningRoadHeight) { return DeFiErrors::GovVarValidateFortCanningRoad(); } } else if (attrV0->typeId != ParamIDs::DFIP2201) { @@ -1876,7 +1876,7 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case AttributeTypes::Locks: - if (view.GetLastHeight() < Params().GetConsensus().FortCanningCrunchHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF16FortCanningCrunchHeight) { return Res::Err("Cannot be set before FortCanningCrunch"); } if (attrV0->typeId != ParamIDs::TokenID) { @@ -1888,19 +1888,19 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { break; case AttributeTypes::Governance: - if (view.GetLastHeight() < Params().GetConsensus().GrandCentralHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF20GrandCentralHeight) { return Res::Err("Cannot be set before GrandCentral"); } break; case AttributeTypes::EVMType: - if (view.GetLastHeight() < Params().GetConsensus().NextNetworkUpgradeHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF22NextHeight) { return Res::Err("Cannot be set before NextNetworkUpgrade"); } break; case AttributeTypes::Transfer: - if (view.GetLastHeight() < Params().GetConsensus().NextNetworkUpgradeHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF22NextHeight) { return Res::Err("Cannot be set before NextNetworkUpgrade"); } if ((attrV0->typeId == TransferIDs::DVMToEVM || attrV0->typeId == TransferIDs::EVMToDVM) && @@ -1917,14 +1917,14 @@ Res ATTRIBUTES::Validate(const CCustomCSView &view) const { case AttributeTypes::Vaults: if (attrV0->typeId == VaultIDs::DUSDVault && attrV0->key == VaultKeys::DUSDVaultEnabled) { - if (view.GetLastHeight() < Params().GetConsensus().NextNetworkUpgradeHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF22NextHeight) { return Res::Err("Cannot be set before NextNetworkUpgrade"); } } break; case AttributeTypes::Rules: - if (view.GetLastHeight() < Params().GetConsensus().NextNetworkUpgradeHeight) { + if (view.GetLastHeight() < Params().GetConsensus().DF22NextHeight) { return Res::Err("Cannot be set before NextNetworkUpgrade"); } break; @@ -2024,7 +2024,7 @@ Res ATTRIBUTES::Apply(CCustomCSView &mnview, const uint32_t height) { return res; } } else if (attrV0->key == TokenKeys::LoanMintingInterest) { - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight) && + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight) && interestTokens.count(attrV0->typeId)) { const auto tokenInterest = std::get_if(&attribute.second); if (!tokenInterest) { @@ -2050,7 +2050,7 @@ Res ATTRIBUTES::Apply(CCustomCSView &mnview, const uint32_t height) { } } } else if (attrV0->key == TokenKeys::LoanCollateralFactor) { - if (height >= static_cast(Params().GetConsensus().FortCanningEpilogueHeight)) { + if (height >= static_cast(Params().GetConsensus().DF19FortCanningEpilogueHeight)) { // Skip on if skip collateral check is passed if (Params().NetworkIDString() == CBaseChainParams::REGTEST && gArgs.GetBoolArg("-regtest-skip-loan-collateral-validation", false)) { diff --git a/src/masternodes/govvariables/loan_daily_reward.cpp b/src/masternodes/govvariables/loan_daily_reward.cpp index a1553d736e..78b45290d4 100644 --- a/src/masternodes/govvariables/loan_daily_reward.cpp +++ b/src/masternodes/govvariables/loan_daily_reward.cpp @@ -22,7 +22,7 @@ UniValue LP_DAILY_LOAN_TOKEN_REWARD::Export() const { } Res LP_DAILY_LOAN_TOKEN_REWARD::Validate(const CCustomCSView &view) const { - Require(view.GetLastHeight() >= Params().GetConsensus().FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); + Require(view.GetLastHeight() >= Params().GetConsensus().DF11FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); return Res::Err("Cannot be set manually."); } diff --git a/src/masternodes/govvariables/loan_liquidation_penalty.cpp b/src/masternodes/govvariables/loan_liquidation_penalty.cpp index a5f7cfc5f3..79e30d7d01 100644 --- a/src/masternodes/govvariables/loan_liquidation_penalty.cpp +++ b/src/masternodes/govvariables/loan_liquidation_penalty.cpp @@ -22,7 +22,7 @@ UniValue LOAN_LIQUIDATION_PENALTY::Export() const { } Res LOAN_LIQUIDATION_PENALTY::Validate(const CCustomCSView &view) const { - Require(view.GetLastHeight() >= Params().GetConsensus().FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); + Require(view.GetLastHeight() >= Params().GetConsensus().DF11FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); Require(penalty >= COIN / 100, []{ return "Penalty cannot be less than 0.01 DFI"; }); return Res::Ok(); diff --git a/src/masternodes/govvariables/loan_splits.cpp b/src/masternodes/govvariables/loan_splits.cpp index 6691b4d86b..b3a1391159 100644 --- a/src/masternodes/govvariables/loan_splits.cpp +++ b/src/masternodes/govvariables/loan_splits.cpp @@ -32,7 +32,7 @@ UniValue LP_LOAN_TOKEN_SPLITS::Export() const { } Res LP_LOAN_TOKEN_SPLITS::Validate(const CCustomCSView &mnview) const { - Require(mnview.GetLastHeight() >= Params().GetConsensus().FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); + Require(mnview.GetLastHeight() >= Params().GetConsensus().DF11FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); CAmount total{0}; for (const auto &kv : splits) { diff --git a/src/masternodes/govvariables/lp_daily_dfi_reward.cpp b/src/masternodes/govvariables/lp_daily_dfi_reward.cpp index 9f4e8d8f5d..7714e4ac19 100644 --- a/src/masternodes/govvariables/lp_daily_dfi_reward.cpp +++ b/src/masternodes/govvariables/lp_daily_dfi_reward.cpp @@ -22,7 +22,7 @@ UniValue LP_DAILY_DFI_REWARD::Export() const { } Res LP_DAILY_DFI_REWARD::Validate(const CCustomCSView &view) const { - Require(view.GetLastHeight() < Params().GetConsensus().EunosHeight, []{ return "Cannot be set manually after Eunos hard fork"; }); + Require(view.GetLastHeight() < Params().GetConsensus().DF8EunosHeight, []{ return "Cannot be set manually after Eunos hard fork"; }); // nothing to do return Res::Ok(); } diff --git a/src/masternodes/govvariables/oracle_block_interval.cpp b/src/masternodes/govvariables/oracle_block_interval.cpp index ed4beba4ad..2f1c7f721a 100644 --- a/src/masternodes/govvariables/oracle_block_interval.cpp +++ b/src/masternodes/govvariables/oracle_block_interval.cpp @@ -24,7 +24,7 @@ UniValue ORACLE_BLOCK_INTERVAL::Export() const { } Res ORACLE_BLOCK_INTERVAL::Validate(const CCustomCSView &view) const { - Require(view.GetLastHeight() >= Params().GetConsensus().FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); + Require(view.GetLastHeight() >= Params().GetConsensus().DF11FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); Require(blockInterval > 0, []{ return "Block interval cannot be less than 1"; }); return Res::Ok(); diff --git a/src/masternodes/govvariables/oracle_deviation.cpp b/src/masternodes/govvariables/oracle_deviation.cpp index 3156f059a7..36270b0cd5 100644 --- a/src/masternodes/govvariables/oracle_deviation.cpp +++ b/src/masternodes/govvariables/oracle_deviation.cpp @@ -22,7 +22,7 @@ UniValue ORACLE_DEVIATION::Export() const { } Res ORACLE_DEVIATION::Validate(const CCustomCSView &view) const { - Require(view.GetLastHeight() >= Params().GetConsensus().FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); + Require(view.GetLastHeight() >= Params().GetConsensus().DF11FortCanningHeight, []{ return "Cannot be set before FortCanning"; }); Require(deviation >= COIN / 100, []{ return "Deviation cannot be less than 1 percent"; }); return Res::Ok(); diff --git a/src/masternodes/historywriter.cpp b/src/masternodes/historywriter.cpp index 79be51ace5..876a64d236 100644 --- a/src/masternodes/historywriter.cpp +++ b/src/masternodes/historywriter.cpp @@ -116,7 +116,7 @@ void CHistoryWriters::EraseHistory(uint32_t height, std::vectorEraseAccountHistoryHeight(height); } - if (height >= static_cast(Params().GetConsensus().FortCanningHeight)) { + if (height >= static_cast(Params().GetConsensus().DF11FortCanningHeight)) { // erase auction fee history if (historyView) { historyView->EraseAuctionHistoryHeight(height); @@ -135,13 +135,13 @@ void CHistoryWriters::EraseHistory(uint32_t height, std::vectorEraseAccountHistory(entries); } - if (height == static_cast(Params().GetConsensus().EunosHeight)) { + if (height == static_cast(Params().GetConsensus().DF8EunosHeight)) { // Make sure to initialize lastTxOut, otherwise it never finds the block and // ends up looping through uninitialized garbage value. uint32_t firstTxOut{}, lastTxOut{}; auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const & key, AccountHistoryValue const &) -> bool { - if (key.owner != Params().GetConsensus().burnAddress || key.blockHeight != static_cast(Params().GetConsensus().EunosHeight)) { + if (key.owner != Params().GetConsensus().burnAddress || key.blockHeight != static_cast(Params().GetConsensus().DF8EunosHeight)) { return false; } @@ -153,13 +153,13 @@ void CHistoryWriters::EraseHistory(uint32_t height, std::vector(Params().GetConsensus().EunosHeight), std::numeric_limits::max()}); + AccountHistoryKey startKey({Params().GetConsensus().burnAddress, static_cast(Params().GetConsensus().DF8EunosHeight), std::numeric_limits::max()}); burnView->ForEachAccountHistory(shouldContinueToNextAccountHistory, Params().GetConsensus().burnAddress, - Params().GetConsensus().EunosHeight); + Params().GetConsensus().DF8EunosHeight); for (auto i = firstTxOut; i <= lastTxOut; ++i) { - burnView->EraseAccountHistory({Params().GetConsensus().burnAddress, static_cast(Params().GetConsensus().EunosHeight), i}); + burnView->EraseAccountHistory({Params().GetConsensus().burnAddress, static_cast(Params().GetConsensus().DF8EunosHeight), i}); } } } diff --git a/src/masternodes/loan.cpp b/src/masternodes/loan.cpp index 431a78f9e6..5802e790d0 100644 --- a/src/masternodes/loan.cpp +++ b/src/masternodes/loan.cpp @@ -168,11 +168,11 @@ void CLoanView::EraseDelayedDestroyScheme(const std::string &loanSchemeID) { std::optional CLoanView::GetInterestRate(const CVaultId &vaultId, const DCT_ID id, const uint32_t height) { - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { return ReadBy(std::make_pair(vaultId, id)); } - if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { if (const auto rate = ReadBy(std::make_pair(vaultId, id))) { return ConvertInterestRateToV3(*rate); } @@ -208,7 +208,7 @@ CInterestAmount InterestPerBlockCalculationV3(CAmount amount, CAmount tokenInter } CAmount CeilInterest(const base_uint<128> &value, uint32_t height) { - if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { CAmount amount = (value / base_uint<128>(HIGH_PRECISION_SCALER)).GetLow64(); amount += CAmount(value != base_uint<128>(amount) * HIGH_PRECISION_SCALER); return amount; @@ -222,7 +222,7 @@ CAmount FloorInterest(const base_uint<128> &value) { static base_uint<128> ToHigherPrecision(CAmount amount, uint32_t height) { base_uint<128> amountHP = amount; - if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) + if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) amountHP *= HIGH_PRECISION_SCALER; return amountHP; @@ -270,9 +270,9 @@ CAmount TotalInterest(const CInterestRateV3 &rate, const uint32_t height) { void CLoanView::WriteInterestRate(const std::pair &pair, const CInterestRateV3 &rate, uint32_t height) { - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { WriteBy(pair, rate); - } else if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { WriteBy(pair, ConvertInterestRateToV2(rate)); } else { WriteBy(pair, ConvertInterestRateToV1(rate)); @@ -300,7 +300,7 @@ Res CLoanView::IncreaseInterest(const uint32_t height, rate.interestToHeight = TotalInterestCalculation(rate, height); rate.height = height; - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { CBalances amounts; ReadBy(vaultId, amounts); @@ -308,12 +308,12 @@ Res CLoanView::IncreaseInterest(const uint32_t height, // in time. rate.interestPerBlock = InterestPerBlockCalculationV3(amounts.balances[id], tokenInterest, scheme->rate); - } else if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { CBalances amounts; ReadBy(vaultId, amounts); rate.interestPerBlock = {false, InterestPerBlockCalculationV2(amounts.balances[id], token->interest, scheme->rate)}; - } else if (height >= static_cast(Params().GetConsensus().FortCanningMuseumHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF12FortCanningMuseumHeight)) { CAmount interestPerBlock = rate.interestPerBlock.amount.GetLow64(); interestPerBlock += std::ceil(InterestPerBlockCalculationV1(loanIncreased, token->interest, scheme->rate)); @@ -357,16 +357,16 @@ Res CLoanView::DecreaseInterest(const uint32_t height, rate.height = height; - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { CBalances amounts; ReadBy(vaultId, amounts); rate.interestPerBlock = InterestPerBlockCalculationV3(amounts.balances[id], token->interest, scheme->rate); - } else if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { CBalances amounts; ReadBy(vaultId, amounts); rate.interestPerBlock = {false, InterestPerBlockCalculationV2(amounts.balances[id], token->interest, scheme->rate)}; - } else if (height >= static_cast(Params().GetConsensus().FortCanningMuseumHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF12FortCanningMuseumHeight)) { CAmount interestPerBlock = rate.interestPerBlock.amount.GetLow64(); CAmount newInterestPerBlock = std::ceil(InterestPerBlockCalculationV1(loanDecreased, token->interest, scheme->rate)); @@ -445,9 +445,9 @@ void EraseInterest(CLoanView &view, const CVaultId &vaultId) { } Res CLoanView::EraseInterest(const CVaultId &vaultId, uint32_t height) { - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { ::EraseInterest(*this, vaultId); - } else if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { ::EraseInterest(*this, vaultId); } else { ::EraseInterest(*this, vaultId); @@ -457,9 +457,9 @@ Res CLoanView::EraseInterest(const CVaultId &vaultId, uint32_t height) { } void CLoanView::EraseInterest(const CVaultId &vaultId, DCT_ID id, uint32_t height) { - if (height >= static_cast(Params().GetConsensus().FortCanningGreatWorldHeight)) { + if (height >= static_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight)) { EraseBy(std::make_pair(vaultId, id)); - } else if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) { + } else if (height >= static_cast(Params().GetConsensus().DF14FortCanningHillHeight)) { EraseBy(std::make_pair(vaultId, id)); } } diff --git a/src/masternodes/masternodes.cpp b/src/masternodes/masternodes.cpp index 3dfe73906c..25879c89d4 100644 --- a/src/masternodes/masternodes.cpp +++ b/src/masternodes/masternodes.cpp @@ -32,9 +32,9 @@ std::unique_ptr pcustomcsDB; int GetMnActivationDelay(int height) { // Restore previous activation delay on testnet after FC - if (height < Params().GetConsensus().EunosHeight || + if (height < Params().GetConsensus().DF8EunosHeight || (IsTestNetwork() && - height >= Params().GetConsensus().FortCanningHeight)) { + height >= Params().GetConsensus().DF11FortCanningHeight)) { return Params().GetConsensus().mn.activationDelay; } @@ -43,9 +43,9 @@ int GetMnActivationDelay(int height) { int GetMnResignDelay(int height) { // Restore previous activation delay on testnet after FC - if (height < Params().GetConsensus().EunosHeight || + if (height < Params().GetConsensus().DF8EunosHeight || (IsTestNetwork() && - height >= Params().GetConsensus().FortCanningHeight)) { + height >= Params().GetConsensus().DF11FortCanningHeight)) { return Params().GetConsensus().mn.resignDelay; } @@ -57,7 +57,7 @@ int GetMnResignDelay(int height) { CAmount GetMnCollateralAmount(int height) { auto &consensus = Params().GetConsensus(); - if (height < consensus.DakotaHeight) { + if (height < consensus.DF6DakotaHeight) { return consensus.mn.collateralAmount; } else { return consensus.mn.collateralAmountDakota; @@ -119,7 +119,7 @@ CMasternode::CMasternode() collateralTx() {} CMasternode::State CMasternode::GetState(int height, const CMasternodesView &mnview) const { - int EunosPayaHeight = Params().GetConsensus().EunosPayaHeight; + int DF10EunosPayaHeight = Params().GetConsensus().DF10EunosPayaHeight; if (height < creationHeight) { return State::UNKNOWN; @@ -143,7 +143,7 @@ CMasternode::State CMasternode::GetState(int height, const CMasternodesView &mnv if (resignHeight == -1 || height < resignHeight) { // enabled or pre-enabled // Special case for genesis block int activationDelay = - height < EunosPayaHeight ? GetMnActivationDelay(height) : GetMnActivationDelay(creationHeight); + height < DF10EunosPayaHeight ? GetMnActivationDelay(height) : GetMnActivationDelay(creationHeight); if (creationHeight == 0 || height >= creationHeight + activationDelay) { return State::ENABLED; } @@ -151,7 +151,7 @@ CMasternode::State CMasternode::GetState(int height, const CMasternodesView &mnv } if (resignHeight != -1) { // pre-resigned or resigned - int resignDelay = height < EunosPayaHeight ? GetMnResignDelay(height) : GetMnResignDelay(resignHeight); + int resignDelay = height < DF10EunosPayaHeight ? GetMnResignDelay(height) : GetMnResignDelay(resignHeight); if (height < resignHeight + resignDelay) { return State::PRE_RESIGNED; } @@ -162,7 +162,7 @@ CMasternode::State CMasternode::GetState(int height, const CMasternodesView &mnv bool CMasternode::IsActive(int height, const CMasternodesView &mnview) const { State state = GetState(height, mnview); - if (height >= Params().GetConsensus().EunosPayaHeight) { + if (height >= Params().GetConsensus().DF10EunosPayaHeight) { return state == ENABLED; } return state == ENABLED || state == PRE_RESIGNED; @@ -316,7 +316,7 @@ Res CMasternodesView::CreateMasternode(const uint256 &nodeId, const CMasternode Res CMasternodesView::ResignMasternode(CMasternode &node, const uint256 &nodeId, const uint256 &txid, int height) { auto state = node.GetState(height, *this); - if (height >= Params().GetConsensus().EunosPayaHeight) { + if (height >= Params().GetConsensus().DF10EunosPayaHeight) { Require(state == CMasternode::ENABLED, [=]{ return strprintf("node %s state is not 'ENABLED'", nodeId.ToString()); }); } else if ((state != CMasternode::PRE_ENABLED && state != CMasternode::ENABLED)) { return Res::Err("node %s state is not 'PRE_ENABLED' or 'ENABLED'", nodeId.ToString()); @@ -494,7 +494,7 @@ std::vector CMasternodesView::GetSubNodesBlockTime(const CKeyID &minter for (uint8_t i{0}; i < SUBNODE_COUNT; ++i) { ForEachSubNode( [&](const SubNodeBlockTimeKey &key, int64_t blockTime) { - if (height >= static_cast(Params().GetConsensus().FortCanningHeight)) { + if (height >= static_cast(Params().GetConsensus().DF11FortCanningHeight)) { if (key.masternodeID == nodeId && key.subnode == i) { times[i] = blockTime; } @@ -566,7 +566,7 @@ std::vector CMasternodesView::GetBlockTimes(const CKeyID &keyID, // Get last block time for non-subnode staking std::optional stakerBlockTime = GetMasternodeLastBlockTime(keyID, blockHeight); - // Get times for sub nodes, defaults to {0, 0, 0, 0} for MNs created before EunosPayaHeight + // Get times for sub nodes, defaults to {0, 0, 0, 0} for MNs created before DF10EunosPayaHeight std::vector subNodesBlockTime = GetSubNodesBlockTime(keyID, blockHeight); // Set first entry to previous accrued multiplier. @@ -574,10 +574,10 @@ std::vector CMasternodesView::GetBlockTimes(const CKeyID &keyID, subNodesBlockTime[0] = *stakerBlockTime; } - if (auto block = ::ChainActive()[Params().GetConsensus().EunosPayaHeight]) { - if (creationHeight < Params().GetConsensus().DakotaCrescentHeight && !stakerBlockTime && + if (auto block = ::ChainActive()[Params().GetConsensus().DF10EunosPayaHeight]) { + if (creationHeight < Params().GetConsensus().DF7DakotaCrescentHeight && !stakerBlockTime && !subNodesBlockTime[0]) { - if (auto dakotaBlock = ::ChainActive()[Params().GetConsensus().DakotaCrescentHeight]) { + if (auto dakotaBlock = ::ChainActive()[Params().GetConsensus().DF7DakotaCrescentHeight]) { subNodesBlockTime[0] = dakotaBlock->GetBlockTime(); } } @@ -641,11 +641,11 @@ CTeamView::CTeam CTeamView::GetCurrentTeam() const { void CTeamView::SetAnchorTeams(const CTeam &authTeam, const CTeam &confirmTeam, const int height) { // Called after fork height - if (height < Params().GetConsensus().DakotaHeight) { + if (height < Params().GetConsensus().DF6DakotaHeight) { LogPrint(BCLog::ANCHORING, "%s: Called below fork. Fork: %d Arg height: %d\n", __func__, - Params().GetConsensus().DakotaHeight, + Params().GetConsensus().DF6DakotaHeight, height); return; } diff --git a/src/masternodes/mn_checks.cpp b/src/masternodes/mn_checks.cpp index b3849653aa..915cd6bca4 100644 --- a/src/masternodes/mn_checks.cpp +++ b/src/masternodes/mn_checks.cpp @@ -336,17 +336,17 @@ class CCustomMetadataParseVisitor { Res IsHardforkEnabled(const uint32_t startHeight) const { const std::unordered_map hardforks = { - { consensus.AMKHeight, "called before AMK height" }, - { consensus.BayfrontHeight, "called before Bayfront height" }, - { consensus.BayfrontGardensHeight, "called before Bayfront Gardens height" }, - { consensus.EunosHeight, "called before Eunos height" }, - { consensus.EunosPayaHeight, "called before EunosPaya height" }, - { consensus.FortCanningHeight, "called before FortCanning height" }, - { consensus.FortCanningHillHeight, "called before FortCanningHill height" }, - { consensus.FortCanningRoadHeight, "called before FortCanningRoad height" }, - { consensus.FortCanningEpilogueHeight, "called before FortCanningEpilogue height" }, - { consensus.GrandCentralHeight, "called before GrandCentral height" }, - { consensus.NextNetworkUpgradeHeight, "called before NextNetworkUpgrade height" }, + { consensus.DF1AMKHeight, "called before AMK height" }, + { consensus.DF2BayfrontHeight, "called before Bayfront height" }, + { consensus.DF4BayfrontGardensHeight, "called before Bayfront Gardens height" }, + { consensus.DF8EunosHeight, "called before Eunos height" }, + { consensus.DF10EunosPayaHeight, "called before EunosPaya height" }, + { consensus.DF11FortCanningHeight, "called before FortCanning height" }, + { consensus.DF14FortCanningHillHeight, "called before FortCanningHill height" }, + { consensus.DF15FortCanningRoadHeight, "called before FortCanningRoad height" }, + { consensus.DF19FortCanningEpilogueHeight, "called before FortCanningEpilogue height" }, + { consensus.DF20GrandCentralHeight, "called before GrandCentral height" }, + { consensus.DF22NextHeight, "called before NextNetworkUpgrade height" }, }; if (startHeight && height < startHeight) { auto it = hardforks.find(startHeight); @@ -374,7 +374,7 @@ class CCustomMetadataParseVisitor { CAccountToUtxosMessage, CAccountToAccountMessage, CMintTokensMessage>()) - return IsHardforkEnabled(consensus.AMKHeight); + return IsHardforkEnabled(consensus.DF1AMKHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.BayfrontHeight); + return IsHardforkEnabled(consensus.DF2BayfrontHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.EunosHeight); + return IsHardforkEnabled(consensus.DF8EunosHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.FortCanningHeight); + return IsHardforkEnabled(consensus.DF11FortCanningHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.BayfrontGardensHeight); + return IsHardforkEnabled(consensus.DF4BayfrontGardensHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.FortCanningHillHeight); + return IsHardforkEnabled(consensus.DF14FortCanningHillHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.FortCanningRoadHeight); + return IsHardforkEnabled(consensus.DF15FortCanningRoadHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.FortCanningEpilogueHeight); + return IsHardforkEnabled(consensus.DF19FortCanningEpilogueHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.GrandCentralHeight); + return IsHardforkEnabled(consensus.DF20GrandCentralHeight); else if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.NextNetworkUpgradeHeight); + return IsHardforkEnabled(consensus.DF22NextHeight); else if constexpr (IsOneOf()) @@ -450,7 +450,7 @@ class CCustomMetadataParseVisitor { template Res DisabledAfter() const { if constexpr (IsOneOf()) - return IsHardforkEnabled(consensus.BayfrontHeight) ? Res::Err("called after Bayfront height") : Res::Ok(); + return IsHardforkEnabled(consensus.DF2BayfrontHeight) ? Res::Err("called after Bayfront height") : Res::Ok(); return Res::Ok(); } @@ -537,9 +537,9 @@ Res CCustomTxVisitor::CheckTokenCreationTx() const { } Res CCustomTxVisitor::CheckCustomTx() const { - if (static_cast(height) < consensus.EunosPayaHeight) + if (static_cast(height) < consensus.DF10EunosPayaHeight) Require(tx.vout.size() == 2, "malformed tx vouts ((wrong number of vouts)"); - if (static_cast(height) >= consensus.EunosPayaHeight) + if (static_cast(height) >= consensus.DF10EunosPayaHeight) Require(tx.vout[0].nValue == 0, "malformed tx vouts, first vout must be OP_RETURN vout with value 0"); return Res::Ok(); } @@ -616,7 +616,7 @@ ResVal CCustomTxVisitor::MintableToken(DCT_ID id, const Coin &auth = coins.AccessCoin(COutPoint(token.creationTx, 1)); // always n=1 output // pre-bayfront logic: - if (static_cast(height) < consensus.BayfrontHeight) { + if (static_cast(height) < consensus.DF2BayfrontHeight) { if (id < CTokensView::DCT_ID_START) { return Res::Err("token %s is a 'stable coin', can't mint stable coin!", id.ToString()); } @@ -650,7 +650,7 @@ ResVal CCustomTxVisitor::MintableToken(DCT_ID id, if (token.IsDAT()) { // Is a DAT, check founders auth - if (height < static_cast(consensus.GrandCentralHeight) && !HasFoundationAuth()) { + if (height < static_cast(consensus.DF20GrandCentralHeight) && !HasFoundationAuth()) { return Res::Err("token is DAT and tx not from foundation member"); } } else { @@ -748,7 +748,7 @@ Res CCustomTxVisitor::NormalizeTokenCurrencyPair(std::set &t } bool CCustomTxVisitor::IsTokensMigratedToGovVar() const { - return static_cast(height) > consensus.FortCanningCrunchHeight + 1; + return static_cast(height) > consensus.DF16FortCanningCrunchHeight + 1; } Res CCustomTxVisitor::IsOnChainGovernanceEnabled() const { @@ -790,10 +790,10 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Res operator()(const CCreateMasterNodeMessage &obj) const { Require(CheckMasternodeCreationTx()); - if (height >= static_cast(consensus.EunosHeight)) + if (height >= static_cast(consensus.DF8EunosHeight)) Require(HasAuth(tx.vout[1].scriptPubKey), "masternode creation needs owner auth"); - if (height >= static_cast(consensus.EunosPayaHeight)) { + if (height >= static_cast(consensus.DF10EunosPayaHeight)) { switch (obj.timelock) { case CMasternode::ZEROYEAR: case CMasternode::FIVEYEAR: @@ -821,7 +821,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { node.operatorAuthAddress = obj.operatorAuthAddress; // Set masternode version2 after FC for new serialisation - if (height >= static_cast(consensus.FortCanningHeight)) + if (height >= static_cast(consensus.DF11FortCanningHeight)) node.version = CMasternode::VERSION0; bool duplicate{}; @@ -849,11 +849,11 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(mnview.CreateMasternode(tx.GetHash(), node, obj.timelock)); // Build coinage from the point of masternode creation - if (height >= static_cast(consensus.EunosPayaHeight)) + if (height >= static_cast(consensus.DF10EunosPayaHeight)) for (uint8_t i{0}; i < SUBNODE_COUNT; ++i) mnview.SetSubNodesBlockTime(node.operatorAuthAddress, static_cast(height), i, time); - else if (height >= static_cast(consensus.DakotaCrescentHeight)) + else if (height >= static_cast(consensus.DF7DakotaCrescentHeight)) mnview.SetMasternodeLastBlockTime(node.operatorAuthAddress, static_cast(height), time); return Res::Ok(); @@ -989,7 +989,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { } rewardType = true; - if (height < static_cast(consensus.NextNetworkUpgradeHeight)) { + if (height < static_cast(consensus.DF22NextHeight)) { if (addressType != PKHashType && addressType != WitV0KeyHashType) { return Res::Err("Reward address must be P2PKH or P2WPKH type"); } @@ -1058,14 +1058,14 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { return Res::Err("tx not from foundation member"); } - if (static_cast(height) >= consensus.BayfrontHeight) { // formal compatibility if someone cheat and create + if (static_cast(height) >= consensus.DF2BayfrontHeight) { // formal compatibility if someone cheat and create // LPS token on the pre-bayfront node if (token.IsPoolShare()) { return Res::Err("Can't manually create 'Liquidity Pool Share' token; use poolpair creation"); } } - auto tokenId = mnview.CreateToken(token, static_cast(height) < consensus.BayfrontHeight); + auto tokenId = mnview.CreateToken(token, static_cast(height) < consensus.DF2BayfrontHeight); if (tokenId && token.IsDAT() && IsEVMEnabled(height, mnview, consensus)) { CrossBoundaryResult result; @@ -1133,7 +1133,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(HasCollateralAuth(token.creationTx)); // Check for isDAT change in non-foundation token after set height - if (static_cast(height) >= consensus.BayfrontMarinaHeight) + if (static_cast(height) >= consensus.DF3BayfrontMarinaHeight) // check foundation auth Require(obj.token.IsDAT() == token.IsDAT() || HasFoundationAuth(), "can't set isDAT to true, tx not from foundation member"); @@ -1142,7 +1142,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { updatedToken.creationTx = token.creationTx; updatedToken.destructionTx = token.destructionTx; updatedToken.destructionHeight = token.destructionHeight; - if (static_cast(height) >= consensus.FortCanningHeight) + if (static_cast(height) >= consensus.DF11FortCanningHeight) updatedToken.symbol = trim_ws(updatedToken.symbol).substr(0, CToken::MAX_TOKEN_SYMBOL_LENGTH); return mnview.UpdateToken(updatedToken); @@ -1150,8 +1150,8 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Res operator()(const CMintTokensMessage &obj) const { const auto isRegTestSimulateMainnet = gArgs.GetArg("-regtest-minttoken-simulate-mainnet", false); - const auto fortCanningCrunchHeight = static_cast(consensus.FortCanningCrunchHeight); - const auto grandCentralHeight = static_cast(consensus.GrandCentralHeight); + const auto fortCanningCrunchHeight = static_cast(consensus.DF16FortCanningCrunchHeight); + const auto grandCentralHeight = static_cast(consensus.DF20GrandCentralHeight); CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::MintTokens}; const auto attributes = mnview.GetAttributes(); @@ -1395,7 +1395,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(HasFoundationAuth()); Require(obj.commission >= 0 && obj.commission <= COIN, "wrong commission"); - if (height >= static_cast(consensus.FortCanningCrunchHeight)) { + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight)) { Require(obj.pairSymbol.find('/') == std::string::npos, "token symbol should not contain '/'"); } @@ -1413,7 +1413,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto tokenB = mnview.GetToken(poolPair.idTokenB); Require(tokenB, "token %s does not exist!", poolPair.idTokenB.ToString()); - const auto symbolLength = height >= static_cast(consensus.FortCanningHeight) + const auto symbolLength = height >= static_cast(consensus.DF11FortCanningHeight) ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH; if (pairSymbol.empty()) { @@ -1503,7 +1503,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { if (amountA.first != pool.idTokenA) std::swap(amountA, amountB); - bool slippageProtection = static_cast(height) >= consensus.BayfrontMarinaHeight; + bool slippageProtection = static_cast(height) >= consensus.DF3BayfrontMarinaHeight; Require(pool.AddLiquidity( amountA.second, amountB.second, @@ -1626,7 +1626,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(token->symbol == "BTC" && token->name == "Bitcoin" && token->IsDAT(), "Only Bitcoin can be swapped in " + obj.name); - if (height >= static_cast(consensus.NextNetworkUpgradeHeight)) { + if (height >= static_cast(consensus.DF22NextHeight)) { mnview.CalculateOwnerRewards(script, height); } @@ -1738,7 +1738,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { CDataStructureV0 liveKey{AttributeTypes::Live, ParamIDs::Economy, economyKey}; auto balances = attributes->GetValue(liveKey, CBalances{}); - if (height >= static_cast(consensus.FortCanningCrunchHeight)) { + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight)) { CalculateOwnerRewards(obj.owner); } @@ -1978,7 +1978,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { } // Validate GovVariables before storing - if (height >= static_cast(consensus.FortCanningCrunchHeight) && + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight) && obj.govVar->GetName() == "ATTRIBUTES") { auto govVar = mnview.GetAttributes(); if (!govVar) { @@ -1998,7 +1998,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { } // After GW exclude TokenSplit if split will have already been performed by startHeight - if (height >= static_cast(consensus.GrandCentralHeight)) { + if (height >= static_cast(consensus.DF20GrandCentralHeight)) { if (const auto attrVar = std::dynamic_pointer_cast(govVar); attrVar) { const auto attrMap = attrVar->GetAttributesMap(); std::vector keysToErase; @@ -2066,7 +2066,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { if (!HasAuth(oracle.val->oracleAddress)) { return Res::Err("tx must have at least one input from account owner"); } - if (height >= uint32_t(consensus.FortCanningHeight)) { + if (height >= uint32_t(consensus.DF11FortCanningHeight)) { for (const auto &tokenPrice : obj.tokenPrices) { for (const auto &price : tokenPrice.second) { if (price.second <= 0) { @@ -2129,7 +2129,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto order = mnview.GetICXOrderByCreationTx(makeoffer.orderTx); Require(order, "order with creation tx " + makeoffer.orderTx.GetHex() + " does not exists!"); - auto expiry = static_cast(height) < consensus.EunosPayaHeight ? CICXMakeOffer::DEFAULT_EXPIRY + auto expiry = static_cast(height) < consensus.DF10EunosPayaHeight ? CICXMakeOffer::DEFAULT_EXPIRY : CICXMakeOffer::EUNOSPAYA_DEFAULT_EXPIRY; Require(makeoffer.expiry >= expiry, "offer expiry must be greater than %d!", expiry - 1); @@ -2186,7 +2186,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { submitdfchtlc.offerTx.GetHex()); uint32_t timeout; - if (static_cast(height) < consensus.EunosPayaHeight) + if (static_cast(height) < consensus.DF10EunosPayaHeight) timeout = CICXSubmitDFCHTLC::MINIMUM_TIMEOUT; else timeout = CICXSubmitDFCHTLC::EUNOSPAYA_MINIMUM_TIMEOUT; @@ -2202,7 +2202,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { CAmount takerFee = offer->takerFee; // EunosPaya: calculating adjusted takerFee only if amount in htlc different than in offer - if (static_cast(height) >= consensus.EunosPayaHeight) { + if (static_cast(height) >= consensus.DF10EunosPayaHeight) { if (calcAmount < offer->amount) { auto BTCAmount = MultiplyAmounts(submitdfchtlc.amount, order->orderPrice); takerFee = (arith_uint256(BTCAmount) * offer->takerFee / offer->amount).GetLow64(); @@ -2251,7 +2251,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { exthtlc->hash.GetHex()); uint32_t timeout, btcBlocksInDfi; - if (static_cast(height) < consensus.EunosPayaHeight) { + if (static_cast(height) < consensus.DF10EunosPayaHeight) { timeout = CICXSubmitDFCHTLC::MINIMUM_2ND_TIMEOUT; btcBlocksInDfi = CICXSubmitEXTHTLC::BTC_BLOCKS_IN_DFI_BLOCKS; } else { @@ -2309,7 +2309,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { "Invalid hash, external htlc hash is different than dfc htlc hash"); uint32_t timeout, btcBlocksInDfi; - if (static_cast(height) < consensus.EunosPayaHeight) { + if (static_cast(height) < consensus.DF10EunosPayaHeight) { timeout = CICXSubmitEXTHTLC::MINIMUM_2ND_TIMEOUT; btcBlocksInDfi = CICXSubmitEXTHTLC::BTC_BLOCKS_IN_DFI_BLOCKS; } else { @@ -2328,7 +2328,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { submitexthtlc.offerTx.GetHex()); uint32_t timeout; - if (static_cast(height) < consensus.EunosPayaHeight) + if (static_cast(height) < consensus.DF10EunosPayaHeight) timeout = CICXSubmitEXTHTLC::MINIMUM_TIMEOUT; else timeout = CICXSubmitEXTHTLC::EUNOSPAYA_MINIMUM_TIMEOUT; @@ -2342,7 +2342,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { CAmount takerFee = offer->takerFee; // EunosPaya: calculating adjusted takerFee only if amount in htlc different than in offer - if (static_cast(height) >= consensus.EunosPayaHeight) { + if (static_cast(height) >= consensus.DF10EunosPayaHeight) { if (calcAmount < offer->amount) { auto BTCAmount = DivideAmounts(offer->amount, order->orderPrice); takerFee = (arith_uint256(submitexthtlc.amount) * offer->takerFee / BTCAmount).GetLow64(); @@ -2406,7 +2406,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(order, "order with creation tx %s does not exists!", offer->orderTx.GetHex()); auto exthtlc = mnview.HasICXSubmitEXTHTLCOpen(dfchtlc->offerTx); - if (static_cast(height) < consensus.EunosPayaHeight) + if (static_cast(height) < consensus.DF10EunosPayaHeight) Require(exthtlc, "cannot claim, external htlc for this offer does not exists or expired!"); // claim DFC HTLC to receiveAddress @@ -2432,7 +2432,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto ICXBugPath = [&](uint32_t height) { if ((IsTestNetwork() && height >= 1250000) || IsRegtestNetwork() || - (IsMainNetwork() && height >= static_cast(consensus.NextNetworkUpgradeHeight))) + (IsMainNetwork() && height >= static_cast(consensus.DF22NextHeight))) return false; return true; }; @@ -2465,7 +2465,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(mnview.ICXCloseDFCHTLC(*dfchtlc, CICXSubmitDFCHTLC::STATUS_CLAIMED)); - if (static_cast(height) >= consensus.EunosPayaHeight) { + if (static_cast(height) >= consensus.DF10EunosPayaHeight) { if (exthtlc) return mnview.ICXCloseEXTHTLC(*exthtlc, CICXSubmitEXTHTLC::STATUS_CLOSED); else @@ -2534,7 +2534,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { offer->closeTx = closeoffer.creationTx; offer->closeHeight = closeoffer.creationHeight; - bool isPreEunosPaya = static_cast(height) < consensus.EunosPayaHeight; + bool isPreEunosPaya = static_cast(height) < consensus.DF10EunosPayaHeight; if (order->orderType == CICXOrder::TYPE_INTERNAL && !mnview.ExistedICXSubmitDFCHTLC(offer->creationTx, isPreEunosPaya)) { @@ -2562,7 +2562,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(HasFoundationAuth(), "tx not from foundation member!"); - if (height >= static_cast(consensus.FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { const auto &tokenId = obj.idToken.v; auto attributes = mnview.GetAttributes(); @@ -2629,7 +2629,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(HasFoundationAuth(), "tx not from foundation member!"); - if (height < static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height < static_cast(consensus.DF18FortCanningGreatWorldHeight)) { Require(obj.interest >= 0, "interest rate cannot be less than 0!"); } @@ -2646,7 +2646,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto tokenId = mnview.CreateToken(token); Require(tokenId); - if (height >= static_cast(consensus.FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { const auto &id = tokenId.val->v; auto attributes = mnview.GetAttributes(); @@ -2703,7 +2703,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(HasFoundationAuth(), "tx not from foundation member!"); - if (height < static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height < static_cast(consensus.DF18FortCanningGreatWorldHeight)) { Require(obj.interest >= 0, "interest rate cannot be less than 0!"); } @@ -2711,7 +2711,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(pair, "Loan token (%s) does not exist!", obj.tokenTx.GetHex()); auto loanToken = - (height >= static_cast(consensus.FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) + (height >= static_cast(consensus.DF16FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) ? mnview.GetLoanTokenByID(pair->first) : mnview.GetLoanToken(obj.tokenTx); @@ -2734,7 +2734,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { Require(mnview.UpdateToken(pair->second)); - if (height >= static_cast(consensus.FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { + if (height >= static_cast(consensus.DF16FortCanningCrunchHeight) && IsTokensMigratedToGovVar()) { const auto &id = pair->first.v; auto attributes = mnview.GetAttributes(); @@ -3000,7 +3000,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { scheme->ratio); } } - if (height >= static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height >= static_cast(consensus.DF18FortCanningGreatWorldHeight)) { if (const auto loanTokens = mnview.GetLoanTokens(obj.vaultId)) { for (const auto &[tokenId, tokenAmount] : loanTokens->balances) { const auto loanToken = mnview.GetLoanTokenByID(tokenId); @@ -3021,7 +3021,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { const CVaultAssets &vaultAssets, const uint32_t ratio) const { std::optional > > tokenDUSD; - if (static_cast(height) >= consensus.FortCanningRoadHeight) { + if (static_cast(height) >= consensus.DF15FortCanningRoadHeight) { tokenDUSD = mnview.GetToken("DUSD"); } @@ -3053,12 +3053,12 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { } // Height checks - auto isPostFCH = static_cast(height) >= consensus.FortCanningHillHeight; - auto isPreFCH = static_cast(height) < consensus.FortCanningHillHeight; - auto isPostFCE = static_cast(height) >= consensus.FortCanningEpilogueHeight; - auto isPostFCR = static_cast(height) >= consensus.FortCanningRoadHeight; - auto isPostGC = static_cast(height) >= consensus.GrandCentralHeight; - auto isPostNext = static_cast(height) >= consensus.NextNetworkUpgradeHeight; + auto isPostFCH = static_cast(height) >= consensus.DF14FortCanningHillHeight; + auto isPreFCH = static_cast(height) < consensus.DF14FortCanningHillHeight; + auto isPostFCE = static_cast(height) >= consensus.DF19FortCanningEpilogueHeight; + auto isPostFCR = static_cast(height) >= consensus.DF15FortCanningRoadHeight; + auto isPostGC = static_cast(height) >= consensus.DF20GrandCentralHeight; + auto isPostNext = static_cast(height) >= consensus.DF22NextHeight; if(isPostNext) { const CDataStructureV0 enabledKey{AttributeTypes::Vaults, VaultIDs::DUSDVault, VaultKeys::DUSDVaultEnabled}; @@ -3180,7 +3180,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto hasDUSDLoans = false; std::optional > > tokenDUSD; - if (static_cast(height) >= consensus.FortCanningRoadHeight) { + if (static_cast(height) >= consensus.DF15FortCanningRoadHeight) { tokenDUSD = mnview.GetToken("DUSD"); } @@ -3236,7 +3236,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { } } - if (height >= static_cast(consensus.NextNetworkUpgradeHeight)) { + if (height >= static_cast(consensus.DF22NextHeight)) { mnview.CalculateOwnerRewards(obj.to, height); } @@ -3281,13 +3281,13 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { auto hasDUSDLoans = false; std::optional > > tokenDUSD; - if (static_cast(height) >= consensus.FortCanningRoadHeight) { + if (static_cast(height) >= consensus.DF15FortCanningRoadHeight) { tokenDUSD = mnview.GetToken("DUSD"); } uint64_t totalLoansActivePrice = 0, totalLoansNextPrice = 0; for (const auto &[tokenId, tokenAmount] : obj.amounts.balances) { - if (height >= static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height >= static_cast(consensus.DF18FortCanningGreatWorldHeight)) { Require(tokenAmount > 0, "Valid loan amount required (input: %d@%d)", tokenAmount, tokenId.v); } @@ -3440,12 +3440,12 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { if (!HasAuth(obj.from)) return DeFiErrors::TXMissingInput(); - if (static_cast(height) < consensus.FortCanningRoadHeight) { + if (static_cast(height) < consensus.DF15FortCanningRoadHeight) { if (!IsVaultPriceValid(mnview, obj.vaultId, height)) return DeFiErrors::LoanAssetPriceInvalid(); } // Handle payback with collateral special case - if (static_cast(height) >= consensus.FortCanningEpilogueHeight && + if (static_cast(height) >= consensus.DF19FortCanningEpilogueHeight && IsPaybackWithCollateral(mnview, obj.loans)) { return PaybackWithCollateral(mnview, *vault, obj.vaultId, height, time); } @@ -3462,7 +3462,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { const auto &paybackTokenId = kv.first; auto paybackAmount = kv.second; - if (height >= static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height >= static_cast(consensus.DF18FortCanningGreatWorldHeight)) { if (paybackAmount <= 0) return DeFiErrors::LoanPaymentAmountInvalid(paybackAmount, paybackTokenId.v); } @@ -3579,8 +3579,8 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { if (!res) return res; - if (height >= static_cast(consensus.FortCanningMuseumHeight) && subLoan < currentLoanAmount && - height < static_cast(consensus.FortCanningGreatWorldHeight)) { + if (height >= static_cast(consensus.DF12FortCanningMuseumHeight) && subLoan < currentLoanAmount && + height < static_cast(consensus.DF18FortCanningGreatWorldHeight)) { auto newRate = mnview.GetInterestRate(obj.vaultId, loanTokenId, height); if (!newRate) return DeFiErrors::TokenInterestRateInvalid(loanToken->symbol); @@ -3598,7 +3598,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { return res; // If interest was negative remove it from sub amount - if (height >= static_cast(consensus.FortCanningEpilogueHeight) && subInterest < 0) + if (height >= static_cast(consensus.DF19FortCanningEpilogueHeight) && subInterest < 0) subLoan += subInterest; // Do not sub balance if negative interest fully negates the current loan amount @@ -3747,14 +3747,14 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { "First bid should include liquidation penalty of %d%%", data->liquidationPenalty * 100 / COIN); - if (static_cast(height) >= consensus.FortCanningMuseumHeight && data->liquidationPenalty && + if (static_cast(height) >= consensus.DF12FortCanningMuseumHeight && data->liquidationPenalty && obj.amount.nValue == batch->loanAmount.nValue) return Res::Err("First bid should be higher than batch one"); } else { auto amount = MultiplyAmounts(bid->second.nValue, COIN + (COIN / 100)); Require(amount <= obj.amount.nValue, "Bid override should be at least 1%% higher than current one"); - if (static_cast(height) >= consensus.FortCanningMuseumHeight && + if (static_cast(height) >= consensus.DF12FortCanningMuseumHeight && obj.amount.nValue == bid->second.nValue) return Res::Err("Bid override should be higher than last one"); @@ -4208,8 +4208,8 @@ Res CustomMetadataParse(uint32_t height, bool IsDisabledTx(uint32_t height, CustomTxType type, const Consensus::Params &consensus) { // All the heights that are involved in disabled Txs - auto fortCanningParkHeight = static_cast(consensus.FortCanningParkHeight); - auto fortCanningHillHeight = static_cast(consensus.FortCanningHillHeight); + auto fortCanningParkHeight = static_cast(consensus.DF13FortCanningParkHeight); + auto fortCanningHillHeight = static_cast(consensus.DF14FortCanningHillHeight); if (height < fortCanningParkHeight) return false; @@ -4351,7 +4351,7 @@ Res ApplyCustomTx(CCustomCSView &mnview, return res; } std::vector metadata; - const auto metadataValidation = height >= static_cast(consensus.FortCanningHeight); + const auto metadataValidation = height >= static_cast(consensus.DF11FortCanningHeight); const auto txType = GuessCustomTxType(tx, metadata, metadataValidation); // Check OP_RETURN sizes @@ -4425,7 +4425,7 @@ Res ApplyCustomTx(CCustomCSView &mnview, } res.code |= CustomTxErrCodes::Fatal; } - if (height >= static_cast(consensus.DakotaHeight)) { + if (height >= static_cast(consensus.DF6DakotaHeight)) { res.code |= CustomTxErrCodes::Fatal; } return res; @@ -4449,7 +4449,7 @@ ResVal ApplyAnchorRewardTx(CCustomCSView &mnview, const uint256 &prevStakeModifier, const std::vector &metadata, const Consensus::Params &consensusParams) { - Require(height < consensusParams.DakotaHeight, "Old anchor TX type after Dakota fork. Height %d", height); + Require(height < consensusParams.DF6DakotaHeight, "Old anchor TX type after Dakota fork. Height %d", height); CDataStream ss(metadata, SER_NETWORK, PROTOCOL_VERSION); CAnchorFinalizationMessage finMsg; @@ -4475,7 +4475,7 @@ ResVal ApplyAnchorRewardTx(CCustomCSView &mnview, } // check reward sum - if (height >= consensusParams.AMKHeight) { + if (height >= consensusParams.DF1AMKHeight) { const auto cbValues = tx.GetValuesOut(); if (cbValues.size() != 1 || cbValues.begin()->first != DCT_ID{0}) return Res::ErrDbg("bad-ar-wrong-tokens", "anchor reward should be payed only in Defi coins"); @@ -4508,7 +4508,7 @@ ResVal ApplyAnchorRewardTx(CCustomCSView &mnview, return Res::ErrDbg("bad-ar-nextteam", "anchor wrong next team"); } mnview.SetTeam(finMsg.nextTeam); - if (height >= consensusParams.AMKHeight) { + if (height >= consensusParams.DF1AMKHeight) { LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", tx.GetHash().ToString(), @@ -4527,7 +4527,7 @@ ResVal ApplyAnchorRewardTxPlus(CCustomCSView &mnview, int height, const std::vector &metadata, const Consensus::Params &consensusParams) { - Require(height >= consensusParams.DakotaHeight, "New anchor TX type before Dakota fork. Height %d", height); + Require(height >= consensusParams.DF6DakotaHeight, "New anchor TX type before Dakota fork. Height %d", height); CDataStream ss(metadata, SER_NETWORK, PROTOCOL_VERSION); CAnchorFinalizationMessagePlus finMsg; @@ -4579,7 +4579,7 @@ ResVal ApplyAnchorRewardTxPlus(CCustomCSView &mnview, anchorReward); CTxDestination destination; - if (height < consensusParams.NextNetworkUpgradeHeight) { + if (height < consensusParams.DF22NextHeight) { destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, FromOrDefaultDestinationTypeToKeyType(finMsg.rewardKeyType), KeyType::MNOwnerKeyType); } else { destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, FromOrDefaultDestinationTypeToKeyType(finMsg.rewardKeyType), KeyType::MNRewardKeyType); @@ -4729,13 +4729,13 @@ std::vector > CPoolSwap::CalculatePoolPaths(CCustomCSView &v Res CPoolSwap::ExecuteSwap(CCustomCSView &view, std::vector poolIDs, const Consensus::Params &consensus, bool testOnly) { Res poolResult = Res::Ok(); // No composite swap allowed before Fort Canning - if (height < static_cast(consensus.FortCanningHeight) && !poolIDs.empty()) { + if (height < static_cast(consensus.DF11FortCanningHeight) && !poolIDs.empty()) { poolIDs.clear(); } Require(obj.amountFrom > 0, "Input amount should be positive"); - if (height >= static_cast(consensus.FortCanningHillHeight) && + if (height >= static_cast(consensus.DF14FortCanningHillHeight) && poolIDs.size() > MAX_POOL_SWAPS) { return Res::Err( strprintf("Too many pool IDs provided, max %d allowed, %d provided", MAX_POOL_SWAPS, poolIDs.size())); @@ -4790,7 +4790,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView &view, std::vector poolIDs, con const auto swapAmount = swapAmountResult; - if (height >= static_cast(consensus.FortCanningHillHeight) && lastSwap) { + if (height >= static_cast(consensus.DF14FortCanningHillHeight) && lastSwap) { Require(obj.idTokenTo != swapAmount.nTokenId, "Final swap should have idTokenTo as destination, not source"); @@ -4861,7 +4861,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView &view, std::vector poolIDs, con intermediateView.Flush(); auto &addView = lastSwap ? view : intermediateView; - if (height >= static_cast(consensus.GrandCentralHeight)) { + if (height >= static_cast(consensus.DF20GrandCentralHeight)) { res = addView.AddBalance(lastSwap ? (obj.to.empty() ? obj.from : obj.to) : obj.from, swapAmountResult); } else { @@ -4908,14 +4908,14 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView &view, std::vector poolIDs, con } } - if (height >= static_cast(consensus.GrandCentralHeight)) { + if (height >= static_cast(consensus.DF20GrandCentralHeight)) { if (swapAmountResult.nTokenId != obj.idTokenTo) { return Res::Err("Final swap output is not same as idTokenTo"); } } // Reject if price paid post-swap above max price provided - if (height >= static_cast(consensus.FortCanningHeight) && !obj.maxPrice.isAboveValid()) { + if (height >= static_cast(consensus.DF11FortCanningHeight) && !obj.maxPrice.isAboveValid()) { if (swapAmountResult.nValue != 0) { const auto userMaxPrice = arith_uint256(obj.maxPrice.integer) * COIN + obj.maxPrice.fraction; if (arith_uint256(obj.amountFrom) * COIN / swapAmountResult.nValue > userMaxPrice) { @@ -5191,14 +5191,14 @@ bool IsMainNetwork() { } bool IsICXEnabled(const int height, const CCustomCSView &view, const Consensus::Params &consensus) { - if (height >= consensus.NextNetworkUpgradeHeight) { + if (height >= consensus.DF22NextHeight) { const CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::ICXEnabled}; auto attributes = view.GetAttributes(); assert(attributes); return attributes->GetValue(enabledKey, false); } // ICX transactions allowed before NextNetwrokUpgrade and some of these conditions - else if (height < consensus.FortCanningParkHeight || IsRegtestNetwork() || (IsTestNetwork() && static_cast(height) >= 1250000)) + else if (height < consensus.DF13FortCanningParkHeight || IsRegtestNetwork() || (IsTestNetwork() && static_cast(height) >= 1250000)) return true; // ICX transactions disabled in all other cases @@ -5206,7 +5206,7 @@ bool IsICXEnabled(const int height, const CCustomCSView &view, const Consensus:: } bool IsEVMEnabled(const int height, const CCustomCSView &view, const Consensus::Params &consensus) { - if (height < consensus.NextNetworkUpgradeHeight) { + if (height < consensus.DF22NextHeight) { return false; } @@ -5217,7 +5217,7 @@ bool IsEVMEnabled(const int height, const CCustomCSView &view, const Consensus:: } bool IsTransferDomainEnabled(const int height, const CCustomCSView &view, const Consensus::Params &consensus) { - if (height < consensus.NextNetworkUpgradeHeight) { + if (height < consensus.DF22NextHeight) { return false; } @@ -5246,7 +5246,7 @@ struct OpReturnLimitsKeys { OpReturnLimits OpReturnLimits::From(const uint64_t height, const CChainParams& chainparams, const ATTRIBUTES& attributes) { OpReturnLimitsKeys k{}; auto item = OpReturnLimits::Default(); - item.shouldEnforce = height >= static_cast(chainparams.GetConsensus().NextNetworkUpgradeHeight); + item.shouldEnforce = height >= static_cast(chainparams.GetConsensus().DF22NextHeight); item.coreSizeBytes = attributes.GetValue(k.coreKey, item.coreSizeBytes); item.dvmSizeBytes = attributes.GetValue(k.dvmKey, item.dvmSizeBytes); item.evmSizeBytes = attributes.GetValue(k.evmKey, item.evmSizeBytes); diff --git a/src/masternodes/mn_checks.h b/src/masternodes/mn_checks.h index 1e831fb155..fa99442b8c 100644 --- a/src/masternodes/mn_checks.h +++ b/src/masternodes/mn_checks.h @@ -271,7 +271,7 @@ CustomTxType FromString(const std::string &str); // it's disabled after Dakota height inline bool NotAllowedToFail(CustomTxType txType, int height) { - return (height < Params().GetConsensus().DakotaHeight && + return (height < Params().GetConsensus().DF6DakotaHeight && (txType == CustomTxType::MintToken || txType == CustomTxType::AccountToUtxos)); } diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index c138646d07..57528e22b1 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -963,7 +963,7 @@ UniValue listgovs(const JSONRPCRequest& request) { if (mode == GovVarsFilter::NoAttributes) { skip = true; } else { - if (height >= Params().GetConsensus().NextNetworkUpgradeHeight) { + if (height >= Params().GetConsensus().DF22NextHeight) { if (auto attributes = dynamic_cast(var.get()); attributes) { AddDefaultVars(height, Params(), *attributes); } @@ -1047,7 +1047,7 @@ UniValue isappliedcustomtx(const JSONRPCRequest& request) { // post Dakota it's not allowed tx to be skipped // so tx that can be found in a block is applyed - if (blockHeight >= Params().GetConsensus().DakotaHeight) { + if (blockHeight >= Params().GetConsensus().DF6DakotaHeight) { result.setBool(true); } else { result.setBool(!IsSkippedTx(tx->GetHash())); diff --git a/src/masternodes/poolpairs.cpp b/src/masternodes/poolpairs.cpp index c3f8fe98a1..093f085dad 100644 --- a/src/masternodes/poolpairs.cpp +++ b/src/masternodes/poolpairs.cpp @@ -217,7 +217,7 @@ auto InitPoolVars(CPoolPairView &view, PoolHeightKey poolKey, uint32_t end) { auto it = view.LowerBound(poolKey); auto height = poolKey.height; - static const uint32_t startHeight = Params().GetConsensus().GrandCentralHeight; + static const uint32_t startHeight = Params().GetConsensus().DF20GrandCentralHeight; poolKey.height = std::max(height, startHeight); while (!MatchPoolId(it, poolId) && poolKey.height < end) { @@ -240,7 +240,7 @@ void CPoolPairView::CalculatePoolRewards(DCT_ID const &poolId, return; } constexpr const uint32_t PRECISION = 10000; - const auto newCalcHeight = uint32_t(Params().GetConsensus().BayfrontGardensHeight); + const auto newCalcHeight = uint32_t(Params().GetConsensus().DF4BayfrontGardensHeight); auto tokenIds = ReadBy(poolId); assert(tokenIds); // contract to verify pool data @@ -418,7 +418,7 @@ Res CPoolPair::Swap(CTokenAmount in, const auto maxPrice256 = arith_uint256(maxPrice.integer) * PRECISION + maxPrice.fraction; // NOTE it has a bug prior Dakota hardfork - const auto price = height < Params().GetConsensus().DakotaHeight ? arith_uint256(reserveT) * PRECISION / reserveF + const auto price = height < Params().GetConsensus().DF6DakotaHeight ? arith_uint256(reserveT) * PRECISION / reserveF : arith_uint256(reserveF) * PRECISION / reserveT; Require(price <= maxPrice256, []{ return "Price is higher than indicated."; }); @@ -458,7 +458,7 @@ CAmount CPoolPair::slopeSwap(CAmount unswapped, CAmount &poolFrom, CAmount &pool arith_uint256 poolT = arith_uint256(poolTo); arith_uint256 swapped = 0; - if (height < Params().GetConsensus().BayfrontGardensHeight) { + if (height < Params().GetConsensus().DF4BayfrontGardensHeight) { CAmount chunk = poolFrom / SLOPE_SWAP_RATE < unswapped ? poolFrom / SLOPE_SWAP_RATE : unswapped; while (unswapped > 0) { // arith_uint256 stepFrom = std::min(poolFrom/1000, unswapped); // 0.1% @@ -474,7 +474,7 @@ CAmount CPoolPair::slopeSwap(CAmount unswapped, CAmount &poolFrom, CAmount &pool arith_uint256 unswappedA = arith_uint256(unswapped); swapped = poolT - (poolT * poolF / (poolF + unswappedA)); - if (height >= Params().GetConsensus().FortCanningHillHeight && swapped != 0) { + if (height >= Params().GetConsensus().DF14FortCanningHillHeight && swapped != 0) { // floor the result --swapped; } @@ -491,9 +491,9 @@ std::pair CPoolPairView::UpdatePoolRewards( std::function onGetBalance, std::function onTransfer, int nHeight) { - bool newRewardCalc = nHeight >= Params().GetConsensus().BayfrontGardensHeight; - bool newRewardLogic = nHeight >= Params().GetConsensus().EunosHeight; - bool newCustomRewards = nHeight >= Params().GetConsensus().ClarkeQuayHeight; + bool newRewardCalc = nHeight >= Params().GetConsensus().DF4BayfrontGardensHeight; + bool newRewardLogic = nHeight >= Params().GetConsensus().DF8EunosHeight; + bool newCustomRewards = nHeight >= Params().GetConsensus().DF5ClarkeQuayHeight; constexpr const uint32_t PRECISION = 10000; // (== 100%) just searching the way to avoid arith256 inflating CAmount totalDistributed = 0; diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index e24366a8b3..21459af419 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -141,7 +141,7 @@ static void onPoolRewards(CCustomCSView &view, uint32_t end, std::function onReward) { CCustomCSView mnview(view); - static const uint32_t eunosHeight = Params().GetConsensus().EunosHeight; + static const uint32_t eunosHeight = Params().GetConsensus().DF8EunosHeight; view.ForEachPoolId([&] (DCT_ID const & poolId) { auto height = view.GetShare(poolId, owner); if (!height || *height >= end) { @@ -1843,7 +1843,7 @@ UniValue listcommunitybalances(const JSONRPCRequest& request) { } if (kv.first == CommunityAccountType::Loan) { - if (::ChainActive().Height() >= Params().GetConsensus().FortCanningHeight) { + if (::ChainActive().Height() >= Params().GetConsensus().DF11FortCanningHeight) { burnt += pcustomcsview->GetCommunityBalance(kv.first); } continue; @@ -2191,7 +2191,7 @@ UniValue getburninfo(const JSONRPCRequest& request) { auto height = ::ChainActive().Height(); auto hash = ::ChainActive().Tip()->GetBlockHash(); - auto fortCanningHeight = Params().GetConsensus().FortCanningHeight; + auto fortCanningHeight = Params().GetConsensus().DF11FortCanningHeight; auto burnAddress = Params().GetConsensus().burnAddress; auto view = *pcustomcsview; auto attributes = view.GetAttributes(); diff --git a/src/masternodes/rpc_icxorderbook.cpp b/src/masternodes/rpc_icxorderbook.cpp index a9c677a8dc..6707ca9b90 100644 --- a/src/masternodes/rpc_icxorderbook.cpp +++ b/src/masternodes/rpc_icxorderbook.cpp @@ -447,7 +447,7 @@ UniValue icxmakeoffer(const JSONRPCRequest& request) { targetHeight = ::ChainActive().Height() + 1; - if (targetHeight < Params().GetConsensus().EunosPayaHeight) + if (targetHeight < Params().GetConsensus().DF10EunosPayaHeight) makeoffer.expiry = CICXMakeOffer::DEFAULT_EXPIRY; else makeoffer.expiry = CICXMakeOffer::EUNOSPAYA_DEFAULT_EXPIRY; @@ -579,14 +579,14 @@ UniValue icxsubmitdfchtlc(const JSONRPCRequest& request) { authScript = order->ownerAddress; if (!submitdfchtlc.timeout) - submitdfchtlc.timeout = (targetHeight < Params().GetConsensus().EunosPayaHeight) ? CICXSubmitDFCHTLC::MINIMUM_TIMEOUT : CICXSubmitDFCHTLC::EUNOSPAYA_MINIMUM_TIMEOUT; + submitdfchtlc.timeout = (targetHeight < Params().GetConsensus().DF10EunosPayaHeight) ? CICXSubmitDFCHTLC::MINIMUM_TIMEOUT : CICXSubmitDFCHTLC::EUNOSPAYA_MINIMUM_TIMEOUT; } else if (order->orderType == CICXOrder::TYPE_EXTERNAL) { authScript = offer->ownerAddress; if (!submitdfchtlc.timeout) - submitdfchtlc.timeout = (targetHeight < Params().GetConsensus().EunosPayaHeight) ? CICXSubmitDFCHTLC::MINIMUM_2ND_TIMEOUT : CICXSubmitDFCHTLC::EUNOSPAYA_MINIMUM_2ND_TIMEOUT; + submitdfchtlc.timeout = (targetHeight < Params().GetConsensus().DF10EunosPayaHeight) ? CICXSubmitDFCHTLC::MINIMUM_2ND_TIMEOUT : CICXSubmitDFCHTLC::EUNOSPAYA_MINIMUM_2ND_TIMEOUT; CTokenAmount balance = pcustomcsview->GetBalance(offer->ownerAddress,order->idToken); if (balance.nValue < offer->amount) diff --git a/src/masternodes/rpc_loan.cpp b/src/masternodes/rpc_loan.cpp index a9f1efbc89..fa9b98becd 100644 --- a/src/masternodes/rpc_loan.cpp +++ b/src/masternodes/rpc_loan.cpp @@ -1197,7 +1197,7 @@ UniValue paybackloan(const JSONRPCRequest& request) { LOCK(cs_main); targetHeight = ::ChainActive().Height() + 1; } - bool isFCR = targetHeight >= Params().GetConsensus().FortCanningRoadHeight; + bool isFCR = targetHeight >= Params().GetConsensus().DF15FortCanningRoadHeight; CBalances amounts; if (hasAmounts){ if(hasLoans) @@ -1526,9 +1526,9 @@ UniValue getinterest(const JSONRPCRequest& request) { return true; }; - if (height >= Params().GetConsensus().FortCanningGreatWorldHeight) { + if (height >= Params().GetConsensus().DF18FortCanningGreatWorldHeight) { pcustomcsview->ForEachVaultInterestV3(vaultInterest); - } else if (height >= Params().GetConsensus().FortCanningHillHeight) { + } else if (height >= Params().GetConsensus().DF14FortCanningHillHeight) { pcustomcsview->ForEachVaultInterestV2([&](const CVaultId& vaultId, DCT_ID tokenId, const CInterestRateV2 &rate) { return vaultInterest(vaultId, tokenId, ConvertInterestRateToV3(rate)); }); @@ -1551,7 +1551,7 @@ UniValue getinterest(const JSONRPCRequest& request) { obj.pushKV("token", token->CreateSymbolKey(tokenId)); obj.pushKV("totalInterest", ValueFromAmount(totalInterest)); obj.pushKV("interestPerBlock", ValueFromAmount(interestPerBlock)); - if (height >= Params().GetConsensus().FortCanningHillHeight) + if (height >= Params().GetConsensus().DF14FortCanningHillHeight) { obj.pushKV("realizedInterestPerBlock", UniValue(UniValue::VNUM, GetInterestPerBlockHighPrecisionString(totalInterestPerBlock))); } diff --git a/src/masternodes/rpc_masternodes.cpp b/src/masternodes/rpc_masternodes.cpp index 03cb245b2e..e1a9a6afc8 100644 --- a/src/masternodes/rpc_masternodes.cpp +++ b/src/masternodes/rpc_masternodes.cpp @@ -48,7 +48,7 @@ UniValue mnToJSON(CCustomCSView& view, uint256 const & nodeId, CMasternode const // Get block times with next block as height const auto subNodesBlockTime = pcustomcsview->GetBlockTimes(node.operatorAuthAddress, currentHeight + 1, node.creationHeight, *timelock); - if (currentHeight >= Params().GetConsensus().EunosPayaHeight) { + if (currentHeight >= Params().GetConsensus().DF10EunosPayaHeight) { const uint8_t loops = *timelock == CMasternode::TENYEAR ? 4 : *timelock == CMasternode::FIVEYEAR ? 3 : 2; UniValue multipliers(UniValue::VARR); for (uint8_t i{0}; i < loops; ++i) { @@ -135,7 +135,7 @@ UniValue createmasternode(const JSONRPCRequest& request) bool eunosPaya; { LOCK(cs_main); - eunosPaya = ::ChainActive().Tip()->nHeight >= Params().GetConsensus().EunosPayaHeight; + eunosPaya = ::ChainActive().Tip()->nHeight >= Params().GetConsensus().DF10EunosPayaHeight; } // Get timelock if any @@ -680,7 +680,7 @@ UniValue getmasternodeblocks(const JSONRPCRequest& request) { return masternodeBlocks(key.masternodeID, key.blockHeight); }, MNBlockTimeKey{mn_id, std::numeric_limits::max()}); - auto tip = ::ChainActive()[std::min(lastHeight, Params().GetConsensus().DakotaCrescentHeight) - 1]; + auto tip = ::ChainActive()[std::min(lastHeight, Params().GetConsensus().DF7DakotaCrescentHeight) - 1]; for (; tip && tip->nHeight > creationHeight && tip->nHeight > startBlock; tip = tip->pprev) { auto id = pcustomcsview->GetMasternodeIdByOperator(tip->minterKey()); diff --git a/src/masternodes/rpc_oracles.cpp b/src/masternodes/rpc_oracles.cpp index 125c7f90dd..7b54e4b688 100644 --- a/src/masternodes/rpc_oracles.cpp +++ b/src/masternodes/rpc_oracles.cpp @@ -487,7 +487,7 @@ UniValue setoracledata(const JSONRPCRequest &request) { } // timestamp is checked at consensus level - if (targetHeight < Params().GetConsensus().FortCanningHeight) { + if (targetHeight < Params().GetConsensus().DF11FortCanningHeight) { if (timestamp <= 0 || timestamp > GetSystemTimeInSeconds() + 300) { throw JSONRPCError(RPC_INVALID_PARAMETER, "timestamp cannot be negative, zero or over 5 minutes in the future"); } diff --git a/src/masternodes/rpc_poolpair.cpp b/src/masternodes/rpc_poolpair.cpp index 7e84d815a4..5542500a41 100644 --- a/src/masternodes/rpc_poolpair.cpp +++ b/src/masternodes/rpc_poolpair.cpp @@ -659,7 +659,7 @@ UniValue createpoolpair(const JSONRPCRequest &request) { targetHeight = ::ChainActive().Height() + 1; } - const auto symbolLength = targetHeight >= Params().GetConsensus().FortCanningHeight + const auto symbolLength = targetHeight >= Params().GetConsensus().DF11FortCanningHeight ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH; if (pairSymbol.length() > symbolLength) { @@ -674,7 +674,7 @@ UniValue createpoolpair(const JSONRPCRequest &request) { poolPairMsg.ownerAddress = ownerAddress; poolPairMsg.pairSymbol = pairSymbol; - if (targetHeight >= Params().GetConsensus().ClarkeQuayHeight) { + if (targetHeight >= Params().GetConsensus().DF5ClarkeQuayHeight) { poolPairMsg.rewards = rewards; } @@ -835,7 +835,7 @@ UniValue updatepoolpair(const JSONRPCRequest &request) { // serialize poolId as raw integer << poolId.v << status << commission << ownerAddress; - if (targetHeight >= Params().GetConsensus().ClarkeQuayHeight) { + if (targetHeight >= Params().GetConsensus().DF5ClarkeQuayHeight) { metadata << rewards; } @@ -1050,7 +1050,7 @@ UniValue compositeswap(const JSONRPCRequest &request) { pwallet->BlockUntilSyncedToCurrentChain(); int targetHeight = chainHeight(*pwallet->chain().lock()) + 1; - if (targetHeight < Params().GetConsensus().FortCanningHeight) { + if (targetHeight < Params().GetConsensus().DF11FortCanningHeight) { throw JSONRPCError(RPC_INVALID_REQUEST, "compositeswap is available post Fort Canning"); } diff --git a/src/masternodes/rpc_tokens.cpp b/src/masternodes/rpc_tokens.cpp index 392085553b..842023ef52 100644 --- a/src/masternodes/rpc_tokens.cpp +++ b/src/masternodes/rpc_tokens.cpp @@ -268,12 +268,12 @@ UniValue updatetoken(const JSONRPCRequest& request) { CTransactionRef optAuthTx; std::set auths; - if (targetHeight < Params().GetConsensus().BayfrontHeight) { + if (targetHeight < Params().GetConsensus().DF2BayfrontHeight) { if (metaObj.size() > 1 || !metaObj.exists("isDAT")) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Only 'isDAT' flag modification allowed before Bayfront fork (<" + std::to_string(Params().GetConsensus().BayfrontHeight) + ")"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Only 'isDAT' flag modification allowed before Bayfront fork (<" + std::to_string(Params().GetConsensus().DF2BayfrontHeight) + ")"); } - // before BayfrontHeight it needs only founders auth + // before DF2BayfrontHeight it needs only founders auth rawTx.vin = GetAuthInputsSmart(pwallet, rawTx.nVersion, auths, true, optAuthTx, txInputs, request.metadata.coinSelectOpts); } else @@ -300,7 +300,7 @@ UniValue updatetoken(const JSONRPCRequest& request) { CDataStream metadata(DfTxMarker, SER_NETWORK, PROTOCOL_VERSION); // tx type and serialized data differ: - if (targetHeight < Params().GetConsensus().BayfrontHeight) { + if (targetHeight < Params().GetConsensus().DF2BayfrontHeight) { metadata << static_cast(CustomTxType::UpdateToken) << tokenImpl.creationTx << metaObj["isDAT"].getBool(); } @@ -607,7 +607,7 @@ UniValue getcustomtx(const JSONRPCRequest& request) auto res = ApplyCustomTx(mnview, view, *tx, Params().GetConsensus(), nHeight); result.pushKV("valid", res.ok); } else { - if (nHeight >= Params().GetConsensus().DakotaHeight) { + if (nHeight >= Params().GetConsensus().DF6DakotaHeight) { result.pushKV("valid", actualHeight); } else { result.pushKV("valid", !IsSkippedTx(tx->GetHash())); diff --git a/src/masternodes/rpc_vault.cpp b/src/masternodes/rpc_vault.cpp index 7627401dd2..8a367c813a 100644 --- a/src/masternodes/rpc_vault.cpp +++ b/src/masternodes/rpc_vault.cpp @@ -178,10 +178,10 @@ namespace { totalInterests += interestCalculation; } if (verbose) { - if (height >= Params().GetConsensus().FortCanningGreatWorldHeight) { + if (height >= Params().GetConsensus().DF18FortCanningGreatWorldHeight) { interestsPerBlockValueHighPrecision = InterestAddition(interestsPerBlockValueHighPrecision, {rate->interestPerBlock.negative, static_cast>(price) * rate->interestPerBlock.amount / COIN}); interestsPerBlockHighPrecission[tokenId] = rate->interestPerBlock; - } else if (height >= Params().GetConsensus().FortCanningHillHeight) { + } else if (height >= Params().GetConsensus().DF14FortCanningHillHeight) { interestsPerBlockValueHighPrecision.amount += static_cast>(price) * rate->interestPerBlock.amount / COIN; interestsPerBlockHighPrecission[tokenId] = rate->interestPerBlock; } else { @@ -232,7 +232,7 @@ namespace { nextCollateralRatio = int(rate.val->ratio()); result.pushKV("nextCollateralRatio", nextCollateralRatio); } - if (height >= Params().GetConsensus().FortCanningHillHeight) { + if (height >= Params().GetConsensus().DF14FortCanningHillHeight) { if(isVaultTokenLocked){ result.pushKV("interestPerBlockValue", -1); } else { diff --git a/src/masternodes/tokens.cpp b/src/masternodes/tokens.cpp index 6c8db2c703..b212816c67 100644 --- a/src/masternodes/tokens.cpp +++ b/src/masternodes/tokens.cpp @@ -81,7 +81,7 @@ ResVal CTokensView::CreateToken(const CTokensView::CTokenImpl &token, bo }, id); if (id == DCT_ID_START) { - // asserted before BayfrontHeight, keep it for strict sameness + // asserted before DF2BayfrontHeight, keep it for strict sameness Require( !isPreBayfront, []{ return "Critical fault: trying to create DCT_ID same as DCT_ID_START for Foundation owner\n"; }); @@ -238,7 +238,7 @@ std::optional CTokensView::ReadLastDctId() const { inline Res CTokenImplementation::IsValidSymbol() const { Require(!symbol.empty() && !IsDigit(symbol[0]), []{ return "token symbol should be non-empty and starts with a letter"; }); Require(symbol.find('#') == std::string::npos, []{ return "token symbol should not contain '#'"; }); - if (creationHeight >= Params().GetConsensus().FortCanningCrunchHeight) { + if (creationHeight >= Params().GetConsensus().DF16FortCanningCrunchHeight) { Require(symbol.find('/') == std::string::npos, []{ return "token symbol should not contain '/'"; }); } return Res::Ok(); diff --git a/src/masternodes/validation.cpp b/src/masternodes/validation.cpp index eb27b160d7..c8d603fdc8 100644 --- a/src/masternodes/validation.cpp +++ b/src/masternodes/validation.cpp @@ -46,14 +46,14 @@ static void UpdateDailyGovVariables(const std::mapnHeight >= chainparams.GetConsensus().EunosHeight) + if (pindex->nHeight >= chainparams.GetConsensus().DF8EunosHeight) { const auto& incentivePair = chainparams.GetConsensus().newNonUTXOSubsidies.find(CommunityAccountType::IncentiveFunding); UpdateDailyGovVariables(incentivePair, cache, pindex->nHeight); } // Hard coded LP_DAILY_LOAN_TOKEN_REWARD change - if (pindex->nHeight >= chainparams.GetConsensus().FortCanningHeight) + if (pindex->nHeight >= chainparams.GetConsensus().DF11FortCanningHeight) { const auto& incentivePair = chainparams.GetConsensus().newNonUTXOSubsidies.find(CommunityAccountType::Loan); UpdateDailyGovVariables(incentivePair, cache, pindex->nHeight); @@ -94,7 +94,7 @@ static void ProcessRewardEvents(const CBlockIndex* pindex, CCustomCSView& cache, LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: event=ProcessRewardEvents fund=%s change=%s\n", GetCommunityAccountName(CommunityAccountType::IncentiveFunding), (CBalances{{{{0}, -distributed.first}}}.ToString())); } - if (pindex->nHeight >= chainparams.GetConsensus().FortCanningHeight) { + if (pindex->nHeight >= chainparams.GetConsensus().DF11FortCanningHeight) { res = cache.SubCommunityBalance(CommunityAccountType::Loan, distributed.second); if (!res.ok) { LogPrintf("Pool rewards: can't update community balance: %s. Block %ld (%s)\n", res.msg, pindex->nHeight, pindex->phashBlock->GetHex()); @@ -107,11 +107,11 @@ static void ProcessRewardEvents(const CBlockIndex* pindex, CCustomCSView& cache, static void ProcessICXEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().EunosHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF8EunosHeight) { return; } - bool isPreEunosPaya = pindex->nHeight < chainparams.GetConsensus().EunosPayaHeight; + bool isPreEunosPaya = pindex->nHeight < chainparams.GetConsensus().DF10EunosPayaHeight; cache.ForEachICXOrderExpire([&](CICXOrderView::StatusKey const& key, uint8_t status) { if (static_cast(key.first) != pindex->nHeight) @@ -263,7 +263,7 @@ Res AddNonTxToBurnIndex(const CScript& from, const CBalances& amounts) } static void ProcessEunosEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight != chainparams.GetConsensus().EunosHeight) { + if (pindex->nHeight != chainparams.GetConsensus().DF8EunosHeight) { return; } @@ -326,7 +326,7 @@ static void ProcessEunosEvents(const CBlockIndex* pindex, CCustomCSView& cache, } static void ProcessOracleEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams){ - if (pindex->nHeight < chainparams.GetConsensus().FortCanningHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF11FortCanningHeight) { return; } auto blockInterval = cache.GetIntervalBlock(); @@ -443,7 +443,7 @@ std::vector CollectAuctionBatches(const CVaultAssets& vaultAssets static void ProcessLoanEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().FortCanningHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF11FortCanningHeight) { return; } @@ -781,7 +781,7 @@ static void ProcessLoanEvents(const CBlockIndex* pindex, CCustomCSView& cache, c static void ProcessFutures(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().FortCanningRoadHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF15FortCanningRoadHeight) { return; } @@ -981,7 +981,7 @@ static void ProcessFutures(const CBlockIndex* pindex, CCustomCSView& cache, cons } static void ProcessGovEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().FortCanningHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF11FortCanningHeight) { return; } @@ -1068,7 +1068,7 @@ static void ProcessTokenToGovVar(const CBlockIndex* pindex, CCustomCSView& cache // Migrate at +1 height so that GetLastHeight() in Gov var // Validate() has a height equal to the GW fork. - if (pindex->nHeight != chainparams.GetConsensus().FortCanningCrunchHeight + 1) { + if (pindex->nHeight != chainparams.GetConsensus().DF16FortCanningCrunchHeight + 1) { return; } @@ -1519,7 +1519,7 @@ static Res VaultSplits(CCustomCSView& view, ATTRIBUTES& attributes, const DCT_ID CVaultId failedVault; std::vector> loanInterestRates; - if (height >= Params().GetConsensus().FortCanningGreatWorldHeight) { + if (height >= Params().GetConsensus().DF18FortCanningGreatWorldHeight) { view.ForEachVaultInterestV3([&](const CVaultId& vaultId, DCT_ID tokenId, const CInterestRateV3& rate) { if (tokenId == oldTokenId) { const auto vaultData = view.GetVault(vaultId); @@ -1733,7 +1733,7 @@ static Res GetTokenSuffix(const CCustomCSView& view, const ATTRIBUTES& attribute } static void ProcessTokenSplits(const CBlock& block, const CBlockIndex* pindex, CCustomCSView& cache, const CreationTxs& creationTxs, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().FortCanningCrunchHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF16FortCanningCrunchHeight) { return; } const auto attributes = cache.GetAttributes(); @@ -1942,7 +1942,7 @@ static void ProcessTokenSplits(const CBlock& block, const CBlockIndex* pindex, C view.SetVariable(*attributes); // Migrate stored unlock - if (pindex->nHeight >= chainparams.GetConsensus().GrandCentralHeight) { + if (pindex->nHeight >= chainparams.GetConsensus().DF20GrandCentralHeight) { bool updateStoredVar{}; auto storedGovVars = view.GetStoredVariablesRange(pindex->nHeight, std::numeric_limits::max()); for (const auto& [varHeight, var] : storedGovVars) { @@ -1983,7 +1983,7 @@ static void ProcessTokenSplits(const CBlock& block, const CBlockIndex* pindex, C static void ProcessFuturesDUSD(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().FortCanningSpringHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF17FortCanningSpringHeight) { return; } @@ -2157,7 +2157,7 @@ static void ProcessNegativeInterest(const CBlockIndex* pindex, CCustomCSView& ca } static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().GrandCentralHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF20GrandCentralHeight) { return; } @@ -2243,7 +2243,7 @@ static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cach LogPrintf("Proposal fee redistribution failed: %s Address: %s Amount: %d\n", res.msg, scriptPubKey.GetHex(), amountPerVoter); } - if (pindex->nHeight >= chainparams.GetConsensus().NextNetworkUpgradeHeight) { + if (pindex->nHeight >= chainparams.GetConsensus().DF22NextHeight) { subView.CalculateOwnerRewards(scriptPubKey, pindex->nHeight); } @@ -2266,10 +2266,10 @@ static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cach return true; } - if (pindex->nHeight < chainparams.GetConsensus().NextNetworkUpgradeHeight && lround(voteYes * 10000.f / voters.size()) <= prop.approvalThreshold) { + if (pindex->nHeight < chainparams.GetConsensus().DF22NextHeight && lround(voteYes * 10000.f / voters.size()) <= prop.approvalThreshold) { cache.UpdateProposalStatus(propId, pindex->nHeight, CProposalStatusType::Rejected); return true; - } else if (pindex->nHeight >= chainparams.GetConsensus().NextNetworkUpgradeHeight) { + } else if (pindex->nHeight >= chainparams.GetConsensus().DF22NextHeight) { auto onlyNeutral = voters.size() == voteNeutral; if (onlyNeutral || lround(voteYes * 10000.f / (voters.size() - voteNeutral)) <= prop.approvalThreshold) { cache.UpdateProposalStatus(propId, pindex->nHeight, CProposalStatusType::Rejected); @@ -2301,7 +2301,7 @@ static void ProcessProposalEvents(const CBlockIndex* pindex, CCustomCSView& cach } static void ProcessMasternodeUpdates(const CBlockIndex* pindex, CCustomCSView& cache, const CCoinsViewCache& view, const CChainParams& chainparams) { - if (pindex->nHeight < chainparams.GetConsensus().GrandCentralHeight) { + if (pindex->nHeight < chainparams.GetConsensus().DF20GrandCentralHeight) { return; } // Apply any pending masternode owner changes @@ -2335,7 +2335,7 @@ static void ProcessMasternodeUpdates(const CBlockIndex* pindex, CCustomCSView& c static void ProcessGrandCentralEvents(const CBlockIndex* pindex, CCustomCSView& cache, const CChainParams& chainparams) { - if (pindex->nHeight != chainparams.GetConsensus().GrandCentralHeight) { + if (pindex->nHeight != chainparams.GetConsensus().DF20GrandCentralHeight) { return; } @@ -2537,7 +2537,7 @@ void ProcessDeFiEvent(const CBlock &block, const CBlockIndex* pindex, CCustomCSV ProcessICXEvents(pindex, cache, chainparams); // Remove `Finalized` and/or `LPS` flags _possibly_set_ by bytecoded (cheated) txs before bayfront fork - if (pindex->nHeight == chainparams.GetConsensus().BayfrontHeight - 1) { // call at block _before_ fork + if (pindex->nHeight == chainparams.GetConsensus().DF2BayfrontHeight - 1) { // call at block _before_ fork cache.BayfrontFlagsCleanup(); } diff --git a/src/miner.cpp b/src/miner.cpp index bc67a4f3d6..ec45da7c76 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -190,7 +190,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc // Skip on main as fix to avoid merkle root error. Allow on other networks for testing. if (Params().NetworkIDString() != CBaseChainParams::MAIN || - (Params().NetworkIDString() == CBaseChainParams::MAIN && nHeight >= chainparams.GetConsensus().EunosKampungHeight)) { + (Params().NetworkIDString() == CBaseChainParams::MAIN && nHeight >= chainparams.GetConsensus().DF9EunosKampungHeight)) { CTeamView::CTeam currentTeam; if (const auto team = pcustomcsview->GetConfirmTeam(pindexPrev->nHeight)) { currentTeam = *team; @@ -201,7 +201,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc bool createAnchorReward{false}; // No new anchors until we hit fork height, no new confirms should be found before fork. - if (pindexPrev->nHeight >= consensus.DakotaHeight && confirms.size() > 0) { + if (pindexPrev->nHeight >= consensus.DF6DakotaHeight && confirms.size() > 0) { // Make sure anchor block height and hash exist in chain. CBlockIndex* anchorIndex = ::ChainActive()[confirms[0].anchorHeight]; if (anchorIndex && anchorIndex->GetBlockHash() == confirms[0].dfiBlockHash) { @@ -220,7 +220,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc metadata << finMsg; CTxDestination destination; - if (nHeight < consensus.NextNetworkUpgradeHeight) { + if (nHeight < consensus.DF22NextHeight) { destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, FromOrDefaultDestinationTypeToKeyType(finMsg.rewardKeyType), KeyType::MNOwnerKeyType); } else { destination = FromOrDefaultKeyIDToDestination(finMsg.rewardKeyID, FromOrDefaultDestinationTypeToKeyType(finMsg.rewardKeyType), KeyType::MNRewardKeyType); @@ -317,7 +317,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc } // TXs for the creationTx field in new tokens created via token split - if (nHeight >= chainparams.GetConsensus().FortCanningCrunchHeight) { + if (nHeight >= chainparams.GetConsensus().DF16FortCanningCrunchHeight) { const auto attributes = mnview.GetAttributes(); if (attributes) { CDataStructureV0 splitKey{AttributeTypes::Oracles, OracleIDs::Splits, static_cast(nHeight)}; @@ -373,9 +373,9 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc CAmount blockReward = GetBlockSubsidy(nHeight, consensus); coinbaseTx.vout[0].nValue = nFees + blockReward; - if (nHeight >= consensus.EunosHeight) { + if (nHeight >= consensus.DF8EunosHeight) { auto foundationValue = CalculateCoinbaseReward(blockReward, consensus.dist.community); - if (nHeight < consensus.GrandCentralHeight) { + if (nHeight < consensus.DF20GrandCentralHeight) { coinbaseTx.vout.resize(2); // Community payment always expected coinbaseTx.vout[1].scriptPubKey = consensus.foundationShareScript; @@ -383,7 +383,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc } // Explicitly set miner reward - if (nHeight >= consensus.FortCanningHeight) { + if (nHeight >= consensus.DF11FortCanningHeight) { coinbaseTx.vout[0].nValue = nFees + CalculateCoinbaseReward(blockReward, consensus.dist.masternode); } else { coinbaseTx.vout[0].nValue = CalculateCoinbaseReward(blockReward, consensus.dist.masternode); @@ -405,7 +405,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc LogPrint(BCLog::STAKING, "%s: post Eunos logic. Block reward %d Miner share %d foundation share %d\n", __func__, blockReward, coinbaseTx.vout[0].nValue, foundationValue); - } else if (nHeight >= consensus.AMKHeight) { + } else if (nHeight >= consensus.DF1AMKHeight) { // assume community non-utxo funding: for (const auto& kv : consensus.nonUtxoBlockSubsidies) { coinbaseTx.vout[0].nValue -= blockReward * kv.second / COIN; @@ -460,7 +460,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc int64_t nTime2 = GetTimeMicros(); pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); - if (nHeight >= chainparams.GetConsensus().EunosHeight && nHeight < chainparams.GetConsensus().EunosKampungHeight) { + if (nHeight >= chainparams.GetConsensus().DF8EunosHeight && nHeight < chainparams.GetConsensus().DF9EunosKampungHeight) { // includes coinbase account changes ApplyGeneralCoinbaseTx(mnview, *(pblock->vtx[0]), nHeight, nFees, chainparams.GetConsensus()); pblock->hashMerkleRoot = Hash2(pblock->hashMerkleRoot, mnview.MerkleRoot()); @@ -1032,7 +1032,7 @@ Staker::Status Staker::stake(const CChainParams& chainparams, const ThreadStaker mintedBlocks = nodePtr->mintedBlocks; if (args.coinbaseScript.empty()) { // this is safe because MN was found - if (tip->nHeight >= chainparams.GetConsensus().FortCanningHeight && nodePtr->rewardAddressType != 0) { + if (tip->nHeight >= chainparams.GetConsensus().DF11FortCanningHeight && nodePtr->rewardAddressType != 0) { scriptPubKey = GetScriptForDestination(FromOrDefaultKeyIDToDestination(nodePtr->rewardAddress, FromOrDefaultDestinationTypeToKeyType(nodePtr->rewardAddressType), KeyType::MNRewardKeyType)); } else { scriptPubKey = GetScriptForDestination(FromOrDefaultKeyIDToDestination(nodePtr->ownerAuthAddress, FromOrDefaultDestinationTypeToKeyType(nodePtr->ownerType), KeyType::MNOwnerKeyType)); @@ -1177,7 +1177,7 @@ Staker::Status Staker::stake(const CChainParams& chainparams, const ThreadStaker template void Staker::withSearchInterval(F&& f, int64_t height) { - if (height >= Params().GetConsensus().EunosPayaHeight) { + if (height >= Params().GetConsensus().DF10EunosPayaHeight) { // Mine up to max future minus 1 second buffer nFutureTime = GetAdjustedTime() + (MAX_FUTURE_BLOCK_TIME_EUNOSPAYA - 1); // 29 seconds } else { diff --git a/src/pos.cpp b/src/pos.cpp index d9f0290d33..b37cd1b852 100644 --- a/src/pos.cpp +++ b/src/pos.cpp @@ -74,17 +74,17 @@ bool ContextualCheckProofOfStake(const CBlockHeader& blockHeader, const Consensu } creationHeight = int64_t(nodePtr->creationHeight); - if (height >= params.EunosPayaHeight) { + if (height >= params.DF10EunosPayaHeight) { const auto optTimeLock = mnView->GetTimelock(masternodeID, *nodePtr, height); if (!optTimeLock) return false; timelock = *optTimeLock; } - // Check against EunosPayaHeight here for regtest, does not hurt other networks. + // Check against DF10EunosPayaHeight here for regtest, does not hurt other networks. // Redundant checks, but intentionally kept for easier fork accounting. - if (height >= params.DakotaCrescentHeight || height >= params.EunosPayaHeight) { - const auto usedHeight = height <= params.EunosHeight ? creationHeight : height; + if (height >= params.DF7DakotaCrescentHeight || height >= params.DF10EunosPayaHeight) { + const auto usedHeight = height <= params.DF8EunosHeight ? creationHeight : height; // Get block times subNodesBlockTime = mnView->GetBlockTimes(nodePtr->operatorAuthAddress, usedHeight, creationHeight, timelock); @@ -148,15 +148,15 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int64_t blockTim } int nHeight{pindexLast->nHeight + 1}; - bool newDifficultyAdjust{nHeight > params.EunosHeight}; + bool newDifficultyAdjust{nHeight > params.DF8EunosHeight}; // Restore previous difficulty adjust on testnet after FC - if (IsTestNetwork() && nHeight >= params.FortCanningHeight) { + if (IsTestNetwork() && nHeight >= params.DF11FortCanningHeight) { newDifficultyAdjust = false; } const auto interval = newDifficultyAdjust ? params.pos.DifficultyAdjustmentIntervalV2() : params.pos.DifficultyAdjustmentInterval(); - bool skipChange = newDifficultyAdjust ? (nHeight - params.EunosHeight) % interval != 0 : nHeight % interval != 0; + bool skipChange = newDifficultyAdjust ? (nHeight - params.DF8EunosHeight) % interval != 0 : nHeight % interval != 0; // Only change once per difficulty adjustment interval if (skipChange) diff --git a/src/pos_kernel.cpp b/src/pos_kernel.cpp index 3278181def..162a713c9d 100644 --- a/src/pos_kernel.cpp +++ b/src/pos_kernel.cpp @@ -43,7 +43,7 @@ namespace pos { arith_uint256 targetProofOfStake; targetProofOfStake.SetCompact(nBits); - if (blockHeight >= static_cast(params.EunosPayaHeight)) { + if (blockHeight >= static_cast(params.DF10EunosPayaHeight)) { const uint8_t loops = timelock == CMasternode::TENYEAR ? 4 : timelock == CMasternode::FIVEYEAR ? 3 : 2; // Check whether we meet hash for each subnode in turn @@ -66,7 +66,7 @@ namespace pos { // New difficulty calculation to make staking easier the longer it has // been since a masternode staked a block. - if (blockHeight >= static_cast(params.DakotaCrescentHeight)) + if (blockHeight >= static_cast(params.DF7DakotaCrescentHeight)) { auto coinDayWeight = CalcCoinDayWeight(params, coinstakeTime, subNodesBlockTime[0]); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 767b75de4e..b41438d53b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -117,7 +117,121 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex return result; } -UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails) +struct MinterInfo { + std::string Id{}; + std::string OwnerAddress{}; + std::string OperatorAddress{}; + std::string RewardAddress{}; + uint64_t MintedBlocks{}; + uint256 StakeModifier{}; + + static std::optional TryFrom(const CBlock& block, const CBlockIndex* blockindex, const CCustomCSView& view) { + MinterInfo result; + CKeyID minter; + block.ExtractMinterKey(minter); + auto id = view.GetMasternodeIdByOperator(minter); + if (!id) return {}; + result.Id = id->ToString(); + auto mn = view.GetMasternode(*id); + if (mn) { + auto dest = mn->operatorType == 1 ? CTxDestination(PKHash(minter)) : CTxDestination(WitnessV0KeyHash(minter)); + result.OperatorAddress = EncodeDestination(dest); + } + result.MintedBlocks = blockindex->mintedBlocks; + result.StakeModifier = blockindex->stakeModifier; + return result; + } + + void PushToUniValueLegacy(UniValue& result) { + // Note: This follows legacy way of empty checks and prints to preserve + // compatibility. Don't change it. Use the new method ToUniValue method + // for new version. + if (Id.empty()) return; + result.pushKV("masternode", Id); + if (!OperatorAddress.empty()) result.pushKV("minter", OperatorAddress); + result.pushKV("mintedBlocks", MintedBlocks); + result.pushKV("stakeModifier", StakeModifier.ToString()); + } +}; + +struct RewardInfo { + struct TokenRewardItems { + CAmount Burnt{}; + CAmount IncentiveFunding{}; + CAmount AnchorReward{}; + CAmount CommunityDevFunds{}; + CAmount Loan{}; + CAmount Options{}; + }; + + CAmount BlockReward{}; + TokenRewardItems TokenRewards{}; + + static std::optional TryFrom(const CBlock& block, const CBlockIndex* blockindex, const Consensus::Params& consensus) { + if (blockindex->nHeight < consensus.DF1AMKHeight) + return {}; + + RewardInfo result{}; + auto& tokenRewards = result.TokenRewards; + CAmount blockReward = GetBlockSubsidy(blockindex->nHeight, consensus); + result.BlockReward = blockReward; + + if (blockindex->nHeight < consensus.DF8EunosHeight) { + for (const auto& [accountType, accountVal] : consensus.nonUtxoBlockSubsidies) + { + CAmount subsidy = blockReward * accountVal / COIN; + switch (accountType) { + // CommunityDevFunds, Loan, Options don't exist in nonUtxoBlockSubsidies here + case CommunityAccountType::AnchorReward:{ tokenRewards.AnchorReward = subsidy; break; } + case CommunityAccountType::IncentiveFunding: { tokenRewards.IncentiveFunding = subsidy; break; } + default: { tokenRewards.Burnt += subsidy; } + } + } + return result; + } + + for (const auto& [accountType, accountVal] : consensus.newNonUTXOSubsidies) + { + if (blockindex->nHeight < consensus.DF20GrandCentralHeight + && accountType == CommunityAccountType::CommunityDevFunds) { + continue; + } + + CAmount subsidy = CalculateCoinbaseReward(blockReward, accountVal); + switch (accountType) { + // Everything else is burnt. Should update post fort canning. Retaining + // compatibility for old logic for now. + case CommunityAccountType::AnchorReward:{ tokenRewards.AnchorReward = subsidy; break; } + case CommunityAccountType::CommunityDevFunds: { tokenRewards.CommunityDevFunds = subsidy; break; } + default: { tokenRewards.Burnt += subsidy; } + } + } + return result; + } + + void PushToUniValueLegacy(UniValue& result) { + // Note: This follows legacy way of empty checks and prints to preserve + // compatibility. Don't change it. Use the new method ToUniValue method + // for new version. + UniValue rewards(UniValue::VARR); + UniValue obj(UniValue::VOBJ); + + auto& r = TokenRewards; + auto items = std::vector>{ + { CommunityAccountType::AnchorReward, r.AnchorReward }, + { CommunityAccountType::CommunityDevFunds, r.CommunityDevFunds }, + { CommunityAccountType::Unallocated, r.Burnt }}; + + for (const auto& [accountName, val]: items) { + obj.pushKV(GetCommunityAccountName(accountName), ValueFromAmount(val)); + } + + rewards.push_back(obj); + result.pushKV("nonutxo", rewards); + } +}; + +UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails, bool xVmDetails) { // Serialize passed information without accessing chain state of the active chain! AssertLockNotHeld(cs_main); // For performance reasons @@ -132,66 +246,22 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn result.pushKV("weight", (int)::GetBlockWeight(block)); result.pushKV("height", blockindex->nHeight); - CKeyID minter; - block.ExtractMinterKey(minter); - auto id = pcustomcsview->GetMasternodeIdByOperator(minter); - if (id) { - result.pushKV("masternode", id->ToString()); - auto mn = pcustomcsview->GetMasternode(*id); - if (mn) { - auto dest = mn->operatorType == 1 ? CTxDestination(PKHash(minter)) : CTxDestination(WitnessV0KeyHash(minter)); - result.pushKV("minter", EncodeDestination(dest)); - } + // For xVMDetails, we fix the past mistakes and don't just modify existing root schema. + // We'll add all these later. + if (!xVmDetails) { + auto minterInfo = MinterInfo::TryFrom(block, blockindex, *pcustomcsview); + if (minterInfo) { minterInfo->PushToUniValueLegacy(result); } } - result.pushKV("mintedBlocks", blockindex->mintedBlocks); - result.pushKV("stakeModifier", blockindex->stakeModifier.ToString()); - + result.pushKV("version", block.nVersion); result.pushKV("versionHex", strprintf("%08x", block.nVersion)); result.pushKV("merkleroot", block.hashMerkleRoot.GetHex()); - UniValue rewards(UniValue::VARR); - if (blockindex->nHeight >= Params().GetConsensus().AMKHeight) - { - CAmount blockReward = GetBlockSubsidy(blockindex->nHeight, Params().GetConsensus()); - UniValue nonutxo(UniValue::VOBJ); - - if (blockindex->nHeight >= Params().GetConsensus().EunosHeight) - { - CAmount burnt{0}; - for (const auto& kv : Params().GetConsensus().newNonUTXOSubsidies) - { - if (blockindex->nHeight < Params().GetConsensus().GrandCentralHeight - && kv.first == CommunityAccountType::CommunityDevFunds) { - continue; - } - - CAmount subsidy = CalculateCoinbaseReward(blockReward, kv.second); - - switch(kv.first) { - case CommunityAccountType::AnchorReward: - case CommunityAccountType::CommunityDevFunds: - nonutxo.pushKV(GetCommunityAccountName(kv.first), ValueFromAmount(subsidy)); - break; - default: - burnt += subsidy; // Everything else goes into burnt - } - } - - // Add burnt total - nonutxo.pushKV(GetCommunityAccountName(CommunityAccountType::Unallocated), ValueFromAmount(burnt)); - } - else - { - for (const auto& kv : Params().GetConsensus().nonUtxoBlockSubsidies) - { - // Anchor and LP incentive - nonutxo.pushKV(GetCommunityAccountName(kv.first), ValueFromAmount(blockReward * kv.second / COIN)); - } - } - rewards.push_back(nonutxo); + if (!xVmDetails) { + auto rewardInfo = RewardInfo::TryFrom(block, blockindex, Params().GetConsensus()); + if (rewardInfo) { rewardInfo->PushToUniValueLegacy(result); } } - result.pushKV("nonutxo", rewards); + UniValue txs(UniValue::VARR); for(const auto& tx : block.vtx) { @@ -216,6 +286,10 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn result.pushKV("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()); if (pnext) result.pushKV("nextblockhash", pnext->GetBlockHash().GetHex()); + + if (xVmDetails) { + // TODO: Add xVM details here + } return result; } @@ -969,7 +1043,7 @@ static UniValue getblock(const JSONRPCRequest& request) return strHex; } - return blockToJSON(block, tip, pblockindex, verbosity >= 2); + return blockToJSON(block, tip, pblockindex, verbosity >= 2, verbosity >= 3); } static UniValue pruneblockchain(const JSONRPCRequest& request) @@ -1335,25 +1409,25 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) const Consensus::Params& consensusParams = Params().GetConsensus(); UniValue softforks(UniValue::VOBJ); - BuriedForkDescPushBack(softforks, "amk", consensusParams.AMKHeight); - BuriedForkDescPushBack(softforks, "bayfront", consensusParams.BayfrontHeight); - BuriedForkDescPushBack(softforks, "clarkequay", consensusParams.ClarkeQuayHeight); - BuriedForkDescPushBack(softforks, "dakota", consensusParams.DakotaHeight); - BuriedForkDescPushBack(softforks, "dakotacrescent", consensusParams.DakotaCrescentHeight); - BuriedForkDescPushBack(softforks, "eunos", consensusParams.EunosHeight); - BuriedForkDescPushBack(softforks, "eunospaya", consensusParams.EunosPayaHeight); - BuriedForkDescPushBack(softforks, "fortcanning", consensusParams.FortCanningHeight); - BuriedForkDescPushBack(softforks, "fortcanningmuseum", consensusParams.FortCanningMuseumHeight); - BuriedForkDescPushBack(softforks, "fortcanningpark", consensusParams.FortCanningParkHeight); - BuriedForkDescPushBack(softforks, "fortcanninghill", consensusParams.FortCanningHillHeight); - BuriedForkDescPushBack(softforks, "fortcanningroad", consensusParams.FortCanningRoadHeight); - BuriedForkDescPushBack(softforks, "fortcanningcrunch", consensusParams.FortCanningCrunchHeight); - BuriedForkDescPushBack(softforks, "fortcanningspring", consensusParams.FortCanningSpringHeight); - BuriedForkDescPushBack(softforks, "fortcanninggreatworld", consensusParams.FortCanningGreatWorldHeight); - BuriedForkDescPushBack(softforks, "fortcanningepilogue", consensusParams.FortCanningEpilogueHeight); - BuriedForkDescPushBack(softforks, "grandcentral", consensusParams.GrandCentralHeight); - BuriedForkDescPushBack(softforks, "grandcentralepilogue", consensusParams.GrandCentralEpilogueHeight); - BuriedForkDescPushBack(softforks, "nextnetworkupgrade", consensusParams.NextNetworkUpgradeHeight); + BuriedForkDescPushBack(softforks, "amk", consensusParams.DF1AMKHeight); + BuriedForkDescPushBack(softforks, "bayfront", consensusParams.DF2BayfrontHeight); + BuriedForkDescPushBack(softforks, "clarkequay", consensusParams.DF5ClarkeQuayHeight); + BuriedForkDescPushBack(softforks, "dakota", consensusParams.DF6DakotaHeight); + BuriedForkDescPushBack(softforks, "dakotacrescent", consensusParams.DF7DakotaCrescentHeight); + BuriedForkDescPushBack(softforks, "eunos", consensusParams.DF8EunosHeight); + BuriedForkDescPushBack(softforks, "eunospaya", consensusParams.DF10EunosPayaHeight); + BuriedForkDescPushBack(softforks, "fortcanning", consensusParams.DF11FortCanningHeight); + BuriedForkDescPushBack(softforks, "fortcanningmuseum", consensusParams.DF12FortCanningMuseumHeight); + BuriedForkDescPushBack(softforks, "fortcanningpark", consensusParams.DF13FortCanningParkHeight); + BuriedForkDescPushBack(softforks, "fortcanninghill", consensusParams.DF14FortCanningHillHeight); + BuriedForkDescPushBack(softforks, "fortcanningroad", consensusParams.DF15FortCanningRoadHeight); + BuriedForkDescPushBack(softforks, "fortcanningcrunch", consensusParams.DF16FortCanningCrunchHeight); + BuriedForkDescPushBack(softforks, "fortcanningspring", consensusParams.DF17FortCanningSpringHeight); + BuriedForkDescPushBack(softforks, "fortcanninggreatworld", consensusParams.DF18FortCanningGreatWorldHeight); + BuriedForkDescPushBack(softforks, "fortcanningepilogue", consensusParams.DF19FortCanningEpilogueHeight); + BuriedForkDescPushBack(softforks, "grandcentral", consensusParams.DF20GrandCentralHeight); + BuriedForkDescPushBack(softforks, "grandcentralepilogue", consensusParams.DF21GrandCentralEpilogueHeight); + BuriedForkDescPushBack(softforks, "nextnetworkupgrade", consensusParams.DF22NextHeight); BIP9SoftForkDescPushBack(softforks, "testdummy", consensusParams, Consensus::DEPLOYMENT_TESTDUMMY); obj.pushKV("softforks", softforks); diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 5c205a8ef9..0d84caedac 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -32,7 +32,7 @@ double GetDifficulty(const CBlockIndex* blockindex); void RPCNotifyBlockChange(bool ibd, const CBlockIndex *); /** Block description to JSON */ -UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails = false) LOCKS_EXCLUDED(cs_main); +UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails = false, bool xVmDetails = false) LOCKS_EXCLUDED(cs_main); /** Mempool information to JSON */ UniValue MempoolInfoToJSON(const CTxMemPool& pool); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c23d4c94d9..984463ecee 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -303,7 +303,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request) // Get block times const auto subNodesBlockTime = pcustomcsview->GetBlockTimes(nodePtr->operatorAuthAddress, height, nodePtr->creationHeight, *timelock); - if (height >= Params().GetConsensus().EunosPayaHeight) { + if (height >= Params().GetConsensus().DF10EunosPayaHeight) { const uint8_t loops = *timelock == CMasternode::TENYEAR ? 4 : *timelock == CMasternode::FIVEYEAR ? 3 : 2; UniValue multipliers(UniValue::VARR); for (uint8_t i{0}; i < loops; ++i) { diff --git a/src/test/applytx_tests.cpp b/src/test/applytx_tests.cpp index abf2c30328..0f08bbb847 100644 --- a/src/test/applytx_tests.cpp +++ b/src/test/applytx_tests.cpp @@ -82,7 +82,7 @@ CScript CreateMetaA2A(CAccountToAccountMessage const & msg) { BOOST_AUTO_TEST_CASE(apply_a2a_neg) { Consensus::Params amkCheated = Params().GetConsensus(); - amkCheated.AMKHeight = 0; + amkCheated.DF1AMKHeight = 0; CCustomCSView mnview(*pcustomcsview); diff --git a/src/test/dip1fork_tests.cpp b/src/test/dip1fork_tests.cpp index 00cb1d2f76..219f3340bd 100644 --- a/src/test/dip1fork_tests.cpp +++ b/src/test/dip1fork_tests.cpp @@ -12,7 +12,7 @@ BOOST_AUTO_TEST_CASE(blockreward_dfip1) { const CScript SCRIPT_PUB{CScript(OP_TRUE)}; const Consensus::Params & consensus = Params().GetConsensus(); - auto height = consensus.AMKHeight; + auto height = consensus.DF1AMKHeight; CMutableTransaction coinbaseTx{}; @@ -83,9 +83,9 @@ BOOST_AUTO_TEST_CASE(blockreward_dfip8) { const CScript SCRIPT_PUB{CScript(OP_TRUE)}; Consensus::Params consensus = Params().GetConsensus(); - consensus.EunosHeight = 10000000; - consensus.GrandCentralHeight = 10000001; - auto height = consensus.EunosHeight; + consensus.DF8EunosHeight = 10000000; + consensus.DF20GrandCentralHeight = 10000001; + auto height = consensus.DF8EunosHeight; CAmount blockReward = GetBlockSubsidy(height, consensus); CMutableTransaction coinbaseTx{}; @@ -147,11 +147,11 @@ BOOST_AUTO_TEST_CASE(blockreward_dfip8) BOOST_AUTO_TEST_CASE(blockreward_dfip8_reductions) { Consensus::Params consensus = Params().GetConsensus(); - consensus.EunosHeight = 10000000; + consensus.DF8EunosHeight = 10000000; auto GetReductionsHeight = [consensus](const uint32_t reductions) { - return consensus.EunosHeight + (reductions * Params().GetConsensus().emissionReductionPeriod); + return consensus.DF8EunosHeight + (reductions * Params().GetConsensus().emissionReductionPeriod); }; // Test coinbase rewards reduction 0 diff --git a/src/test/liquidity_tests.cpp b/src/test/liquidity_tests.cpp index f242965afd..2fc7065838 100644 --- a/src/test/liquidity_tests.cpp +++ b/src/test/liquidity_tests.cpp @@ -79,7 +79,7 @@ struct CLiquidityRewardsTest : public TestingSetup { CLiquidityRewardsTest() { - const_cast(Params().GetConsensus().FortCanningHillHeight) = 7; + const_cast(Params().GetConsensus().DF14FortCanningHillHeight) = 7; } }; @@ -454,7 +454,7 @@ BOOST_AUTO_TEST_CASE(owner_rewards) }); // new calculation - const_cast(Params().GetConsensus().BayfrontGardensHeight) = 6; + const_cast(Params().GetConsensus().DF4BayfrontGardensHeight) = 6; auto newRewardCalculation = [](CAmount liquidity, const CPoolPair& pool) -> CAmount { return COIN / 2880 * pool.rewardPct / COIN * liquidity / pool.totalLiquidity; @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(owner_rewards) }; mnview.CalculatePoolRewards(idPool, onLiquidity, 1, 10, [&](RewardType type, CTokenAmount amount, uint32_t height) { - if (height >= static_cast(Params().GetConsensus().BayfrontGardensHeight)) { + if (height >= static_cast(Params().GetConsensus().DF4BayfrontGardensHeight)) { if (type == RewardType::Pool) { for (const auto& reward : pool.rewards.balances) { auto providerReward = static_cast((arith_uint256(reward.second) * arith_uint256(onLiquidity()) / arith_uint256(pool.totalLiquidity)).GetLow64()); diff --git a/src/test/loan_tests.cpp b/src/test/loan_tests.cpp index aea77955b5..1e777cf27d 100644 --- a/src/test/loan_tests.cpp +++ b/src/test/loan_tests.cpp @@ -314,7 +314,7 @@ BOOST_AUTO_TEST_CASE(loan_interest_rate) BOOST_AUTO_TEST_CASE(loan_total_interest_calculation) { // Activate negative interest rate - const_cast(Params().GetConsensus().FortCanningGreatWorldHeight) = 1; + const_cast(Params().GetConsensus().DF18FortCanningGreatWorldHeight) = 1; CCustomCSView mnview(*pcustomcsview); diff --git a/src/validation.cpp b/src/validation.cpp index dff65fcef6..2ec9fa4b89 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1170,10 +1170,10 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) if (Params().NetworkIDString() != CBaseChainParams::REGTEST || (Params().NetworkIDString() == CBaseChainParams::REGTEST && gArgs.GetBoolArg("-subsidytest", false))) { - if (nHeight >= consensusParams.EunosHeight) + if (nHeight >= consensusParams.DF8EunosHeight) { nSubsidy = consensusParams.newBaseBlockSubsidy; - const size_t reductions = (nHeight - consensusParams.EunosHeight) / consensusParams.emissionReductionPeriod; + const size_t reductions = (nHeight - consensusParams.DF8EunosHeight) / consensusParams.emissionReductionPeriod; // See if we already have this reduction calculated and return if found. if (subsidyReductions.find(reductions) != subsidyReductions.end()) @@ -1808,7 +1808,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI mnview.SetTeam(finMsg.currentTeam); - if (pindex->nHeight >= Params().GetConsensus().AMKHeight) { + if (pindex->nHeight >= Params().GetConsensus().DF1AMKHeight) { mnview.AddCommunityBalance(CommunityAccountType::AnchorReward, tx.GetValueOut()); // or just 'Set..' LogPrint(BCLog::ANCHORING, "%s: post AMK logic, add community balance %d\n", __func__, tx.GetValueOut()); } @@ -1864,7 +1864,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI } // one time downgrade to revert CInterestRateV2 structure - if (pindex->nHeight == Params().GetConsensus().FortCanningHillHeight) { + if (pindex->nHeight == Params().GetConsensus().DF14FortCanningHillHeight) { auto time = GetTimeMillis(); LogPrintf("Interest rate reverting ...\n"); mnview.RevertInterestRateToV1(); @@ -1872,7 +1872,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI } // one time downgrade to revert CInterestRateV3 structure - if (pindex->nHeight == Params().GetConsensus().FortCanningGreatWorldHeight) { + if (pindex->nHeight == Params().GetConsensus().DF18FortCanningGreatWorldHeight) { auto time = GetTimeMillis(); LogPrintf("Interest rate reverting ...\n"); mnview.RevertInterestRateToV2(); @@ -1886,7 +1886,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI if (!fIsFakeNet) { mnview.DecrementMintedBy(*nodeId); - if (pindex->nHeight >= Params().GetConsensus().EunosPayaHeight) { + if (pindex->nHeight >= Params().GetConsensus().DF10EunosPayaHeight) { mnview.EraseSubNodesLastBlockTime(*nodeId, static_cast(pindex->nHeight)); } else { mnview.EraseMasternodeLastBlockTime(*nodeId, static_cast(pindex->nHeight)); @@ -2051,216 +2051,208 @@ Res ApplyGeneralCoinbaseTx(CCustomCSView & mnview, CTransaction const & tx, int if (cbValues.size() != 1 || cbValues.begin()->first != DCT_ID{0}) return Res::ErrDbg("bad-cb-wrong-tokens", "coinbase should pay only Defi coins"); + auto finalCheckAndReturn = [&]() { + if (cbValues.at(DCT_ID{0}) > blockReward + nFees) + return Res::ErrDbg("bad-cb-amount", "coinbase pays too much (actual=%d vs limit=%d)", cbValues.at(DCT_ID{0}), blockReward + nFees); + return Res::Ok(); + }; - if (height >= consensus.AMKHeight) - { - CAmount foundationReward{0}; - if (height >= consensus.GrandCentralHeight) - { - // no foundation utxo reward check anymore - } - else if (height >= consensus.EunosHeight) - { - foundationReward = CalculateCoinbaseReward(blockReward, consensus.dist.community); - } - else if (!consensus.foundationShareScript.empty() && consensus.foundationShareDFIP1) - { - foundationReward = blockReward * consensus.foundationShareDFIP1 / COIN; - } - - if (foundationReward) - { - bool foundationsRewardfound = false; - for (auto& txout : tx.vout) - { - if (txout.scriptPubKey == consensus.foundationShareScript) - { - if (txout.nValue < foundationReward) - { - return Res::ErrDbg("bad-cb-foundation-reward", "coinbase doesn't pay proper foundation reward! (actual=%d vs expected=%d", txout.nValue, foundationReward); - } + auto logAccountChange = [](const CTransaction& tx, const CAmount subsidy, const std::string account) { + LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", + tx.GetHash().ToString(), + account, + (CBalances{{{{0}, subsidy}}}.ToString())); + }; - foundationsRewardfound = true; - break; - } - } + auto isUnusedEmissionFundEnabled = [](const ATTRIBUTES& attrs) { + CDataStructureV0 k{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund}; + return attrs.GetValue(k, false); + }; - if (!foundationsRewardfound) - { - return Res::ErrDbg("bad-cb-foundation-reward", "coinbase doesn't pay foundation reward!"); - } - } + auto isGovernanceEnabled = [](const ATTRIBUTES& attrs) { + CDataStructureV0 k{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + return attrs.GetValue(k, false); + }; - // count and subtract for non-UTXO community rewards - CAmount nonUtxoTotal = 0; - if (height >= consensus.EunosHeight) - { - CAmount subsidy; - for (const auto& kv : consensus.newNonUTXOSubsidies) - { - if (kv.first == CommunityAccountType::CommunityDevFunds) { - if (height < consensus.GrandCentralHeight) { - continue; - } - } + if (height < consensus.DF1AMKHeight) { + return finalCheckAndReturn(); + } - subsidy = CalculateCoinbaseReward(blockReward, kv.second); + // TODO(legacy-cleanup): Clean up the rest of the method with proper structures + // and a more comprehensible flow - Res res = Res::Ok(); + CAmount foundationReward{0}; + if (height >= consensus.DF20GrandCentralHeight) { + // no foundation utxo reward check anymore + } + else if (height >= consensus.DF8EunosHeight) { + foundationReward = CalculateCoinbaseReward(blockReward, consensus.dist.community); + } + else if (!consensus.foundationShareScript.empty() && consensus.foundationShareDFIP1) { + foundationReward = blockReward * consensus.foundationShareDFIP1 / COIN; + } - // Loan below FC and Options are unused and all go to Unallocated (burnt) pot. - if ((height < consensus.FortCanningHeight && kv.first == CommunityAccountType::Loan) || - (height < consensus.GrandCentralHeight && kv.first == CommunityAccountType::Options)) - { - res = mnview.AddCommunityBalance(CommunityAccountType::Unallocated, subsidy); - if (res) - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", tx.GetHash().ToString(), GetCommunityAccountName(CommunityAccountType::Unallocated), (CBalances{{{{0}, subsidy}}}.ToString())); + if (foundationReward) { + bool foundationsRewardfound = false; + for (auto& txout : tx.vout) { + if (txout.scriptPubKey == consensus.foundationShareScript) { + if (txout.nValue < foundationReward) { + return Res::ErrDbg("bad-cb-foundation-reward", + "coinbase doesn't pay proper foundation reward! (actual=%d vs expected=%d", txout.nValue, foundationReward); } - else - { - if (height >= consensus.GrandCentralHeight) - { - const auto attributes = mnview.GetAttributes(); - assert(attributes); - - if (kv.first == CommunityAccountType::CommunityDevFunds) { - CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + foundationsRewardfound = true; + break; + } + } - if (!attributes->GetValue(enabledKey, false)) - { - res = mnview.AddBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", - tx.GetHash().ToString(), ScriptToString(consensus.foundationShareScript), - (CBalances{{{{0}, subsidy}}}.ToString())); - nonUtxoTotal += subsidy; + if (!foundationsRewardfound) { + return Res::ErrDbg("bad-cb-foundation-reward", "coinbase doesn't pay foundation reward!"); + } + } - continue; - } - } else if (kv.first == CommunityAccountType::Unallocated || kv.first == CommunityAccountType::Options) { - CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund}; - - if (attributes->GetValue(enabledKey, false)) { - res = mnview.AddBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy}); - if (res) { - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", - tx.GetHash().ToString(), ScriptToString(consensus.unusedEmission), - (CBalances{{{{0}, subsidy}}}.ToString())); - } - } else { - // Previous behaviour was for Options and Unallocated to go to Unallocated - res = mnview.AddCommunityBalance(CommunityAccountType::Unallocated, subsidy); - if (res) - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", tx.GetHash().ToString(), GetCommunityAccountName(CommunityAccountType::Unallocated), (CBalances{{{{0}, subsidy}}}.ToString())); - } + // count and subtract for non-UTXO community rewards + CAmount nonUtxoTotal = 0; - nonUtxoTotal += subsidy; + if (height < consensus.DF8EunosHeight) { + for (const auto& [accountType, accountVal] : consensus.nonUtxoBlockSubsidies) { + CAmount subsidy = blockReward * accountVal / COIN; + Res res = mnview.AddCommunityBalance(accountType, subsidy); + if (!res.ok) { + return Res::ErrDbg("bad-cb-community-rewards", "can't take non-UTXO community share from coinbase"); + } else { + logAccountChange(tx, subsidy, GetCommunityAccountName(accountType)); + } + nonUtxoTotal += subsidy; + } + blockReward -= nonUtxoTotal; + return finalCheckAndReturn(); + } - continue; - } - } + CAmount subsidy; + for (const auto& [accountType, accountVal] : consensus.newNonUTXOSubsidies) { + if (accountType == CommunityAccountType::CommunityDevFunds) { + if (height < consensus.DF20GrandCentralHeight) { + continue; + } + } - res = mnview.AddCommunityBalance(kv.first, subsidy); - if (res) - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", tx.GetHash().ToString(), GetCommunityAccountName(kv.first), (CBalances{{{{0}, subsidy}}}.ToString())); - } + subsidy = CalculateCoinbaseReward(blockReward, accountVal); + Res res = Res::Ok(); - if (!res.ok) - { - return Res::ErrDbg("bad-cb-community-rewards", "Cannot take non-UTXO community share from coinbase"); + // Loan below FC and Options are unused and all go to Unallocated (burnt) pot. + if ((height < consensus.DF11FortCanningHeight && accountType == CommunityAccountType::Loan) || + (height < consensus.DF20GrandCentralHeight && accountType == CommunityAccountType::Options)) { + res = mnview.AddCommunityBalance(CommunityAccountType::Unallocated, subsidy); + if (res) { + logAccountChange(tx, subsidy, GetCommunityAccountName(CommunityAccountType::Unallocated)); + } + } else { + if (height >= consensus.DF20GrandCentralHeight) { + const auto attributes = mnview.GetAttributes(); + assert(attributes); + if (accountType == CommunityAccountType::CommunityDevFunds) { + if (!isGovernanceEnabled(*attributes)) { + continue; + } else { + res = mnview.AddBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); + // TODO: Result check missed; check full sync and add checks + logAccountChange(tx, subsidy, ScriptToString(consensus.foundationShareScript)); + nonUtxoTotal += subsidy; + continue; + } + } else if (accountType == CommunityAccountType::Unallocated || accountType == CommunityAccountType::Options) { + if (isUnusedEmissionFundEnabled(*attributes)) { + res = mnview.AddBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy}); + if (res) { logAccountChange(tx, subsidy, ScriptToString(consensus.unusedEmission)); } + } else { + // Previous behaviour was for Options and Unallocated to go to Unallocated + res = mnview.AddCommunityBalance(CommunityAccountType::Unallocated, subsidy); + if (res) { logAccountChange(tx, subsidy, GetCommunityAccountName(CommunityAccountType::Unallocated)); } + } + nonUtxoTotal += subsidy; + continue; } + } - nonUtxoTotal += subsidy; + res = mnview.AddCommunityBalance(accountType, subsidy); + if (res) { + logAccountChange(tx, subsidy, GetCommunityAccountName(accountType)); } } - else - { - for (const auto& kv : consensus.nonUtxoBlockSubsidies) { - CAmount subsidy = blockReward * kv.second / COIN; - Res res = mnview.AddCommunityBalance(kv.first, subsidy); - if (!res.ok) { - return Res::ErrDbg("bad-cb-community-rewards", "can't take non-UTXO community share from coinbase"); - } else { - LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: hash=%s fund=%s change=%s\n", tx.GetHash().ToString(), GetCommunityAccountName(kv.first), (CBalances{{{{0}, subsidy}}}.ToString())); - } - nonUtxoTotal += subsidy; - } + + if (!res.ok) { + return Res::ErrDbg("bad-cb-community-rewards", "Cannot take non-UTXO community share from coinbase"); } - blockReward -= nonUtxoTotal; + nonUtxoTotal += subsidy; } - // pre-AMK logic, compatible after prev blockReward mod: - if (cbValues.at(DCT_ID{0}) > blockReward + nFees) - return Res::ErrDbg("bad-cb-amount", "coinbase pays too much (actual=%d vs limit=%d)", cbValues.at(DCT_ID{0}), blockReward + nFees); - - return Res::Ok(); + blockReward -= nonUtxoTotal; + return finalCheckAndReturn(); } void ReverseGeneralCoinbaseTx(CCustomCSView & mnview, int height, const Consensus::Params& consensus) { - CAmount blockReward = GetBlockSubsidy(height, Params().GetConsensus()); + CAmount blockReward = GetBlockSubsidy(height, consensus); + + auto isUnusedEmissionFundEnabled = [](const ATTRIBUTES& attrs) { + CDataStructureV0 k{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund}; + return attrs.GetValue(k, false); + }; - if (height >= Params().GetConsensus().AMKHeight) - { - if (height >= Params().GetConsensus().EunosHeight) - { - for (const auto& kv : Params().GetConsensus().newNonUTXOSubsidies) - { - if (kv.first == CommunityAccountType::CommunityDevFunds) { - if (height < Params().GetConsensus().GrandCentralHeight) { - continue; - } - } + auto isGovernanceEnabled = [](const ATTRIBUTES& attrs) { + CDataStructureV0 k{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + return attrs.GetValue(k, false); + }; - CAmount subsidy = CalculateCoinbaseReward(blockReward, kv.second); + if (height < consensus.DF1AMKHeight) { + return; + } - // Remove Loan and Options balances from Unallocated - if ((height < Params().GetConsensus().FortCanningHeight && kv.first == CommunityAccountType::Loan) || - (height < consensus.GrandCentralHeight && kv.first == CommunityAccountType::Options)) - { - mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); - } - else - { - if (height >= consensus.GrandCentralHeight) - { - const auto attributes = mnview.GetAttributes(); - assert(attributes); + // TODO(legacy-cleanup): Use proper structures - if (kv.first == CommunityAccountType::CommunityDevFunds) { - CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled}; + if (height < consensus.DF8EunosHeight) { + for (const auto& [accountType, accountVal] : consensus.nonUtxoBlockSubsidies) { + CAmount subsidy = blockReward * accountVal / COIN; + mnview.SubCommunityBalance(accountType, subsidy); + } + return; + } - if (!attributes->GetValue(enabledKey, false)) - { - mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); + for (const auto& [accountType, accountVal] : consensus.newNonUTXOSubsidies) { + if (accountType == CommunityAccountType::CommunityDevFunds) { + if (height < consensus.DF20GrandCentralHeight) { + continue; + } + } - continue; - } - } else if (kv.first == CommunityAccountType::Unallocated || kv.first == CommunityAccountType::Options) { - CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund}; + CAmount subsidy = CalculateCoinbaseReward(blockReward, accountVal); - if (attributes->GetValue(enabledKey, false)) { - mnview.SubBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy}); - } else { - mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); - } + // Remove Loan and Options balances from Unallocated + if ((height < consensus.DF11FortCanningHeight && accountType == CommunityAccountType::Loan) || + (height < consensus.DF20GrandCentralHeight && accountType == CommunityAccountType::Options)) { + mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); + } else { + if (height >= consensus.DF20GrandCentralHeight) { + const auto attributes = mnview.GetAttributes(); + assert(attributes); - continue; - } + if (accountType == CommunityAccountType::CommunityDevFunds) { + if (!isGovernanceEnabled(*attributes)) { + mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy}); + continue; } - - mnview.SubCommunityBalance(kv.first, subsidy); + } else if (accountType == CommunityAccountType::Unallocated || accountType == CommunityAccountType::Options) { + if (isUnusedEmissionFundEnabled(*attributes)) { + mnview.SubBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy}); + } else { + mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy); + } + continue; } } - } - else - { - for (const auto& kv : Params().GetConsensus().nonUtxoBlockSubsidies) - { - CAmount subsidy = blockReward * kv.second / COIN; - mnview.SubCommunityBalance(kv.first, subsidy); - } + mnview.SubCommunityBalance(accountType, subsidy); } } } @@ -2407,14 +2399,14 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl // one time upgrade to convert the old CInterestRate data structure // we don't neeed it in undos - if (pindex->nHeight == chainparams.GetConsensus().FortCanningHillHeight) { + if (pindex->nHeight == chainparams.GetConsensus().DF14FortCanningHillHeight) { auto time = GetTimeMillis(); LogPrintf("Interest rate migration ...\n"); mnview.MigrateInterestRateToV2(mnview,(uint32_t)pindex->nHeight); LogPrint(BCLog::BENCH, " - Interest rate migration took: %dms\n", GetTimeMillis() - time); } - if (pindex->nHeight == chainparams.GetConsensus().FortCanningGreatWorldHeight) { + if (pindex->nHeight == chainparams.GetConsensus().DF18FortCanningGreatWorldHeight) { auto time = GetTimeMillis(); LogPrintf("Interest rate migration ...\n"); mnview.MigrateInterestRateToV3(mnview, static_cast(pindex->nHeight)); @@ -2681,7 +2673,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl LogApplyCustomTx(tx, applyCustomTxTime); if (!res.ok && (res.code & CustomTxErrCodes::Fatal)) { - if (pindex->nHeight >= chainparams.GetConsensus().EunosHeight) { + if (pindex->nHeight >= chainparams.GetConsensus().DF8EunosHeight) { return state.Invalid(ValidationInvalidReason::CONSENSUS, error("%s: ApplyCustomTx on %s failed with %s", __func__, tx.GetHash().ToString(), res.msg), REJECT_CUSTOMTX, "bad-custom-tx"); @@ -2826,8 +2818,8 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl return accountsView.Flush(); // keeps compatibility // validates account changes as well - if (pindex->nHeight >= chainparams.GetConsensus().EunosHeight - && pindex->nHeight < chainparams.GetConsensus().EunosKampungHeight) { + if (pindex->nHeight >= chainparams.GetConsensus().DF8EunosHeight + && pindex->nHeight < chainparams.GetConsensus().DF9EunosKampungHeight) { bool mutated; uint256 hashMerkleRoot2 = BlockMerkleRoot(block, &mutated); if (block.hashMerkleRoot != Hash2(hashMerkleRoot2, accountsView.MerkleRoot())) { @@ -2874,9 +2866,9 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl mnview.IncrementMintedBy(*nodeId); // Store block staker height for use in coinage - if (pindex->nHeight >= Params().GetConsensus().EunosPayaHeight) { + if (pindex->nHeight >= Params().GetConsensus().DF10EunosPayaHeight) { mnview.SetSubNodesBlockTime(minterKey, static_cast(pindex->nHeight), ctxState.subNode, pindex->GetBlockTime()); - } else if (pindex->nHeight >= Params().GetConsensus().DakotaCrescentHeight) { + } else if (pindex->nHeight >= Params().GetConsensus().DF7DakotaCrescentHeight) { mnview.SetMasternodeLastBlockTime(minterKey, static_cast(pindex->nHeight), pindex->GetBlockTime()); } } @@ -2908,7 +2900,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl LogPrint(BCLog::BENCH, " - Pruning undo data takes: %dms\n", GetTimeMillis() - time); } // we can safety delete old interest keys - if (it->first > chainparams.GetConsensus().FortCanningHillHeight) { + if (it->first > chainparams.GetConsensus().DF14FortCanningHillHeight) { CCustomCSView view(mnview); mnview.ForEachVaultInterest([&](const CVaultId& vaultId, DCT_ID tokenId, CInterestRate) { view.EraseBy(std::make_pair(vaultId, tokenId)); @@ -3383,7 +3375,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp UpdateTip(pindexNew, chainparams); // Update teams every anchoringTeamChange number of blocks - if (pindexNew->nHeight >= Params().GetConsensus().DakotaHeight && + if (pindexNew->nHeight >= Params().GetConsensus().DF6DakotaHeight && pindexNew->nHeight % Params().GetConsensus().mn.anchoringTeamChange == 0) { pcustomcsview->CalcAnchoringTeams(blockConnecting.stakeModifier, pindexNew); @@ -3556,7 +3548,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar fContinue = false; if (state.GetRejectReason() == "high-hash" || (pindexConnect == pindexMostWork - && pindexConnect->nHeight >= chainparams.GetConsensus().FortCanningParkHeight + && pindexConnect->nHeight >= chainparams.GetConsensus().DF13FortCanningParkHeight && state.GetRejectCode() == REJECT_CUSTOMTX)) { UpdateMempoolForReorg(disconnectpool, false); return false; @@ -3579,7 +3571,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar } } if (pindexConnect == pindexMostWork - && (pindexConnect->nHeight < chainparams.GetConsensus().EunosHeight + && (pindexConnect->nHeight < chainparams.GetConsensus().DF8EunosHeight || state.GetRejectCode() == REJECT_CUSTOMTX)) { // NOTE: Invalidate blocks back to last checkpoint auto &checkpoints = chainparams.Checkpoints().mapCheckpoints; @@ -4153,8 +4145,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P // Check the merkle root. // block merkle root is delayed to ConnectBlock to ensure account changes - if (fCheckMerkleRoot && (height < consensusParams.EunosHeight - || height >= consensusParams.EunosKampungHeight)) { + if (fCheckMerkleRoot && (height < consensusParams.DF8EunosHeight + || height >= consensusParams.DF9EunosKampungHeight)) { bool mutated; uint256 hashMerkleRoot2 = BlockMerkleRoot(block, &mutated); if (block.hashMerkleRoot != hashMerkleRoot2) @@ -4186,9 +4178,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P TBytes dummy; for (unsigned int i = 1; i < block.vtx.size(); i++) { if (block.vtx[i]->IsCoinBase() && - !IsAnchorRewardTx(*block.vtx[i], dummy, height >= consensusParams.FortCanningHeight) && - !IsAnchorRewardTxPlus(*block.vtx[i], dummy, height >= consensusParams.FortCanningHeight) && - !IsTokenSplitTx(*block.vtx[i], dummy, height >= consensusParams.FortCanningCrunchHeight)) + !IsAnchorRewardTx(*block.vtx[i], dummy, height >= consensusParams.DF11FortCanningHeight) && + !IsAnchorRewardTxPlus(*block.vtx[i], dummy, height >= consensusParams.DF11FortCanningHeight) && + !IsTokenSplitTx(*block.vtx[i], dummy, height >= consensusParams.DF16FortCanningCrunchHeight)) return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-cb-multiple", "more than one coinbase"); } } @@ -4202,7 +4194,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), state.GetDebugMessage())); } - if (!fIsFakeNet && fCheckPOS && height >= consensusParams.FortCanningHeight) { + if (!fIsFakeNet && fCheckPOS && height >= consensusParams.DF11FortCanningHeight) { CKeyID minter; // this is safe cause pos::ContextualCheckProofOfStake checked block.ExtractMinterKey(minter); @@ -4210,7 +4202,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P auto node = pcustomcsview->GetMasternode(*nodeId); if (node->rewardAddressType != 0) { CTxDestination destination; - if (height < consensusParams.NextNetworkUpgradeHeight) { + if (height < consensusParams.DF22NextHeight) { destination = FromOrDefaultKeyIDToDestination(node->rewardAddress, FromOrDefaultDestinationTypeToKeyType(node->rewardAddressType), KeyType::MNOwnerKeyType); } else { destination = FromOrDefaultKeyIDToDestination(node->rewardAddress, FromOrDefaultDestinationTypeToKeyType(node->rewardAddressType), KeyType::MNRewardKeyType); @@ -4312,7 +4304,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta assert(pindexPrev != nullptr); const int nHeight = pindexPrev->nHeight + 1; - if (nHeight >= params.GetConsensus().FortCanningMuseumHeight && static_cast(nHeight) != block.deprecatedHeight) { + if (nHeight >= params.GetConsensus().DF12FortCanningMuseumHeight && static_cast(nHeight) != block.deprecatedHeight) { return state.Invalid(ValidationInvalidReason::BLOCK_INVALID_HEADER, false, REJECT_INVALID, "incorrect-height", "incorrect height set in block header"); } @@ -4334,7 +4326,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta return state.Invalid(ValidationInvalidReason::BLOCK_INVALID_HEADER, false, REJECT_INVALID, "time-too-old", strprintf("block's timestamp is too early. Block time: %d Min time: %d", block.GetBlockTime(), pindexPrev->GetMedianTimePast())); // Check timestamp - if (Params().NetworkIDString() != CBaseChainParams::REGTEST && nHeight >= consensusParams.EunosPayaHeight) { + if (Params().NetworkIDString() != CBaseChainParams::REGTEST && nHeight >= consensusParams.DF10EunosPayaHeight) { if (block.GetBlockTime() > GetTime() + MAX_FUTURE_BLOCK_TIME_EUNOSPAYA) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", strprintf("block timestamp too far in the future. Block time: %d Max time: %d", block.GetBlockTime(), GetTime() + MAX_FUTURE_BLOCK_TIME_EUNOSPAYA)); } @@ -4342,7 +4334,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future"); - if (nHeight >= consensusParams.DakotaCrescentHeight) { + if (nHeight >= consensusParams.DF7DakotaCrescentHeight) { if (block.GetBlockTime() > GetTime() + MAX_FUTURE_BLOCK_TIME_DAKOTACRESCENT) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", strprintf("block timestamp too far in the future. Block time: %d Max time: %d", block.GetBlockTime(), GetTime() + MAX_FUTURE_BLOCK_TIME_DAKOTACRESCENT)); } @@ -4732,7 +4724,7 @@ void ProcessAuthsIfTipChanged(CBlockIndex const * oldTip, CBlockIndex const * ti } // Select a block further back to avoid Anchor too new error. - if (pindex->nHeight >= consensus.FortCanningHeight) { + if (pindex->nHeight >= consensus.DF11FortCanningHeight) { timeDepth += consensus.mn.anchoringAdditionalTimeDepth; while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > pindex->nTime) { --anchorHeight; @@ -4856,7 +4848,7 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptrnHeight >= chainparams.GetConsensus().DakotaHeight) { + if (tip->nHeight >= chainparams.GetConsensus().DF6DakotaHeight) { panchors->CheckPendingAnchors(); } } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ca748f1b5d..cf25e02c32 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5099,5 +5099,5 @@ CKey GetWalletsKey(const CKeyID & keyid) int32_t GetTransactionVersion(int height) { - return height >= Params().GetConsensus().AMKHeight ? CTransaction::TOKENS_MIN_VERSION : CTransaction::TX_VERSION_2; + return height >= Params().GetConsensus().DF1AMKHeight ? CTransaction::TOKENS_MIN_VERSION : CTransaction::TX_VERSION_2; }