test: Replace gArgs with local argsman in bench #18662

pull MarcoFalke wants to merge 4 commits into bitcoin:master from MarcoFalke:2004-toolsArgsman changing 3 files +30 −29
  1. MarcoFalke commented at 11:26 PM on April 15, 2020: member

    All utilities use the same gArgs global that the node uses. This is generally fine and does not lead to issues unless a bench test is going to spin up a NodeContext via the TestingSetup. In that case the two uses of gArgs conflict and currently it needs to be cleared:

    https://github.com/bitcoin/bitcoin/blob/544709763e1f45148d1926831e07ff03487673ee/src/bench/bench_bitcoin.cpp#L76

    One solution would be to do nothing, because the current code works with that workaround. Another solution would be to not use the same global in all binaries.

  2. MarcoFalke added the label Utils/log/libs on Apr 15, 2020
  3. MarcoFalke force-pushed on Apr 16, 2020
  4. tools: Add unused argsman to bench_bitcoin fa2bc4141d
  5. scripted-diff: Replace gArgs with local argsman in bench
    -BEGIN VERIFY SCRIPT-
    sed -i -e 's/gArgs/argsman/g' src/bench/bench_bitcoin.cpp
    -END VERIFY SCRIPT-
    fa46aebeb1
  6. bench: Remove unused argsman.ClearArgs fae00a77e2
  7. MarcoFalke force-pushed on Apr 16, 2020
  8. MarcoFalke renamed this:
    refactor: Replace gArgs with local argsman in all utility tools
    test: Replace gArgs with local argsman in bench
    on Apr 16, 2020
  9. in src/util/settings.h:12 in fae00a77e2 outdated
       8 | @@ -9,7 +9,7 @@
       9 |  #include <string>
      10 |  #include <vector>
      11 |  
      12 | -class UniValue;
      13 | +#include <univalue.h> // For util::SettingsValue = UniValue
    


    promag commented at 9:35 AM on April 16, 2020:

    Why this change? Isn't forward declaration enough?


    MarcoFalke commented at 11:32 AM on April 16, 2020:

    It doesn't compile without this change


    promag commented at 11:35 AM on April 16, 2020:

    But include just in src/bench/bench_bitcoin.cpp?


    MarcoFalke commented at 11:35 AM on April 16, 2020:

    Reason is that SettingsValue is a return value of one of the methods of ArgsManager. Not sure why C++ doesn't require the struct layout for return values of methods when no object with such method is initialized. Though it does require the layout when an object with such method is instantiated... I can't change the way C++ works.


    MarcoFalke commented at 11:38 AM on April 16, 2020:

    But include just in src/bench/bench_bitcoin.cpp?

    Yes, that works, but it feels weird to require to include implementation details of one class on the module that ends up happening to use the class.


    ryanofsky commented at 3:16 PM on April 16, 2020:

    re: #18662 (review)

    Reason is that SettingsValue is a return value of one of the methods of ArgsManager. Not sure why C++ doesn't require the struct layout for return values of methods when no object with such method is initialized. Though it does require the layout when an object with such method is instantiated... I can't change the way C++ works.

    Complier error messages here are pretty unhelfpul, but this happens because of the ArgsManager destructor, not the method return value. Following change should fix:

    diff --git a/src/util/settings.h b/src/util/settings.h
    index bbb6abe2c09..1d03639fa26 100644
    --- a/src/util/settings.h
    +++ b/src/util/settings.h
    @@ -9,7 +9,7 @@
     #include <string>
     #include <vector>
     
    -#include <univalue.h> // For util::SettingsValue = UniValue
    +class UniValue;
     
     namespace util {
     
    diff --git a/src/util/system.cpp b/src/util/system.cpp
    index b0a538b5277..49a3ab447b9 100644
    --- a/src/util/system.cpp
    +++ b/src/util/system.cpp
    @@ -231,6 +231,8 @@ ArgsManager::ArgsManager()
         // nothing to do
     }
     
    +ArgsManager::~ArgsManager() {}
    +
     const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
     {
         std::set<std::string> unsuitables;
    diff --git a/src/util/system.h b/src/util/system.h
    index 3138522b5c8..96f51e6074a 100644
    --- a/src/util/system.h
    +++ b/src/util/system.h
    @@ -192,6 +192,7 @@ protected:
     
     public:
         ArgsManager();
    +    ~ArgsManager();
     
         /**
          * Select the network in use
    

    MarcoFalke commented at 4:27 PM on April 16, 2020:

    Thanks. Pushed.

  10. promag commented at 9:41 AM on April 16, 2020: member

    Code review ACK fae00a77e2589cc784650e3e60e1b99c22ca8a7b.

  11. practicalswift commented at 10:22 AM on April 16, 2020: contributor

    Concept ACK

    On behalf of future generations on Bitcoin Core developers: thanks for doing these cleanups - that will make their lives easier :)

    The short-term gain from each individual clean-up might seem small but the cumulative long-term gain will make a big difference.

  12. MarcoFalke cross-referenced this on Apr 16, 2020 from issue Pass ArgsManager into functions that register args with AddArg by MarcoFalke
  13. ryanofsky approved
  14. ryanofsky commented at 3:19 PM on April 16, 2020: contributor

    Code review ACK fae00a77e2589cc784650e3e60e1b99c22ca8a7b

  15. util: Document why ArgsManager (con/de)structor is not inline faf989f936
  16. ryanofsky approved
  17. ryanofsky commented at 5:31 PM on April 16, 2020: contributor

    Code review ACK faf989f93695d29099f6e152d5a2e117cd304183. Just new commit added restoring forward declaration

  18. promag commented at 8:18 PM on April 16, 2020: member

    ACK faf989f93695d29099f6e152d5a2e117cd304183.

  19. MarcoFalke merged this on Apr 16, 2020
  20. MarcoFalke closed this on Apr 16, 2020

  21. MarcoFalke deleted the branch on Apr 16, 2020
  22. sidhujag referenced this in commit c4f9bc4d11 on Apr 17, 2020
  23. glowang cross-referenced this on Apr 28, 2020 from issue Pass ArgsManager into functions that register args with AddArg by glowang
  24. MarcoFalke cross-referenced this on May 13, 2020 from issue doc: noban precludes maxuploadtarget disconnects by MarcoFalke
  25. MarcoFalke referenced this in commit fa1552b6ef on May 14, 2020
  26. MarcoFalke cross-referenced this on Jul 14, 2020 from issue Pass ArgsManager into functions that register args with AddArg by MarcoFalke
  27. S3RK cross-referenced this on Jul 21, 2020 from issue refactor: Pass ArgsManager into functions that register args by S3RK
  28. MarcoFalke referenced this in commit 62d137ac3b on Jul 30, 2020
  29. jasonbcox referenced this in commit b515add335 on Oct 23, 2020
  30. MarcoFalke cross-referenced this on Jan 25, 2021 from issue Remove gArgs by MarcoFalke
  31. bitcoin 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: 2026-05-18 22:54 UTC

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