More verbose warning for multiple network argument error. #26028

pull amovfx wants to merge 1 commits into bitcoin:master from amovfx:network-argument-collision-verbosity changing 2 files +5 −10
  1. amovfx commented at 2:58 AM on September 7, 2022: none

    This PR has bitcoin print a more verbose message when a network argument collisions happens. I'm new to using the bitcoin software and was reconfiguring an old node. I also have limited experience at coding, this is my first PR on an open-source project, so any feedback on how to improve this process is welcomed.

    If a chain argument is in the bitcoin.conf and then a bitcoin command has a network flag or a chain argument, such as : bitcoind -regtest currently you are presented with the message:

    "Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one."
    

    As I am a new to this software, with not knowing that the bitcoin.conf was being merge in the command line, I was at a loss until I got guidance in the bitcoin-core-dev irc.

    In this PR, if a user makes this error, they will be notified to check their conf files.

    The new error is a bit more verbose for the command bitcoind -regtest if the chain argument is set in the command line.

    "Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one. Please check if chain is specified in config file."
    

    In regards to the unit test util_tests/util_ChainMerge:

    I had to write a script to check if the resulting output of master branch was the same output as the test from my branch and then update the hash accordingly. It is a simple compare of two txt files.

    You can download the scripts here: https://github.com/amovfx/btc-argument-collision-warning.git

    I understand that your time is valuable and this isn't a significant change but I thought it was something within my ability I could contribute. Thank you for your time. Also, thanks to everyone that helped me get to this point to even submit a PR. Jonas at chain code, the blockchains commons project, programming bitcoin by Jimmy Song, Achow101's twitch stream, the many hosts of the bitcoin-pr-review club and the devs in the bitcoin-core-dev and bitcoin stack exchange answering my questions.

  2. maflcko commented at 7:37 AM on September 7, 2022: member

    What about just modifying the error string to encourage the user to re-check the command line and config file?

  3. amovfx force-pushed on Sep 7, 2022
  4. amovfx force-pushed on Sep 7, 2022
  5. amovfx force-pushed on Sep 7, 2022
  6. amovfx force-pushed on Sep 7, 2022
  7. amovfx force-pushed on Sep 7, 2022
  8. amovfx force-pushed on Sep 7, 2022
  9. amovfx commented at 12:23 AM on September 8, 2022: none

    Hi @MarcoFalke, Well that would be simpler for sure. I am open to that if you think it is a good idea. Perhaps I went overboard. I can modify that string, ditch the feature test and make sure the unit test still works.

    I'm trying to get past this listing error on python -utf8. If you have any insights that would be appreciated.

  10. amovfx force-pushed on Sep 8, 2022
  11. amovfx force-pushed on Sep 8, 2022
  12. amovfx commented at 5:29 PM on September 8, 2022: none

    @MarcoFalke I made your suggested changes, doesn't need the additional functional test. LInting error solved.

  13. amovfx marked this as ready for review on Sep 8, 2022
  14. in src/util/system.cpp:1064 in a73caa9bc6 outdated
    1060 | @@ -1061,7 +1061,7 @@ std::string ArgsManager::GetChainName() const
    1061 |          LOCK(cs_args);
    1062 |          util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg),
    1063 |              /* ignore_default_section_config= */ false,
    1064 | -            /*ignore_nonpersistent=*/false,
    1065 | +            /* ignore_nonpersistent= */ false,
    


    fanquake commented at 9:49 AM on September 9, 2022:

    You can remove this, and the rest of the unrelated code changes.

  15. in src/util/system.cpp:1079 in a73caa9bc6 outdated
    1076 | +        throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one. Please check if chain is specified in config file.");
    1077 |      }
    1078 |      if (fRegTest)
    1079 |          return CBaseChainParams::REGTEST;
    1080 | -    if (fSigNet) {
    1081 | +    if (fSigNet)
    


    luke-jr commented at 11:25 PM on September 10, 2022:

    This is a regression in coding style. If you want to update these, they should probably all be one liners.

    eg

        if (fSigNet) return CBaseChainParams::SIGNET;
    
  16. amovfx commented at 12:03 AM on September 13, 2022: none

    Thanks @luke-jr @MarcoFalke I'm not sure the protocol for submitting suggested changes. I'm squashing the commit down. Or would it be better to have the suggested changes into a separate commit for better transparency for future reviewers?

  17. amovfx force-pushed on Sep 13, 2022
  18. More verbose warning for multiple network argument error. 90f5c531da
  19. amovfx force-pushed on Sep 20, 2022
  20. maflcko approved
  21. amovfx commented at 3:17 PM on September 21, 2022: none

    As small of a change this was, and as difficult as it was I'm super happy to have this approved. Thank you to all the reviewers for their time.

  22. DrahtBot commented at 4:07 AM on September 23, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #26489 (test: Split overly large util_tests.cpp file by MarcoFalke)

    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.

  23. in src/util/system.cpp:1075 in 90f5c531da
    1071 | @@ -1072,16 +1072,11 @@ std::string ArgsManager::GetChainName() const
    1072 |      const bool is_chain_arg_set = IsArgSet("-chain");
    1073 |  
    1074 |      if ((int)is_chain_arg_set + (int)fRegTest + (int)fSigNet + (int)fTestNet > 1) {
    1075 | -        throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.");
    1076 | +        throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one. Please check if chain is specified in config file.");
    


    jonatack commented at 8:25 AM on September 23, 2022:
            throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one. Please check your config options on the command line and in the bitcoin.conf file.");
    
  24. jonatack commented at 8:30 AM on September 23, 2022: contributor

    I'm not sure the protocol for submitting suggested changes. I'm squashing the commit down. Or would it be better to have the suggested changes into a separate commit for better transparency for future reviewers?

    Yes, in this project it's generally preferred to squash the changes, if needed, into their final form. See CONTRIBUTING.md for more info.

  25. DrahtBot commented at 9:00 PM on November 15, 2022: contributor

    <!--cf906140f33d8803c4a75a2196329ecb-->

    🐙 This pull request conflicts with the target branch and needs rebase.

  26. DrahtBot added the label Needs rebase on Nov 15, 2022
  27. fanquake commented at 4:26 PM on February 6, 2023: member

    @amovfx are you going to follow up here? This is not currently mergable.

  28. fanquake marked this as a draft on Feb 16, 2023
  29. maflcko commented at 8:07 PM on April 4, 2023: member

    Closing for now due to lack of activity. Let us know when the should be reopened.

  30. maflcko closed this on Apr 4, 2023

  31. bitcoin locked this on Apr 3, 2024

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-01 03:14 UTC

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