From 1d5a8c9dd4b8c9bbf2b6b133995978e4fe90914d Mon Sep 17 00:00:00 2001 From: kanon <60179867+decryp2kanon@users.noreply.github.com> Date: Sat, 9 May 2020 23:42:06 +0900 Subject: [PATCH] IBD: do not check PoW (Yespower) during downloading headers (#122) * 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 --- src/validation.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 52fa782f3..d8e83003a 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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; } @@ -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; @@ -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