Load `-allowdeprecated` settings after reading the config file

We need to load these early so that it's possible for other
initialization steps to respect them. However, we were loading them
slightly too early, before the config file had been read, which meant
that only CLI arguments were being used.

We now load the `-allowdeprecated` settings just after the config file
is parsed and the chain parameters are prepared; neither of these are
features we would ever consider deprecating (at least while `zcashd`
exists in its Bitcoin Core-derived form).

Closes zcash/zcash#6420.
This commit is contained in:
Jack Grigg 2023-02-10 22:13:36 +00:00
parent 774f2d8eda
commit b814336aec
3 changed files with 11 additions and 11 deletions

View File

@ -94,14 +94,6 @@ bool AppInit(int argc, char* argv[])
return true;
}
// Handle setting of allowed-deprecated features as early as possible
// so that it's possible for other initialization steps to respect them.
auto deprecationError = SetAllowedDeprecatedFeaturesFromCLIArgs();
if (deprecationError.has_value()) {
fprintf(stderr, "%s", deprecationError.value().c_str());
return false;
}
try
{
if (!fs::is_directory(GetDataDir(false)))
@ -143,6 +135,14 @@ bool AppInit(int argc, char* argv[])
return false;
}
// Handle setting of allowed-deprecated features as early as possible
// so that it's possible for other initialization steps to respect them.
auto deprecationError = LoadAllowedDeprecatedFeatures();
if (deprecationError.has_value()) {
fprintf(stderr, "%s", deprecationError.value().c_str());
return false;
}
// Command-line RPC
bool fCommandLine = false;
for (int i = 1; i < argc; i++)

View File

@ -61,7 +61,7 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
}
}
std::optional<std::string> SetAllowedDeprecatedFeaturesFromCLIArgs() {
std::optional<std::string> LoadAllowedDeprecatedFeatures() {
auto args = GetMultiArg("-allowdeprecated");
std::set<std::string> allowdeprecated(args.begin(), args.end());

View File

@ -71,13 +71,13 @@ extern bool fEnableWalletTxVJoinSplit;
void EnforceNodeDeprecation(int nHeight, bool forceLogging=false, bool fThread=true);
/**
* Checks command-line arguments for enabling and/or disabling of deprecated
* Checks config options for enabling and/or disabling of deprecated
* features and sets flags that enable deprecated features accordingly.
*
* @return std::nullopt if successful, or an error message indicating what
* values are permitted for `-allowdeprecated`.
*/
std::optional<std::string> SetAllowedDeprecatedFeaturesFromCLIArgs();
std::optional<std::string> LoadAllowedDeprecatedFeatures();
/**
* Returns a comma-separated list of the valid arguments to the -allowdeprecated