The gArgs global should be removed.
Motivation
Bitcoin Core has a single gArgs, which is used by all binaries (bitcoind, bitcoin-qt, bench_bitcoin, bitcoin-wallet, …). This is generally fine, because binaries only need to parse arguments for themselves.
However, for testing purposes in bench_bitcoin, some benchmarks spin up a Bitcoin Core node via the TestingSetup NodeContext. Thus, they will end up with conflicting use of gArgs. This issue is popping up too often for me. For example #18662, #21003, …
Moreover, test_bitcoin might want to set up and pass around local ArgsManager
s without modifying the “main” global gArgs.
And finally, globals usually come with other issues such as the static initialization fiasco. Getting rid of them will make the code cleaner.
However, “the GUI already relies on a global QApplication instance, a global event loop, global settings state and probably other global state, so getting rid of gArgs there doesn’t seem to accomplish much.” (See https://github.com/bitcoin-core/gui/pull/75#issuecomment-689675368)