3 min de lectura
Ethereum: Is there a way to reindex from disk but not start from blk0000.dat?
CRYPTOCURRENCY
Reindexing Ethereum Blocks: Can I Start From a Different File?
As an experienced Bitcoin and Ethereum user, I recently encountered a frustrating issue with my daily sync process. My Ethereum wallet was complaining about loading blocks from a corrupt file, which ultimately led me to explore the possibility of reindexing from disk but starting from a different file.
The Error Message
Here is the error message that appeared in my terminal:
Error: Could not find file blk00217.dat or blk0000.dat
At first glance, it seemed like a simple issue with loading full blocks from disk. However, when I dug deeper, I discovered that Bitcoin-Qt was not only loading full blocks, but also trying to start the sync from blk0000.dat
, which is a corrupt file.
Understanding the reindexing process
To understand what is happening, let’s dive into the basics of Ethereum block reindexing. When you run eip155dumper
on your Bitcoin-Qt wallet (or any other Ethereum node), it generates a list of blocks that can be used to restore the blockchain to its previous state.
The reindexing process involves loading these blocks from disk and then rebuilding the blockchain. This is necessary because blocks are not stored in memory, but rather on disk, where they are periodically updated by the network.
Reindexing from disk but without starting from a different file
Now, let’s get to the crux of the problem: starting the reindex from blk0000.dat
instead of loading full blocks from disk. To achieve this, you’ll need to understand how Bitcoin-Qt loads and stores blocks on disk.
The blk0000.dat
file is used as a «scratchpad» to load new blocks during reindexing. It is not the actual blockchain data that is stored on disk; rather, it is a temporary buffer that contains the latest block from the network.
When Bitcoin-Qt begins reindexing, it loads this scratchpad file (or blk0000.dat
in this case) and uses its contents to update the blockchain. The reindexed blocks are then written back to disk, restoring the blockchain to its previous state.
Workaround: Reindexing from a different scratchpad file
As I said before, there is no direct way to start reindexing from a different scratchpad file (e.g., blk0000.dat
). However, you can achieve a similar result using a different approach:
- Load blocks from disk using standard
blk
files (e.g.,blk0010.dat
,blk0020.dat
, etc.).
- Create a new scratchpad file (e.g.,
scratchpad.dat
) that contains the most recent block data.
- Use the
scratched
command to reindex from this scratchpad file.
To use scratched
, you can follow these steps:
- Load complete blocks from disk using
blk
files:blk0010.dat
,blk0020.dat
, etc.
- Create a new scratchpad file (e.g.,
scratchpad.dat
) that contains the most recent block data:
scratched -o scratchpad.dat < blk0010.dat
- Run Ethereum-Qt with the updated scratchpad file:
eip155dumper
on your wallet.
- Start reindexing from the scratchpad file using
reindex
.
Conclusion
While it is not possible to start reindexing from a different scratchpad file, you can work around this limitation by using standard blk
files and creating a new scratchpad file that contains the most recent block data. By following these steps, you should be able to achieve the desired result without having to reload full blocks from disk.
Keep in mind that reindexing is an ongoing process, so be sure to periodically check the state of your blockchain and adjust your configuration as needed. Happy reindexing!