This introduces an insignificant performance penalty, as it means locator
construction needs to use the skiplist-based CBlockIndex::GetAncestor()
function instead of the lookup-based CChain, but avoids the need for
callers to have access to a relevant CChain object.
This is a partial backport of core#25717
https://github.com/bitcoin/bitcoin/pull/25717/commits/ed470940cddbeb40425960d51cefeec4948febe4
Depends on D15124