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 PR17737:
The lock change in wallet_tests.cpp is not needed due to out of order
Depends on D8540.