Pass ArgsManager into functions that register args with AddArg #19511

issue MarcoFalke openend this issue on July 14, 2020
  1. MarcoFalke commented at 8:00 am on July 14, 2020: member

    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 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 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.

  2. MarcoFalke added the label good first issue on Jul 14, 2020
  3. S3RK commented at 4:22 am on July 15, 2020: member
    I’d like to work on this one as a way to extend my understanding of codebase beyond functional test framework.
  4. MarcoFalke commented at 6:38 pm on July 19, 2020: member
    @S3RK Sounds good. Feel free to open a PR once you have a solution that passes all unit and functional tests
  5. MarcoFalke closed this on Jul 30, 2020

  6. fanquake referenced this in commit 6a2ba62685 on Aug 26, 2020
  7. sidhujag referenced this in commit 60a866c284 on Aug 26, 2020
  8. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 13:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me