Merge #6368: fix(qt): set prune dependent options correctly

2d99b2c02b fix: force correct `-disablegovernance` and `-txindex` values when pruning is requested via init dialog (UdjinM6)
64b20f0691 fix(qt): set prune dependent options correctly (Kittywhiskers Van Gogh)

Pull request description:

  ## Issue being fixed or feature implemented
  A few things to note:
  1. we shouldn't rely on `bPrune` cause it can be overridden via cmd-line
  2. `addOverriddenOption` is used to highlight that there are GUI options that were overridden via cmd-line and neither `-disablegovernance` nor `-txindex` override anything, we simply set them to correct values here.
  3. we should do all that in `SetPruneEnabled` case that's the central point for GUI prune option logic

  fixes https://github.com/dashpay/dash/issues/6366

  https://github.com/dashpay/dash/pull/6367's alternative

  ## What was done?

  ## How Has This Been Tested?

  `./src/qt/dash-qt --regtest --resetguisettings` (could also add `--txindex=1` and/or `--disablegovernance=0`), check "Limit ..." box, click OK and confirm it continues with no errors (but with a warning about disabled governance, that's by design)

  close qt and check 2 more things:
  1. `./src/qt/dash-qt --regtest` should have a warning about disabled governance
  2. `./src/qt/dash-qt --regtest --prune=0` should have no warning about disabled governance (not true on `develop`)

  ## Breaking Changes

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  kwvg:
    ACK 2d99b2c02b
  PastaPastaPasta:
    utACK 2d99b2c02b

Tree-SHA512: 465bd2f1ca86358145c4671af554078b00b2472375d65b8de7e01ae0db8b24c9b01844a2b8e5a4c85a6d65a892a169ee61797591c0dfc0f51ec044a8e2bba58a
This commit is contained in:
pasta 2024-10-29 09:14:47 -05:00
commit 93cfd5bc94
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -190,18 +190,6 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
SetPruneEnabled(settings.value("bPrune").toBool());
// If GUI is setting prune, then we also must set disablegovernance and txindex
if (settings.value("bPrune").toBool()) {
if (gArgs.SoftSetBoolArg("-disablegovernance", true)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -disablegovernance=true\n", __func__);
addOverriddenOption("-disablegovernance");
}
if (gArgs.SoftSetBoolArg("-txindex", false)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -txindex=false\n", __func__);
addOverriddenOption("-txindex");
}
}
if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
@ -405,11 +393,19 @@ void OptionsModel::SetPruneEnabled(bool prune, bool force)
std::string prune_val = prune ? ToString(prune_target_mib) : "0";
if (force) {
gArgs.ForceSetArg("-prune", prune_val);
if (prune) {
gArgs.ForceSetArg("-disablegovernance", "1");
gArgs.ForceSetArg("-txindex", "0");
}
return;
}
if (!gArgs.SoftSetArg("-prune", prune_val)) {
addOverriddenOption("-prune");
}
if (gArgs.GetArg("-prune", 0) > 0) {
gArgs.SoftSetBoolArg("-disablegovernance", true);
gArgs.SoftSetBoolArg("-txindex", false);
}
}
void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force)