Skip to content

Conversation

@kwvg
Copy link
Collaborator

@kwvg kwvg commented Oct 27, 2024

Additional Information

The bug reported in #6366 can be reproduced by deleting ~/.config/*/Dash-Qt*.conf and running dash-qt (the decision on whether to display the splash screen is based on Qt settings, which are read before datadir).

This bug has been reproduced on develop (f211bb9) and as early as v20.0.4 (the ability to enable pruning was introduced in #5255).

The bug occurs we're given two opportunities to disable of -txindex and enable of -disablegovernance if -prune is set, InitParameterInteraction() (source) (via BitcoinApplication::parameterSetup(), source) and OptionsModel::Init() (source) but both opportunities are exhausted before we set the -prune flag in response to enabling the option in the UI (source).

We cannot simply just move BitcoinApplication::InitPruneSetting() up as it assumes OptionsModel is initialized and OptionsModel::Init() is called from the constructor.

This means when arguments are parsed for the last time, we get our "Prune mode is incompatible with -txindex" (source) because our parameter interactions took place before prune settings were set.

This PR resolves that by running BitcoinApplication::parameterSetup() again after BitcoinApplication::InitPruneSetting(). We do this instead of using OptionsModel::Init() as all the SoftSet{Bool}Arg() failures will result in an unnaturally populated overridden arguments list.

Breaking Changes

None expected

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 (note: N/A)
  • I have made corresponding changes to the documentation (note: N/A)
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@kwvg kwvg added this to the 22 milestone Oct 27, 2024
kwvg added 2 commits October 27, 2024 18:05
New prune settings aren't set until `InitPruneSetting()` is called at
the tail end of init logic.

The two opportunities we have to influence `-txindex` and
`-disablegovernance`, `parameterSetup()` and `OptionsModel::Init()`, are
executed well before `InitPruneSetting()` is run.

So let's run `parameterSetup()` again to make sure parameter
interactions affected by prune settings are processed appropriately.
The startup warning that alerts us that governance is disabled and that
it's expected when we're pruning is sufficient.
@kwvg
Copy link
Collaborator Author

kwvg commented Oct 28, 2024

Superseded by #6368

@kwvg kwvg closed this Oct 28, 2024
PastaPastaPasta added a commit that referenced this pull request Oct 29, 2024
2d99b2c fix: force correct `-disablegovernance` and `-txindex` values when pruning is requested via init dialog (UdjinM6)
64b20f0 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 #6366

  #6367 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 2d99b2c
  PastaPastaPasta:
    utACK 2d99b2c

Tree-SHA512: 465bd2f1ca86358145c4671af554078b00b2472375d65b8de7e01ae0db8b24c9b01844a2b8e5a4c85a6d65a892a169ee61797591c0dfc0f51ec044a8e2bba58a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant