Author

Topic: My blockchain is b0rked, would like to repair it (Read 1651 times)

legendary
Activity: 1526
Merit: 1002
Waves | 3PHMaGNeTJfqFfD4xuctgKdoxLX188QM8na
why not just delete everything except wallet.dat and bitcoin.conf (if you have it), and let the client redownload the blocks?

I wouldn't learn anything by doing that.

Yes you would.
You would learn it saves a lot of time and trouble  Grin
legendary
Activity: 1974
Merit: 1029
why not just delete everything except wallet.dat and bitcoin.conf (if you have it), and let the client redownload the blocks?

I wouldn't learn anything by doing that.
legendary
Activity: 2058
Merit: 1452
why not just delete everything except wallet.dat and bitcoin.conf (if you have it), and let the client redownload the blocks?
legendary
Activity: 1974
Merit: 1029
Some days ago I found this:

Code:
$ bitcoind getblockhash 3
0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449
$ bitcoind getblock 0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449
error: no response from server

debug.log:

Code:
2013-04-01 10:29:34 ThreadRPCServer method=getblock
2013-04-01 10:29:35 ERROR: CheckProofOfWork() : nBits below minimum work
2013-04-01 10:29:35 ERROR: CBlock::ReadFromDisk() : errors in block header

syslog:

Code:
[12:35:48] kernel: [616350.252104] bitcoin-rpchand[21782]: segfault at 10 ip 00000000005393a3 sp 00007f217a401e70 error 4 in bitcoind[400000+3cd000]

This happened with all blocks between 1 and 59571, inclusive. A couple of days later when examining my blk00000.dat I noticed that the genesis block was followed by a bunch of null bytes, until exactly the 16 MiB mark. The next magic value showed up not much later, followed by the block 59573. I assume that the data between 16 MiB and that point was part of the block 59572.

So I tried extracting the missing data from my copy of the bootstrap.dat but I only managed to completely break the blk00000.dat Smiley. Then I took a peek to the blk00001.dat to look what was the first block there, and stored all previous blocks in the blk00000.dat.

Bitcoin starts and runs fine, but reading some blocks still kills the process, while reading some others returns garbage. I wrote a small blockchain parser and it seems to be sane; after all, the data came from the bootstrap.dat. So I'm not sure why bitcoin is dying on them (though I have some hypotheses).

I have another copy of the datadir handy, not to mention the bootstrap.dat itself, but I'd really like to repair this one. Does the .bitcoin/blocks/index directory have something to do? Can/should I remove it? Anything else worth a try?
Jump to: