Updating the version of the blockchain database should result in a clean re-index #1034
Labels
Consensus
Consensus related issues
enhancement
New feature or request
storage
Everything related to storage, whether it's blockchain, wallet or otherwise
Backwards compatibility should be handled by version numbers in the blockchain storage. Currently, there's nothing done for that, but a version number exists that can be used. What should happen is: If the hard-coded version number of the database is not equal to the currently stored version in the database on disk, a full re-index of the database should happen. The full re-index can be seen in two different ways:
Technically speaking, reading the database with an incompatible version isn't always safe. Hence, we should also have a mechanism in place that can detect whether a re-index is possible from the current data in the database. The minimum set of data we need to do a full re-index is:
Any information that will be read from the database should only be read when we're sure it's valid. Checksums can be used (by, for example, re-hashing blocks and comparing them to the values in height vs blocks map) to ensure that the data is valid.
Notice that a similar process should be there for wallets, but for wallets it's much more complicated because we MUST salvage data from wallets, unlike for the blockchain storage, where we could just resync from peers.
The text was updated successfully, but these errors were encountered: