This is a partial backport of core#24595
https://github.com/bitcoin/bitcoin/pull/24595/commits/deffe0df6c36225bada18603b5a840139f030f2c
https://github.com/bitcoin/bitcoin/pull/24595/commits/78adef17536edef833a0bfca06b61ce28120e486
We don't have a g_versionbitscache global, and the point of the PR in the source material is to make that global a ChainstateManager member. The only rationale for backporting this in Bitcoin ABC is to make following backports easier (for instance in core#25704 one of the functions touched here will use the chainman argument)
Depends on D15808