Add -checklevel and improve -checkblocks #972

pull sipa wants to merge 1 commits into bitcoin:master from sipa:checklevel changing 2 files +100 −3
  1. sipa commented at 10:17 PM on March 21, 2012: member

    -checkblocks now takes a numeric argument: the number of blocks that must be verified at the end of the chain. Default is 2500, and 0 means all blocks.

    -checklevel specifies how thorough the verification must be: 0: only check whether the block exists on disk 1: verify block validity (default) 2: verify transaction index validity 3: check transaction hashes 4: check whether spent txouts were spent within the main chain 5: check whether all prevouts are marked spent 6: check whether spent txouts were spent by a valid transaction that consume them

  2. Add -checklevel and improve -checkblocks
    -checkblocks now takes a numeric argument: the number of blocks that must
    be verified at the end of the chain. Default is 2500, and 0 means all
    blocks.
    
    -checklevel specifies how thorough the verification must be:
    0: only check whether the block exists on disk
    1: verify block validity (default)
    2: verify transaction index validity
    3: check transaction hashes
    4: check whether spent txouts were spent within the main chain
    5: check whether all prevouts are marked spent
    6: check whether spent txouts were spent by a valid transaction that consumes them
    4538e45c46
  3. jgarzik commented at 4:07 AM on March 22, 2012: contributor

    Code appears correct. It would be nice to see -checklevel documentation somewhere besides the git log.

  4. sipa commented at 4:11 AM on March 22, 2012: member

    I've done a level-6 check on a full blockchain without any found errors (takes around 10 minutes in combination with fastblocks). Note that even level 6 does not do signature/script checking.

    Also: agree, check levels should be documented. But where?

  5. gavinandresen commented at 1:14 PM on March 22, 2012: contributor

    Where to document:

    How about a doc/troubleshooting file that describes how to use -checkblocks and -rescan and -dumpblock and any other undocumented goodies hiding in the source code?

  6. gmaxwell commented at 1:32 PM on March 22, 2012: contributor

    I'd really like to see the level turned up on the initial check, but I don't think we can do this until we're more confident that the check is incorrect.

    Perhaps make it run with the higher level on the initial check— but only yell in the logs if it fails any of the harder tests?

    Can you think of a way of detecting that the database was copied from another node? Doing a complete check at the highest level would go a long way to making blockchain downloads safer. (My concern being data errors creeping into a popular download site causing a massive fork)

  7. sipa commented at 2:01 PM on March 22, 2012: member

    Benchmark, with blk0001.dat and blkindex.dat entirely in OS cache before bitcoind startup:

    -checkblocks=10000 -checklevel=?: [1,3,10,20,20,27,45] seconds

    -checkblocks=172354 -checklevel=?: [6,22,57,122,123,153,274] seconds

  8. sipa commented at 2:26 PM on March 22, 2012: member

    @gmaxwell What do you mean, only yell if it fails any of the harder tests? Failing the easier tests is probably much worse.

  9. gavinandresen merged this on Mar 22, 2012
  10. gavinandresen closed this on Mar 22, 2012

  11. suprnurd referenced this in commit bf335ddfb3 on Dec 5, 2017
  12. ptschip referenced this in commit 8064f600ed on Feb 28, 2018
  13. DrahtBot 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-19 09:16 UTC

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