This allows us to easily initialize multiple chainstates on startup in future commits. It retires the g_chainstate global in lieu of g_chainman.
Partial backport (3/5) of core PR17737:
https://github.com/bitcoin/bitcoin/pull/17737/commits/4ae29f5f0c5117032debb722d7049664fdceeae8
Includes a fix to qt/test/apptests.cpp from the next commit to unbreak
the bitcoin-qt tests:
https://github.com/bitcoin/bitcoin/pull/17737/commits/2b081c4568e8019886fdb0f2a57babc73d7487f7#diff-41e328d9ba5879d2bd026a700743339b5b300b9bee50844795ef9e27f60bdfb8R85
Depends on D8538.