Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Mar 29, 2018

When QT launches, move the following QSettings to bitcoin_rw.conf (added in #11082):

-lang (language)
-dbcache (nDatabaseCache)
-par (nThreadsScriptVerif)
-prune (bPrune,bPruneSize)
-spendzeroconfchange (bSpendZeroConfChange)
-upnp (fUseUPnP)
-listen (fListen)
-proxy (fUseProxy)
-onion (fUseSeparateProxyTor)

~This is a step towards being able to configure prune from the GUI (#6461). ~ (already done )

There's potentially a safety benefit in storing listen, proxy and onion in bitcoin_rw.conf in case the user ever decides to run bitcoind.

@laanwj
Copy link
Member

laanwj commented Mar 29, 2018

Please, never write to bitcoin.conf. It is exceptionally bad form for a daemon to write to its configuration file. If you want to do this, I'd suggest adding an additional file (in the datadir) for read/write settings (as @luke-jr did AFAIK).

@laanwj laanwj added the GUI label Mar 29, 2018
@Sjors
Copy link
Member Author

Sjors commented Mar 30, 2018

@laanwj two files is indeed what @luke-jr did, but I don't see how that changes anything. It's critical that bitcoind uses this second file (for settings like prune) and treats it the same as bitcoin.conf. So by the same reasoning it shouldn't write to that second file.

Also note that only QT needs this ability, so I could refactor it such that bitcoind daemon only has read-only access.

I thought of a completely different approach to handle the prune case, so we might be able to kick this shared settings can down the road. Will open a PR for later.

@laanwj
Copy link
Member

laanwj commented Mar 30, 2018

@laanwj two files is indeed what @luke-jr did, but I don't see how that changes anything.

One thing is permissions. The data directory is guaranteed writable. The configuration file might be -conf=/etc/bitcoind.conf.

Also note that only QT needs this ability, so I could refactor it such that bitcoind daemon only has read-only access.

Unlike QSettings the second file would be used by both the GUI and the daemon.

And it might be useful to edit settings in bitcoind at real-time as well. The GUI shouldn't really be special there, that gets in the way of the whole idea of unifying the settings mechanism.

@Sjors
Copy link
Member Author

Sjors commented Mar 30, 2018

If bitcoin.conf is not writeable, because the user configured a custom read-only directory, the UI elements that change settings this way could be disabled.

And it might be useful to edit settings in bitcoind at real-time as well.

Indeed.

I thought having two separate files leads to a more complicated implementation than just having one, but I didn't remove that much from the original code so far. It helps that settings can be overridden by repeating them in the new file.

So in that case it might more sense to get #11082 merged, in which case this PR just adds QSettings migration code on top of that.

@Sjors Sjors force-pushed the 2018/03/bitcoin-conf-rw branch 4 times, most recently from 3f4d27f to 518f630 Compare April 3, 2018 16:03
@Sjors Sjors changed the title WIP [qt] move QSettings to bitcoin.conf where possible [qt] move QSettings to bitcoin.conf where possible Apr 3, 2018
@Sjors
Copy link
Member Author

Sjors commented Apr 3, 2018

I pushed a new version that uses bitcoin_rw.conf. I could probably add some helper functions to make the change more compact.

@jonasschnelli
Copy link
Contributor

I'm not sure if moving the QT settings from pure QT format in the QT chosen file to the bitcoind compatible bitcoin_rw.conf format reduces the complexity. Configuration file complexity can be harmful (-datadir, eventually once config files per network, includes, etc.).

I also think we could expose prune to the QT layer without sharing the configuration value with bitcoind.

Users using bitcoind & QT with the same settings and datadir do probably know the ramification of GUI only settings. A warning when enabling prune in QT (once implemented) that it will not automatically be enabled in daemon mode seems sufficient to me.

@Sjors
Copy link
Member Author

Sjors commented Apr 4, 2018

@jonasschnelli in addition to a warning, we can even make bitcoind actually handle QT's prune elegantly, see my suggestion here.

For settings other than prune there might be similar workarounds on a case by case basis (other than warning).

@Sjors
Copy link
Member Author

Sjors commented Apr 17, 2018

This and #11082 need a likely non-trivial rebase after #11862. I'm going to try the other approach first though.

@Sjors
Copy link
Member Author

Sjors commented May 15, 2018

#11862 has been merged. I'll rebase this once #11082 is rebased.

QT doesn't have any concept (yet) of network specific configuration though.

@ryanofsky
Copy link
Contributor

I like this approach. I think it'd be a simplification to stop using the windows registry and other config backends in bitcoin-qt. And it seems like it would be less surprising and error prone if bitcoin-qt and bitcoind used the same settings, instead of slightly different but overlapping sources of settings like they do now, so I don't get the objection in #12833 (comment).

One thing I don't understand about the implementation though is why the "Active command-line options that override above options" display is removed. Will command line settings not override config file settings anymore with this change? I think it would be bad if that were the case.

@Sjors
Copy link
Member Author

Sjors commented Oct 9, 2018

@ryanofsky wrote:

Will command line settings not override config file settings anymore with this change?

They will. The phrase "active command-line options" actually referred to both bitcoin.conf and command line options, either of which can override QT settings, as well as each other.

Afaik QT can't tell the difference between settings that came from bitcoin.conf and those that came from a command line option, which is why I removed that text. It's also pretty difficult in practice to launch QT with command line options, involving editing desktop shortcuts etc.

@Sjors Sjors changed the title [qt] move QSettings to bitcoin.conf where possible [qt] move QSettings to bitcoin_rw.conf where possible Nov 10, 2018
@Sjors Sjors force-pushed the 2018/03/bitcoin-conf-rw branch from 518f630 to decad6a Compare November 10, 2018 12:11
@Sjors
Copy link
Member Author

Sjors commented Nov 10, 2018

Rebased and added pruning to the list of imported settings.

I changed the meaning of disabling prune in the GUI to mean stop further pruning, instead undo previous pruning. It just sets prune=1, which avoids forcing the user to re-download the chain. We could later add a button to re-download the whole chain.

@@ -243,6 +171,7 @@ static const QString GetDefaultProxyAddress()
// read QSettings values and return them
QVariant OptionsModel::data(const QModelIndex & index, int role) const
{
int64_t prune = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope of prune can be limited to the scope of case Prune and case PruneSize below :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That results in error: redefinition of 'prune'.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 13, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16673 (Relog configuration args on debug.log rotation by LarryRuane)
  • #15934 (Merge settings one place instead of five places by ryanofsky)
  • #15454 (Remove the automatic creation and loading of the default wallet by achow101)
  • #14866 (Improve property evaluation way in bitcoin.conf by AkioNak)
  • #13818 (More intuitive GUI settings behavior when -proxy is set by Sjors)
  • #13339 (wallet: Replace %w by wallet name in -walletnotify script by promag)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@Sjors
Copy link
Member Author

Sjors commented Nov 20, 2018

I'll rebase and fix code issues after the next upstream PR rebase.

@Sjors Sjors force-pushed the 2018/03/bitcoin-conf-rw branch from decad6a to 09e150a Compare January 15, 2019 19:34
@Sjors Sjors force-pushed the 2018/03/bitcoin-conf-rw branch 3 times, most recently from 1c03dc1 to 3142a95 Compare October 29, 2019 11:11
Sjors added 3 commits October 29, 2019 14:44
When QT launches, move the following QSettings to
bitcoin_rw.conf:

-lang (language)
-dbcache (nDatabaseCache)
-par (nThreadsScriptVerif)
-prune (bPrune,nPruneSize)
-spendzeroconfchange (bSpendZeroConfChange)
-upnp (fUseUPnP)
-listen (fListen)
-proxy (fUseProxy)
-onion (fUseSeparateProxyTor)

Disabling pruning in the GUI now sets prune=1 if the chain is pruned, otherwise prune=0.
@Sjors Sjors force-pushed the 2018/03/bitcoin-conf-rw branch from 3142a95 to b950472 Compare October 29, 2019 13:44
@DrahtBot
Copy link
Contributor

Needs rebase

@jonasschnelli
Copy link
Contributor

Closing for now since this is dependant on a dormant PR #11082

@Sjors
Copy link
Member Author

Sjors commented May 29, 2020

I'll nag to reopen this once 11082 is rebased.

@Sjors
Copy link
Member Author

Sjors commented Jun 26, 2020

@jonasschnelli 11082 is rebased, can you re-open this?

@Rspigler
Copy link
Contributor

@Sjors are you still working on this/asking this to be opened, with #15935 being merged and #15936 being discussed?

@Sjors
Copy link
Member Author

Sjors commented Aug 22, 2020

I have to read up on the alternative approach that was merged. If I build on top of that, I'll make a new PR. For now, consider this up for grabs.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants