diff --git a/configure.ac b/configure.ac index 0f691a0472..f8660f8f27 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 2) define(_CLIENT_VERSION_MINOR, 0) -define(_CLIENT_VERSION_REVISION, 1) +define(_CLIENT_VERSION_REVISION, 2) define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2018) diff --git a/src/pow.cpp b/src/pow.cpp index fa3680d018..6828cb8e14 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -12,6 +12,8 @@ #include "uint256.h" #include "util.h" #include "validation.h" +#include "chainparams.h" +#include "tinyformat.h" unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { /* current difficulty formula, dash - DarkGravity v3, written by Evan Duffield - evan@dash.org */ @@ -123,16 +125,19 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead int dgw = DarkGravityWave(pindexLast, pblock, params); int btc = GetNextWorkRequiredBTC(pindexLast, pblock, params); int64_t nPrevBlockTime = (pindexLast->pprev ? pindexLast->pprev->GetBlockTime() : pindexLast->GetBlockTime()); - if (AreAssetsDeployed()) { - LogPrintf("Block %s: found next work required using DGW: [%s] (BTC would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", - pindexLast->nHeight, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime); + + int version = (pblock->nVersion & 0xF0000000) >> 28; + if (version >= 3 && !CheckPOWHeightAssets(pindexLast->nHeight + 1)) { + LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using DGW: [%s] (BTC would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", + pindexLast->nHeight, pblock->nVersion, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime); return dgw; } else { - LogPrintf("Block %s: found next work required using BTC: [%s] (DGW would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", - pindexLast->nHeight, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime); + LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using BTC: [%s] (DGW would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n", + pindexLast->nHeight, pblock->nVersion, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime); return btc; } + } unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params) @@ -178,3 +183,25 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& return true; } + +// Used to determine if one of these block heights is failing the check because these were mined with block version of 3 before RIP2 was active. +bool CheckPOWHeightAssets(const int height) +{ + if (Params().NetworkIDString() == "test") { + return (height == 319456 || + height == 319468 || + height == 319469 || + height == 319494 || + height == 319500 || + height == 319501 || + height == 319502 || + height == 319520 || + height == 319522 || + height == 319532 || + height == 319533); + } else { + return false; + } + + +} diff --git a/src/pow.h b/src/pow.h index 537d828e1b..cb60404e09 100644 --- a/src/pow.h +++ b/src/pow.h @@ -17,6 +17,7 @@ class uint256; unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&); unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&); +bool CheckPOWHeightAssets(const int height); /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&); diff --git a/src/validation.cpp b/src/validation.cpp index dd5481fea0..8c0a664626 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3359,7 +3359,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P for (const auto& tx : block.vtx) if (!CheckTransaction(*tx, state, passets, false)) return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), - strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), state.GetDebugMessage())); + strprintf("Transaction check failed (tx hash %s) %s %s", tx->GetHash().ToString(), state.GetDebugMessage(), state.GetRejectReason())); unsigned int nSigOps = 0; for (const auto& tx : block.vtx)