From 032184c4e70cb53b7c817bc2e65dcc6b3541f9a2 Mon Sep 17 00:00:00 2001 From: kanon <60179867+decryp2kanon@users.noreply.github.com> Date: Tue, 5 May 2020 07:33:12 +0900 Subject: [PATCH 1/3] IBD: do not check PoW (Yespower) during Downloading headers 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. --- src/validation.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 52fa782f3..796d97eb5 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; } @@ -3334,7 +3341,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 From 35687e3c07f865b0af672dfa1ee7871b324898a8 Mon Sep 17 00:00:00 2001 From: kanon <60179867+decryp2kanon@users.noreply.github.com> Date: Sat, 9 May 2020 12:10:49 +0900 Subject: [PATCH 2/3] remove: debug printf --- src/validation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 796d97eb5..14b738f53 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3051,8 +3051,8 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, // 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()); + // 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; } From 666cab96d3a2d56f3243936c12b3fe67d046ed0d Mon Sep 17 00:00:00 2001 From: kanon <60179867+decryp2kanon@users.noreply.github.com> Date: Sat, 9 May 2020 14:03:05 +0900 Subject: [PATCH 3/3] adding comment suggested by volbil --- src/validation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 14b738f53..d8e83003a 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3064,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;