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

Make module.Manager.RunMigrations handle new modules correctly #8988

Merged
merged 4 commits into from
Mar 25, 2021

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Mar 25, 2021

Came across this when looking at the migrations code.

Also I noticed there are actually no tests for RunMigrations. Should we add them @AmauryM ?


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@orijbot
Copy link

orijbot commented Mar 25, 2021

@orijbot
Copy link

orijbot commented Mar 25, 2021

@codecov
Copy link

codecov bot commented Mar 25, 2021

Codecov Report

Merging #8988 (fac9078) into master (8ee9da7) will increase coverage by 0.02%.
The diff coverage is 61.66%.

❗ Current head fac9078 differs from pull request most recent head 631e807. Consider uploading reports for the commit 631e807 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8988      +/-   ##
==========================================
+ Coverage   58.88%   58.90%   +0.02%     
==========================================
  Files         571      571              
  Lines       32120    32115       -5     
==========================================
+ Hits        18914    18918       +4     
+ Misses      10984    10978       -6     
+ Partials     2222     2219       -3     
Impacted Files Coverage Δ
simapp/simd/cmd/root.go 61.47% <ø> (-0.32%) ⬇️
types/module/module.go 73.62% <0.00%> (-2.51%) ⬇️
x/auth/client/tx.go 39.28% <ø> (ø)
x/auth/tx/builder.go 74.24% <ø> (ø)
client/tx/tx.go 29.62% <43.75%> (+0.53%) ⬆️
x/auth/tx/service.go 73.61% <66.66%> (+0.75%) ⬆️
x/bank/keeper/keeper.go 76.71% <85.18%> (+3.52%) ⬆️
x/bank/keeper/genesis.go 78.94% <100.00%> (ø)

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Yes, good catch.

We have one small test for RunMigrations here, do you have ideas for better tests?

I'm running today some manual tests using gaia, will try to find a way to incorporate them in the SDK somehow (maybe inside cosmovisor?)

@orijbot
Copy link

orijbot commented Mar 25, 2021

@orijbot
Copy link

orijbot commented Mar 25, 2021


// only run migrations when the from version is > 0
// from version will be 0 when a new module is added and migrations shouldn't be run in this case
if fromVersion > 0 {
Copy link
Contributor

@amaury1093 amaury1093 Mar 25, 2021

Choose a reason for hiding this comment

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

I'm thinking about the hub right now. It has fromVersion == 0 for all modules.

I agree with skipping & calling InitGenesis #8989 (with an empty genesis) for new modules with fromVersion == 0. However, for the hub with pre-existing modules with fromversion == 0, we should do something too.

The easiest way I can think of is add a hardcoded map of old module versions inside the hub's UpgradeHandler, something like this

Copy link
Member Author

@aaronc aaronc Mar 25, 2021

Choose a reason for hiding this comment

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

Yep I see no other choice if this is the first upgrade. We need to make sure this is well documented.

@aaronc
Copy link
Member Author

aaronc commented Mar 25, 2021

We have one small test for RunMigrations here, do you have ideas for better tests?

That's fine. It would be nice to have a case for new module.

I'm running today some manual tests using gaia, will try to find a way to incorporate them in the SDK somehow (maybe inside cosmovisor?)

Sure, if you can figure out how to do that!

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@aaronc aaronc added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 25, 2021
@mergify mergify bot merged commit 697d8d5 into master Mar 25, 2021
@mergify mergify bot deleted the aaronc/fix-migrations-from-zero branch March 25, 2021 19:51
@orijbot
Copy link

orijbot commented Mar 25, 2021

@orijbot
Copy link

orijbot commented Mar 25, 2021

@orijbot
Copy link

orijbot commented Mar 26, 2021

@orijbot
Copy link

orijbot commented Mar 26, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants