diff --git a/src/chain.h b/src/chain.h index 1c88d441cb..9879f19f41 100644 --- a/src/chain.h +++ b/src/chain.h @@ -535,9 +535,18 @@ class CDiskBlockIndex : public CBlockIndex READWRITE(anonymitySetHash); } - if (!(s.GetType() & SER_GETHASH) && nHeight >= params.nEvoSporkStartBlock && nHeight < params.nEvoSporkStopBlock) - READWRITE(activeDisablingSporks); - + if (!(s.GetType() & SER_GETHASH) && nHeight >= params.nEvoSporkStartBlock) { + if (nHeight < params.nEvoSporkStopBlock && + // Workaround for late rollout of version 0.14.9.3 in which nEvoSporkStopBlock was extended + // If version of a record for block is less than 140903 and nHeight is greater than previous value + // of nEvoSporkStopBlock we don't read activeDisablingSpork from index database + !(params.nEvoSporkStopBlockExtensionVersion != 0 && + nVersion < params.nEvoSporkStopBlockExtensionVersion && + nHeight >= params.nEvoSporkStopBlockPrevious && + nHeight < params.nEvoSporkStopBlockPrevious + params.nEvoSporkStopBlockExtensionGracefulPeriod)) + + READWRITE(activeDisablingSporks); + } nDiskBlockVersion = nVersion; } diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7dc7624b3e..4538efcca3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -411,6 +411,9 @@ class CMainParams : public CChainParams { consensus.evoSporkKeyID = "a78fERshquPsTv2TuKMSsxTeKom56uBwLP"; consensus.nEvoSporkStartBlock = ZC_LELANTUS_STARTING_BLOCK; consensus.nEvoSporkStopBlock = ZC_LELANTUS_STARTING_BLOCK + 2*24*12*365; // two years after lelantus + consensus.nEvoSporkStopBlockExtensionVersion = 140903; + consensus.nEvoSporkStopBlockPrevious = ZC_LELANTUS_STARTING_BLOCK + 1*24*12*365; // one year after lelantus + consensus.nEvoSporkStopBlockExtensionGracefulPeriod = 24*12*14; // two weeks // reorg consensus.nMaxReorgDepth = 5; @@ -681,6 +684,7 @@ class CTestNetParams : public CChainParams { consensus.evoSporkKeyID = "TWSEa1UsZzDHywDG6CZFDNdeJU6LzhbbBL"; consensus.nEvoSporkStartBlock = 22000; consensus.nEvoSporkStopBlock = 40000; + consensus.nEvoSporkStopBlockExtensionVersion = 0; // reorg consensus.nMaxReorgDepth = 4; @@ -898,6 +902,7 @@ class CDevNetParams : public CChainParams { consensus.evoSporkKeyID = "TdxR3tfoHiQUkowcfjEGiMBfk6GXFdajUA"; consensus.nEvoSporkStartBlock = 1; consensus.nEvoSporkStopBlock = 40000; + consensus.nEvoSporkStopBlockExtensionVersion = 0; // reorg consensus.nMaxReorgDepth = 4; @@ -1116,6 +1121,7 @@ class CRegTestParams : public CChainParams { consensus.evoSporkKeyID = "TSpmHGzQT4KJrubWa4N2CRmpA7wKMMWDg4"; // private key is cW2YM2xaeCaebfpKguBahUAgEzLXgSserWRuD29kSyKHq1TTgwRQ consensus.nEvoSporkStartBlock = 1000; consensus.nEvoSporkStopBlock = 1500; + consensus.nEvoSporkStopBlockExtensionVersion = 0; // reorg consensus.nMaxReorgDepth = 4; diff --git a/src/consensus/params.h b/src/consensus/params.h index f34748fb87..1dc7ba4e9b 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -245,6 +245,16 @@ struct Params { // The block number to stop using evo sporks int nEvoSporkStopBlock; + // Workaround for a late rollout of version 0.14.9.3 + // If non-zero allow special behavior for reading index when block index version < nEvoSporkStopBlockExtensionVersion + int nEvoSporkStopBlockExtensionVersion; + + // Previous value of stop block + int nEvoSporkStopBlockPrevious; + + // Graceful period (number of blocks) to allow this workaround + int nEvoSporkStopBlockExtensionGracefulPeriod; + // Key to sign spork txs std::string evoSporkKeyID;