MockCValidationState state;
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "version-too-low", false)).Times(1);
- EXPECT_FALSE(CheckBlock(block, state, verifier, false, false));
+ EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false));
}
auto verifier = libzcash::ProofVerifier::Strict();
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-version-too-low", false)).Times(1);
- EXPECT_FALSE(CheckBlock(block, state, verifier, false, false));
+ EXPECT_FALSE(CheckBlock(block, state, Params(), verifier, false, false));
}
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(block, state, fExpensiveChecks ? verifier : disabledVerifier, !fJustCheck, !fJustCheck))
+ if (!CheckBlock(block, state, chainparams, fExpensiveChecks ? verifier : disabledVerifier, !fJustCheck, !fJustCheck))
return false;
// verify that the view's current state corresponds to the previous block
return true;
}
-bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
+bool CheckBlockHeader(
+ const CBlockHeader& block,
+ CValidationState& state,
+ const CChainParams& chainparams,
+ bool fCheckPOW)
{
// Check block version
if (block.nVersion < MIN_BLOCK_VERSION)
REJECT_INVALID, "version-too-low");
// Check Equihash solution is valid
- if (fCheckPOW && !CheckEquihashSolution(&block, Params().GetConsensus()))
+ if (fCheckPOW && !CheckEquihashSolution(&block, chainparams.GetConsensus()))
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),
REJECT_INVALID, "invalid-solution");
// Check proof of work matches claimed amount
- if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus()))
+ if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus()))
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),
REJECT_INVALID, "high-hash");
}
bool CheckBlock(const CBlock& block, CValidationState& state,
+ const CChainParams& chainparams,
libzcash::ProofVerifier& verifier,
bool fCheckPOW, bool fCheckMerkleRoot)
{
// Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader.
- if (!CheckBlockHeader(block, state, fCheckPOW))
+ if (!CheckBlockHeader(block, state, chainparams, fCheckPOW))
return false;
// Check the merkle root.
return true;
}
- if (!CheckBlockHeader(block, state))
+ if (!CheckBlockHeader(block, state, chainparams))
return false;
// Get prev block index
// See method docstring for why this is always disabled
auto verifier = libzcash::ProofVerifier::Disabled();
- if ((!CheckBlock(block, state, verifier)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
+ if ((!CheckBlock(block, state, chainparams, verifier)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
if (state.IsInvalid() && !state.CorruptionPossible()) {
pindex->nStatus |= BLOCK_FAILED_VALID;
setDirtyBlockIndex.insert(pindex);
{
// Preliminary checks
auto verifier = libzcash::ProofVerifier::Disabled();
- bool checked = CheckBlock(*pblock, state, verifier);
+ bool checked = CheckBlock(*pblock, state, chainparams, verifier);
{
LOCK(cs_main);
// NOTE: CheckBlockHeader is called by CheckBlock
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
return false;
- if (!CheckBlock(block, state, verifier, fCheckPOW, fCheckMerkleRoot))
+ if (!CheckBlock(block, state, chainparams, verifier, fCheckPOW, fCheckMerkleRoot))
return false;
if (!ContextualCheckBlock(block, state, pindexPrev))
return false;
if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus()))
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 1: verify block validity
- if (nCheckLevel >= 1 && !CheckBlock(block, state, verifier))
+ if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams, verifier))
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 2: verify undo validity
if (nCheckLevel >= 2 && pindex) {