Author

Topic: create corrupted database / block (Read 103 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
May 20, 2024, 05:10:16 AM
#6
Is there some reliable way to create a corrupted db to use for testing?  (on linux: ubuntu direct connect)

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.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
May 19, 2024, 02:31:06 AM
#5
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.
member
Activity: 85
Merit: 25
May 19, 2024, 02:06:08 AM
#4
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.  
sr. member
Activity: 448
Merit: 560
Crypto Casino and Sportsbook
May 19, 2024, 02:00:31 AM
#3
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.
member
Activity: 85
Merit: 25
May 19, 2024, 01:04:27 AM
#2
Just a follow on:  I just started renaming blocks in blocks, chainstate and received the startup error:
Code:
2024-05-19T05:46:48Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
2024-05-19T05:46:48Z Opening LevelDB in /home/xxxx3/.bitcoin/chainstate
2024-05-19T05:46:48Z Fatal LevelDB error: Corruption: 3 missing files; e.g.: /home/xxxx3/.bitcoin/chainstate/123425.ldb
2024-05-19T05:46:48Z You can use -debug=leveldb to get more complete diagnostic messages
2024-05-19T05:46:48Z Fatal LevelDB error: Corruption: 3 missing files; e.g.: /home/xxxx3/.bitcoin/chainstate/123425.ldb
2024-05-19T05:46:48Z : Error opening block database.
So if you want to create a corruption in db for testing, this works Smiley
member
Activity: 85
Merit: 25
May 19, 2024, 12:13:30 AM
#1
I previously had a slight issue where my computer died and it corrupted the block so I reran bitcoind with the -reindex option to correct the block issue.  I was looking into on startup detecting whether or not the chain / db is corrupted and was hoping to create the condition of the database being corrupted.  I have tried to create a condition where the db is corrupted, but just stopping power does not seem to work (must be power outage at particular spot in the chain maintenance).  Is there some reliable way to create a corrupted db to use for testing?  (on linux: ubuntu direct connect)
Jump to: