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 (at the time of writing I believe two) spin up a Bitcoin Core node via the TestingSetup NodeContext. Thus, they will end up with conflicting use of gArgs. This issue is fixed in #18662
Moreover, test_bitcoin might want to set up and pass around local ArgsManager
s without modifying the “main” global gArgs. Also, some args are parsed from gArgs inside the mempool or other validation code, which also makes it hard for unit tests to mock those settings. Slowly getting rid of usages of gArgs is going to help with that.
And finally, globals usually come with other issues such as the static initialization fiasco. Getting rid of them will make the code cleaner.
I started doing that in commit fa6b97ce38baaa91991d8efa3e32d260fea298fa, which can serve as an example of how to do it for the other functions.
They can be found with git grep -W 'gArgs.AddArg("'
.
Useful skills:
Basic knowledge of how to compile Bitcoin Core, modify its source code and contribute patches via git on GitHub.
Want to work on this issue?
For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.