Skip to content

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Oct 30, 2020

This PR does not change behavior when bitcoin is built normally with both the SQLite and BDB libraries. It just makes non-SQLite and non-BDB builds more similar to the normal build. Specifically:

  • It makes wallet directory lists always include all wallets so wallets don't appear missing depending on the build.

  • It now triggers specific "Build does not support SQLite database format" and "Build does not support Berkeley DB database format" errors if a wallet can't be loaded instead of the more ambiguous and scary "Data is not in recognized format" error.

Both changes are implemented in the last commit. The previous commits are just refactoring cleanups that make the last commit possible and consolidate and reduce code.

@hebasto
Copy link
Member

hebasto commented Oct 30, 2020

Concept ACK.

In 6066221 commit message:

"Remove circular dependencies between wallet translation units"

What are those dependencies?

@ryanofsky
Copy link
Contributor Author

What are those dependencies?

Oh, I think I need to drop that comment. The dependency I was thinking of was walletutil.cpp depending on bdb.cpp for ExistsBerkeleyDatabase, and bdb.cpp depending on walletutil.cpp for SplitWalletPath. And I thought there were others. But actually SplitWalletPath is in db.cpp not walletutil.cpp, and now I don't think there are other dependencies.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 30, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

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.

Concept ACK.

@ryanofsky
Copy link
Contributor Author

@mjdietzx your questions about the IsBDBFile are good but I think not directly relevant to this PR, which is just moving the IsBDBFile function from one file to another, not changing it at all.

Viewing individual commits https://github.com/bitcoin/bitcoin/pull/20275/commits/ may be clearer than viewing the consolidated diff. Any case, I'll try follow up with answers soon.

@jonatack
Copy link
Member

jonatack commented Nov 1, 2020

Concept ACK

@achow101
Copy link
Member

achow101 commented Nov 2, 2020

ACK e21dc6c

@promag
Copy link
Contributor

promag commented Nov 2, 2020

Tested ACK e21dc6c. Tested listwalletdir and loadwallet with a wallet in walletdir and with an external wallet.

Startup fails if any wallets -wallet or settings.json is sqlite.

Copy link
Contributor Author

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

This has two ACKS so I didn't make any tweaks. Just responding to review comments

@maflcko
Copy link
Member

maflcko commented Nov 4, 2020

Is this for 0.21?

@ryanofsky
Copy link
Contributor Author

Is this for 0.21?

I'm not requesting it. I see this mostly as a code cleanup. For users, the only ones who would be affected would be those compiling from scratch and disabling sqlite, or maybe those using gentoo or nixos type packages with build customizations. The effect for these users at worst would be some confusion seeing incomplete wallet listings, or seeing scarier "Data is not in recognized format" error in place of "Build does not support SQLite database format"

@promag
Copy link
Contributor

promag commented Nov 4, 2020

or seeing scarier "Data is not in recognized format"

The same error would also happen if the the user attempts to open sqlite wallet with previous versions.

@maflcko
Copy link
Member

maflcko commented Nov 5, 2020

Also, it would be hard to create a sqlite wallet with a non-sqlite build. Assigning 22.0 milestone

@ryanofsky
Copy link
Contributor Author

ryanofsky commented Nov 13, 2020

Rebased e21dc6c -> 417e95a (pr/exist.1 -> pr/exist.2, compare) due to conflict with #19502
Rebased 417e95a -> 727e0aa (pr/exist.2 -> pr/exist.3, compare) due to conflict with #18836

This commit does not change to any code and behavior. It it is easily reviewed
with the --color-moved=dimmed_zebra git diff option.

Motivation for this change is to:

- Consolidate redundant functions
  IsBDBFile /ExistsBerkeleyDatabase / SplitWalletPath, and
  IsSQLiteFile / ExistsSQLiteDatabase in the next commits

- Detect SQLite wallets consistently regardless whether bitcoin is built with
  SQLite support in the next commits

- Avoid attempting to open SQLite databases with the BDB library when bitcoin
  is built without SQLite support in the next commits
No change to behavior. This is just cleanup after previous MOVEONLY commit to
make db.h list function fit conventions of surrounding functions.
No observable change in behavior. This just avoids a redundant environment
lookup. Motivation is to be able to simplify the GetWalletEnv implementation in
an upcoming commit.
…ions

