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:

     0diff --git a/src/util/settings.h b/src/util/settings.h
     1index bbb6abe2c09..1d03639fa26 100644
     2--- a/src/util/settings.h
     3+++ b/src/util/settings.h
     4@@ -9,7 +9,7 @@
     5 #include <string>
     6 #include <vector>
     7 
     8-#include <univalue.h> // For util::SettingsValue = UniValue
     9+class UniValue;
    10 
    11 namespace util {
    12 
    13diff --git a/src/util/system.cpp b/src/util/system.cpp
    14index b0a538b5277..49a3ab447b9 100644
    15--- a/src/util/system.cpp
    16+++ b/src/util/system.cpp
    17@@ -231,6 +231,8 @@ ArgsManager::ArgsManager()
    18     // nothing to do
    19 }
    20 
    21+ArgsManager::~ArgsManager() {}
    22+
    23 const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
    24 {
    25     std::set<std::string> unsuitables;
    26diff --git a/src/util/system.h b/src/util/system.h
    27index 3138522b5c8..96f51e6074a 100644
    28--- a/src/util/system.h
    29+++ b/src/util/system.h
    30@@ -192,6 +192,7 @@ protected:
    31 
    32 public:
    33     ArgsManager();
    34+    ~ArgsManager();
    35 
    36     /**
    37      * 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. ryanofsky approved
  13. ryanofsky commented at 3:19 pm on April 16, 2020: member
    Code review ACK fae00a77e2589cc784650e3e60e1b99c22ca8a7b
  14. util: Document why ArgsManager (con/de)structor is not inline faf989f936
  15. ryanofsky approved
  16. ryanofsky commented at 5:31 pm on April 16, 2020: member
    Code review ACK faf989f93695d29099f6e152d5a2e117cd304183. Just new commit added restoring forward declaration
  17. promag commented at 8:18 pm on April 16, 2020: member
    ACK faf989f93695d29099f6e152d5a2e117cd304183.
  18. MarcoFalke merged this on Apr 16, 2020
  19. MarcoFalke closed this on Apr 16, 2020

  20. MarcoFalke deleted the branch on Apr 16, 2020
  21. sidhujag referenced this in commit c4f9bc4d11 on Apr 17, 2020
  22. MarcoFalke referenced this in commit fa1552b6ef on May 14, 2020
  23. MarcoFalke referenced this in commit 62d137ac3b on Jul 30, 2020
  24. jasonbcox referenced this in commit b515add335 on Oct 23, 2020
  25. 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-07-01 13:12 UTC

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