Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argentum v3.11.4 #6

Merged
merged 2 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
88 changes: 84 additions & 4 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)",
Expand All @@ -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",
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/pow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand All @@ -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&);
Expand Down