Fixup mining PoW checks

This commit is contained in:
jl777
2018-04-16 05:25:07 +03:00
parent 3283cb53e7
commit 96f9009e29
3 changed files with 10 additions and 11 deletions

View File

@@ -2429,7 +2429,7 @@ static int64_t nTimeIndex = 0;
static int64_t nTimeCallbacks = 0;
static int64_t nTimeTotal = 0;
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck)
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW)
{
const CChainParams& chainparams = Params();
@@ -2447,7 +2447,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
auto disabledVerifier = libzcash::ProofVerifier::Disabled();
// Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in
if (!CheckBlock(pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, 1, !fJustCheck)) //!fJustCheck, !fJustCheck))
if (!CheckBlock(pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck)) //!fJustCheck, !fJustCheck))
return false;
// verify that the view's current state corresponds to the previous block
@@ -2923,7 +2923,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
{
CCoinsViewCache view(pcoinsTip);
bool rv = ConnectBlock(*pblock, state, pindexNew, view);
bool rv = ConnectBlock(*pblock, state, pindexNew, view, false, true);
GetMainSignals().BlockChecked(*pblock, state);
if (!rv) {
if (state.IsInvalid())
@@ -3565,8 +3565,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
// redundant with the call in AcceptBlockHeader.
if (!CheckBlockHeader(height,pindex,block,state,fCheckPOW))
{
fprintf(stderr,"checkblockheader error\n");
fprintf(stderr,"checkblockheader error PoW.%d\n",fCheckPOW);
return false;
}
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
@@ -3971,7 +3970,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
}
if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
{
//fprintf(stderr,"TestBlockValidity failure B\n");
fprintf(stderr,"TestBlockValidity failure B\n");
return false;
}
if (!ContextualCheckBlock(block, state, pindexPrev))
@@ -3979,7 +3978,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
fprintf(stderr,"TestBlockValidity failure C\n");
return false;
}
if (!ConnectBlock(block, state, &indexDummy, viewNew, true))
if (!ConnectBlock(block, state, &indexDummy, viewNew, true,fCheckPOW))
{
fprintf(stderr,"TestBlockValidity failure D\n");
return false;
@@ -4417,7 +4416,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
if (!ConnectBlock(block, state, pindex, coins))
if (!ConnectBlock(block, state, pindex, coins,false, true))
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
}
}

View File

@@ -447,7 +447,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool* pfClean = NULL);
/** Apply the effects of this block (with given index) on the UTXO set represented by coins */
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false);
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false,bool fCheckPOW = false);
/** Context-independent validity checks */
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex,const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);

View File

@@ -935,9 +935,9 @@ void static BitcoinMiner()
else
{
CValidationState state;
if ( !TestBlockValidity(state, *pblock, chainActive.Tip(), false, false))
if ( !TestBlockValidity(state, *pblock, chainActive.Tip(), true, false))
{
//fprintf(stderr,"Invalid block mined, try again\n");
fprintf(stderr,"Invalid block mined, try again\n");
return(false);
}
if ( NOTARY_PUBKEY33[0] != 0 )