What does validation (.h and .cpp) cover conceptually in the Bitcoin Core codebase?

This question was asked by Larry Ruane at the May 12th 2021 Bitcoin Core PR review club on a Carl Dong PR to de-globalize ChainstateManager

1 Answer 1


John Newbery answered this at the Bitcoin Core PR review club session.

Conceptually validation stores and maintains our best view of the blockchain and associated UTXO set. It also includes an interface to submit unconfirmed transactions to the mempool.

In addition, James O'Beirne's slides from a presentation on Bitcoin Core architecture at Bitcoin Edge Dev++ stated:

Validation handles modifying in-memory data structures for chainstate and transactions (mempool) on the basis of certain acceptance rules.

It both defines some of these data structures (CChainState, mapBlockIndex) as well as procedures for validating them, e.g. CheckBlock().

Oddly, it also contains some utility functions for marshalling data to and from disk, e.g. ReadBlockFromDisk(), FlushStateToDisk(), {Dump,Load}Mempool(). This is probably because validation.{h,cpp} is the result of refactoring main.{h,cpp} into smaller pieces.

Here is a diagram from James' presentation showing how validation relates to other regions of the codebase.

James validation diagram

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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