Skip to content

Commit

Permalink
Allow upgrade to 0.14.9.3 without reindex (#1127)
Browse files Browse the repository at this point in the history
* Allow graceful period to upgrade to 0.14.9.3 without reindex

* Extend graceful period to 2 weeks

* Comment text fixed
  • Loading branch information
psolstice authored and levonpetrosyan93 committed May 17, 2023
1 parent 9bc1c3a commit ab3add1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -681,6 +684,7 @@ class CTestNetParams : public CChainParams {
consensus.evoSporkKeyID = "TWSEa1UsZzDHywDG6CZFDNdeJU6LzhbbBL";
consensus.nEvoSporkStartBlock = 22000;
consensus.nEvoSporkStopBlock = 40000;
consensus.nEvoSporkStopBlockExtensionVersion = 0;

// reorg
consensus.nMaxReorgDepth = 4;
Expand Down Expand Up @@ -898,6 +902,7 @@ class CDevNetParams : public CChainParams {
consensus.evoSporkKeyID = "TdxR3tfoHiQUkowcfjEGiMBfk6GXFdajUA";
consensus.nEvoSporkStartBlock = 1;
consensus.nEvoSporkStopBlock = 40000;
consensus.nEvoSporkStopBlockExtensionVersion = 0;

// reorg
consensus.nMaxReorgDepth = 4;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ab3add1

Please sign in to comment.