```
I'd previously attempted to create a specialized lock for
ChainstateManager, but it turns out that because that lock would be
required for functions like ChainActive() and ChainstateActive(), it
created irreconcilable lock inversions since those functions are used so
broadly throughout the codebase.
Instead, I'm just using cs_main to protect the contents of g_chainman.
```
Completes backport (5/5) of core [[https://github.com/bitcoin/bitcoin/pull/17737 | PR17737]]:
https://github.com/bitcoin/bitcoin/pull/17737/commits/c9017ce3bc27665594c9d80f395780d40755bb22
The lock change in `wallet_tests.cpp` is not needed due to out of order
backports.
Depends on D8540.