Pass ArgsManager into functions that register args with AddArg #18804

issue glowang openend this issue on April 28, 2020
  1. glowang commented at 3:21 pm on April 28, 2020: contributor

    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. @MarcoFalke started doing that in commit fa6b97c, as an example.

    They can be found with git grep -W ‘gArgs.AddArg("’.

    This idea is proposed by @MarcoFalke

  2. glowang commented at 3:21 pm on April 28, 2020: contributor
    There are quite a few places where gArgs needs to be replaced with a local manager. I will start with getarg_tests and make modular changes in separate PRs.
  3. promag commented at 1:40 am on May 5, 2020: member
    Concept ACK.
  4. MarcoFalke added the label Refactoring on May 5, 2020
  5. MarcoFalke added the label Utils/log/libs on May 5, 2020
  6. MarcoFalke referenced this in commit cb88de3e3d on May 29, 2020
  7. sidhujag referenced this in commit 2f57154071 on May 31, 2020
  8. MarcoFalke commented at 7:58 am on July 14, 2020: member
    #18926 was merged, so closing this for now
  9. MarcoFalke closed this on Jul 14, 2020

  10. DrahtBot locked this on Feb 15, 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-11-17 09:12 UTC

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