Skip to content

Conversation

@ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Apr 3, 2023

This is based on #27302. The non-base commits are:


Currently if your choose a non-default datadir in the GUI intro screen, the datadir is ignored by CLI tools.

This PR makes GUI and CLI tools the same datadir setting by default. It is followup to bitcoin-core/gui#602 which made GUI and CLI tools use the same settings as long as they loaded the same datadir.

The reason GUI and CLI tools use inconsistent datadirs is that GUI stores the datadir path in a strDataDir field in .config/Bitcoin/Bitcoin-Qt.conf1 which CLI tools ignore. This PR changes the GUI to instead store the datadir path at the default datadir location ~/.bitcoin2 as a symlink that CLI tools will already follow, or as a text file if the filesystem does not support symlinks.

If upgrading from a previous version of the GUI and there is only a GUI datadir, the strDataDir setting will be automatically migrated to a symlink so CLI tools will start using it as well.

If upgrading and GUI and CLI tools are using different datadirs, the GUI will show a prompt allowing either of the datadirs to be loaded on startup, with an option to set one as the default going forward.

Footnotes

  1. strDataDir value is stored in .config/Bitcoin/Bitcoin-Qt.conf on linux, in property list files on macos, and in registry keys on windows.

  2. The default datadir location is ~/.bitcoin on linux, ~/Library/Application Support/Bitcoin on macos, and %APPDATA%\Bitcoin on windows

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 3, 2023

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/27409.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #bitcoin-core/gui/870 ([DRAFT] Expose AssumeUTXO Load Snapshot Functionality To The GUI by D33r-Gee)
  • #33550 (Fix windows libc++ fs::path fstream compile errors by ryanofsky)
  • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)

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.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • inccludeconf -> includeconf [spelling error in comment makes the identifier unclear]
  • fo -> of [typo in comment: "Newer version fo the GUI" should be "Newer versions of the GUI"]
  • datadirectory -> data directory [missing space in "datadirectory" in error/status message makes phrase harder to read]
  • that -> than [comparison error in comment: "different datadir path that the default..." should be "different datadir path than the default..."]

No other added lines contain typographic or grammatical errors that make the English incomprehensible.

drahtbot_id_5_m

@ryanofsky
Copy link
Contributor Author

This is a draft PR and not fully implemented. Just opening it to share progress since it's taking longer than I expected to implement correctly

@pinheadmz
Copy link
Member

This PR probably closes #8106

@luke-jr
Copy link
Member

luke-jr commented Jun 22, 2023

Won't this change/break putting the bitcoin.conf in the GUI-selected datadir?

@ryanofsky
Copy link
Contributor Author

Won't this change/break putting the bitcoin.conf in the GUI-selected datadir?

No, I definitely need to update this and it may contain bugs. But do you see something here that would cause that to happen?

@luke-jr
Copy link
Member

luke-jr commented Jun 22, 2023

No, I didn't get to the code yet - was just commenting from the description of this PR and #27302

Comment on lines 117 to 187
# Disable this test for windows currently because trying to override
# the default datadir through the environment does not seem to work.
if sys.platform == "win32":
return
Copy link
Member

Choose a reason for hiding this comment

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

@maflcko
Copy link
Member

maflcko commented Jun 28, 2024

@ryanofsky What is the status of this?

@ryanofsky
Copy link
Contributor Author

ryanofsky commented Jun 28, 2024

re: #27409 (comment)

@ryanofsky What is the status of this?

It's a change I'd really like to get back to, but is not ready now. The last time I worked on it, which was months ago, I started writing a Qt test for it but there are so many permutations of configurations (presence/absense of different data directory locations) that I was struggling to write it. I would like to get back to this at some point and I do have work in progress, but I don't think I will have an update on it soon, given other things I'm working on.


Rebased 5855150 -> 5864569 (pr/1data.2 -> pr/1data.3, compare)

Currently bitcoin-wallet accepts a -datadir argument but ignores and config
file in that directory. This changes it to load the config file for consistency
with other cli tools, and in case it contains any significant settings.

Also update various tests using the data directory to call ReadConfigFiles.

Motivation for these changes is to prevent errors after the next commit makes
it at assert error to get the datadir path without reading the configuration
first.
It's always been possible for bitcoin default datadirs ($HOME/.bitcoin,
$HOME/Library/Application Support/Bitcoin, %APPDATA%\Bitcoin) to point at an
external locations using symlinks, but not all filesystems support symlinks, so
add extra support for pointing at external locations using text file.

This feature is used in the following commit to allow the bitcoin GUI to select
a default datadir location that will also be treated as the default datadir for
CLI tools. Currently when a custom data is set in the GUI, CLI tools ignore it
by default.
Currently if a you choose a non-default datadir in the GUI intro screen, the
datadir is ignored by CLI tools. This means `bitcoin-cli` and `bitcoin-wallet`
will try to use the wrong datadir and show errors if they are called without a
-datadir arguments, and `bitcoind` will appear to work but use a different
datadir, not loading the same wallets and settings, and downloading blocks into
the wrong place.

There are also more subtle inconsistencies between GUI and CLI selection of
datadirs such as bitcoin#27273 where GUI might ignore a datadir= line in a
bitcoin.conf that CLI tools would apply.

This PR gets rid of inconsistencies between GUI and CLI tools and makes them
use the same datadir setting by default. It is followup to
bitcoin-core/gui#602 which made GUI and CLI tools use
the same `-dbcache`, `-par`, `-spendzeroconfchange`, `-signer`, `-upnp`,
`-natpmp`, `-listen`, `-server`, `-prune`, `-proxy`, `-onion`, and `-lang`
settings as long as they loaded the same datadir.

The reason for GUI and CLI tools using inconsistent datadirs, is that GUI
stores the datadir path in a `strDataDir` field in
`.config/Bitcoin/Bitcoin-Qt.conf`[^1] which CLI tools ignore. This PR changes
the GUI to instead store the datadir path at the default datadir location
`~/.bitcoin`[^2] as a symlink that CLI tools will already follow, or as a text
file if the filesystem does not support creating symlinks.

If upgrading from a previous version of the GUI and there is only a GUI
datadir, the `strDataDir` setting will be automatically migrated to a symlink
so CLI tools will start using it as well. If CLI and GUI tools are currently
using different default datadirs, the GUI will show a prompt allowing either of
the datadirs to be loaded and optionally set as the common default going
forward.
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants