From 30536b2e6f5f888bbb95a213da0b73d7415b7821 Mon Sep 17 00:00:00 2001
From: Alexander Block <ablock84@gmail.com>
Date: Thu, 22 Nov 2018 17:20:05 +0100
Subject: [PATCH 1/4] Properly initialize confirmedHash in
 CSimplifiedMNListEntry

---
 src/evo/simplifiedmns.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp
index 26d26eb47ccd..b630e06d318e 100644
--- a/src/evo/simplifiedmns.cpp
+++ b/src/evo/simplifiedmns.cpp
@@ -15,6 +15,7 @@
 
 CSimplifiedMNListEntry::CSimplifiedMNListEntry(const CDeterministicMN& dmn) :
     proRegTxHash(dmn.proTxHash),
+    confirmedHash(dmn.pdmnState->confirmedHash),
     service(dmn.pdmnState->addr),
     pubKeyOperator(dmn.pdmnState->pubKeyOperator),
     keyIDVoting(dmn.pdmnState->keyIDVoting),

From 9c92446709c4b912e9aa012e19c6936c1212400f Mon Sep 17 00:00:00 2001
From: Alexander Block <ablock84@gmail.com>
Date: Thu, 22 Nov 2018 17:21:48 +0100
Subject: [PATCH 2/4] Add consensus params for temporary hard-fork on testnet

This hard-fork is required on testnet as we have to fix a few consensus
bugs in DIP3/DIP4. It will also be required to introduce LLMQ commitments
to testnet.
---
 src/chainparams.cpp    | 5 +++++
 src/consensus/params.h | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 7af989cf72d4..4f58a236f8d5 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -378,6 +378,11 @@ class CTestNetParams : public CChainParams {
         // Testnet Dash BIP44 coin type is '1' (All coin's testnet default)
         nExtCoinType = 1;
 
+        // This is temporary until we reset testnet for retesting of the full DIP3 deployment
+        consensus.nTemporaryTestnetForkDIP3Height = 264000;
+        consensus.nTemporaryTestnetForkHeight = 271000;
+        consensus.nTemporaryTestnetForkDIP3BlockHash.SetHex("00000048e6e71d4bd90e7c456dcb94683ae832fcad13e1760d8283f7e89f332f");
+
         fMiningRequiresPeers = true;
         fDefaultConsistencyChecks = false;
         fRequireStandard = false;
diff --git a/src/consensus/params.h b/src/consensus/params.h
index b59491cf3689..f5131d2b6caa 100644
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -95,6 +95,11 @@ struct Params {
     int nMinimumDifficultyBlocks{0};
     int nHighSubsidyBlocks{0};
     int nHighSubsidyFactor{1};
+
+    // This is temporary until we reset testnet for retesting of the full DIP3 deployment
+    int nTemporaryTestnetForkDIP3Height{0};
+    uint256 nTemporaryTestnetForkDIP3BlockHash;
+    int nTemporaryTestnetForkHeight{0};
 };
 } // namespace Consensus
 

From 09c5b2b08bfd8f4635171b3d9676330fbbaae99c Mon Sep 17 00:00:00 2001
From: Alexander Block <ablock84@gmail.com>
Date: Thu, 22 Nov 2018 17:23:22 +0100
Subject: [PATCH 3/4] Add temporary fork-logic for testnet, which sets
 confirmedHash to null

...before fork activation. Otherwise we'd invalidate all DIP3 blocks on
testnet.
---
 src/evo/cbtx.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp
index 43d3bcb4f9fe..a21fe7db6b0f 100644
--- a/src/evo/cbtx.cpp
+++ b/src/evo/cbtx.cpp
@@ -7,6 +7,7 @@
 #include "simplifiedmns.h"
 #include "specialtx.h"
 
+#include "chainparams.h"
 #include "univalue.h"
 #include "validation.h"
 
@@ -71,6 +72,19 @@ bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev
     }
 
     CSimplifiedMNList sml(tmpMNList);
+
+    // BEGIN TEMPORARY CODE
+    const auto& consensus = Params().GetConsensus();
+    if (consensus.nTemporaryTestnetForkHeight != 0 &&
+        pindexPrev->nHeight + 1 >= consensus.nTemporaryTestnetForkDIP3Height &&
+        pindexPrev->nHeight + 1 < consensus.nTemporaryTestnetForkHeight &&
+        chainActive[consensus.nTemporaryTestnetForkDIP3Height]->GetBlockHash() == consensus.nTemporaryTestnetForkDIP3BlockHash) {
+        for (auto& sme : sml.mnList) {
+            sme.confirmedHash.SetNull();
+        }
+    }
+    // END TEMPORARY CODE
+
     bool mutated = false;
     merkleRootRet = sml.CalcMerkleRoot(&mutated);
     return !mutated;

From 0371d0ffe26353487e3d1078cdb2f153fc75213f Mon Sep 17 00:00:00 2001
From: Alexander Block <ablock84@gmail.com>
Date: Fri, 23 Nov 2018 08:35:55 +0100
Subject: [PATCH 4/4] Bump nTemporaryTestnetForkHeight to 273000

---
 src/chainparams.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 4f58a236f8d5..b58fedff33ae 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -380,7 +380,7 @@ class CTestNetParams : public CChainParams {
 
         // This is temporary until we reset testnet for retesting of the full DIP3 deployment
         consensus.nTemporaryTestnetForkDIP3Height = 264000;
-        consensus.nTemporaryTestnetForkHeight = 271000;
+        consensus.nTemporaryTestnetForkHeight = 273000;
         consensus.nTemporaryTestnetForkDIP3BlockHash.SetHex("00000048e6e71d4bd90e7c456dcb94683ae832fcad13e1760d8283f7e89f332f");
 
         fMiningRequiresPeers = true;
