Move CheckBlockIndex() from Chainstate to ChainstateManager
Summary:
Also rewrite CheckBlockIndex() to perform tests on all chainstates.
This increases sanity-check coverage, as any place in our code where we were
invoke CheckBlockIndex() on a single chainstate will now invoke the sanity
checks on all chainstates.
This change also tightens up the checks on setBlockIndexCandidates and
mapBlocksUnlinked, to more precisely match what we aim for even in the presence
of assumed-valid blocks.
This is a partial backport of core#27746
https://github.com/bitcoin/bitcoin/pull/27746/commits/3556b850221bc0e597d7dd749d4d47ab58dc8083
Depends on D17536
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D17537