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

Remove the controller from storage #174

Merged
merged 5 commits into from
Jul 11, 2022

Conversation

ramtinms
Copy link
Contributor

@ramtinms ramtinms commented Jun 30, 2022

Description

This PR

  • updates the emulator to be compatible with the flow-go changes (controller field of storage has been deprecated and will be removed)
  • adds a fallback method to decode the keys

For contributor use:

  • Targeted PR against master branch
  • Linked to GitHub issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the GitHub PR explorer
  • Added appropriate labels

Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

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

This looks good.

The concern i have is that anyone using persistent storage will have to start fresh, as the reads are no longer compatible.

One solution would be to fetch registers at both the old key and the new key, but we would have to keep that code in for a long time.

The other solution would be to offer some persistent storage migration tool or maybe a guide guide or just automatically migrate persistent storage at first load.

@ramtinms ramtinms changed the title [Don't Merge] remove the controller from storage Remove the controller from storage Jul 8, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #174 (7ee4147) into master (2cc6a4f) will decrease coverage by 0.13%.
The diff coverage is 55.00%.

@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
- Coverage   51.90%   51.76%   -0.14%     
==========================================
  Files          29       29              
  Lines        2335     2345      +10     
==========================================
+ Hits         1212     1214       +2     
- Misses        984      991       +7     
- Partials      139      140       +1     
Flag Coverage Δ
unittests 51.76% <55.00%> (-0.14%) ⬇️

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

Impacted Files Coverage Δ
storage/badger/keys.go 76.74% <35.71%> (-17.71%) ⬇️
storage/badger/store.go 50.00% <100.00%> (-0.14%) ⬇️
storage/memstore/memstore.go 23.07% <100.00%> (ø)
blockchain.go 75.95% <0.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cc6a4f...7ee4147. Read the comment docs.

@ramtinms ramtinms requested a review from janezpodhostnik July 8, 2022 19:31
Comment on lines +118 to +129
c := strings.Count(registerString, "-")
if c == 3 { // old format
parts := strings.SplitN(registerString, "-", 3)
if len(parts) < 3 {
return flowgo.RegisterID{}, fmt.Errorf("failed to parse register ID from %s", string(key))
}
return flowgo.RegisterID{
Owner: parts[0],
Key: parts[2], // skip the controller
}, nil
}
// else is the new format
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this backwards-compatibility. Can we just remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we don't need it initially, but Janez is right people might have use persistant storage that have these values, it seems there is no harm to keep it in case we have to load things.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

@ramtinms ramtinms merged commit 945d217 into master Jul 11, 2022
@psiemens psiemens deleted the ramtin/remove-controller-from-ledger branch July 12, 2022 22:53
@psiemens
Copy link
Contributor

@ramtinms It looks like this branch references flow-go commit 7015f054a69f that isn't on master (I think it's in this PR: onflow/flow-go#2713).

After you merge that PR, can you update the emulator to import from flow-go@master? We're running into downstream co-dependency issues because commit 7015f054a69f doesn't have some of the changes needed from master.

In the future, please avoid merging an emulator PR the depends on unmerged code in flow-go 🙏

@ramtinms
Copy link
Contributor Author

@psiemens good point, going to update this as soon as the other PR is merged, I also going to create an issue so we could remove the dependency of flow-go to flow-emulator, that seems not natural.

@ramtinms
Copy link
Contributor Author

updated here #177

@ramtinms ramtinms mentioned this pull request Jul 16, 2022
6 tasks
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.

5 participants