Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Sep 15, 2017

Writes the GUI settings to guisettings.bak in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. #11262) where -resetguisettings solves the problem.
(as discussed in yesterday's IRC meeting)

@laanwj laanwj added this to the 0.15.1 milestone Sep 15, 2017
Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

utACK 232a108, really good idea 👍

Couple of small nits

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, GetDataDir() argument defaults to true so it'd be clearer to leave it out imo

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it the other way around: clearer to leave it in, because it's explicit?

Copy link
Contributor

Choose a reason for hiding this comment

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

Normally I'd say yes, but in this case it just leaves me wondering what the argument is doing, because in most other cases of GetDataDir in the code, the argument is left out. Personal preference

Copy link
Member Author

Choose a reason for hiding this comment

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

During the initialization sequence it's really important to get this right. E.g. I had to check the order in src/qt/bitcoin.cpp that calling GetDataDir(true) was allowed at this point.

Agree that boolean arguments are unclear, so are default arguments, so it's kind of choosing between evils here. Instead of an argument to GetDataDir we should have done GetSpecificDataDir and GetRootDataDir or such. Anyhow... I don't think this code is particularly unclear, I'll add 'to chain-specific datadir' in the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, space between &key and the colon

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix

@laanwj laanwj force-pushed the 2017_10_backup_resetguisettings branch 2 times, most recently from 3141a2f to bb37a03 Compare September 15, 2017 10:12
@meshcollider
Copy link
Contributor

meshcollider commented Sep 15, 2017

re-utACK bb37a03 4e9dc85

@laanwj laanwj force-pushed the 2017_10_backup_resetguisettings branch from bb37a03 to 4e9dc85 Compare September 15, 2017 10:55
@laanwj
Copy link
Member Author

laanwj commented Sep 15, 2017

Travis was failing. Changed qInfo to qWarning, as qInfo was only introduced in Qt 5.5 and the result is the same anyhow: it unconditionally ends up in debug.log.

@laanwj
Copy link
Member Author

laanwj commented Sep 15, 2017

Added a dst.clear (suggested by @promag) to avoid the edge case of older settings staying behind.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

utACK modulus nits.

/** Helper function to copy contents from one QSettings to another.
* By using allKeys this also covers nested settings in a hierarchy.
*/
static void copySettings(QSettings &dst, const QSettings &src)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't see the benefit of this function, move the code to backupSettings()? Otherwise & next to type name.

Copy link
Member Author

Choose a reason for hiding this comment

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

The point is that this is a general function, it could be also e.g. used to restore QSettings from a backup, if that is ever necessary. Would prefer to keep it. Better too much factoring than too little.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok then, just update to CopySettings and move &.

}

/** Back up a QSettings to an ini-formatted file. */
static void backupSettings(const fs::path &filename, const QSettings &src)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to BackupSettings and & next to type name.

