Skip to content

Commit 3d552b0

Browse files
Sjorssdaftuar
andcommitted
[doc] explain why CheckBlock() is called before AcceptBlock()
Co-authored-by: Suhas Daftuar <[email protected]>
1 parent 07ededa commit 3d552b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/validation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,8 +3605,11 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s
36053605
// Therefore, the following critical section must include the CheckBlock() call as well.
36063606
LOCK(cs_main);
36073607

3608-
// Ensure that CheckBlock() passes before calling AcceptBlock, as
3609-
// belt-and-suspenders.
3608+
// Skipping AcceptBlock() for CheckBlock() failures means that we will never mark a block as invalid if
3609+
// CheckBlock() fails. This is protective against consensus failure if there are any unknown forms of block
3610+
// malleability that cause CheckBlock() to fail; see e.g. CVE-2012-2459 and
3611+
// https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-February/016697.html. Because CheckBlock() is
3612+
// not very expensive, the anti-DoS benefits of caching failure (of a definitely-invalid block) are not substantial.
36103613
bool ret = CheckBlock(*block, state, chainparams.GetConsensus());
36113614
if (ret) {
36123615
// Store to disk

0 commit comments

Comments
 (0)