-
Notifications
You must be signed in to change notification settings - Fork 37.7k
init: Error if ignored bitcoin.conf file is found #27302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
c661be4
to
780c696
Compare
CI's hate this one weird PR. Updated c661be4 -> 780c696 (
https://cirrus-ci.com/task/6162407618248704?logs=ci#L10177
https://cirrus-ci.com/task/5036507711406080?logs=ci#L3761
https://cirrus-ci.com/task/5317982688116736?logs=build#L1748
|
Concept ACK on that. |
780c696
to
53d9955
Compare
Updated 780c696 -> 53d9955 (
https://cirrus-ci.com/task/5753433081249792?logs=functional_tests#L82 |
src/common/init.cpp
Outdated
"- Delete or rename the %2$s file in data directory %1$s.\n" | ||
"- Change datadir= or conf= options to specify one configuration file, not two, and use " | ||
"includeconf= to include any other configuration files.\n" | ||
"- Set warnignoredconf=1 option to ignore the %2$s file in data directory %1$s with a " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilst I appreciate that this is a simple and elegant way to remain backwards-compatible, I can't help but wonder if it's something we actually want to support with a new option; what is the use-case here? The operator either has to modify their current config with this new flag, or... fix their config?
If the operator is going to fix something up, then I think it should be the latter!
Perhaps I am missing a use-case though where they would want this old config to be purposefully ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Whilst I appreciate that this is a simple and elegant way to remain backwards-compatible, I can't help but wonder if it's something we actually want to support with a new option; what is the use-case here? The operator either has to modify their current config with this new flag, or... fix their config?
There may be other use cases, but the backwards compatibility use-case I had in mind is where someone has a bitcoin datadir on a portable drive that they use with more than one PC, and the PC's are not configured the exact same way. I'd be reluctant to add a hard error where new a new version of bitcoin refuses to work with a datadir that worked previously and is otherwise fine except for having an extra config file.
Separately, the option also turned out to be useful in the python -acceptnonstdtxn python test, so the test could bypass the bitcoin.conf
file created by the test framework without deleting it.
If other reviewers are more confident that adding a hard error won't cause problems, though, I'd be happy to remove the escape hatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking about the portable datdir use case, I think it is ok to allow a bypass. It's a bit funny calling it "warn...=1" though. I understand you mean "warn instead of throw an error" but I almost think something like -ignoreignoredconf
or -ignoreextraconf
makes more literal sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Another name could be allowignoredconf if that is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowignoredconf
yeah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
53d9955
to
9723357
Compare
Updated 53d9955 -> 9723357 (
https://cirrus-ci.com/task/5315879898972160?logs=functional_tests#L2770 |
9723357
to
d00762c
Compare
Updated 9723357 -> d00762c (
|
d00762c
to
37ffeca
Compare
Updated d00762c -> 37ffeca ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concept ACK
Reviewed code, I have a few questions about the implementation and test below. I reverted the linter commit to reproduce the error and confirm the fix. Also set up the data directories and conf files to reproduce the use case and tested with bitcoind on regtest with and without the warning flag.
src/common/init.cpp
Outdated
"- Delete or rename the %2$s file in data directory %1$s.\n" | ||
"- Change datadir= or conf= options to specify one configuration file, not two, and use " | ||
"includeconf= to include any other configuration files.\n" | ||
"- Set warnignoredconf=1 option to ignore the %2$s file in data directory %1$s with a " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking about the portable datdir use case, I think it is ok to allow a bypass. It's a bit funny calling it "warn...=1" though. I understand you mean "warn instead of throw an error" but I almost think something like -ignoreignoredconf
or -ignoreextraconf
makes more literal sense.
@@ -332,5 +390,21 @@ def run_test(self): | |||
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks')) | |||
|
|||
|
|||
def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this os-specific path generator instead of just adding a single subdir to the direcotry where the test framework is already working? On my system at least, it doesn't actually return the "real" default path:
/tmp/bitcoin_func_test_yg47qoyn/home/Library/Application Support/Bitcoin
so why not just add home/
on every platform and use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Why do you need this os-specific path generator instead of just adding a single subdir to the direcotry where the test framework is already working? On my system at least, it doesn't actually return the "real" default path:
/tmp/bitcoin_func_test_yg47qoyn/home/Library/Application Support/Bitcoin
IIUC, that path is literally the path this function is generating and returning. The point of this function is to let python code write a bitcoin.conf file that bitcoind will use, but if there's another suggestion about how to achieve this I'm happy to adopt it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I understand now, I tried removing it but now I see the environment variables are important for setting the initial "where's the conf" directory without spoiling -datadir
. I also notice get_temp_default_datadir()
has a windows branch but windows will skip this test anyway! Not a bad idea to leave it in there anyway though I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for me, but curious if this kind of function should go in a broader utility package like test_node.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is get_datadir_path()
in test_framework/util.py:
bitcoin/test/functional/test_framework/util.py
Lines 417 to 418 in b759cef
def get_datadir_path(dirname, n): | |
return os.path.join(dirname, "node" + str(n)) |
So perhaps could go next to that in a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review
@@ -332,5 +390,21 @@ def run_test(self): | |||
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks')) | |||
|
|||
|
|||
def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Why do you need this os-specific path generator instead of just adding a single subdir to the direcotry where the test framework is already working? On my system at least, it doesn't actually return the "real" default path:
/tmp/bitcoin_func_test_yg47qoyn/home/Library/Application Support/Bitcoin
IIUC, that path is literally the path this function is generating and returning. The point of this function is to let python code write a bitcoin.conf file that bitcoind will use, but if there's another suggestion about how to achieve this I'm happy to adopt it.
src/common/init.cpp
Outdated
"- Delete or rename the %2$s file in data directory %1$s.\n" | ||
"- Change datadir= or conf= options to specify one configuration file, not two, and use " | ||
"includeconf= to include any other configuration files.\n" | ||
"- Set warnignoredconf=1 option to ignore the %2$s file in data directory %1$s with a " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Another name could be allowignoredconf if that is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
|
It's debatable whether it should be ignored, but the reason it is ignored is that one configuration file has already been parsed and trying to merge in a second configuration file in another datadir would be new and potentially confusing behavior. Merging in another configuration file could lead to unexpected conflicts between settings in the two files, or weird scenarios like a datadir containing a configuration file pointing to another datadir containing another configuration file, potentially in an infinite loop. So the simplest improvement we can make is just to show a warning or error if multiple configuration files present and it is not clear which one is supposed to be used.
it would be a change in behavior that could break existing configurations in non-obvious ways. We did discuss different options for doing it in #27246 (comment), but there also didn't seem to be a good use case that wouldn't be better addressed by using -includeconf |
37ffeca
to
ac9fee6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 37ffeca -> ac9fee6 (pr/ignoredconf.8
-> pr/ignoredconf.9
, compare) with some changes to wording and adding a new commit ac9fee6 which can be an alternative to #27303
src/common/init.cpp
Outdated
"- Delete or rename the %2$s file in data directory %1$s.\n" | ||
"- Change datadir= or conf= options to specify one configuration file, not two, and use " | ||
"includeconf= to include any other configuration files.\n" | ||
"- Set warnignoredconf=1 option to ignore the %2$s file in data directory %1$s with a " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not convinced. Sorry. NACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ac9fee6
Reviewed code and ran tests. Confirmed tests fail on master, not on branch. I believe this PR also closes #19990 as a nice added bonus.
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK ac9fee615a4f0c4d1bbed0d69486c54be4860dcb
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmQh374ACgkQ5+KYS2KJ
yTqaMRAAzyu11syUK7aDjZBg4ofpo0Juk6BQXjg5MZ8/b3ThNoTNt2oqHv2UXI6S
mcZk+4pBfZoM9p0qG1LknMpzjuaISjH6PbuUHa2eGofkPGf0kuhBYBdL2hPwdD8g
VhV8nG4B96dIVwRx24JRR+lpK2Cgklo+c1Qk6MQKhProK1SuvKoJ3lk+CWKjyEuV
zuicbRt73D+0vgfrqKMFrVQQ60qtfRbct2f2HSP911wBl0CaNOCxARpOfVk7phLf
ebtqYNPuhPipFAKxMTzJfw1E6tGSVauAHieWFJXKIUTbflQCrcnq0aN/5ruJs2UL
kDuHBH2At2FwjJvJuwuT0yJPhPdp8iqpwMgEia/4uubrvokxIra0EoRKuvfzmr9H
3YmaeYgk+ud9NupXmxxiDOT4+BZIabLTMswDQ9DNP9laSKiweSZuNB5HTj+MIbEV
ZvT6s7xay1cSIbODy8j8uYonAMifa1yV/iNfztFPnJXvnQfRZz2+xJ0Lhxil/UvA
OZi5dppCAHt0KXteMLeQ70nu8zfasKk+aA6c4OLXeGlOXqxeZji4IWmvRwCrzoWg
4+HKz2iXC5N+ZlL9oM9TMcwM7i1EILKbeXGGMM5F10S1F3vtEPwUBeMdLePONXGU
IfkoysTVFSDUe5tNbewM081axGf0Wp43kozNCXTX2pkz3al4BXc=
=n8np
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
@@ -332,5 +390,21 @@ def run_test(self): | |||
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks')) | |||
|
|||
|
|||
def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for me, but curious if this kind of function should go in a broader utility package like test_node.py
?
I guess you want multiple bitcoin.conf files if detected to be merged together. But I'm not sure you should NACK this PR because they aren't merged together currently. This PR just warns the user about multiple files being present, and should make it easier and safer to merge them later if someone wants to implement that. |
This PR confirms we are okay with buggy behaviour defined in #27302 (comment) I am not okay with that. It's okay if others want to do commits that don't really fix anything. |
@willcl-ark this PR is not trying to error when one datadir setting takes precedence over another one. As the PR description states it adds an error for cases where "a bitcoin datadir that is being used contains a bitcoin.conf file that is ignored" (emphasis added). It does not show an error in cases where a bitcoin datadir that not being used contains a bitcoin.conf file that is ignored, because the whole directory is ignored, so there is nothing special about one file in it. But we could open a separate PR or issue there should be a warning about a command line -datadir= argument overriding a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0319de5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0319de5
Code review and run bitcoind and -qt with various conf file configurations to see errors and warnings. A few style nits below, can be ignored (especially the release note since that will get reviewed again upon actual release)
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK 0319de5cbedd1a8f8766cfec61151c58b3fb27ef
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmRifEUACgkQ5+KYS2KJ
yToIABAArY2mwOFAHYDCg/86hxjzZtiKV7CzsAN2G5639KH/HhMYASg+Lo+RU9jU
okayFjZpunwnKaKoePSFAVMUhIMSmRQTfq0gYaYJoamft/2jb4ZK4Ea8f/ICMrfA
y+rNReXmG3ViMrzXUFq67A208VT96/jGn1KxVQLahCIeT3bN8zYlhgHk95CERa9B
6s5P9ScHbq/UJwMLuQC7xn49blh2IiLdE9LezaTDiGVSBRgh8baqGKYGW33RWmDO
1ObKjVe7VxHQ0fAfA+tDk0q9KQT80Meh78m1DnNe+4a/TU7KDtRMjqk76FUXKwuI
DrTHWmrgfjwmhgHoiQHBOc1sUTgH4FwGuubkgqayBMFga6lm+PAHtVeg3LmC5CVl
KCkNqst3kdhunbnwkkbUAM1tedc+CmUra0HsdIWXmoEM+yVJpJK6Mzzx5YBgBUeZ
l/vG+if4QQaazny1b1sFCRCyN5ARnhBWQ/scHBH7dV2T1EHh/+wFGG3rTySxPA/D
M21QRkBGJ7j0vA5UMUkPtKP43bKbV/QtyCgagSxtdfcWYtts78vavwo6MkiS1LY6
RJWV2S9IoIZ9giBW3a9H1xDakgc8JxdDB7jAO6UL5QKmOwBNSFHDjjoVNyJafOLr
P7065vXz/NcdMJOq3wqApvebZgb0MbedSZYVWUk/xrSaXVnL//c=
=dV5U
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
doc/release-notes-27302.md
Outdated
Configuration | ||
--- | ||
|
||
- `bitcoind` and `bitcoin-qt` will now raise an error on startup if a datadir that is being used contains a bitcoin.conf file that would be ignored, which can happen when a datadir= line is used in a bitcoin.conf file. The error message is just a diagnostic intended prevent accidental misconfiguration, and it can be disabled to restore previous behavior of using the datadir while ignoring the bitcoin.conf contained in in it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `bitcoind` and `bitcoin-qt` will now raise an error on startup if a datadir that is being used contains a bitcoin.conf file that would be ignored, which can happen when a datadir= line is used in a bitcoin.conf file. The error message is just a diagnostic intended prevent accidental misconfiguration, and it can be disabled to restore previous behavior of using the datadir while ignoring the bitcoin.conf contained in in it. | |
- `bitcoind` and `bitcoin-qt` will now raise an error on startup if a datadir that is being used contains a bitcoin.conf file that will be ignored, which can happen when a datadir= line is used in a bitcoin.conf file. The error message is just a diagnostic intended to prevent accidental misconfiguration, and it can be disabled to restore the previous behavior of using the datadir while ignoring the bitcoin.conf contained in it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Thanks! Applied change
else: | ||
env = dict(HOME=str(temp_dir)) | ||
if sys.platform == "darwin": | ||
datadir = temp_dir / "Library/Application Support/Bitcoin" | ||
else: | ||
datadir = temp_dir / ".bitcoin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent should be +2 more spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK 0319de5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated 0319de5 -> eefe569 (pr/ignoredconf.13
-> pr/ignoredconf.14
, compare) with suggestions
Thanks for the reviews!
@@ -282,6 +289,55 @@ def test_connect_with_seednode(self): | |||
unexpected_msgs=seednode_ignored): | |||
self.restart_node(0, extra_args=[connect_arg, '-seednode=fakeaddress2']) | |||
|
|||
def test_ignored_conf(self): | |||
self.log.info('Test error is triggered when datadir contains a bitcoin.conf file that would be ignored ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
If you re-touch, perhaps this could read:
'Test error is triggered when the datadir in use contains a bitcoin.conf file that would be ignored '
Thanks applied suggestion
@@ -332,5 +390,21 @@ def run_test(self): | |||
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks')) | |||
|
|||
|
|||
def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc/release-notes-27302.md
Outdated
Configuration | ||
--- | ||
|
||
- `bitcoind` and `bitcoin-qt` will now raise an error on startup if a datadir that is being used contains a bitcoin.conf file that would be ignored, which can happen when a datadir= line is used in a bitcoin.conf file. The error message is just a diagnostic intended prevent accidental misconfiguration, and it can be disabled to restore previous behavior of using the datadir while ignoring the bitcoin.conf contained in in it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #27302 (comment)
Thanks! Applied change
else: | ||
env = dict(HOME=str(temp_dir)) | ||
if sys.platform == "darwin": | ||
datadir = temp_dir / "Library/Application Support/Bitcoin" | ||
else: | ||
datadir = temp_dir / ".bitcoin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK eefe569
Confirmed nits addressed since last ACK, minimal diff. All tests pass locally for me, CI failures are unrelated to code changes.
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK eefe56967b4eb4b5144325cde4f40fc1cbde3e65
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmRucOIACgkQ5+KYS2KJ
yTpqZg//YoQc3ivctelv3QQLCGcGruDO9twOQMm8TRx+8mZRtIV2UqPom2pwLjXM
BnZ2oWvd5k/8bX12q7p5kWRdWuAu77pZ/OltrJp/+PstFh+G9J/uWaS7y7bxPICb
zfeslfAhywVQzHsPPLlo1KF0WJY2TfdFRZwmcL+qJ9Jhy1iQLxrMUb3cdbUeLwsa
km9UlJWmRBNF60kD79YY+pPiLNET45CSfvFlJIMk4cb+vXdVtwYqq+XOxLPLLJ0R
bUHclTDTgoRJTzMGdsiwoTq3wCVx2WMzkzEyX+3KwS4MJZjke58wqwVP1UOQ7pFv
OMGAOk4kZWOqQ9JSKTu4Abbq+K64FXXsCZuDFRz31dUiCoSPBbppTIP7dQi711Fz
YT2ICOvpI8CXcWUdlaBKJWC+6JuNyjfNb16GD5jq77ylzUNMsZLL9Glg293zwGHk
T48wE/MHxPmp1qyU/EDdg1mM/o0AoXrtMdi2smYROw/tQwsT81AFpoADdSJFkbog
5nUMNR5bNBiUnT/UyZ73WTkZ5/kjRgc1kDbfCaPvQhJYU7gVo9xGZ8sLBemmgDS6
tREcNf5nHno1vc8ctrE0eOK3h+ndiXOp8LwVmS92UX/tCB35xphONfbejmhlCaVn
AiejqtCmuBnG3yPcdIXxPV9EA0iSI3PJzIjuTfJLT9AD2BBWbLg=
=e+a2
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK eefe569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK eefe569
@ryanofsky does this close #27246 ? |
No I still need to figure out what the last message #27246 (comment) means, and finish #27409 to fix the "Unfortunately the behavior for bitcoin-qt is stupider than bitcoind..." issue |
…have argument positions Do not error on valid format specifications like strprintf("arg2=%2$s arg1=%1$s arg2=%2$s", arg1, arg2); Needed to avoid lint error in upcoming commit: https://cirrus-ci.com/task/4755032734695424?logs=lint#L221 Additionally tested with python -m doctest test/lint/run-lint-format-strings.py Github-Pull: bitcoin#27302 Rebased-From: 398c371
Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happen: - One case reported in bitcoin#27246 (comment) happens when a bitcoin.conf file in the default datadir (e.g. $HOME/.bitcoin/bitcoin.conf) has a "datadir=/path" line that sets different datadir containing a second bitcoin.conf file. Currently the second bitcoin.conf file is ignored with no warning. - Another way this could happen is if a -conf= command line argument points to a configuration file with a "datadir=/path" line and that specified path contains a bitcoin.conf file, which is currently ignored. This change only adds an error message and doesn't change anything about way settings are applied. It also doesn't trigger errors if there are redundant -datadir or -conf settings pointing at the same configuration file, only if they are pointing at different files and one file is being ignored. Github-Pull: bitcoin#27302 Rebased-From: 3746f00
Currently debug.log will show the wrong bitcoin.conf config file path when bitcoind is invoked without -conf or -datadir arguments, and there's a default bitcoin.conf file which specifies another datadir= location. When this happens, the debug.log will include an incorrect "Config file:" line referring to a bitcoin.conf file in the other datadir, instead of the referring to the actual configuration file in the default datadir which was parsed. The bad log print was reported and originally fixed in bitcoin#27303 by Matthew Zipkin <pinheadmz@gmail.com> This PR takes a slightly different approach to fixing the bug, trying to avoid future bugs by not allowing the GetConfigFilePath function to be called before the the configuration is parsed, and deleting GetConfigFile function which could be confused with GetConfigFilePath. It also includes a test for the bug which the original fix did not have. Co-authored-by: Matthew Zipkin <pinheadmz@gmail.com> Github-Pull: bitcoin#27302 Rebased-From: eefe569
@ryanofsky I just wanted to give feedback that this kind of bit me [*], in running Joinmarket tests - the [*] My fault for not reading the release notes 😄 |
Thanks @AdamISZ, this is great feedback. In your case it sounds like you have a Hopefully it should be clear why there is an ambiguity. If a data directory is being used, and data directory contains a |
and
That would be unarguable if we weren't talking about a manual setting of a different If it's possible to use more than one [*] I know we tend, a lot of the time, to automate things with shell scripts, but ultimately command line invocation exists as a way to make a concrete decision now, "I am running this in this specific way, this time" - which is why having command line flags as distinct from always setting things in configuration files, is useful. And in that context only override makes sense (caveat - if it's a "single slot", i.e. only one value is possible at once), which is why I think software basically always works that way. Which is why this completely flummoxed me. |
That makes sense, so I'd change "the only reasonable expectation" to "a reasonable expectation" in my reply above. I also think your "single slot" model of the -conf option is accurate, and we shouldn't try to merge a configuration file specified with -conf on the command line with a different I'm very open to making changes though if this doesn't work well in your use-case, or if we just need to do something to make the situation clearer. |
Show an error on startup if a bitcoin datadir that is being used contains a
bitcoin.conf
file that is ignored. There are two cases where this could happen:One case reported in #27246 (comment) happens when a
bitcoin.conf
file in the default datadir (e.g.$HOME/.bitcoin/bitcoin.conf
) has adatadir=/path
line that sets different datadir containing a secondbitcoin.conf
file. Currently the secondbitcoin.conf
file is ignored with no warning.Another way this could happen is if a
-conf=
command line argument points to a configuration file with adatadir=/path
line and that path contains abitcoin.conf
file, which is currently ignored.This change only adds an error message and doesn't change anything about way settings are applied. It also doesn't trigger errors if there are redundant
-datadir
or-conf
settings pointing at the same configuration file, only if they are pointing at different files and one file is being ignored.