*/
static void copySettings(QSettings &dst, const QSettings &src)
{
for (const QString &key : src.allKeys()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

& next to type name.

doc/files.md Outdated
* wallet.dat: personal wallet (BDB) with keys and transactions
* .cookie: session RPC authentication cookie (written at start when cookie authentication is used, deleted on shutdown): since 0.12.0
* onion_private_key: cached Tor hidden service private key for `-listenonion`: since 0.12.0
* guisettings.bak: backup of former GUI settings after `-resetguisettings` is used
Copy link
Contributor

Choose a reason for hiding this comment

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

.ini.bak?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah why not...

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing doc update.

@TheBlueMatt
Copy link
Contributor

Tested ACK f725dbb, needs squash obviously, didn't bother to try to review in-depth for whether this is going to put the guisettings.bak file in a strange datadir (bitcoin.conf-based? the old GUI settings one?) but there isnt a "correct" answer there anyway, so I cant say I care much.

@sipa
Copy link
Member

sipa commented Sep 15, 2017

Concept ACK

@jonasschnelli
Copy link
Contributor

utACK f725dbb

Since this uses QSettings::IniFormat, there is no easy way how to restore a such backup. Is the backup file only intended to use for inspection of old values or also for a full restore? The later would very likely require a restore function (QSettings::IniFormat to native format or similar).

@laanwj
Copy link
Member Author

laanwj commented Sep 16, 2017

didn't bother to try to review in-depth for whether this is going to put the guisettings.bak file in a strange datadir (bitcoin.conf-based? the old GUI settings one?)

I think that's handled, it puts it in the new datadir that you have to select when using -resetguisettings.

Since this uses QSettings::IniFormat, there is no easy way how to restore a such backup. Is the backup file only intended to use for inspection of old values or also for a full restore?

Not opposed to restore functionality if there is a pressing use-case, although the intended purpose (as mentioned in OP) is diagnostics. This is much easier with .ini format. Also windows' NativeFormat cannot be exported to an arbitrary file just to other registry paths.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Tested ACK. It works even if the file already exists in either INI or other format (it's always overwritten).

There are still some code nits. One small and final thing, for me this is more of a dump than backup.

@achow101
Copy link
Member

there is no easy way how to restore a such backup.

I don't think there needs to be a way to restore such a backup. This backup is only created when you run -resetguisettings which implies that the settings are corrupted anyways and you don't want a backup of something that's corrupted.

@promag
Copy link
Contributor

promag commented Sep 16, 2017

which implies that the settings are corrupted

Or settings are fine and there is a bug?

@achow101
Copy link
Member

tACK b28af38

@jonasschnelli
Copy link
Contributor

Found a strange issue while testing this.
Compiling locally on OSX with MacOS 10.12.6 with Qt5.9.0 works perfect (guisettings.ini.bak is present after running with -resetguisettings).
However, using the gtitian build (https://bitcoin.jonasschnelli.ch/build/312) will result in not creating the guisettings.ini.bak file. Not sure if it is a local issue but would be good if someone could test this (via gitian)

@maflcko
Copy link
Member

maflcko commented Sep 18, 2017

@jonasschnelli The embedded commit hash does not match the advertised commit hash on the website of the downloaded gitian binaries.

@jonasschnelli
Copy link
Contributor

@MarcoFalke: the commit hash is different because my build script builds it on top of master. I just did everything again and the gtitian version does not create the backup file.
https://bitcoin.jonasschnelli.ch/build/315
(Maybe someone should double-check via an gitian build).

@achow101
Copy link
Member

@jonasschnelli I performed my own gitian build and tested it but could not reproduce your issue. It will create guisettings.ini.bak as it should.

I did notice that if you did not have any gui settings to begin with, the file will not be created. Perhaps that's what you are seeing?

@jonasschnelli
Copy link
Contributor

@achow101: even with enabling coincontrol I had no success on OSX.
What OS did you test? It may be a platform issue?

@achow101
Copy link
Member

@jonasschnelli I am using Ubuntu 17.04

@laanwj
Copy link
Member Author

laanwj commented Sep 19, 2017

I did notice that if you did not have any gui settings to begin with, the file will not be created. Perhaps that's what you are seeing?

Hm, that's interesting, haven't thought about that. I think that behavior makes sense, though.

Copy link
Contributor

@gmaxwell gmaxwell left a comment

Choose a reason for hiding this comment

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

ut(not very useful at reviewing QT stuff)ACK.

Writes the GUI settings to `guisettings.bak` in the data directory
before wiping them. This can be used to retroactively troubleshoot
issues (e.g. bitcoin#11262) where `-resetguisettings` solves the problem.
@laanwj laanwj force-pushed the 2017_10_backup_resetguisettings branch from b28af38 to 723aa1b Compare September 23, 2017 07:39
@laanwj
Copy link
Member Author

laanwj commented Sep 23, 2017

Squashed 4e9dc85 f725dbb 0f29983 b28af38723aa1b

@laanwj laanwj merged commit 723aa1b into bitcoin:master Sep 23, 2017
laanwj added a commit that referenced this pull request Sep 23, 2017
723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan)

Pull request description:

  Writes the GUI settings to `guisettings.bak` in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. #11262) where `-resetguisettings` solves the problem.
  (as discussed in yesterday's IRC meeting)

Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 4, 2017
Writes the GUI settings to `guisettings.bak` in the data directory
before wiping them. This can be used to retroactively troubleshoot
issues (e.g. bitcoin#11262) where `-resetguisettings` solves the problem.

Github-Pull: bitcoin#11338
Rebased-From: 723aa1b
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 13, 2019
Summary:
723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan)

Pull request description:

  Writes the GUI settings to `guisettings.bak` in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. #11262) where `-resetguisettings` solves the problem.
  (as discussed in yesterday's IRC meeting)

Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586

Backport of Core PR11338
bitcoin/bitcoin#11338

Test Plan:
  make check
  ./bitcoin-qt -resetguisettings
  guisettings.ini.bak should exist in your .bitcoin dir

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3934
codablock pushed a commit to codablock/dash that referenced this pull request Sep 25, 2019
…ings`

723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan)

Pull request description:

  Writes the GUI settings to `guisettings.bak` in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. bitcoin#11262) where `-resetguisettings` solves the problem.
  (as discussed in yesterday's IRC meeting)

Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 22, 2019
Summary:
723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan)

Pull request description:

  Writes the GUI settings to `guisettings.bak` in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. #11262) where `-resetguisettings` solves the problem.
  (as discussed in yesterday's IRC meeting)

Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586

Backport of Core PR11338
bitcoin/bitcoin#11338

Test Plan:
  make check
  ./bitcoin-qt -resetguisettings
  guisettings.ini.bak should exist in your .bitcoin dir

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3934
proteanx pushed a commit to devaultcrypto/devault that referenced this pull request Dec 23, 2019
Summary:
723aa1b qt: Backup former GUI settings on `-resetguisettings` (Wladimir J. van der Laan)

Pull request description:

  Writes the GUI settings to `guisettings.bak` in the data directory before wiping them. This can be used to retroactively troubleshoot issues (e.g. #11262) where `-resetguisettings` solves the problem.
  (as discussed in yesterday's IRC meeting)

Tree-SHA512: c64f5052d992eb02057ba285435f143c42d0cc456144a4c565e1c87be833737f9df750d0aee10810f85047c820d9b4f9f22fd94a6f09f4b28a9cf41b63a56586

Backport of Core PR11338
bitcoin/bitcoin#11338

Test Plan:
  make check
  ./bitcoin-qt -resetguisettings
  guisettings.ini.bak should exist in your .bitcoin dir

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3934
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants