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

Allow substore migrations upon multistore loading #4724

Merged

Conversation

ethanfrey
Copy link
Contributor

@ethanfrey ethanfrey commented Jul 15, 2019

This is needed for the regen upgrade module (#4233), as there are cases (eg. 0.34 -> 0.36) where a substore is renamed (distr -> distribution). The current master panics when trying to read the store with an unknown key. This no longer panics, and allows the user to pass in a set of rename steps to actually rename the store upon loading (so other data migration steps of individual items can function)

Provides a few different store loaders for testing and demonstration purposes. This actual functionality probably doesn't make too much sense to an end-user until #4233 is merged, but it may be needed in cases where one does want to rename stores before doing some debugging.

  • 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.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [stanza] [message]

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

store/rootmulti/store.go Outdated Show resolved Hide resolved
store/rootmulti/store.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 15, 2019

Codecov Report

Merging #4724 into master will decrease coverage by 0.05%.
The diff coverage is 54.44%.

@@            Coverage Diff             @@
##           master    #4724      +/-   ##
==========================================
- Coverage   54.12%   54.06%   -0.06%     
==========================================
  Files         272      272              
  Lines       17358    17425      +67     
==========================================
+ Hits         9395     9421      +26     
- Misses       7280     7319      +39     
- Partials      683      685       +2

@codecov
Copy link

codecov bot commented Jul 15, 2019

Codecov Report

Merging #4724 into master will increase coverage by 0.07%.
The diff coverage is 73.83%.

@@            Coverage Diff             @@
##           master    #4724      +/-   ##
==========================================
+ Coverage   54.18%   54.25%   +0.07%     
==========================================
  Files         269      269              
  Lines       17225    17302      +77     
==========================================
+ Hits         9334     9388      +54     
- Misses       7201     7216      +15     
- Partials      690      698       +8

@aaronc aaronc mentioned this pull request Jul 16, 2019
5 tasks
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

Blocking on additional unit testing to avoid coverage falling even further below what is generally acceptable. Else ACK on both functionality design and implementation.

store/types/store.go Show resolved Hide resolved
@ethanfrey
Copy link
Contributor Author

ethanfrey commented Jul 17, 2019

Thanks for the feedback @alessio I also see some code written in baseapp, but only tested in simapp. I can add some smaller tests for that.

Is there an easy way to see what code is not covered, so I can add targeted tests?

Click on the details link of codecov/patch which is my expected approach, doesn't give any info.

(Maybe this happens as the code is in a fork?)

@alessio
Copy link
Contributor

alessio commented Jul 17, 2019

(Maybe this happens as the code is in a fork?)

Yes, I think that that's the reason. I'd suggest to go with go test -cover - I usually leverage VSCode/Goland integration for more convenient visualization

@ethanfrey
Copy link
Contributor Author

Added lots more tests, let me know.

@ethanfrey
Copy link
Contributor Author

ethanfrey commented Jul 17, 2019

And good tip to use built-in vscode test coverage. What I wrote seems all green, except for many error return lines, like:

		if err != nil {
			return fmt.Errorf("Cannot read upgrade file %s: %v", upgradeInfoPath, err)
		}

This seems to be the case with the existing code base (and most go projects as well). It should be fine for now, but I'd be curious for a longer-term approach to ensure good error handling.

@fedekunze
Copy link
Collaborator

@ethanfrey is this still WIP?

@fedekunze fedekunze added the WIP label Jul 18, 2019
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looks great @ethanfrey. Left a few points of feedback :)

baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Show resolved Hide resolved
store/rootmulti/store.go Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Show resolved Hide resolved
Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

ACK pending Bez comments addressed

baseapp/baseapp.go Show resolved Hide resolved
baseapp/baseapp.go Show resolved Hide resolved
@ethanfrey
Copy link
Contributor Author

Thanks for the reviews, I will make requested changes.

Open question about delete behavior (I will update godoc in any case), especially as the function is meant for the opinionated upgrade module.

@ethanfrey ethanfrey force-pushed the regen-network/multistore-migrations branch from b892355 to 34996b2 Compare July 29, 2019 11:22
@ethanfrey
Copy link
Contributor Author

@fedekunze You can remove the WIP label. All code comments have been resolved (I think).

baseapp/baseapp.go Outdated Show resolved Hide resolved
@ethanfrey
Copy link
Contributor Author

I think this is ready now, and I just polished it.
If there are any docs (besides godoc) that I should update, please let me know.

@fedekunze fedekunze added R4R and removed WIP labels Jul 29, 2019
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM

.pending/features/store/4724-Multistore-supp Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
server/mock/store.go Show resolved Hide resolved
store/types/store.go Outdated Show resolved Hide resolved
store/types/store.go Outdated Show resolved Hide resolved
@ethanfrey ethanfrey force-pushed the regen-network/multistore-migrations branch from 9fb342f to 1c2f472 Compare August 6, 2019 08:52
@ethanfrey
Copy link
Contributor Author

Okay @alexanderbez I made the requested changes and rebased on the current master.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

utACK ⚡️

@alexanderbez alexanderbez merged commit 1f8cdee into cosmos:master Aug 6, 2019
hyperspeednetwork added a commit to hyperspeednetwork/cosmos-sdk that referenced this pull request Aug 6, 2019
Merge PR cosmos#4724: Allow substore migrations upon multistore loading
@ryanchristo ryanchristo deleted the regen-network/multistore-migrations branch December 12, 2022 18:14
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.

6 participants