9

The standard bitcoin-qt/bitcoind client has an option -checklevel which purports to perform various checks on the block data stored on disk. Is there current documentation (other than the source) describing specifically what is checked at the different levels?

The function VerifyDB in the source has brief comments describing the levels:

// check level 0: read from disk
// check level 1: verify block validity
// check level 2: verify undo validity
// check level 3: check for inconsistencies during memory-only disconnect of tip blocks

It would be nice to see these explained in terms of the Bitcoin protocol. For example, are block hashes verified? Do we check that all the blocks in the chain correctly link back to one another? Are transaction signatures verified? Et cetera.

4

The other answer seems to be out of date, even at the time it was answered. The following seems to be a more up to date explanation: From https://bitcointalk.org/index.php?topic=141200.msg1504768#msg1504768

  • 0: Validate all block headers + compare (by hash) to blocks on disk for the last -checkblocks blocks
  • 1: In addition, verify (standalong) validity of those -checkblocks blocks
  • 2: In addition, verify that undo data matches checksums
  • 3: In addition, check that the current chainstate matches can reasonably be the result of the last N blocks, where N is limited by both -checkblocks and the amount of in-memory cache (-dbcache); typically it's around 150.
  • 4: In addition, for the last N blocks (see above), do full validation (including signature checks).

Note that the new default (3) is in fact a stronger check than the previous highest level (6).

3

Check comments in this commit https://gitorious.org/bitcoin/luke-jr-bitcoin/commit/4538e45c46d3829a21aed7685e6fbac7e8aafad3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.