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
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityWhat 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
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 becausevalidation.{h,cpp}
is the result of refactoringmain.{h,cpp}
into smaller pieces.
Here is a diagram from James' presentation showing how validation relates to other regions of the codebase.