Skip to content

Pass ArgsManager into functions that register args with AddArg #14

@maflcko

Description

@maflcko

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 bitcoin#18662

Moreover, test_bitcoin might want to set up and pass around local ArgsManagers 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 fa6b97c, 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?

The purpose of the good first issue label is to highlight which issues are suitable for a new contributor without a deep understanding of the codebase.

You do not need to request permission to start working on this. You are encouraged to comment on the issue if you are planning to work on it. This will help other contributors monitor which issues are actively being addressed and is also an effective way to request assistance if and when you need it.

For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions