This is an alternative to #14803.
Refs:
It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?
This is an alternative to #14803.
Refs:
It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
3529 | @@ -3530,12 +3530,12 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons 3530 | CBlockIndex *pindex = nullptr; 3531 | if (fNewBlock) *fNewBlock = false; 3532 | CValidationState state; 3533 | - // Ensure that CheckBlock() passes before calling AcceptBlock, as 3534 | - // belt-and-suspenders. 3535 | - bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus()); 3536 | 3537 | LOCK(cs_main);
Could add a comment to explain why this lock is here?
@MarcoFalke Thank you for your review. Your comment has been addressed.
3529 | @@ -3530,12 +3530,14 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons 3530 | CBlockIndex *pindex = nullptr; 3531 | if (fNewBlock) *fNewBlock = false; 3532 | CValidationState state; 3533 | - // Ensure that CheckBlock() passes before calling AcceptBlock, as 3534 | - // belt-and-suspenders. 3535 | - bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus()); 3536 | 3537 | + // CheckBlock() does not support multi-threaded block validation due to CBlock::fChecked can cause data race.
Wording: due to -> because
utACK
This prevents data race for CBlock::fChecked.
@kallewoof Thank you for your review. Your comment has been addressed.
utACK c5ed6e73d3e18f26558c49fa3ecb1b7b0bb40d12
Has someone validated that all other calls to checkblock are also under a lock?
@gmaxwell yes ☝️ #14841 (comment)
Yes, but adding the annotation would poison the blockencodings header. Not sure if that is worth it.
Great! (still utACK)
utACK c5ed6e73d3e18f26558c49fa3ecb1b7b0bb40d12