Enforce minor Dogecoin parameters (#1427)

* Minimum number of blocks and blockchain size are increased for pruning. In comparison to Bitcoin this uses 24 hours as a minimum, rather than 48, although given blocks are rarely full this likely reflects a lot longer in reality.
* Multiply fork detection parameters by 5. The wall clock time elapsed for "long" forks is therefore half that of Bitcoin, but IMHO those figures are excessive for a chain with 1 minute block times.
* BIP16 and BIP30 have both been enabled on Dogecoin since inception and should not be conditional.
This commit is contained in:
Ross Nicoll 2018-01-20 16:39:49 +00:00
parent ad9e54ca72
commit 2860c4bc31
2 changed files with 16 additions and 17 deletions

View file

@ -1255,12 +1255,12 @@ void CheckForkWarningConditions()
if (IsInitialBlockDownload())
return;
// If our best fork is no longer within 72 blocks (+/- 12 hours if no one mines it)
// If our best fork is no longer within 360 blocks (+/- 6 hours if no one mines it)
// of our head, drop it
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 72)
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 360)
pindexBestForkTip = NULL;
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (GetBlockProof(*chainActive.Tip()) * 6)))
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (GetBlockProof(*chainActive.Tip()) * 30)))
{
if (!GetfLargeWorkForkFound() && pindexBestForkBase)
{
@ -1829,9 +1829,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
// two in the chain that violate it. This prevents exploiting the issue against nodes during their
// initial block download.
bool fEnforceBIP30 = (!pindex->phashBlock) || // Enforce on CreateNewBlock invocations which don't have a hash.
!((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
(pindex->nHeight==91880 && pindex->GetBlockHash() == uint256S("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
// Dogecoin: BIP30 has been active since inception
bool fEnforceBIP30 = true;
// Once BIP34 activated it was not possible to create new duplicate coinbases and thus other than starting
// with the 2 existing duplicate coinbase pairs, not possible to create overwriting txs. But by the
@ -1853,8 +1852,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}
// BIP16 didn't become active until Apr 1 2012
int64_t nBIP16SwitchTime = 1333238400;
bool fStrictPayToScriptHash = (pindex->GetBlockTime() >= nBIP16SwitchTime);
// Dogecoin: BIP16 has been enabled since inception
bool fStrictPayToScriptHash = true;
unsigned int flags = fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE;

View file

@ -197,20 +197,20 @@ extern bool fPruneMode;
/** Number of MiB of block files that we're trying to stay below. */
extern uint64_t nPruneTarget;
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of chainActive.Tip() will not be pruned. */
static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
static const unsigned int MIN_BLOCKS_TO_KEEP = 1440;
static const signed int DEFAULT_CHECKBLOCKS = 6;
static const unsigned int DEFAULT_CHECKLEVEL = 3;
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
// At 1MB per block, 288 blocks = 288MB.
// Add 15% for Undo data = 331MB
// Add 20% for Orphan block rate = 397MB
// We want the low water mark after pruning to be at least 397 MB and since we prune in
// Require that user allocate at least 22,00MB for block & undo files (blk???.dat and rev???.dat)
// At 1MB per block, 1,440 blocks = 1,440MB.
// Add 15% for Undo data = 1,656MB
// Add 20% for Orphan block rate = 1,987MB
// We want the low water mark after pruning to be at least 1987 MB and since we prune in
// full block file chunks, we need the high water mark which triggers the prune to be
// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
// Setting the target to > than 550MB will make it likely we can respect the target.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
// one 128MB block file + added 15% undo data = 147MB greater for a total of 2,134MB
// Setting the target to > than 2200MB will make it likely we can respect the target.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 2200ULL * 1024 * 1024;
/**
* Process an incoming block. This only returns after the best known valid