Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBD: do not check PoW (Yespower) during Download headers #122

Merged
merged 3 commits into from
May 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
decryp2kanon marked this conversation as resolved.
Show resolved Hide resolved
return error("%s: Consensus::CheckBlockHeader: %s, %s", __func__, hash.ToString(), FormatStateMessage(state));

// Get prev block index
Expand Down