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

[BFT] Database migration for flow.DKGEndState #6861

Open
wants to merge 10 commits into
base: feature/efm-recovery
Choose a base branch
from

Conversation

durkmurder
Copy link
Member

#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

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 69.76744% with 13 lines in your changes missing coverage. Please review.

Project coverage is 41.73%. Comparing base (3cfafb6) to head (0f7adab).

Files with missing lines Patch % Lines
cmd/consensus/main.go 0.00% 7 Missing ⚠️
storage/badger/operation/dkg.go 83.33% 4 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
unittests 41.73% <69.76%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jordanschalm jordanschalm left a 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.

storage/badger/operation/dkg.go Outdated Show resolved Hide resolved
// 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 {
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@AlexHentschel AlexHentschel left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return err
return fmt.Errorf("aborting conversion from DKG end states: %w", err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants