Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: separate config files from cache directories #5422

Open
coolaj86 opened this issue Jun 8, 2023 · 4 comments
Open

enhancement: separate config files from cache directories #5422

coolaj86 opened this issue Jun 8, 2023 · 4 comments

Comments

@coolaj86
Copy link

coolaj86 commented Jun 8, 2023

Separate Cache from Config

As a general best practice, cache files and directories and config / user data and directories should not be mixed together.

Caches are often Rebuilt

In the specific case of dashd (and dash-qt), it's common to need to delete the blockchain data when it becomes corrupted from:

  • the program being quit unexpectedly
  • crashing due to running out of RAM
  • the server not being shut down correctly
  • not finishing during a sync
  • changing certain settings
  • etc

Using Flags

The -testnet flag already does the right thing by creating a separate testnet3 which can be removed at any time without an issue (I think).

It would make a lot of sense to create a mainnet folder for the mainnet cache rather that putting it alongside dash.conf and settings.json which contain valuable secrets, user config, etc.

I'm not sure which other files also contain valuable data (Wallet Phrase, legacy private keys), but it would be a lot easier to manage the mistakes if there were a clear delineation between what needs to be backup up and what doesn't before blowing away the cache directories - because if they aren't blown away then it seems they just duplicate information rather than resuming from the last good state or pruning the unrecoverable data entirely.

Standards Already Exist

My greatest preference would be to follow the existing standards used by most other CLI tools and switch configuration data to ~/.config/dashcore/ by default, and ~/.local/opt for program files, and other folders in ~/.local for larger important data specific to the user according to standards and best-practice conventions.

@coolaj86
Copy link
Author

coolaj86 commented Jun 8, 2023

Also, -datadir is a misnomer, at least from a user perspective. Perhaps that should be -cachedir and -userdir.

Or there should otherwise be some clear distinction between data that is "NOT unique" and "unique to this instance" and "unique to this user".

In the case of running a Full Node, I assume the purpose is just for creating APIs to interact with transactions and balances, etc, so it's not a big deal - but dashcore as a package doesn't really distinguish between use cases of "User is doing stuff with money" vs "Service provider is providing services" vs "MNO is voting" - everything is everything is everything, which makes it even more important to provide clear distinction at the folder level.

@coolaj86
Copy link
Author

coolaj86 commented Jun 9, 2023

The current behavior is also dangerous because there's no way to future-proof against it.

I can personally change -datadir and -conf, but then later -walletdir comes along and then -settings comes along and so on and so forth.

It needs to be the responsibility of the developers to choose safe defaults, not the responsibility of the user to be constantly vigilant in setting command line options, checking the notes of each release, etc, etc, etc.

Users are dumb. I'm dumb. Computers should protect us from our dumbness, not lead us into traps. People are bad at following rules and guidelines and methodologies, but computers are great at it. Y'know?

@thephez
Copy link
Collaborator

thephez commented Jun 9, 2023

The -testnet flag already does the right thing by creating a separate testnet3 which can be removed at any time without an issue (I think).

Fwiw, it is not safe to remove the testnet3 (or regtest or devnet-*) directory at any time. This is because wallet files for each network type are stored within that network's directory.

@coolaj86
Copy link
Author

coolaj86 commented Jun 9, 2023

wallet files for each network type are stored within that network's directory

I found a bug there too: #5423

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

No branches or pull requests

2 participants