From 51d287559a0106a5a29e9d8dc12701bf3b72480f Mon Sep 17 00:00:00 2001 From: jc Date: Wed, 28 Feb 2018 20:25:06 -0500 Subject: [PATCH] Finalize parameter updates after snapshot definition --- src/chainparams.cpp | 10 +++++----- src/init.cpp | 8 ++++++-- src/main.cpp | 4 ++-- src/main.h | 2 +- src/miner.cpp | 15 +++------------ src/pow.cpp | 7 +------ 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 714ba042..1ac29eb5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -43,7 +43,7 @@ public: consensus.nMajorityEnforceBlockUpgrade = 750; consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 4000; - consensus.powLimit = uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + consensus.powLimit = uint256S("07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowAveragingWindow = 17; assert(maxUint/UintToArith256(consensus.powLimit) >= consensus.nPowAveragingWindow); consensus.nPowMaxAdjustDown = 32; // 32% adjustment down @@ -61,8 +61,8 @@ public: pchMessageStart[0] = 0xa8; pchMessageStart[1] = 0xea; - pchMessageStart[2] = 0xb2; - pchMessageStart[3] = 0xed; + pchMessageStart[2] = 0xa2; + pchMessageStart[3] = 0xcd; vAlertPubKey = ParseHex("04f2cd746e629ffd320a81287474c98c2ad15d15b0a210b0144edcd8f3e1301c6311fd751fa34ba17d88090374cfec7cd9aaca55a5a0c4456511acc01b922005de"); nDefaultPort = 7933; nMaxTipAge = 24 * 60 * 60; @@ -200,8 +200,8 @@ public: assert(vFoundersRewardAddress.size() <= consensus.GetLastFoundersRewardBlockHeight()); //current ZCL height is 200K-300K, this value here is placeholder, it will have to be changed to correct fork block height - nForkStartHeight = 1000000; - nForkHeightRange = 65000; + nForkStartHeight = 272991; + nForkHeightRange = 5467; } }; static CMainParams mainParams; diff --git a/src/init.cpp b/src/init.cpp index 09acbda9..440e5ed3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -712,6 +712,8 @@ static void ZC_LoadParams() pzcashParams->setProvingKeyPath(pk_path.string()); } +bool IsInitialBlockDownloadBind(){ return IsInitialBlockDownload(false); } + bool AppInitServers(boost::thread_group& threadGroup) { RPCServer::OnStopped(&OnRPCStopped); @@ -897,10 +899,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #ifdef FORK_CB_INPUT - forkUtxoPath = GetArg("-utxo-path", ""); + auto default_data_dir = GetDataDir() / "utxo_snapshot"; + forkUtxoPath = GetArg("-utxo-path", default_data_dir.string()); forkStartHeight = GetArg("-fork-startheight", chainparams.ForkStartHeight()); forkHeightRange = GetArg("-fork-heightrange", chainparams.ForkHeightRange()); forkCBPerBlock = GetArg("-fork-cbperblock", FORK_COINBASE_PER_BLOCK); + LogPrintf("Running with fork parameters datadir=%s forkStartHeight=%d, forkHeightRange=%d\n", forkUtxoPath, forkStartHeight, forkHeightRange); #endif // ********************************************************* Step 3: parameter-to-internal-flags @@ -1697,7 +1701,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Monitor the chain, and alert if we get blocks much quicker or slower than expected int64_t nPowTargetSpacing = Params().GetConsensus().nPowTargetSpacing; - CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownload, + CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownloadBind, boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing); scheduler.scheduleEvery(f, nPowTargetSpacing); diff --git a/src/main.cpp b/src/main.cpp index 163be185..115dce46 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1477,7 +1477,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) return nSubsidy; } -bool IsInitialBlockDownload() +bool IsInitialBlockDownload(bool includeFork) { const CChainParams& chainParams = Params(); LOCK(cs_main); @@ -1485,7 +1485,7 @@ bool IsInitialBlockDownload() return true; if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints())) return true; - if (chainActive.Height() < chainParams.ForkStartHeight() + chainParams.ForkHeightRange()) + if (includeFork && chainActive.Height() < chainParams.ForkStartHeight() + chainParams.ForkHeightRange()) return true; static bool lockIBDState = false; diff --git a/src/main.h b/src/main.h index caed23f1..b6093982 100644 --- a/src/main.h +++ b/src/main.h @@ -211,7 +211,7 @@ void ThreadScriptCheck(); /** Try to detect Partition (network isolation) attacks against us */ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader, int64_t nPowTargetSpacing); /** Check whether we are doing an initial block download (synchronizing from disk or network) */ -bool IsInitialBlockDownload(); +bool IsInitialBlockDownload(bool includeFork=false); /** Format a string that describes several potential problems detected by the core */ std::string GetWarnings(const std::string& strFor); /** Retrieve a transaction (from memory pool, or from disk, if possible) */ diff --git a/src/miner.cpp b/src/miner.cpp index 3f4c69f3..02224a00 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -720,6 +720,8 @@ void static BitcoinMiner() try { while (true) { if (chainparams.MiningRequiresPeers()) { + bool fForkMiner = GetBoolArg("-fork-mine", false); + // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. miningTimer.stop(); @@ -729,7 +731,7 @@ void static BitcoinMiner() LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!fvNodesEmpty && !IsInitialBlockDownload()) + if (!fvNodesEmpty && (fForkMiner || !IsInitialBlockDownload(true))) break; MilliSleep(1000); } while (true); @@ -747,17 +749,6 @@ void static BitcoinMiner() bool isNextBlockFork = isForkBlock(pindexPrev->nHeight+1); - bool mineOnlyFork = GetBoolArg("-forkmineonly", false); - if(mineOnlyFork && !isNextBlockFork) { - miningTimer.stop(); - do { - MilliSleep(100); - pindexPrev = chainActive.Tip(); - isNextBlockFork = isForkBlock(pindexPrev->nHeight + 1); - } while(!isNextBlockFork); - miningTimer.start(); - } - if (isNextBlockFork) { if (!bForkModeStarted) { LogPrintf("BTCPrivate Miner: switching into fork mode\n"); diff --git a/src/pow.cpp b/src/pow.cpp index ca95f8bc..e5175e46 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -25,12 +25,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead { int nHeight = pindexLast->nHeight + 1; - arith_uint256 proofOfWorkLimit; - if(isForkBlock(nHeight) || isForkBlock(nHeight - params.nPowAveragingWindow)) - proofOfWorkLimit = UintToArith256(uint256S("07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")); - else - proofOfWorkLimit = UintToArith256(params.powLimit); - + arith_uint256 proofOfWorkLimit = UintToArith256(params.powLimit); unsigned int nProofOfWorkLimit = proofOfWorkLimit.GetCompact(); unsigned int nProofOfWorkBomb = UintToArith256(uint256S("000000000000000000000000000000000000000000000000000000000000ffff")).GetCompact();