Skip to content

Commit a748782

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#15545: [doc] explain why CheckBlock() is called before AcceptBlock
3d552b0 [doc] explain why CheckBlock() is called before AcceptBlock() (Sjors Provoost) Pull request description: Based on https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-February/016697.html and its PDF attachment. ACKs for top commit: MarcoFalke: cr ACK 3d552b0 Tree-SHA512: d1ef39855317853e0e7e051ec6015054d0d227fcdf20281c2c1921056537f1f79044aa1bdd35f46475edd17596fbcae79aeb338c4865b1269a01b158f6cb2ac4
2 parents c7dd9ff + 3d552b0 commit a748782

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)