No change in behavior. Just remove a little bit of code, reduce macro usage,
remove duplicative functions, and make BDB and SQLite implementations more
consistent with each other.
This commit does not change behavior when bitcoin is built normally with both
the SQLite and BDB libraries. It just makes non-SQLite and non-BDB builds
more similar to the normal build. Specifically:

- It makes wallet directory lists always include all wallets so wallets don't
  appear missing depending on the build.

- It now triggers specific "Build does not support SQLite database format" and
  "Build does not support Berkeley DB database format" errors if a wallet can't
  be loaded instead of the more ambiguous and scary "Data is not in recognized
  format" error.
@ryanofsky ryanofsky changed the title wallet: List SQLite wallets in non-SQLite builds wallet: List all wallets in non-SQLite and non-BDB builds Dec 4, 2020
@ryanofsky
Copy link
Contributor Author

Rebased 727e0aa -> f3d870f (pr/exist.3 -> pr/exist.4, compare) due to conflict with #20202. #20202 added some new code that was originally part of this PR so this PR is a little simpler now.

@jonasschnelli
Copy link
Contributor

Concept ACK

@ryanofsky
Copy link
Contributor Author

@achow101 @promag you ACKed this previously and might be interested to reACK. There haven't been any changes except rebasing on top of #20202 making this PR a little smaller (new MakeDatabase code originally added here got added in #20202 instead)

@achow101
Copy link
Member

ACK f3d870f

@promag
Copy link
Contributor

promag commented Dec 11, 2020

Tested ACK f3d870f. Tested a --without-sqlite build with sqlite wallets.

Startup fails if any wallets -wallet or settings.json is sqlite.

This still happens - specifying sqlite wallet on a --without-sqlite build at command line (or settings.json) leads to startup failure. Not sure if this is expected or if it should just ignore it. Note that startup succeeds if you specify a wallet that doesn't exists.

@ryanofsky
Copy link
Contributor Author

This still happens - specifying sqlite wallet on a --without-sqlite build at command line (or settings.json) leads to startup failure. Not sure if this is expected or if it should just ignore it. Note that startup succeeds if you specify a wallet that doesn't exists.

Does the PR cause this somehow? Or is this a preexisting bug not related to the PR?

@promag
Copy link
Contributor

promag commented Dec 12, 2020

Existing behavior is to fail startup if -wallet points to a unknown file format. In this case it's a known but unsupported file format. I'm fine with both outcomes.

@ryanofsky
Copy link
Contributor Author

I don't understand what's being reported still. AFAIK, before this PR this case failed at startup, and after this PR it still fails at startup. But before this PR the error message was misleading, and after this PR the error message is more accurate.

If the only thing that's changing is the error message, that's good to know and thanks for testing it. But if something else is changing here besides the message, that's not intended, and is probably something that should be fixed here or at least noted in the PR description.

@promag
Copy link
Contributor

promag commented Dec 12, 2020

That's my question - If it should remain a startup error of if it should be ignored since now it's a known wallet format wallet. If the user loads a sqlite wallet, it's saved on settings, then restart with a --without-sqlite build will always fail.

@ryanofsky
Copy link
Contributor Author

ryanofsky commented Dec 12, 2020

That's my question - If it should remain a startup error of if it should be ignored since now it's a known wallet format wallet. If the user loads a sqlite wallet, it's saved on settings, then restart with a --without-sqlite build will always fail.

These are different questions. I'm asking what does happen, and you are asking what should happen. It sounds like in the last sentence you are confirming that the PR description here is accurate, and the PR is behaving as expected, and that only change before this PR and after this PR is that some error text is slightly improved.

If this is correct, then the answer to your question about what should happen is a matter of opinion. My opinion is that any of the 4 alternatives in bitcoin-core/gui#95 (comment) would be a good solution. I like alternative 4 in that list the best, but there a lot of good options. But this issue seems only vaguely related to this PR if the only effect of this PR is tweaking and improving the error text, so it probably should be discussed separately.

@promag
Copy link
Contributor

promag commented Dec 12, 2020

you are confirming that the PR description here is accurate, and the PR is behaving as expected

Yes, that's what I ACK'ed above.

Ah I keep forgetting bitcoin-core/gui#95 😩 thanks for pointing it.

@ryanofsky
Copy link
Contributor Author

Thanks for testing and clarifying! Sorry I didn't understand right away.

@maflcko maflcko merged commit ffc4d04 into bitcoin:master Dec 12, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 13, 2020
@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.