Block migration db flag (only migrate once) #3512
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #3511
We only need to run the block migration process to completion once, to migrate existing blocks from v2 -> v3.
This PR introduces -
batch.is_blocks_v3_migrated()
batch.set_blocks_v3_migrated(true)
BoolFlag
(de/ser of simple bool value in lmdb)BOOL_FLAG_PREFIX
prefix for arbitrary bool flags in the dbBLOCKS_V3_MIGRATED
lmdb key for this specific bool flagBoolFlag
and the associated db code should be reusable if we decide to store additional flags in the db.This PR also reworks the actual migration process to reduce the amount of deserialization attempts required to determine which blocks do need migrating. This will reduce the time required for the initial migration process.
We were attempting reads of both
v2
andv3
format and looking for errors duringv3
.We now do a single
v3
read and only on failure do we perform the additionalv2
read.Empty blocks do not need to be migrated (no inputs to migrate) which is why we can skip successful
v3
reads.And for these we do not need the additional redundant
v2
read.After a successful migration, subsequent node restarts will result in -