Error in CheckBlockHeader() when doing full checkblocks on master #4246

issue laanwj opened this issue on May 29, 2014
  1. laanwj commented at 8:57 AM on May 29, 2014: member

    When I run with -checkblocks=0 -checklevel=2 on master, I get the following error:

    2014-05-29 06:53:38 ERROR: CheckBlockHeader() : block with timestamp before last checkpoint
    2014-05-29 06:53:38 ERROR: VerifyDB() : *** found bad block at 278999, hash=0000000000000001ed51db67f98e83ac76209fe00dabc2a42c80cbc9a4ef6c45
    

    We've discussed on IRC a bit and @gmaxwell was able to reproduce it, so it's not local corruption. Seemingly it picks 279000 as last checkpoint instead of 250000 for block 278999.

    This problem does not exist on the 0.9.2 branch, so it must have been introduced in one of the recent changes in main.cpp/h.

  2. laanwj added the label Bug on May 29, 2014
  3. laanwj added the label Priority Medium on May 29, 2014
  4. sipa commented at 3:13 PM on May 29, 2014: member

    I believe the problem is that when processing the block, the header is already processed. This means that 290000's header is already in mapBlockIndex when its block data is processed. As that invokes CheckBlock, which on its turn invokes CheckBlockHeader again, which calls GetLastCheckPoint, which returns the block being verified itself, and then compares its parent against that, resulting in time seemingly going backward.

    Two possible solutions:

    • Make GetLastCheckpoint take the verification level of the mapBlockIndex passed into account, and ignore not-fully-validated ones (easier).
    • Pass chainActive to GetLastCheckpoint instead of mapBlockIndex, which will never contain a block itself while it is still being verified (cleaner, imho).
  5. sipa commented at 3:47 PM on May 29, 2014: member

    I'm probably wrong.

  6. laanwj closed this on Jun 19, 2014

  7. nzsquirrell referenced this in commit 5e70510c51 on Nov 7, 2015
  8. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me