coinstats: Separate hasher/index lookup codepaths
Summary:
tl;dr: Split GetUTXOStats into ComputeUTXOStats and CoinStatsIndex::LookUpStats, and use ComputeUTXOStats in validation to enable decoupling validation from indexing.
coinstats: Separate hasher/index lookup codepaths
Split out ComputeUTXOStats and LookupUTXOStatsWithIndex from
GetUTXOStats, since the hashing and indexing codepaths are quite
disparate in practice.Also allow add a constructor to CCoinsStats for it to be constructed
from a a block height and hash. This is used in both codepaths.Also add a note in GetUTXOStats documenting a behaviour quirk that
predates this patchset.[META] This allows the hashing codepath to be moved to a separate file
in a future commit, decoupling callers that only rely on the hashing codepath from the indexing one. This is key for libbitcoinkernel, which needs to have the hashing codepath for AssumeUTXO, but does not wish to be coupled with indexes.
https://github.com/bitcoin/bitcoin/pull/24410/commits/1352e410a5b84070279ff28399083cb3ab278593
Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStats
The indexing codepath logic in node/coinstats.cpp is simple enough to be
moved into CoinStatsIndex::LookUpStats, avoiding an additional layer of
function calls. Callers are modified accordingly.Also, add 2 missed BOOST_CHECKs to the coinstatsindex_initial_sync unit
test.
https://github.com/bitcoin/bitcoin/pull/24410/commits/b7634fe02b6b030f5d62502c73db84ba9a276640
Use ComputeUTXOStats in validation
This is the "fruit of our labor" for this patchset.
ChainstateManager::PopulateAndValidateSnapshot can now directly call
ComputeUTXOStats(...).This opens the way for our consensus engine to be fully decoupled from all indices.
https://github.com/bitcoin/bitcoin/pull/24410/commits/f1006875665ffe8ff5da8185effe25b860743b4e
Note: I backported this last commit without the node -> kernel refactoring. I will do this in a separate commit, together with all the moving of code it involves.
This is a partial backport of core#24410
Depends on D14672
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14673