-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
[Wallet] replace BDB with internal append only (logdb) backend #5686
Conversation
b124c37
to
00ff8e9
Compare
Currently there is no migration tool from bdb to logdb. IMO the version code 0.1x should make clear that such required manual migrations are still possible. |
@jonasschnelli Agree that a migration tool is necessary before rolling this out. There are a few complications with python that would need double-checking:
I would prefer a C++ migration tool. Eventually you could split it off into a separate project or repository if the continued BDB link-time dependency remains annoying. |
@jgarzik a C++ tool would probably get better results. Agreed. Moving the c++ migration tool to separate repository makes sense. There we could also support the |
Yes - Python is generally linked against the system's BDB, which on modern systems is always >4.8. Newer BDB versions have no problem reading old databases. The problem is the other way around. After the file is "touched" it won't be backwards compatible anymore. Making a temporary copy then reading that would be a strategy to keep the origin file as-is. |
Apart form that: nice work! I agree with your internal roadmap. I think it makes sense to do this work on a 'newwallet' branch so that other people can cooperate, and we can merge it into master when the work is complete, which will likely be no sooner than 0.12. |
+1 @laanwj Concept ACK for the wallet changes. |
@jonasschnelli Yes. I go back and forth between "separate repo now" and "separate repo later" For the initial conversion, it makes everything easier if the migration tool is in bitcoin/bitcoin.git and is built with the current build system. That is the path of least resistance. Build system & install Just Works. You automatically get the migration tool, even if you didn't know you needed it until (oops, right now!) I try to be extra-conservative with Real Money(tm), which is what we're dealing with when it comes to the "legacy wallet" we're maintaining. |
00ff8e9
to
0f70347
Compare
It may be a good idea to have 0.11 still compatible with bdb wallets without upgrading them - note that all our wallet upgrades have been opt-in so far, and you can still use a 0.4.0 wallet with 0.10 while retaining backward compatibility. |
0f70347
to
4f64c94
Compare
Supporting both (bdb and logdb) wallet formats (at runtime) would require some work. I agree with not letting users in the dark and support a migration tool (c++, included in bitcoind for 0.11 or 0.12, but slowly extract migration tool to different repository). Migration of a wallet is a risky process and it's probably better to do this outside of bitcoind as a conscious decision from the user. |
b227792
to
add1fb3
Compare
On IRC I've explicitly argued against dual database support, and I'm going to do so here again. An alternative option I've thought of is to leave the old wallet untouched. Move Then build this new wallet with new database, new interface in Using a configure option, one can then either build against the new wallet or the old wallet. In the beginning the legacywallet will be the default and the new wallet will be experimental-only. This is basically the "fork the wallet and develop it separately" approach, but a bit improvised as it's all in one repository - for now. It means we can merge this soon(TM) and experiment with it, instead of delaying that to a further future 'when it's ready'. (the only complication here I see is with regard to the UI, which has to interface with both, but a similar thing can be done there; UI that only applies to the old wallet can be moved to a legacy directory) |
Sounds reasonable, but if we can't build with both supported, how will binaries go out? Probably not too much more effort to just keep the class names unique and switch between them at runtime startup, is it? |
I like laanwjs idea of supporting both formats with a compile option. Two concerns I see:
The 2nd concern is more a "conceptual" one. If we support both wallet formats, why should one upgrade his wallet? Couldn't that not lead to a need of supporting both formats? And if we once drop support of BDB, how is the migration process different now from the one in future (the user has to do it once anyway)? Maybe we could force people to upgrade and save some - already rare - development resources. I mean it's not the network, it's the wallet. |
The original idea I discussed w/ @sipa on IRC was dropping support for BDB from bitcoind entirely, plus an auto-launched migration tool. Still prefer that arrangement. From bitcoind's standpoint, BDB support is deleted. No dual mode codebase. |
More daring users can use the new wallet, whereas more conservative users can stay with the old wallet for say a major release or two until it is completely axed (but the new one, as well as the conversion process, much better tested). @luke-jr Building a monster executable with both wallet implementations could be possible, with e.g. an command line option to switch. Not sure if this is a good idea in practice, but I don't want to exclude the possibility upfront. We'll see when we get there I suppose. In the beginning this won't be an issue as the new wallet will be experimental-only so requiring build-time invocations is a good thing. |
@laanwj hmmm, that is an interesting way to transition. Let's think through the user making that old wallet / new wallet choice. That plan would indeed make for a nice, clean separation. |
357911b
to
34d5853
Compare
Sounds like a good plan to me. Can you reference those PRs from here as you create them? |
88e2e02
to
196931d
Compare
- add wallet encryption/unlocking test - cleanup logdb, remove of initial header with logdb-file version number - remove fileBackend=false option (doesn't make sense anymore) - remove wallet max/min version
196931d
to
bde59e1
Compare
A suggestion for a more robust frame format.
|
|
@pstratem but wouldn't the 2nd and 3rd element ( |
The purpose of allowing an unspecified length is extremely long records, those simply do not exist in a bitcoin wallet.
eh... yeah I guess sometimes, but that should be defined as part of the format for the Body, note everything else is 64 bit aligned |
you're gonna have to explain that one |
Ah now i see! |
#include <unistd.h> | ||
#include <sys/stat.h> | ||
|
||
#include "logdb.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Include group ordering (own headers before system ones).
Edit: Also obsolete file/license header...
This kind of stuff is the reason for the frame to be more robust. |
Leaning towards closing as Work In Progress. General IRC consensus has been "we want this" for a long time, so concept ACK from most developers seems implied, myself included. However, this seems more of a longer term project resulting in a long lived PR. Recommend storing this on a branch and opening a mailing list thread to follow development. |
Closing. |
I started an append only key/value file format in pure C, based on @sipa concept, that aims to be storage format for wallets (libbtc/libbtc#41), suitable for MCUs, smartphones, desktop, etc. Just in case someone wants to contribute. |
What's the status on this? It's been over a year now, is this idea dead? |
This pull request is in early stage but discussions could help driving this into the right direction.
It will basically remove bdb (currently not on compile level) and make use of a internal key/value store.
Logdb (the internal key/value store) is a append only store where every key/value-frame contains a sha256 checksum all available frames. Consistency is guaranteed.
The current implementation passes all tests but has lack of recover/rewrite possibilities.
Why this
What's next / ToDos
add compact(added 2015/01/22)Rewrite()
function (save whole memory map atomically to a clean file): this is required after encrypting the walletRecover()
function: scan through a corrupt wallet file and try to recover keys even when some key/value-frames and/or checksums are corruptedThis is on my internal roadmap: