Skip to content

Commit 5392aee

Browse files
author
MarcoFalke
committed
Merge bitcoin#15629: init: Throw error when network specific config is ignored
fae38c3 doc: Fix all typos reported by codespell (MarcoFalke) fa9058f doc: Add release notes for 15629 (MarcoFalke) fa4a922 qa: Add test for missing testnet section in conf file (MarcoFalke) dddd6f0 init: Throw error when network specific config is ignored (MarcoFalke) Pull request description: This should have no effect on mainnet users, but simplifies testing, where config settings are currently ignored with only a warning. Fix this by making it an error. Issues: * bitcoin client 0.17.0 ignores wallet's name (file) bitcoin#14523 * Can't set custom rpcport on testnet bitcoin#13777 * ... ACKs for commit fae38c: Tree-SHA512: 2e209526898eea6e444c803ec2666989cee4ca137492d32984998733c50a70056cb54657df8dc3027a6a0612738a8afce0bc35824b868c5f22281e00e0188530
2 parents 93de9ab + fae38c3 commit 5392aee

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

doc/release-notes.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ Low-level Changes section below.
8585
Low-level changes
8686
=================
8787

88-
Example item
88+
Configuration
8989
------------
9090

91+
* An error is issued where previously a warning was issued when a setting in
92+
the config file was specified in the default section, but not overridden for
93+
the selected network. This change takes only effect if the selected network
94+
is not mainnet.
95+
9196
Credits
9297
=======
9398

src/init.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -828,19 +828,6 @@ void InitParameterInteraction()
828828
if (gArgs.SoftSetBoolArg("-whitelistrelay", true))
829829
LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
830830
}
831-
832-
// Warn if network-specific options (-addnode, -connect, etc) are
833-
// specified in default section of config file, but not overridden
834-
// on the command line or in this network's section of the config file.
835-
std::string network = gArgs.GetChainName();
836-
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
837-
InitWarning(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
838-
}
839-
840-
// Warn if unrecognized section name are present in the config file.
841-
for (const auto& section : gArgs.GetUnrecognizedSections()) {
842-
InitWarning(strprintf("%s:%i " + _("Section [%s] is not recognized."), section.m_file, section.m_line, section.m_name));
843-
}
844831
}
845832

846833
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
@@ -950,6 +937,19 @@ bool AppInitParameterInteraction()
950937

951938
// also see: InitParameterInteraction()
952939

940+
// Warn if network-specific options (-addnode, -connect, etc) are
941+
// specified in default section of config file, but not overridden
942+
// on the command line or in this network's section of the config file.
943+
std::string network = gArgs.GetChainName();
944+
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
945+
return InitError(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
946+
}
947+
948+
// Warn if unrecognized section name are present in the config file.
949+
for (const auto& section : gArgs.GetUnrecognizedSections()) {
950+
InitWarning(strprintf("%s:%i " + _("Section [%s] is not recognized."), section.m_file, section.m_line, section.m_name));
951+
}
952+
953953
if (!fs::is_directory(GetBlocksDir())) {
954954
return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist."), gArgs.GetArg("-blocksdir", "").c_str()));
955955
}

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ bool CChainState::InvalidateBlock(CValidationState& state, const CChainParams& c
27992799
bool ret = DisconnectTip(state, chainparams, &disconnectpool);
28002800
// DisconnectTip will add transactions to disconnectpool.
28012801
// Adjust the mempool to be consistent with the new tip, adding
2802-
// transactions back to the mempool if disconnecting was succesful,
2802+
// transactions back to the mempool if disconnecting was successful,
28032803
// and we're not doing a very deep invalidation (in which case
28042804
// keeping the mempool up to date is probably futile anyway).
28052805
UpdateMempoolForReorg(disconnectpool, /* fAddToMempool = */ (++disconnected <= 10) && ret);

test/functional/feature_config_args.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def test_config_file_parser(self):
2525
conf.write('-dash=1\n')
2626
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 1: -dash=1, options in configuration file must be specified without leading -')
2727

28+
with open(inc_conf_file_path, 'w', encoding='utf8') as conf:
29+
conf.write("wallet=foo\n")
30+
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on regtest network when in [regtest] section.')
31+
2832
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
2933
conf.write('nono\n')
3034
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 1: nono, if you intended to specify a negated option, use nono=1 instead')

test/functional/test_framework/test_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def test_success(cmd):
369369
stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) == 0
370370

371371
if not sys.platform.startswith('linux'):
372-
self.log.warning("Can't profile with perf; only availabe on Linux platforms")
372+
self.log.warning("Can't profile with perf; only available on Linux platforms")
373373
return None
374374

375375
if not test_success('which perf'):

test/functional/wallet_importmulti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ def run_test(self):
760760
assert_equal(addr2, newaddr2)
761761

762762
# Import a multisig and make sure the keys don't go into the keypool
763-
self.log.info('Imported scripts with pubkeys shoud not have their pubkeys go into the keypool')
763+
self.log.info('Imported scripts with pubkeys should not have their pubkeys go into the keypool')
764764
addr1 = self.nodes[0].getnewaddress()
765765
addr2 = self.nodes[0].getnewaddress()
766766
pub1 = self.nodes[0].getaddressinfo(addr1)['pubkey']

0 commit comments

Comments
 (0)