-
Notifications
You must be signed in to change notification settings - Fork 180
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
[BFT] Database migration for flow.DKGEndState
#6861
base: feature/efm-recovery
Are you sure you want to change the base?
[BFT] Database migration for flow.DKGEndState
#6861
Conversation
…l state. Added implementation for DKG end state migration between v1 and v2
… protocol state. Added implementation for DKG end state migration between v1 and v2" This reverts commit 4f59be0.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/efm-recovery #6861 +/- ##
========================================================
+ Coverage 41.72% 41.73% +0.01%
========================================================
Files 2033 2033
Lines 181418 181461 +43
========================================================
+ Hits 75690 75740 +50
+ Misses 99495 99487 -8
- Partials 6233 6234 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - I'd like to add a test for the migration before merging, though.
// It reads already stored data by deprecated prefix and writes it to the new prefix with values converted to the new representation. | ||
// TODO(EFM, #6794): This function is introduced to implement a backward-compatible upgrade from v1 to v2. | ||
// Remove this once we complete the network upgrade. | ||
func MigrateDKGEndStateFromV1() func(txn *badger.Txn) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some tests for this function? I think we should test the following:
- migrate each of the possible v1 end states
- should migrate correctly and delete v1 prefix
- migrate a database where no v1 prefixes are defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…kward-compatibility
Co-authored-by: Jordan Schalm <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 👏
|
||
for _, op := range ops { | ||
if err := op(txn); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err | |
return fmt.Errorf("aborting conversion from DKG end states: %w", err) |
#6786
Context
This PR implements a database migration for
flow.DKGEndState
(enum that was used in protocol version v1). It is implemented by reading values under the old key(which is now deprecated), converting them to correct values and writing them back under the new key. The database migration is scheduled to happen at first launch of the consensus node. Since old keys are removed after the migration, all next runs will be no-op.In next release this logic can be removed as part of #6772