So, I had this problem before where my computer crashed and it messed up a block. To fix it, I just ran bitcoind with the -reindex option to sort out the block issue. Now, I'm curious about how to check if the chain or database is corrupted at startup and I'm trying to simulate a corrupted database. I've been testing ways to cause a corrupted state, but just cutting off the power doesn’t seem to do the trick. I think the power outage needs to happen at a specific point during chain maintenance. Is there a reliable method to create a corrupted database for testing? I'm running Ubuntu and connected directly.
how to create a corrupted database or block
5 replies 82 views
Just a follow on: I just started renaming blocks in blocks, chainstate and received the startup error:
So if you want to create a corruption in db for testing, this works
SwiftMinerSenior Member
Posts: 259 · Reputation: 1036
#3Jun 30, 2021, 03:00 PM
Firstly Op if I may ask , why are you trying to corrupt the drive? Probably it may exist, but I haven't really come across a drive corruption after the device have been successfully synced with the block chain. Majority of the cases I have come across especially on this forum are those where the drive got corrupt during the process of syncing with the block chain. Sometimes as a result of power outage and sometimes because the block chain was synced to a drive with the wrong format like FAT32 which sometimes has issues when the file load is huge.
RAM also has a huge role to play when it comes to computation during the syncronisation process which will attribute how long it will take before the sync is completed.
Thanks for asking. Basically the other day when initially loading the blockchain there was a sudden power outage. When the system came back up the bitcoind errored out. Eventually my plan is to have a script which checks if the blockchain (local data stored on my system) is intact (this will run as a ExecStartPre in systemd), and then if not have a systemd process which will in those cases run the bitcoind with the -reindex option. I already have a simple script which checks if the bitcoind is unable to start and will then hook it up to systemd process which runs with the -reindex in those cases.
You shouldn't try to simulate a power outage as that can actually damage your motherboard. What would be better for testing purposes would be to force-kill the bitcoind process - either by Task Manager or by sending SIGKILL (not sigterm) to it on Linux or Max.
Bitcoin Core check recent block when you open it. So you probably just need to edit recently created blk*dat or rev*dat files to achieve that goal. I said probably since i didn't try it on my own Bitcoin Core files.
?Reply
Sign in to reply to this topic
Related topics
- Vanitygen: Create Your Own Bitcoin Address with This Tool 19
- issues with bitcoin core database read error 2
- Testing 64-bit Nonce Collision on the Genesis Block with an Extended Header 2
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3