Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block migration db flag (only migrate once) #3512

Merged
merged 2 commits into from
Dec 8, 2020

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Dec 7, 2020

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 db
  • BLOCKS_V3_MIGRATED lmdb key for this specific bool flag

BoolFlag 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 and v3 format and looking for errors during v3.
We now do a single v3 read and only on failure do we perform the additional v2 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 -

20201207 20:56:44.437 DEBUG grin_chain::chain - migrate_db_v2_v3: previously migrated, skipping

@antiochp antiochp added this to the 5.0.0 milestone Dec 7, 2020
@antiochp antiochp merged commit eaf9bcf into mimblewimble:master Dec 8, 2020
@antiochp antiochp deleted the block_migration_flag branch December 8, 2020 09:37
@antiochp antiochp mentioned this pull request May 6, 2021
bayk added a commit to mwcproject/mwc-node that referenced this pull request Jun 11, 2024
…imble#3512)

* rework migrate_db_v2_v3
* db flag to track block migration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block migration check during node init unacceptably slow for full archive node
2 participants