Skip to content

Conversation

amovfx
Copy link

@amovfx amovfx commented Sep 7, 2022

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.

@maflcko
Copy link
Member

maflcko commented Sep 7, 2022

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

@amovfx amovfx force-pushed the network-argument-collision-verbosity branch 6 times, most recently from 5b4f6c7 to 4b0de90 Compare September 7, 2022 19:04
@amovfx
Copy link
Author

amovfx commented Sep 8, 2022

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.

@amovfx amovfx force-pushed the network-argument-collision-verbosity branch 2 times, most recently from 8ed8ac3 to a73caa9 Compare September 8, 2022 16:55
@amovfx
Copy link
Author

amovfx commented Sep 8, 2022

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

@amovfx amovfx marked this pull request as ready for review September 8, 2022 18:39
@@ -1061,7 +1061,7 @@ std::string ArgsManager::GetChainName() const
LOCK(cs_args);
util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg),
/* ignore_default_section_config= */ false,
/*ignore_nonpersistent=*/false,
/* ignore_nonpersistent= */ false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

}
if (fRegTest)
return CBaseChainParams::REGTEST;
if (fSigNet) {
if (fSigNet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

eg

Suggested change
if (fSigNet)
if (fSigNet) return CBaseChainParams::SIGNET;

Copy link
Author

@amovfx amovfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@amovfx amovfx force-pushed the network-argument-collision-verbosity branch from a73caa9 to 17df428 Compare September 13, 2022 00:04
@amovfx amovfx force-pushed the network-argument-collision-verbosity branch from 17df428 to 90f5c53 Compare September 20, 2022 17:17
@amovfx
Copy link
Author

amovfx commented Sep 21, 2022

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 23, 2022

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

Reviews

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

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.

@@ -1072,16 +1072,11 @@ std::string ArgsManager::GetChainName() const
const bool is_chain_arg_set = IsArgSet("-chain");

if ((int)is_chain_arg_set + (int)fRegTest + (int)fSigNet + (int)fTestNet > 1) {
throw std::runtime_error("Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.");
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.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.");
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.");

@jonatack
Copy link
Member

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.

@DrahtBot
Copy link
Contributor

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

@fanquake
Copy link
Member

fanquake commented Feb 6, 2023

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

@fanquake fanquake marked this pull request as draft February 16, 2023 12:30
@maflcko
Copy link
Member

maflcko commented Apr 4, 2023

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

@maflcko maflcko closed this Apr 4, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants