diff --git a/configure.ac b/configure.ac index 08a78eef46569..1e39185459302 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) define(_CLIENT_VERSION_MINOR, 11) -define(_CLIENT_VERSION_REVISION, 3) -define(_CLIENT_VERSION_BUILD, 1) +define(_CLIENT_VERSION_REVISION, 4) +define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2017) AC_INIT([Argentum],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/argentumproject/argentum/issues],[argentum]) diff --git a/src/clientversion.h b/src/clientversion.h index 1785561992fb0..24e4205beae83 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -16,8 +16,8 @@ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 11 -#define CLIENT_VERSION_REVISION 3 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_REVISION 4 +#define CLIENT_VERSION_BUILD 0 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/main.cpp b/src/main.cpp index 6bf38a4504722..70743555f87b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1326,7 +1326,7 @@ static bool ReadBlockOrHeader(T& block, const CDiskBlockPos& pos) // Check the header // AuxPow: We don't necessarily have block height, so we depend on using the base parameters - if (!CheckAuxPowProofOfWork(block, Params().GetConsensus())) + if (!CheckAuxPowProofOfWorkB(block, Params().GetConsensus())) return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString()); return true; diff --git a/src/pow.cpp b/src/pow.cpp index d63c47ce21328..ad8a2856f1222 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -511,6 +511,29 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& return true; } +bool CheckProofOfWorkB(uint256 hash, unsigned int nBits, const Consensus::Params& params) +{ + bool fNegative; + bool fOverflow; + arith_uint256 bnTarget; + + bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + + // Check range + if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) + return error("CheckProofOfWork(): nBits below minimum work"); + + // Check proof of work matches claimed amount + /*if (nHeight > params.nCoinbaseMaturityV2Start){ + if (UintToArith256(hash) > bnTarget) + return error("CheckProofOfWork(): hash doesn't match nBits");}*/ + + /*if (UintToArith256(hash) > bnTarget) + return error("CheckProofOfWork(): hash doesn't match nBits");*/ + + return true; +} + arith_uint256 GetBlockProofBase(const CBlockIndex& block) { arith_uint256 bnTarget; @@ -696,9 +719,6 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params& the chain ID is correct. Legacy blocks are not allowed since the merge-mining start, which is checked in AcceptBlockHeader where the height is known. */ - LOCK(cs_main); - int nHeight = chainActive.Height(); - if (nHeight >= params.nStartAuxPow){ if (!block.nVersion.IsLegacy() && params.fStrictChainId && block.nVersion.GetChainId() != params.nAuxpowChainId) return error("%s : block does not have our chain ID" " (got %d, expected %d, full nVersion %d)", @@ -707,7 +727,6 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params& params.nAuxpowChainId, block.nVersion.GetFullVersion()); /* If there is no auxpow, just check the block hash. */ - } if (!block.auxpow) { if (block.nVersion.IsAuxpow()) return error("%s : no auxpow on block with auxpow version", @@ -753,6 +772,67 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params& return true; } +bool CheckAuxPowProofOfWorkB(const CBlockHeader& block, const Consensus::Params& params) +{ + int algo = block.GetAlgo(); + /* Except for legacy blocks with full version 1, ensure that + the chain ID is correct. Legacy blocks are not allowed since + the merge-mining start, which is checked in AcceptBlockHeader + where the height is known. */ + + if (!block.nVersion.IsLegacy() && params.fStrictChainId && block.nVersion.GetChainId() != params.nAuxpowChainId) + return error("%s : block does not have our chain ID" + " (got %d, expected %d, full nVersion %d)", + __func__, + block.nVersion.GetChainId(), + params.nAuxpowChainId, + block.nVersion.GetFullVersion()); + /* If there is no auxpow, just check the block hash. */ + if (!block.auxpow) { + if (block.nVersion.IsAuxpow()) + return error("%s : no auxpow on block with auxpow version", + __func__); + + if (!CheckProofOfWorkB(block.GetPoWHash(algo), block.nBits, params)) + return error("%s : non-AUX proof of work failed", __func__); + + return true; + } + + /* We have auxpow. Check it. */ + + if (!block.nVersion.IsAuxpow()) + return error("%s : auxpow on block with non-auxpow version", __func__); + + if (!block.auxpow->check(block.GetHash(), block.nVersion.GetChainId(), params)) + return error("%s : AUX POW is not valid", __func__); + + if(fDebug) + { + bool fNegative; + bool fOverflow; + arith_uint256 bnTarget; + bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow); + + LogPrintf("DEBUG: proof-of-work submitted \n parent-PoWhash: %s\n target: %s bits: %08x \n", + block.auxpow->getParentBlockPoWHash(algo).ToString().c_str(), + bnTarget.ToString().c_str(), + bnTarget.GetCompact()); + } + + if (!(algo == ALGO_SHA256D || algo == ALGO_SCRYPT) ) + { + return error("%s : AUX POW is not allowed on this algo", __func__); + } + + if (!CheckProofOfWorkB(block.auxpow->getParentBlockPoWHash(algo), block.nBits, params)) + { + return error("%s : AUX proof of work failed", __func__); + } + + return true; +} + int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params) { arith_uint256 r; diff --git a/src/pow.h b/src/pow.h index 96b20c01ad693..a186aaa23f9ef 100644 --- a/src/pow.h +++ b/src/pow.h @@ -25,6 +25,7 @@ unsigned int GetNextWorkRequired_Legacy(const CBlockIndex* pindexLast, const CBl /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&); +bool CheckProofOfWorkB(uint256 hash, unsigned int nBits, const Consensus::Params&); arith_uint256 GetBlockProof(const CBlockIndex& block); /** @@ -34,6 +35,7 @@ arith_uint256 GetBlockProof(const CBlockIndex& block); * @return True iff the PoW is correct. */ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params& params); +bool CheckAuxPowProofOfWorkB(const CBlockHeader& block, const Consensus::Params& params); /** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */ int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params&);