On bitcoind startup, write config args to debug.log #16115

pull LarryRuane wants to merge 1 commits into bitcoin:master from LarryRuane:args-to-debug-log changing 6 files +113 −6
  1. LarryRuane commented at 4:37 am on May 29, 2019: contributor
    When a developer is examining debug.log after something goes wrong, it’s often useful to know the exact options the failing instance of bitcoind was started with. Sometimes the debug.log file is all that’s available for the analysis. This PR logs the bitcoin.conf entries and command-line arguments to debug.log on startup.
  2. DrahtBot commented at 6:20 am on May 29, 2019: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17812 (config, test: asmap functional tests and feature refinements by jonatack)
    • #17783 (util: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior by ryanofsky)
    • #17581 (refactor: Remove settings merge reverse precedence code by ryanofsky)
    • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
    • #17493 (util: Forbid ambiguous multiple assignments in config file by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. jonasschnelli commented at 6:57 am on May 29, 2019: contributor
    Knowing the startup parameters for debug purposes is certainly helpful. Unsure about logging rpcpassword (maybe add a blacklist?).
  4. DrahtBot added the label Utils/log/libs on May 29, 2019
  5. laanwj commented at 8:56 am on May 29, 2019: member

    Knowing the startup parameters for debug purposes is certainly helpful. Unsure about logging rpcpassword (maybe add a blacklist?).

    Yepp. Agree this is very useful for troubleshooting, but be careful with logging sensitive information (people do post these things to the internet sometimes).

  6. in src/util/system.cpp:969 in 8bf605fc56 outdated
    963@@ -964,6 +964,20 @@ std::string ArgsManager::GetChainName() const
    964     return CBaseChainParams::MAIN;
    965 }
    966 
    967+void ArgsManager::LogArgs() const
    968+{
    969+    for (const auto arg: m_config_args) {
    


    practicalswift commented at 8:47 am on May 30, 2019:

    Accessing m_config_args requires holding cs_args.

    Also: use const reference to avoid copying. The const reference comment applies also for the for loops below.

  7. in src/util/system.cpp:974 in 8bf605fc56 outdated
    969+    for (const auto arg: m_config_args) {
    970+        for (const auto value: arg.second) {
    971+            LogPrintf("config-file arg:  %s=%s\n", arg.first, value);
    972+        }
    973+    }
    974+    for (const auto arg: m_override_args) {
    


    practicalswift commented at 8:48 am on May 30, 2019:
    And accessing m_override_args requires holding cs_args :-)
  8. LarryRuane force-pushed on May 30, 2019
  9. LarryRuane commented at 3:39 pm on May 30, 2019: contributor

    Thank all of you for the good comments! Force-pushed (since this PR is so small) to address all review comments. I added a blacklist, but please verify that it contains the correct items. I tested this manually, bitcoin.conf contains:

    0debug=1
    1debug=xxx
    2torpassword=hellotor
    

    and then I ran bitcoind --debug=cmdline111 --rpcuser=hellouser and the following appeared in debug.log:

    02019-05-30T15:31:29Z config-file arg:  -debug=1
    12019-05-30T15:31:29Z config-file arg:  -debug=xxx
    22019-05-30T15:31:29Z config-file arg:  -torpassword=****
    32019-05-30T15:31:29Z command-line arg: -debug=cmdline111
    42019-05-30T15:31:29Z command-line arg: -rpcuser=****
    52019-05-30T15:31:29Z command-line arg: -server=1
    
  10. promag commented at 3:45 pm on May 30, 2019: member
    Related to #15493.
  11. in src/util/system.cpp:967 in 2cfbac279b outdated
    963@@ -964,6 +964,31 @@ std::string ArgsManager::GetChainName() const
    964     return CBaseChainParams::MAIN;
    965 }
    966 
    967+void ArgsManager::LogArgs() const
    


    fanquake commented at 3:51 pm on May 30, 2019:
    @ryanofsky You might have some thoughts on this?

    ryanofsky commented at 8:55 pm on July 15, 2019:

    @ryanofsky You might have some thoughts on this?

    I don’t object to this change, but it does seems a little unusual to write the config file to the debug log. Especially when you have to mask passwords and such.

    For debugging purposes, my preferred alternative would be to have a -printconfig flag (similar to existing -help or -version flags) that would print the current settings in ini format. This could be more convenient for debugging because you’d be able to parse the config and get instant feedback without having to bring the daemon up and down. I was also thinking about this as a way of implementing A.J’s suggestion from #15935 (comment) to help debug dynamic settings (“viewing/exporting the current dynamic settings […], so you can paste them into your bitcoin.conf”)

  12. kristapsk commented at 11:00 pm on June 11, 2019: contributor

    Concept ACK, but found two issues.

    02019-06-11T22:57:43Z config-file arg:  -regtest.rpcpassword=123456abcdef
    12019-06-11T22:57:43Z config-file arg:  -regtest.rpcuser=bitcoinrpc
    22019-06-11T22:57:43Z config-file arg:  -rpcpassword=****
    32019-06-11T22:57:43Z config-file arg:  -rpcuser=****
    42019-06-11T22:57:43Z config-file arg:  -server=1
    52019-06-11T22:57:43Z config-file arg:  -test.bind=127.0.0.1
    62019-06-11T22:57:43Z config-file arg:  -test.prune=1000
    72019-06-11T22:57:43Z command-line arg: -testnet=
    
    1. Blacklisted args does not seem to work for regtest (I assume the same problem is for testnet).
    2. Probably there isn’t need for a “=” part for no value arguments (or use “=1”?).
  13. dongcarl commented at 2:53 pm on June 12, 2019: member
    Not 100% sure if this is possible or in scope, but it’d be very useful to have the effective command line configuration at-a-glance, especially when trying to debug for others from looking at their logs.
  14. promag commented at 3:01 pm on June 12, 2019: member

    @dongcarl that’s a bigger change. Basically all default values are defined when the arg is used, so what you want would require to duplicate all of that or move the defaults to one place elsewhere. I don’t think debug log should have all args but maybe we could add an option to control that.

    In #15493 I propose to add a RPC to also see effective arg values.

  15. LarryRuane force-pushed on Jun 14, 2019
  16. LarryRuane commented at 0:25 am on June 14, 2019: contributor
    @kristapsk, I force-pushed a fix for both of your suggestions, thanks! I decided to leave the = off if there are no value arguments, because I didn’t want to assume that having no values would always be the same as =1.
  17. LarryRuane commented at 5:59 am on June 15, 2019: contributor

    I just noticed this PR is incomplete. To provide a little background for those not very familiar with the logging code: The client shrinks debug.log upon startup if it’s larger than a moderate size (11 MB), preserving the most recent 10 MB. This happens only at startup, so if bitcoind runs for a long time, and happens to do a lot of logging, the log file can become enormous.

    External log rotation tools can be configured to prevent the log file from growing unbounded, see #917. Typically the way these tools work is, they first move (as in, the rename system call) debug.log to a different name. Because the client has an open file handle to this file, it continues to log to it even though it’s been moved. Then the log rotation tool sends the client a SIGHUP signal to cause it to close its file descriptor and reopen debug.log. Now it’s actually creating a new debug.log file, and future logging goes there. No data are lost during this switch. The log rotation tool can now do whatever it wants with the renamed (old) log file. It may compress it, offload it, or, either immediately or after some time, delete it.

    If it deletes it, the configuration information that this PR causes to be logged during startup no longer exists anywhere.

    The latest commit, https://github.com/bitcoin/bitcoin/pull/16115/commits/df891038ccce1ea15d2cabcd6717acf60ca9e9ee, re-logs the configuration information whendebug.log is reopened. This guarantees that debug.log always contains the configuration messages. My first idea was to re-log only the configuration file and command line arguments (that are being written by the first part of this PR). But there’s a lot of other useful stuff that gets logged at just after startup. Here’s what appears in debug.log during my testing, after it’s reopened (this does not appear on the console):

     02019-06-15T05:38:03Z Logging: start relogging initial messages
     12019-06-15T05:37:09Z Bitcoin Core version v0.18.99.0-df891038c (release build)
     22019-06-15T05:37:09Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures.
     32019-06-15T05:37:09Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463
     42019-06-15T05:37:09Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
     52019-06-15T05:37:09Z Using RdSeed as additional entropy source
     62019-06-15T05:37:09Z Using RdRand as an additional entropy source
     72019-06-15T05:37:09Z Default data directory /home/larry/.bitcoin
     82019-06-15T05:37:09Z Using data directory /home/larry/.bitcoin/testnet3
     92019-06-15T05:37:09Z Config file: /home/larry/.bitcoin/bitcoin.conf
    102019-06-15T05:37:09Z config-file arg:  -testnet=1
    112019-06-15T05:37:09Z command-line arg: -server=1
    122019-06-15T05:37:09Z Using at most 125 automatic connections (1024 file descriptors available)
    132019-06-15T05:37:09Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
    142019-06-15T05:37:10Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
    152019-06-15T05:37:10Z Using 4 threads for script verification
    162019-06-15T05:37:10Z No wallet support compiled in!
    172019-06-15T05:37:10Z scheduler thread start
    182019-06-15T05:37:10Z HTTP: creating work queue of depth 16
    192019-06-15T05:37:10Z No rpcpassword set - using random cookie authentication.
    202019-06-15T05:37:10Z Generated RPC authentication cookie /home/larry/.bitcoin/testnet3/.cookie
    212019-06-15T05:37:10Z HTTP: starting 4 worker threads
    222019-06-15T05:37:10Z init message: Loading banlist...
    232019-06-15T05:37:10Z Cache configuration:
    242019-06-15T05:37:10Z * Using 2.0 MiB for block index database
    252019-06-15T05:37:10Z * Using 8.0 MiB for chain state database
    262019-06-15T05:37:10Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
    272019-06-15T05:38:03Z Logging: end relogging initial messages
    282019-06-15T05:38:03Z UpdateTip: new best=0000000000000046799df07296169b65f1a203c13b22ffe6df812454ca1e6e45 height=1382445 version=0x20000000 log2_work=71.151478 tx=27610552 date='2018-08-09T15:30:58Z' progress=0.622489 cache=1.6MiB(12574txo)
    292019-06-15T05:38:03Z UpdateTip: new best=000000000000007cdf5e7a5a62f116cad1bb1ba492df4c8aef6b2f9a56075d9f height=1382446 version=0x20000000 log2_work=71.151519 tx=27611112 date='2018-08-09T15:31:47Z' progress=0.622494 cache=1.6MiB(12585txo)
    30[.....]
    

    It’s great to know the exact version number, that this client doesn’t include a wallet, and other configuration things. Note the two “extra” lines that begin with Logging: to show the start and end of this re-logging. The timestamps of the re-logged messages are the original timestamps from when the client actually started (in this case only about a minute earlier); out-of-order timestamps are a little odd, but on the other hand it’s nice to know when the client actually started. After the Logging: end relogging initial messages line, the logging continues where it left off before the file reopen (I was doing reindex at the time).

  18. DrahtBot added the label Needs rebase on Jun 18, 2019
  19. LarryRuane force-pushed on Jun 19, 2019
  20. DrahtBot removed the label Needs rebase on Jun 19, 2019
  21. DrahtBot added the label Needs rebase on Aug 2, 2019
  22. LarryRuane force-pushed on Aug 3, 2019
  23. DrahtBot removed the label Needs rebase on Aug 3, 2019
  24. in src/util/system.cpp:982 in 44f444dcb9 outdated
    977+                LogPrintf("%s %s\n", prefix, arg.first);
    978+                continue;
    979+            }
    980+            std::string v = value;
    981+            for (const auto& b : blacklist) {
    982+                if (arg.first.find(b) != std::string::npos) {
    


    jkczyz commented at 6:54 pm on August 12, 2019:
    This may inadvertently match an arg that contains a blacklisted arg name as a substring (but nonetheless should not be matched). Consider stripping any ignorable prefix from the arg and matching exactly instead. An added benefit is you can use a set for the blacklist as you had before.

    jkczyz commented at 5:57 pm on August 14, 2019:

    During the PR review club session, it came up that a flag could be added for sensitive args.

    https://github.com/bitcoin/bitcoin/blob/a7aa809027633556dd3280c6e29ca98eb3235a3d/src/util/system.h#L138 https://github.com/bitcoin/bitcoin/blob/a7aa809027633556dd3280c6e29ca98eb3235a3d/src/util/system.cpp#L542

    Then rather than maintaining a blacklist, the flag could be checked before logging.


    LarryRuane commented at 2:59 am on August 16, 2019:
    @jkczyz, thanks, adding a flag is an excellent idea, implemented in b6e55d566a92427f1af9775d676ab629eaacbe41. Does that also address your concern about matching a substring? It seems to me it does, since we’re not doing any string or pattern matching at all.
  25. in src/util/system.h:302 in 44f444dcb9 outdated
    296@@ -297,6 +297,12 @@ class ArgsManager
    297      * Return ArgsManager::NONE for unknown arg.
    298      */
    299     unsigned int FlagsOfKnownArg(const std::string& key) const;
    300+
    301+    /**
    302+     * During startup, LogPrintf() the config file options and
    


    jkczyz commented at 9:56 pm on August 12, 2019:

    A couple nits:

    1. Drop “During startup” as this is referring to the call site.
    2. s/LogPrintf()/Log/ to avoid leaking implementation details in the documentation.

    These will help keep the documentation in sync with the code as it changes.


    LarryRuane commented at 3:00 am on August 16, 2019:
    Good suggestion, implemented in latest commit, b6e55d566a92427f1af9775d676ab629eaacbe41.
  26. in test/functional/feature_config_args.py:88 in 371278f727 outdated
    81@@ -82,10 +82,23 @@ def test_log_buffer(self):
    82             self.start_node(0, extra_args=['-noconnect=0'])
    83         self.stop_node(0)
    84 
    85+    def test_args_log(self):
    86+        with self.nodes[0].assert_debug_log(expected_msgs=[
    87+                'command-line arg: -addnode=some.node',
    88+                'command-line arg: -torpassword=****',
    


    jkczyz commented at 10:44 pm on August 12, 2019:
    Could you add any test cases for redacted args beginning with an ignorable prefix (e.g -regtest.)?

    jkczyz commented at 5:59 pm on August 14, 2019:

    Also during the PR review club, it was suggested to update ArgsManager’s unit tests rather than using a functional test.

    https://github.com/bitcoin/bitcoin/blob/master/src/test/getarg_tests.cpp


    jonatack commented at 6:57 pm on August 14, 2019:
    In addition to the other comments e.g. testing of edge cases and using unit tests where possible, tests should also cover each of the blacklisted terms and not just one of them.
  27. jkczyz changes_requested
  28. jkczyz commented at 11:21 pm on August 12, 2019: contributor

    External log rotation tools can be configured to prevent the log file from growing unbounded, see #917. Typically the way these tools work is, they first move (as in, the rename system call) debug.log to a different name. Because the client has an open file handle to this file, it continues to log to it even though it’s been moved. Then the log rotation tool sends the client a SIGHUP signal to cause it to close its file descriptor and reopen debug.log. Now it’s actually creating a new debug.log file, and future logging goes there. No data are lost during this switch. The log rotation tool can now do whatever it wants with the renamed (old) log file. It may compress it, offload it, or, after some time, delete it.

    If it deletes it, the configuration information that this PR causes to be logged during startup no longer exists anywhere.

    The latest commit, df89103, re-logs the configuration information whendebug.log is reopened. This guarantees that debug.log always contains the configuration messages. My first idea was to re-log only the configuration file and command line arguments (that are being written by the first part of this PR). But there’s a lot of other useful stuff that gets logged at just after startup. Here’s what appears in debug.log during my testing, after it’s reopened (this does not appear on the console):

    There’s quite a bit of complexity added to the code to handle this case (e.g. the additional logic in BCLog::Logger::LogPrintStr and the fact m_relog_save is modified across different functions).

    In practice, how often does this situation arise and where the missing information would have been helpful? Would it be reasonable for users to configure their log rotation tools to preserve the first log file instead?

  29. fjahr commented at 5:38 pm on August 14, 2019: member
    The commit message for the test is incorrect: it is a functional test, not a unit test.
  30. jkczyz changes_requested
  31. in src/logging.cpp:247 in 371278f727 outdated
    245     m_started_new_line = !str.empty() && str[str.size()-1] == '\n';
    246 
    247+    // While the system is initializing, save some reasonable number
    248+    // of (configuration-related) log messages for re-logging when
    249+    // the log file rotates (gets reopened).
    250+    if (m_relog_save && m_msgs_relog.size() < 200) {
    


    narula commented at 6:05 pm on August 14, 2019:
    200 seems arbitrary
  32. jnewbery commented at 6:07 pm on August 14, 2019: member

    I think this PR should be split in two. The two commits on startup, write config options to debug.log and re-log configuration when debug.log is reopened both address logging, but are essentially independent.

    I’m a concept ACK for the first commit (on startup, write config options to debug.log) and would like to see it merged, but a weak concept NACK on the second (re-log configuration when debug.log is reopened) since I think it adds unnecessary complexity to the bitcoind code for something that should really be handled externally.

  33. narula commented at 6:10 pm on August 14, 2019: contributor
    I think it would be better for saving startup debug information to be handled outside of bitcoind. That way there’s less confusion about what should/shouldn’t get relogged, less code complexity, and users who save all their logs files will not be logging things redundantly.
  34. in src/util/system.cpp:967 in 371278f727 outdated
    958@@ -959,6 +959,43 @@ std::string ArgsManager::GetChainName() const
    959     return CBaseChainParams::MAIN;
    960 }
    961 
    962+static void logArgs(
    963+    const std::string& prefix,
    964+    const std::map<std::string, std::vector<std::string>>& args)
    965+{
    966+    // don't log passwords and other sensitive values
    967+    static const std::string blacklist[] = {
    


    jonatack commented at 7:02 pm on August 14, 2019:

    Short of refactoring this PR to use a flag as suggested elsewhere and during the PR Review Club (log here);

    • a whitelist would be safer than a blacklist
    • there needs to be some mechanism - code docs and perhaps also in the developer notes docs - to help ensure this list is updated on future arg changes

    LarryRuane commented at 2:58 am on August 16, 2019:
    @jonatack, great suggestion, modified to use a flag in b6e55d566a92427f1af9775d676ab629eaacbe41. (I also agree that a whitelist would be better than a blacklist.) I will investigate to find a good place to document this. (I’m new here, so any suggestions would be appreciated.)
  35. jonatack commented at 7:05 pm on August 14, 2019: member
    Concept ACK with reserves regarding the approach and implementation so the changes can be robust, maintainable, safe and adequately covered by tests.
  36. LarryRuane force-pushed on Aug 16, 2019
  37. LarryRuane commented at 3:11 am on August 16, 2019: contributor
    Thanks for the review comments; they’re very helpful. The latest commit, b6e55d566a92427f1af9775d676ab629eaacbe41, addresses some of the comments (I’ll address the others soon). This was a force-push because of rebase with master.
  38. in test/functional/feature_config_args.py:112 in 99931694ed outdated
     97+                ]):
     98             self.start_node(0, extra_args=[
     99                 '-addnode=some.node',
    100-                '-torpassword=mypass',
    101+                '-torpassword=torpassword',
    102             ])
    


    LarryRuane commented at 7:39 pm on August 16, 2019:
    This test was not verifying that arguments that should not be logged to debug.log are indeed not logged. I wanted to add test the full list of what should not be logged (torpassword, rpcauth, rpcbind, rpcpassword, rpcuser), but specifying any of those except torpassword on the command line causes the test framework to fail ("Error: no RPC connection), so I couldn’t think of a way to test that the logging of those is suppressed. I think this test is still useful, however, because it’s pretty easy to see in init.cpp that torpassword is treated the same as the others (namely, that they all include ArgsManager::DONT_LOG).

    jonatack commented at 2:54 pm on January 12, 2020:
    Thanks @LarryRuane for taking the suggestion to cover all the DONT_LOG cases and your change to pass only the values to unexpected_messages makes it even better. The only thing I regret is having suggested “satoshi” as the rpcuser because it pollutes git grepping; a name that isn’t already used by the codebase like “charlie” or “abc123”, etc., would have been better.
  39. LarryRuane force-pushed on Aug 17, 2019
  40. LarryRuane commented at 5:13 pm on August 17, 2019: contributor

    Thanks for all the review feedback! The most recent force-push removes the second part of this PR (the extra logging that happens when the log rotates). I agree with @narula’s and others’ opinions that this can be handled outside of bitcoind. I will probably submit a separate PR for relogging the config information on log rotation.

    A good way for the log rotation tools to work is to either save all the log files (which may not be practical), or, when rotating the log file, check to see if the file being rotated out includes the start of the currently-running bitcoind instance (it could search for the string Bitcoin Core version). If found, keep the file, or at least that section of the file. Then remember to send that part to a developer or support person requesting debug.log. (It’s that “remember” part that makes me wonder if relogging on log rotation might still be a good idea.)

  41. LarryRuane commented at 2:18 am on August 19, 2019: contributor

    An additional thought related to this part of my most recent comment:

    Then remember to send that part to a developer or support person requesting debug.log

    Here’s a better procedure that the log rotation tool can follow: After moving debug.log to a new name, it can create a new debug.log file and write the initial (configuration-related) messages to it. Then send the SIGHUP signal. The next log message will be appended to debug.log – after the initial messages. (I verified this behavior.)

  42. LarryRuane force-pushed on Aug 19, 2019
  43. DrahtBot added the label Needs rebase on Aug 21, 2019
  44. LarryRuane force-pushed on Aug 21, 2019
  45. DrahtBot removed the label Needs rebase on Aug 21, 2019
  46. LarryRuane force-pushed on Aug 21, 2019
  47. in src/util/system.cpp:979 in 10ff7f645e outdated
    974+        if (FlagsOfKnownArg(arg.first) & DONT_LOG)
    975+            continue;
    976+        for (auto& value : arg.second) {
    977+            if (value.empty()) {
    978+                LogPrintf("%s %s\n", prefix, arg.first);
    979+                continue;
    


    jkczyz commented at 7:37 pm on August 22, 2019:
    Rather than use continue, it would be more natural to use an else clause.

    LarryRuane commented at 2:59 pm on August 23, 2019:
    Good suggestion, thanks, fixed 7f4640338de05fce1cf59bc567b6674a94931c23.
  48. in src/util/system.cpp:975 in 10ff7f645e outdated
    970+    const std::string& prefix,
    971+    const std::map<std::string, std::vector<std::string>>& args) const
    972+{
    973+    for (const auto& arg : args) {
    974+        if (FlagsOfKnownArg(arg.first) & DONT_LOG)
    975+            continue;
    


    jkczyz commented at 7:47 pm on August 22, 2019:
    Don’t you still want to log that the arg was set only with the value redacted?

    LarryRuane commented at 3:05 pm on August 23, 2019:
    What do you think? Somehow I changed my mind and thought it might be better to not show it at all. But it is more informative to show that the argument was specified. I can easily change it back.

    LarryRuane commented at 1:00 pm on August 25, 2019:
    @jkczyz, after more thought, I agree your idea is better, 676eb23315cd23c84bbfe5bc4c41652b1f6d8bb5.
  49. jkczyz commented at 8:46 pm on August 22, 2019: contributor

    @jkczyz, thanks, adding a flag is an excellent idea, implemented in b6e55d5. Does that also address your concern about matching a substring? It seems to me it does, since we’re not doing any string or pattern matching at all.

    Yeah, looks like FlagsOfKnownArg handles this for you.

  50. in test/functional/test_framework/test_node.py:303 in f67dc7bbbd outdated
    306@@ -307,7 +307,9 @@ def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
    307         wait_until(self.is_node_stopped, timeout=timeout)
    308 
    309     @contextlib.contextmanager
    310-    def assert_debug_log(self, expected_msgs, unexpected_msgs=[], timeout=2):
    311+    def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
    312+        if unexpected_msgs is None:
    313+            unexpected_msgs = []
    


    LarryRuane commented at 3:21 am on August 26, 2019:
    @practicalswift found this bug while reviewing #16673 but the bug originated in the current PR (which #16673 is based on). Fixed here, will rebase #16673 to pick up the fix there.
  51. in src/util/system.cpp:890 in f67dc7bbbd outdated
    972+{
    973+    for (const auto& arg : args) {
    974+        for (auto& value : arg.second) {
    975+            if (value.empty()) {
    976+                LogPrintf("%s %s\n", prefix, arg.first);
    977+            } else {
    


    jkczyz commented at 3:39 pm on August 26, 2019:
    You can reduce one level of nesting by making this an else-if.
  52. DrahtBot added the label Needs rebase on Sep 5, 2019
  53. LarryRuane force-pushed on Sep 5, 2019
  54. DrahtBot removed the label Needs rebase on Sep 5, 2019
  55. laanwj added the label Feature on Sep 30, 2019
  56. ysangkok commented at 7:51 pm on November 9, 2019: none
    Should I wait for a rebase to test this, or is it better if I test it as it is? Or should I try to rebase myself?
  57. LarryRuane force-pushed on Nov 18, 2019
  58. LarryRuane force-pushed on Nov 18, 2019
  59. LarryRuane force-pushed on Nov 19, 2019
  60. LarryRuane commented at 6:25 am on November 19, 2019: contributor
    @ysangkok, I integrated with the conflicting recent change (7f40528cd50fc43ac0bd3e785de24d661adddb7a) using a separate commit (https://github.com/bitcoin/bitcoin/pull/16115/commits/07f11f171c82bcbd9d79272c8f87002e39a7521b), force-pushed rebase. Now would be a good time to test, thanks.
  61. LarryRuane commented at 6:47 am on November 19, 2019: contributor

    To give you a little better understanding of what this PR does, here’s part of the debug.log file after running one of the functional (python) tests with the -nocleanup option. After the most recent rebase, the config file section string gets printed out (within square brackets):

     02019-11-18T22:47:48.371866Z [init] Default data directory /home/larry/.bitcoin
     12019-11-18T22:47:48.371882Z [init] Using data directory /tmp/bitcoin_func_test_z99aclji/node0/regtest
     22019-11-18T22:47:48.371901Z [init] Config file: /tmp/bitcoin_func_test_z99aclji/node0/bitcoin.conf
     32019-11-18T22:47:48.371922Z [init] config-file arg: regtest=1
     42019-11-18T22:47:48.371937Z [init] config-file arg: [regtest] bind=127.0.0.1
     52019-11-18T22:47:48.371950Z [init] config-file arg: [regtest] discover=0
     62019-11-18T22:47:48.371963Z [init] config-file arg: [regtest] dnsseed=0
     72019-11-18T22:47:48.371976Z [init] config-file arg: [regtest] fallbackfee=0.0002
     82019-11-18T22:47:48.371990Z [init] config-file arg: [regtest] keypool=1
     92019-11-18T22:47:48.372002Z [init] config-file arg: [regtest] listenonion=0
    102019-11-18T22:47:48.372015Z [init] config-file arg: [regtest] port=14243
    112019-11-18T22:47:48.372031Z [init] config-file arg: [regtest] printtoconsole=0
    122019-11-18T22:47:48.372049Z [init] config-file arg: [regtest] rpcport=19243
    132019-11-18T22:47:48.372072Z [init] config-file arg: [regtest] server=1
    142019-11-18T22:47:48.372088Z [init] config-file arg: [regtest] shrinkdebugfile=0
    152019-11-18T22:47:48.372106Z [init] config-file arg: [regtest] upnp=0
    162019-11-18T22:47:48.372119Z [init] command-line arg: datadir=/tmp/bitcoin_func_test_z99aclji/node0
    172019-11-18T22:47:48.372135Z [init] command-line arg: debug
    182019-11-18T22:47:48.372150Z [init] command-line arg: debugexclude=libevent
    192019-11-18T22:47:48.372165Z [init] command-line arg: debugexclude=leveldb
    202019-11-18T22:47:48.372179Z [init] command-line arg: logthreadnames
    212019-11-18T22:47:48.372194Z [init] command-line arg: logtimemicros
    222019-11-18T22:47:48.372209Z [init] command-line arg: uacomment=testnode0
    232019-11-18T22:47:48.372223Z [init] command-line arg: wallet=0
    242019-11-18T22:47:48.372236Z [init] Using at most 125 automatic connections (1024 file descriptors available)
    

    It actually could be useful to have this information available when trying to debug or analyze a functional test or the code being tested (although you can figure it out if you study the code enough), because some of these values differ across the tests.

  62. LarryRuane force-pushed on Nov 21, 2019
  63. in src/util/system.cpp:879 in d95fdc78c9 outdated
    891+                if (valueStr.size()) {
    892+                    LogPrintf("%s %s%s=%s\n", prefix, sectionStr, arg.first, valueStr);
    893+                } else {
    894+                    LogPrintf("%s %s%s\n", prefix, sectionStr, arg.first);
    895+                }
    896+            }
    


    ryanofsky commented at 4:50 pm on November 25, 2019:

    In commit “merge with ‘Deduplicate settings’ commit” (d95fdc78c965708866156898588221a8d983396f)

    Would suggest:

    0if (FlagsOfKnownArg(arg.first) & DONT_LOG) {
    1    LogPrintf("%s %s%s=****\n", prefix, sectionStr, arg.first);
    2} else {
    3    LogPrintf("%s %s%s=%s\n", prefix, sectionStr, arg.first, value.write());
    4}
    

    This is simpler than formatting code in the PR, more future proof, and also less ambiguous about negated options.

    Would also suggest squashing commits.


    LarryRuane commented at 5:10 pm on November 26, 2019:

    @ryanofsky, thanks, I like that much better. I implemented your suggestion (with a small difference, only a single call to LogPrintf()), rebased, squashed, force-pushed (eb973ff916f88ed36b59ae6466ec16dd30811215). The formatting is slightly different now, but I like that the code is much simpler and the output is more consistent (this is from one of the functional tests):

     02019-11-26T16:09:54.048744Z [init] config-file arg: regtest="1"
     12019-11-26T16:09:54.048755Z [init] config-file arg: [regtest] bind="127.0.0.1"
     22019-11-26T16:09:54.048765Z [init] config-file arg: [regtest] discover="0"
     32019-11-26T16:09:54.048774Z [init] config-file arg: [regtest] dnsseed="0"
     42019-11-26T16:09:54.048784Z [init] config-file arg: [regtest] fallbackfee="0.0002"
     52019-11-26T16:09:54.048793Z [init] config-file arg: [regtest] keypool="1"
     62019-11-26T16:09:54.048802Z [init] config-file arg: [regtest] listenonion="0"
     72019-11-26T16:09:54.048812Z [init] config-file arg: [regtest] port="11068"
     82019-11-26T16:09:54.048822Z [init] config-file arg: [regtest] printtoconsole="0"
     92019-11-26T16:09:54.048833Z [init] config-file arg: [regtest] rpcport="16068"
    102019-11-26T16:09:54.048843Z [init] config-file arg: [regtest] server="1"
    112019-11-26T16:09:54.048854Z [init] config-file arg: [regtest] shrinkdebugfile="0"
    122019-11-26T16:09:54.048865Z [init] config-file arg: [regtest] upnp="0"
    132019-11-26T16:09:54.048874Z [init] command-line arg: datadir="/tmp/bitcoin_func_test_wmar_kd1/node0"
    142019-11-26T16:09:54.048884Z [init] command-line arg: debug=""
    152019-11-26T16:09:54.048895Z [init] command-line arg: debugexclude="libevent"
    162019-11-26T16:09:54.048904Z [init] command-line arg: debugexclude="leveldb"
    172019-11-26T16:09:54.048914Z [init] command-line arg: logthreadnames=""
    182019-11-26T16:09:54.048924Z [init] command-line arg: logtimemicros=""
    192019-11-26T16:09:54.048934Z [init] command-line arg: uacomment="testnode0"
    

    I like the way negative arguments are displayed; as you say, they are less ambiguous. There are no examples of such from above, but I ran src/bitcoind -noreindex and the following appears in debug.log:

    02019-11-26T17:00:24Z command-line arg: reindex=false
    

    I added a unit test for this too. Thank you for taking the time to review!

  64. LarryRuane force-pushed on Nov 26, 2019
  65. LarryRuane force-pushed on Nov 26, 2019
  66. in src/util/system.cpp:882 in eb973ff916 outdated
    873@@ -874,6 +874,29 @@ std::string ArgsManager::GetChainName() const
    874     return GetArg("-chain", CBaseChainParams::MAIN);
    875 }
    876 
    877+void ArgsManager::logArgsPrefix(
    878+    const std::string& prefix,
    879+    const std::string& section,
    880+    const std::map<std::string, std::vector<util::SettingsValue>>& args) const
    881+{
    882+    std::string sectionStr = section.empty() ? "" : "[" + section + "] ";
    


    ryanofsky commented at 5:31 pm on November 26, 2019:

    In commit “on startup, write config options to debug.log” (eb973ff916f88ed36b59ae6466ec16dd30811215)

    sectionStr is an older convention for variable names. Newer code is using section_str https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-c

  67. ryanofsky approved
  68. ryanofsky commented at 9:01 pm on November 26, 2019: member

    Code review ACK eb973ff916f88ed36b59ae6466ec16dd30811215. Looks good!

    I don’t know how to write an automated test for these changes, suggestions are welcome.

    Could remove this line from the PR description since there are tests now.

  69. LarryRuane force-pushed on Nov 27, 2019
  70. LarryRuane commented at 4:14 pm on November 27, 2019: contributor
    Thanks, @ryanofsky, fixed variable names (in two places), rebased, force-pushed. Also, I changed the PR description as suggested, and simplified it (since it goes into the commit history), no need to show sample output there, which was out of date anyway.
  71. ryanofsky approved
  72. ryanofsky commented at 5:47 pm on November 27, 2019: member
    Code review ACK 85f44c083d75b71bce149eff4ecdc9b543dd7dfa. Just variable renames and updated PR description since last review
  73. DrahtBot added the label Needs rebase on Dec 13, 2019
  74. LarryRuane force-pushed on Dec 13, 2019
  75. DrahtBot removed the label Needs rebase on Dec 13, 2019
  76. ryanofsky approved
  77. ryanofsky commented at 8:02 pm on December 16, 2019: member
    Code review ACK 6d195a8da92b60161669e56de6cbb4a5baafdf84. No changes since last review other than rebase due to conflict from adjacent rpcwhitelist line
  78. DrahtBot added the label Needs rebase on Dec 19, 2019
  79. jnewbery commented at 9:16 pm on December 19, 2019: member
    Definite concept ACK. This needs a rebase, but I’ve read the current code and it looks good. I’ll re-review once this has been rebased on master.
  80. LarryRuane force-pushed on Dec 20, 2019
  81. LarryRuane commented at 7:10 am on December 20, 2019: contributor
    Rebased onto master, force-pushed 3028a27
  82. DrahtBot removed the label Needs rebase on Dec 20, 2019
  83. in src/util/system.cpp:887 in 3028a27c5f outdated
    882+
    883+void ArgsManager::LogArgs() const
    884+{
    885+    LOCK(cs_args);
    886+    for (const auto& section : m_settings.ro_config) {
    887+        logArgsPrefix("config-file arg:", section.first, section.second);
    


    jnewbery commented at 4:38 pm on December 20, 2019:
    nit: s/config-file/Config file/ (config file is not usually hyphenated)
  84. in src/util/system.cpp:889 in 3028a27c5f outdated
    884+{
    885+    LOCK(cs_args);
    886+    for (const auto& section : m_settings.ro_config) {
    887+        logArgsPrefix("config-file arg:", section.first, section.second);
    888+    }
    889+    logArgsPrefix("command-line arg:", "", m_settings.command_line_options);
    


    jnewbery commented at 4:40 pm on December 20, 2019:
    s/command-line/Command-line/ (first letter of logs are usually capitalized)

    LarryRuane commented at 10:04 pm on December 20, 2019:
    Thanks, done, separate commit 717099eef1cc5670180a58d0fec6d027a1e2f95d. I’ll squash after review (or, at least before merge).

    hebasto commented at 10:26 pm on December 20, 2019:

    I’ll squash after review (or, at least before merge)

    It is better to squash before review as a merge commit should contain ACKs with the latest commit hash.

  85. jnewbery commented at 4:41 pm on December 20, 2019: member

    Tested ACK 3028a27c5fde8e341cccb743b31a02c1bd7d934d

    I’ve left a couple of small style nit. Feel free to ignore.

  86. jnewbery commented at 11:15 pm on December 20, 2019: member
    ACK 717099eef1cc5670180a58d0fec6d027a1e2f95d
  87. LarryRuane force-pushed on Dec 21, 2019
  88. LarryRuane commented at 3:22 pm on December 21, 2019: contributor
    Rebased onto master, squashed, force-pushed.
  89. LarryRuane force-pushed on Dec 22, 2019
  90. jnewbery commented at 3:04 pm on December 24, 2019: member

    Code review ACK 4a88ddac84235398a0ea8c041baee7192a6b4d09

    Rebased onto master …

    I don’t think this needed rebasing on master. It’s better not to rebase on master unless necessary, since it generates additional work for reviewers

  91. LarryRuane commented at 7:56 pm on December 24, 2019: contributor

    I don’t think this needed rebasing on master. It’s better not to rebase on master unless necessary, since it generates additional work for reviewers

    Absolutely right, sorry about that; I actually thought of that just after I did that. I’ll avoid unnecessary rebases from now on. Thanks for the new ACK.

  92. hebasto commented at 8:58 am on December 25, 2019: member
    Concept ACK. Will test.
  93. hebasto approved
  94. hebasto commented at 10:27 am on December 25, 2019: member

    ACK 4a88ddac84235398a0ea8c041baee7192a6b4d09, I have tested the code on Linux Mint 19.3, including:

    • no bitcoin.conf
    • duplicated option names in bitcoin.conf and in the command line

    Every time it works as expected.

  95. ryanofsky approved
  96. ryanofsky commented at 10:05 pm on January 8, 2020: member
    Code review ACK 4a88ddac84235398a0ea8c041baee7192a6b4d09. Just rebase and spelling/capitalization tweaks since last review
  97. jnewbery commented at 3:37 am on January 9, 2020: member
    @ryanofsky : current branch is 4a88dda
  98. ryanofsky commented at 5:58 pm on January 9, 2020: member

    @ryanofsky : current branch is 4a88dda

    Thanks fixed comment. That was the hash I meant

  99. jonatack commented at 7:02 pm on January 9, 2020: member
    Will re-review and test tomorrow.
  100. in test/functional/test_framework/test_node.py:303 in 4a88ddac84 outdated
    297@@ -298,7 +298,9 @@ def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
    298         wait_until(self.is_node_stopped, timeout=timeout)
    299 
    300     @contextlib.contextmanager
    301-    def assert_debug_log(self, expected_msgs, timeout=2):
    302+    def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
    303+        if unexpected_msgs is None:
    304+            unexpected_msgs = []
    


    jonatack commented at 8:46 pm on January 10, 2020:

    Can simplify?

    0-    def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
    1-        if unexpected_msgs is None:
    2-            unexpected_msgs = []
    3+    def assert_debug_log(self, expected_msgs, unexpected_msgs=[], timeout=2):
    

    jnewbery commented at 10:13 pm on January 10, 2020:
    It’s generally best to use None as the default argument instead of a mutable default arg: https://docs.python-guide.org/writing/gotchas/#what-you-should-do-instead

    jonatack commented at 10:34 pm on January 10, 2020:
    Thanks @jnewbery, TIL.
  101. in test/functional/feature_config_args.py:86 in 4a88ddac84 outdated
    82@@ -83,10 +83,28 @@ def test_log_buffer(self):
    83             self.start_node(0, extra_args=['-noconnect=0'])
    84         self.stop_node(0)
    85 
    86+    def test_args_log(self):
    


    jonatack commented at 8:48 pm on January 10, 2020:

    Could use a docstring or logging here, e.g.

    0+        self.log.info('Test config args logging')
    

    That said, the whole file is lacking logging, not just this test, so feel free to ignore.

  102. jonatack commented at 9:17 pm on January 10, 2020: member
    Tested ACK 4a88ddac84235398a0ea8c041baee7192a6b4d09 modulo comments below.
  103. in test/functional/feature_config_args.py:99 in 4a88ddac84 outdated
    94+                unexpected_msgs=[
    95+                    'torpassword=torpassword',
    96+                ]):
    97+            self.start_node(0, extra_args=[
    98+                '-addnode=some.node',
    99+                '-torpassword=torpassword',
    


    jonatack commented at 9:22 pm on January 10, 2020:

    This test can be improved with (tested change):

     0                 expected_msgs=[
     1                     'Command-line arg: addnode="some.node"',
     2+                    'Command-line arg: rpcauth=****',
     3+                    'Command-line arg: rpcbind=****',
     4+                    'Command-line arg: rpcpassword=****',
     5+                    'Command-line arg: rpcuser=****',
     6                     'Command-line arg: torpassword=****',
     7                     'Config file arg: regtest="1"',
     8                     'Config file arg: [regtest] server="1"',
     9                 ],
    10                 unexpected_msgs=[
    11+                    'rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
    12+                    'rpcbind=127.1.1.1',
    13+                    'rpcuser=satoshi',
    14                     'torpassword=torpassword',
    15                 ]):
    16             self.start_node(0, extra_args=[
    17                 '-addnode=some.node',
    18+                '-rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
    19+                '-rpcbind=127.1.1.1',
    20+                '-rpcpassword=',
    21+                '-rpcuser=satoshi',
    22                 '-torpassword=torpassword',
    
  104. jonatack commented at 9:25 pm on January 10, 2020: member
    • My main comment was not saved by GitHub in my review so I am re-adding it below.
    • I tested this PR and the suggested changes after rebasing to current master at e7f84503571c171a7e6728cd2d77dd4103bd7a6f.
  105. LarryRuane force-pushed on Jan 11, 2020
  106. LarryRuane commented at 4:39 pm on January 11, 2020: contributor
    @jonatack, thanks for the suggestions, force-pushed (without rebasing onto master) both changes. I made one other change that I hope you agree is an improvement: I removed the keywords from the list of unexpected messages, for example, changed rpcuser=satoshi to just satoshi. The reason is, if there was a weird bug by which the log contained (let’s say) ruser=satoshi or rpcuser = satoshi (note the spaces around =) or many other variants, this test would still pass. What we really care about is not leaking the values of these settings (the string satoshi) to the log file, so those values are what we should make sure aren’t present in the log file.
  107. hebasto commented at 4:44 pm on January 11, 2020: member

    @LarryRuane

    … force-pushed (without rebasing onto master)…

    Needless rebasing makes reviewing of consequent changes harder ;) Thank you.

  108. hebasto approved
  109. hebasto commented at 4:54 pm on January 11, 2020: member
    ACK 8c09bf9508b12e3593e4f6d23ed4dcfdabda7f2b, the only change in feature_config_args.py test, tested locally on Linux Mint 19.3.
  110. in src/test/getarg_tests.cpp:200 in 8c09bf9508 outdated
    194+
    195+    // Log the arguments to debug.log
    196+    gArgs.LogArgs();
    197+
    198+    // Open and read debug.log.
    199+    FILE* file = fsbridge::fopen(LogInstance().m_file_path, "rb");
    


    jonatack commented at 2:49 pm on January 12, 2020:

    Should #include <fs.h> be explicitly added to this file? Other code and unit tests using fsbridge seem to include it, and according to developer-notes.md:

    0- Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other
    1  definitions from, even if those headers are already included indirectly through other headers.
    2
    3  - *Rationale*: Excluding headers because they are already indirectly included results in compilation
    4    failures when those indirect dependencies change. Furthermore, it obscures what the real code
    5    dependencies are.
    

    jonatack commented at 2:57 pm on January 12, 2020:

    Other than that, the new unit tests look good and provide helpful feedback when run with

    src/test/test_bitcoin -t getarg_tests/logargs -l all


    laanwj commented at 3:31 pm on January 15, 2020:
    I think we could test this without reading an actual file by registering a log callback with PushBackCallback (and DeleteCallback afterwards).

    MarcoFalke commented at 3:46 pm on January 15, 2020:
    I think there is also an ASSERT_DEBUG_LOG which might come in handy
  111. jonatack commented at 2:59 pm on January 12, 2020: member
    ACK 8c09bf9508b12e3593e4f6d23ed4dcfdabda7f2b Two comments, feel free to ignore or handle them in a follow-up.
  112. in src/init.cpp:1234 in 8c09bf9508 outdated
    1217@@ -1218,6 +1218,7 @@ bool AppInitMain(NodeContext& node)
    1218         // Not categorizing as "Warning" because it's the default behavior
    1219         LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string());
    1220     }
    1221+    gArgs.LogArgs();
    


    jonatack commented at 3:05 pm on January 12, 2020:

    nit: this is commented in the unit test but not here; perhaps add:

    0+
    1+    // Log the config arguments to debug.log
    2     gArgs.LogArgs();
    

    hebasto commented at 8:49 am on January 13, 2020:
    It seems this comment does not add any value here, no?

    jonatack commented at 11:03 am on January 13, 2020:
    I think it may gain time for occasional contributors/readers, and perhaps for those who haven’t reviewed this PR, by confirming what the laconic gArgs.LogArgs(); is doing exactly (which args, logged where) without the need to git grep. At least, more help than harm.
  113. LarryRuane force-pushed on Jan 13, 2020
  114. LarryRuane commented at 4:07 pm on January 13, 2020: contributor
    Thanks, I force-pushed the suggested changes.
  115. ryanofsky approved
  116. ryanofsky commented at 7:27 pm on January 13, 2020: member
    Code review ACK 8317bb35b63062e0d54de3af19d923456e1cb467. Just new comments, include, test cases since last review
  117. jonatack commented at 7:30 pm on January 13, 2020: member

    Tested ACK 8317bb35b63062e0d54de3af19d923456e1cb467

    git diff 8c09bf9..8317bb3 since last push:

     0diff --git a/src/init.cpp b/src/init.cpp
     1index 04305c9b23..6a91c8c1ce 100644
     2--- a/src/init.cpp
     3+++ b/src/init.cpp
     4@@ -1218,6 +1218,8 @@ bool AppInitMain(NodeContext& node)
     5         // Not categorizing as "Warning" because it's the default behavior
     6         LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string());
     7     }
     8+
     9+    // Log the config arguments to debug.log
    10     gArgs.LogArgs();
    11 
    12     LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
    13diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp
    14index 090c544be3..bebc56c57b 100644
    15--- a/src/test/getarg_tests.cpp
    16+++ b/src/test/getarg_tests.cpp
    17@@ -2,6 +2,7 @@
    18 // Distributed under the MIT software license, see the accompanying
    19 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
    20 
    21+#include <fs.h>
    22 #include <util/strencodings.h>
    23 #include <util/system.h>
    24 #include <test/util/setup_common.h>
    25diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py
    26index de8461ea5a..ec6268f5fb 100755
    27--- a/test/functional/feature_config_args.py
    28+++ b/test/functional/feature_config_args.py
    29@@ -99,16 +99,16 @@ class ConfArgsTest(BitcoinTestFramework):
    30                 unexpected_msgs=[
    31                     'alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
    32                     '127.1.1.1',
    33-                    'satoshi',
    34-                    'tpass',
    35+                    'secret-rpcuser',
    36+                    'secret-torpassword',
    37                 ]):
    38             self.start_node(0, extra_args=[
    39                 '-addnode=some.node',
    40                 '-rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
    41                 '-rpcbind=127.1.1.1',
    42                 '-rpcpassword=',
    43-                '-rpcuser=satoshi',
    44-                '-torpassword=tpass',
    45+                '-rpcuser=secret-rpcuser',
    46+                '-torpassword=secret-torpassword',
    47             ])
    48         self.stop_node(0)
    

    Launching bitcoind with this PR adds the following lines to the debug log that correctly list all of the custom settings, re-sorted in alphabetical order (first the config file settings, followed by the command line args) between Config file: and Using at most 512 automatic connections:

     02020-01-13T19:14:02Z Config file arg: addresstype="bech32"
     12020-01-13T19:14:02Z Config file arg: blocksonly="0"
     22020-01-13T19:14:02Z Config file arg: dbcache="8192"
     32020-01-13T19:14:02Z Config file arg: logips="1"
     42020-01-13T19:14:02Z Config file arg: maxconnections="512"
     52020-01-13T19:14:02Z Config file arg: maxuploadtarget="0"
     62020-01-13T19:14:02Z Config file arg: par="0"
     72020-01-13T19:14:02Z Config file arg: rpcpassword=****
     82020-01-13T19:14:02Z Config file arg: rpcuser=****
     92020-01-13T19:14:02Z Config file arg: server="1"
    102020-01-13T19:14:02Z Config file arg: txindex="1"
    112020-01-13T19:14:02Z Config file arg: walletbroadcast="1"
    122020-01-13T19:14:02Z Command-line arg: dbcache="256"
    132020-01-13T19:14:02Z Command-line arg: logips="0"
    142020-01-13T19:14:02Z Command-line arg: walletbroadcast="0"
    
  118. jnewbery commented at 8:00 pm on January 13, 2020: member
    ACK 8317bb35b63062e0d54de3af19d923456e1cb467
  119. hebasto approved
  120. hebasto commented at 9:29 am on January 14, 2020: member
    re-ACK 8317bb35b63062e0d54de3af19d923456e1cb467
  121. in src/util/system.h:149 in 8317bb35b6 outdated
    144@@ -145,6 +145,8 @@ class ArgsManager
    145          * between mainnet and regtest/testnet won't cause problems due to these
    146          * parameters by accident. */
    147         NETWORK_ONLY = 0x200,
    148+        // This argument's value is sensitive (such as a password).
    149+        DONT_LOG = 0x400,
    


    MarcoFalke commented at 3:49 pm on January 15, 2020:
    I’d prefer to call this SENSITIVE or PRIVATE or similar to avoid a negated option (which might lead to double negations), but more importantly make it agnostic of how the values are reported. If in the future someone adds a getconfigargs RPC, the internal wording “log” seems a bit off.
  122. LarryRuane force-pushed on Jan 19, 2020
  123. LarryRuane force-pushed on Jan 19, 2020
  124. LarryRuane commented at 1:54 am on January 19, 2020: contributor

    Implemented review suggestions:

    • rename DONT_LOG to SENSITIVE
    • in the unit test, verify log file contents without opening and reading debug.log

    Here are the changes in the last force-push (I think this PR should remain a single commit), in case that’s helpful to reviewers: https://github.com/LarryRuane/bitcoin/compare/8317bb35b63062e0d54de3af19d923456e1cb467..03fdf86b6d4bc036c707a0b0d84995f438283b11

  125. LarryRuane force-pushed on Jan 20, 2020
  126. jnewbery commented at 7:50 pm on January 20, 2020: member
    ACK 03fdf86b6d4bc036c707a0b0d84995f438283b11
  127. DrahtBot added the label Needs rebase on Jan 29, 2020
  128. on startup, write config options to debug.log b951b0973c
  129. LarryRuane force-pushed on Jan 29, 2020
  130. DrahtBot removed the label Needs rebase on Jan 29, 2020
  131. jonatack commented at 9:13 pm on January 30, 2020: member

    ACK b951b0973c reviewed diff, re-code review, built, ran tests, launched bitcoind and reviewed debug log output, verified value of str debug log in the added unit test.

    0$ src/test/test_bitcoin -t getarg_tests/logargs -l test_suite
    1.../...
    2
    32020-01-30T20:48:38Z Command-line arg: dontlog=****
    42020-01-30T20:48:38Z Command-line arg: okaylog="public"
    52020-01-30T20:48:38Z Command-line arg: okaylog-bool=""
    62020-01-30T20:48:38Z Command-line arg: okaylog-negbool=false
    
     0$ bitcoind -dbcache=512 -logips=0 -walletbroadcast=0
     12020-01-30T19:01:24Z Bitcoin Core version v0.19.99.0-b951b0973c (debug build)
     22020-01-30T19:01:24Z Assuming ancestors of block 00000000000000000005f8920febd3925f8272a6a71237563d78c2edfdd09ddf have valid signatures.
     32020-01-30T19:01:24Z Setting nMinimumChainWork=000000000000000000000000000000000000000008ea3cf107ae0dec57f03fe8
     42020-01-30T19:01:24Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
     52020-01-30T19:01:24Z Using RdSeed as additional entropy source
     62020-01-30T19:01:24Z Using RdRand as an additional entropy source
     72020-01-30T19:01:24Z Default data directory /home/jon/.bitcoin
     82020-01-30T19:01:24Z Using data directory /home/jon/.bitcoin
     92020-01-30T19:01:24Z Config file: /home/jon/.bitcoin/bitcoin.conf
    102020-01-30T19:01:24Z Config file arg: addresstype="bech32"
    112020-01-30T19:01:24Z Config file arg: blocksonly="0"
    122020-01-30T19:01:24Z Config file arg: dbcache="10240"
    132020-01-30T19:01:24Z Config file arg: logips="1"
    142020-01-30T19:01:24Z Config file arg: maxconnections="512"
    152020-01-30T19:01:24Z Config file arg: maxuploadtarget="0"
    162020-01-30T19:01:24Z Config file arg: par="0"
    172020-01-30T19:01:24Z Config file arg: rpcpassword=****
    182020-01-30T19:01:24Z Config file arg: rpcuser=****
    192020-01-30T19:01:24Z Config file arg: server="1"
    202020-01-30T19:01:24Z Config file arg: txindex="1"
    212020-01-30T19:01:24Z Config file arg: walletbroadcast="1"
    222020-01-30T19:01:24Z Command-line arg: dbcache="512"
    232020-01-30T19:01:24Z Command-line arg: logips="0"
    242020-01-30T19:01:24Z Command-line arg: walletbroadcast="0"
    252020-01-30T19:01:24Z Using at most 512 automatic connections (1024 file descriptors available)
    
  132. MarcoFalke commented at 10:10 pm on January 30, 2020: member

    ACK b951b0973cfd4e0db4607a00d434a04afb0d6199 🐪

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK b951b0973cfd4e0db4607a00d434a04afb0d6199 🐪
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUgHewwAixdou/20sx/EQar5cdubgAQpvKEAXE9fZwjP6zu0ZBrabem2sc8gsVkD
     8bvQPvnTscdaIvHkOzkZ860STB+nr77x483AKc+Dl4G4Z4LecMv8iXSQmoVOwlxl2
     9rsdUVFQnLAUB9phu9RccJwXUyEsoaGAy/sUcoaHwv3nuApqgNZZptjmCUO3lK5sw
    10vQ/XT30gVZ6xSlfP21ZQaMaqps4MHOB9Z1X5hjnxm49/XMg+4Et3TJKbGyTNwcm6
    11Ue/raLdaPtq6htfkhMIro9cc95Bfy1Nr9X4fGpte7IAu4waT5bJQVF2EeoQPyh0d
    12LEOHe5cQPRsUOd5RvzYmCFqGsM5qRZw9BrQ6yUG13c7tYOi4xc7tdCabE8BUgFuR
    13NqAw90SZMFl8wdDsQHub0H0V5EDxo92YzukM1J+h40OgG3ozZc3dS7SbPhqNpnoN
    14uul5igOr4HICcNDPDHufDW4WAzvh8PpUlqCQnzF/BKnbYQjGZvhtB7asR4v0lH3w
    15LtVy1Blz
    16=hrjv
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 7113306c6076473032eb8637f29927398a935b895b4ee90467fca953dfb9ba72 -

  133. MarcoFalke referenced this in commit 1d1f8bbf57 on Jan 30, 2020
  134. MarcoFalke merged this on Jan 30, 2020
  135. MarcoFalke closed this on Jan 30, 2020

  136. LarryRuane deleted the branch on Jan 31, 2020
  137. LarryRuane referenced this in commit f4213afab3 on Mar 20, 2020
  138. deadalnix referenced this in commit d116c4e9a2 on May 2, 2020
  139. 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