-
Notifications
You must be signed in to change notification settings - Fork 37.9k
Add -reindex, to perform in-place reindexing of blockchain data files #1870
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
Conversation
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/68e760d2656716cc9d538567c0735c77d8e5749e for binaries and test log. |
src/main.cpp
Outdated
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.
I really wouldn't delete bdb database files yourself. Use the dbenv methods to do so.
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.
I agree with sipa, dbenv seemed to get very confused when I renamed database files behind its back for my corrupt wallet.dat handling code.
Surprising how little code changes are necessary for this. Ultraprune already has a CDiskBlockPos however, which is also used inside CTxBlockPos, so maybe you can use that instead? I think you can just copy it, and remove the IMPLEMENT_SERIALIZE. |
I also wonder about this: what if the current best chain happens to be known in the new/repained blockchain? There should be no need to rebuild the entire index in that case, only the block positions. EDIT: right, you can't, as in the current database structure, transactions also contain disk positions. It's something that can be done post-ultraprune though. |
Updated with the following changes:
|
Have you tested this?
|
I wrote up a 4-step test plan that I've been working through. I also have a branch (not published) to reconcile this with my corrupt wallet handling pull; @jgarzik see https://github.com/gavinandresen/bitcoin-git/commits/BDB_RECOVER The testplan I was working through:
I haven't tested 4/5 yet, and don't know enough about BDB major version compatibility to know what is reasonable to expect. |
Doing the database remove in the environment definitely creates a super-large removal transactions, yet does not actually remove blkindex.dat. blk0002.dat is growing here, which should not be the case. Further debugging is needed. |
Instead of: I think passing NULL as the third argument removes the file. |
Caveat: a new genesis block is added to blkNNNN.dat with each run, thanks to LoadBlockIndex() creating one, when it creates a blank block index.
Fixed a few bugs, and rebased on top of @gavinandresen 's ::RemoveDb(). blkindex.dat is now properly removed, and reindex proceeds as expected. Things appear to be working now. Caveat: a genesis block is newly stored to blkNNNN.dat, for each -reindex invocation. LoadBlockIndex() adds a new one to the (it thinks) newly created block file. All other blocks are properly read and processed in-place. -reindex highlights the poor speed of BDB indexing alone... and should provide a useful apples-to-apples basis for comparing the old BDB system with ultraprune. |
Needs rebase. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/f49f2631856a4a233a957ce8361ffab3b08561cc for binaries and test log. |
Superceded by #1943, closing |
626b0d9 incrementalmerkletree file added to cmake. (furszy) 4368a00 incremental merkle tree test: resolve invalid deserialization/serialization data equality check. (furszy) 9cfb0a7 rename sapling util file to not shadow src/util file. (furszy) 68d494d Incremental Merkle Tree + merkletree tests back port (furszy) Pull request description: This is coming from bitcoin#1798, focused on include the incremental merkle tree primitive with all of its unit tests. This base primitive class is almost one to one with upstream. Decoupled the following commits: * Incremental Merkle Tree + merkletree tests back port —> 762d5f1 * Rename sapling util file to not shadow src/util file --> cae89d3 ACKs for top commit: random-zebra: ACK 626b0d9 Fuzzbawls: utACK 626b0d9 Tree-SHA512: 9bae913aa553ec42864b5f5f252f8ce6bd9fd6fd89011c63c31e1de06cba820dc99feeaabe38801f012a54abc81b8213aee0334695c4e0673591e48dc07d5954
b11b357 removing global namespace usage for noteencryption and sapling_note unit tests (furszy) 52da4e0 [Sapling] Note Encryption unit tests back ported. (furszy) 4d2f01a [Sapling] change cm() to cmu() in SaplingNote class (furszy) Pull request description: Another decoupling from bitcoin#1798. Similar to bitcoin#1870, these changes are part of the primitives unit test coverage back port work. Commits included: * change cm() to cmu() in SaplingNote class —> d437276 * Note Encryption unit tests back ported. —> e4c1bbf ACKs for top commit: Fuzzbawls: ACK b11b357 random-zebra: re-utACK b11b357 Tree-SHA512: 56914dba65ee239f7e6713a111abca5bd1a4e684fadcdbed4314295f499f3b6689271fa7999c7f182dcba069ebe29299bed944e7ee6b1bcb3aad987884811242
Hopefully this is done in a database-independent manner, with minimal interference to the upcoming ultraprune.