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

Regen network/skip upgrade #5367

Merged
merged 61 commits into from
Jan 3, 2020

Conversation

anilcse
Copy link
Collaborator

@anilcse anilcse commented Dec 5, 2019

Closes: regen-network#5

Description


For contributor use:

  • 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

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

server/start.go Outdated Show resolved Hide resolved
x/upgrade/abci.go Outdated Show resolved Hide resolved
x/upgrade/abci.go Outdated Show resolved Hide resolved
x/upgrade/abci_test.go Outdated Show resolved Hide resolved
x/upgrade/internal/keeper/utils.go Outdated Show resolved Hide resolved
x/upgrade/internal/types/proposal.go Outdated Show resolved Hide resolved
x/upgrade/module.go Outdated Show resolved Hide resolved
server/start.go Outdated Show resolved Hide resolved
x/upgrade/abci.go Outdated Show resolved Hide resolved
x/upgrade/abci.go Show resolved Hide resolved
x/upgrade/abci_test.go Outdated Show resolved Hide resolved
server/start.go Outdated Show resolved Hide resolved
x/upgrade/internal/keeper/keeper.go Show resolved Hide resolved
x/upgrade/module.go Outdated Show resolved Hide resolved
@sahith-narahari
Copy link
Contributor

Made requested changes except workaround on viper, will update once I change how the array of heights is being read

@anilcse
Copy link
Collaborator Author

anilcse commented Dec 21, 2019

@alexanderbez @fedekunze all the changes are updated. It's ready for review.

x/upgrade/abci_test.go Outdated Show resolved Hide resolved
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.

Looking good @anilcse -- left a few more comments 👍


Question: skipUpgradeHeights are provided to the module from user CLI input, no? This array/map dictates the control flow of BeginBlock (in that it clears the plan). What if different nodes set (or dont set at all) different values of skipUpgradeHeights? Is this OK?

x/upgrade/alias.go Outdated Show resolved Hide resolved
x/upgrade/internal/keeper/keeper.go Show resolved Hide resolved
x/upgrade/internal/keeper/keeper.go Outdated Show resolved Hide resolved
x/upgrade/internal/types/utils.go Outdated Show resolved Hide resolved
x/upgrade/abci.go Show resolved Hide resolved
@@ -131,7 +131,7 @@ type SimApp struct {

// NewSimApp returns a reference to an initialized SimApp.
func NewSimApp(
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH, I'm not totally thrilled about updating the app's constructor this way simply to proxy the argument to the upgrade module's constructor. But I cannot think of a cleaner way of doing it :-/

Thoughts @aaronc @ethanfrey?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking, but I think we can think of cleaner way by passing in keeper "option" functions similar to the way we handle baseapp. However, this requires more plumbing and most notably requires the semantics of keepers to chance by operating on references and not copies.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like your approach @alexanderbez

x/upgrade/abci.go Outdated Show resolved Hide resolved
@anilcse
Copy link
Collaborator Author

anilcse commented Dec 25, 2019

@alexanderbez thanks for the quick review. Updated all the suggestions.

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.

ACK -- left two more (non-blocking) comments. Thanks @anilcse 🎉

@fedekunze please re-review at your earliest convenience.

Name: test
Height: 100
Info: `, upgrade.Plan{Name: "test", Height: 100}.String())
}

func TestTestSuite(t *testing.T) {
suite.Run(t, new(TestSuite))
func VerifyNotDone(t *testing.T, newCtx sdk.Context, name string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit/non-blocking: the structure & style of tests and comments can definitely be cleaned up. e.g.

  • space between // and start comment
  • avoid punctuation unless it's a sentence
  • avoid group var statements when you assign values
  • remove commented-out code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noted. We'll ensure these things are taken care from next time. Any specific reason to avoid group var statements?

Copy link
Contributor

Choose a reason for hiding this comment

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

var (
  foo int64 = 4
  bar bool = true
)

Instead,

foo := 4 // or foo := int64(4)
bar := true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I understand. Just wanted to know if there's any specific reason to avoid group declarations. I think having group declartion for this particular scenario is needed as it is making more readable. It is creating a bit of inconsistency in the code, too. We can take a call.

@@ -131,7 +131,7 @@ type SimApp struct {

// NewSimApp returns a reference to an initialized SimApp.
func NewSimApp(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking, but I think we can think of cleaner way by passing in keeper "option" functions similar to the way we handle baseapp. However, this requires more plumbing and most notably requires the semantics of keepers to chance by operating on references and not copies.

x/upgrade/abci.go Outdated Show resolved Hide resolved
@@ -131,7 +131,7 @@ type SimApp struct {

// NewSimApp returns a reference to an initialized SimApp.
func NewSimApp(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like your approach @alexanderbez

module module.AppModule
keeper upgrade.Keeper
querier sdk.Querier
handler gov.Handler
ctx sdk.Context
}

func (s *TestSuite) SetupTest() {
Copy link
Collaborator

@fedekunze fedekunze Dec 30, 2019

Choose a reason for hiding this comment

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

why did this change? It was cleaner before imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We were using viper previously and after your review we understood viper should be sticked to cli and it should not be used inside keeper. The change in code needed a way to set different skipUpgradeHeights everytime, so we had to replace the Suite with this setupTest to expect skipUpgradeHeights as a param

x/upgrade/internal/keeper/keeper.go Outdated Show resolved Hide resolved
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.

utACK

@codecov
Copy link

codecov bot commented Jan 2, 2020

Codecov Report

Merging #5367 into master will increase coverage by 0.13%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5367      +/-   ##
==========================================
+ Coverage   54.38%   54.52%   +0.13%     
==========================================
  Files         313      318       +5     
  Lines       18836    19137     +301     
==========================================
+ Hits        10244    10434     +190     
- Misses       7807     7917     +110     
- Partials      785      786       +1
Impacted Files Coverage Δ
simapp/test_helpers.go 0% <0%> (ø) ⬆️
x/upgrade/abci.go 100% <100%> (ø) ⬆️
simapp/app.go 89.63% <100%> (+0.12%) ⬆️
x/upgrade/handler.go 80% <0%> (-5.72%) ⬇️
x/params/proposal_handler.go 73.68% <0%> (-4.1%) ⬇️
x/mock/test_utils.go 60% <0%> (-3.05%) ⬇️
x/auth/types/stdtx.go 58.67% <0%> (-2.87%) ⬇️
types/errors/errors.go 67.16% <0%> (-1.59%) ⬇️
x/mock/app.go 62.83% <0%> (-1.36%) ⬇️
x/bank/internal/keeper/keeper.go 67.85% <0%> (-0.82%) ⬇️
... and 59 more

@alexanderbez alexanderbez merged commit a5fc7d6 into cosmos:master Jan 3, 2020
@ryanchristo ryanchristo deleted the regen-network/skip-upgrade branch December 12, 2022 18:14
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --unsafe-skip-upgrade CLI flag
7 participants