Skip to content

Commit

Permalink
IBD: do not check PoW (Yespower) during downloading headers (#122)
Browse files Browse the repository at this point in the history
* IBD: do not check PoW (Yespower) during downloading headers
However this means checking PoW during IBD is, not actually skipped, but still checking in another places. This makes IBD much faster.
* remove: debug printf
* adding comment by volbil
  • Loading branch information
decryp2kanon committed May 9, 2020
1 parent 43bb57c commit 1d5a8c9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,13 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state,
if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash_cached(), block.nBits, consensusParams))
return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed");

// FIXME.SUGAR // check PoW: SKIPPED during downloading headers (IBD)
// You can see this log when IBD.
// This means PoW check during IBD is not actually skipped, but still its checking in another places.
// What we skipped is only when Downloading headers, but not else. This makes IBD much faster.
// if (IsInitialBlockDownload())
// printf("%s IBD=%d CBH=%s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str(), IsInitialBlockDownload(), block.GetHash().ToString().c_str());

return true;
}

Expand All @@ -3057,8 +3064,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
if (block.fChecked)
return true;

// FIXME.SUGAR // check PoW: SKIPPED during downloading headers (IBD)
// Check that the header is valid (particularly PoW). This is mostly
// redundant with the call in AcceptBlockHeader.
// redundant with the call in AcceptBlockHeader, but when IBD mode, its SKIPPED.
if (!CheckBlockHeader(block, state, consensusParams, fCheckPOW))
return false;

Expand Down Expand Up @@ -3334,7 +3342,9 @@ bool CChainState::AcceptBlockHeader(const CBlockHeader& block, CValidationState&
return true;
}

if (!CheckBlockHeader(block, state, chainparams.GetConsensus()))
// FIXME.SUGAR // check PoW: SKIPPED during downloading headers (IBD)
// IBD: do not check PoW (Yespower) during Download headers for performance reason
if (!IsInitialBlockDownload() && !CheckBlockHeader(block, state, chainparams.GetConsensus()))
return error("%s: Consensus::CheckBlockHeader: %s, %s", __func__, hash.ToString(), FormatStateMessage(state));

// Get prev block index
Expand Down

0 comments on commit 1d5a8c9

Please sign in to comment.