-
Notifications
You must be signed in to change notification settings - Fork 205
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
v4/upgrade handler #384
v4/upgrade handler #384
Changes from all commits
c901393
ed71c64
af9e33e
ce2d6d1
8faf91f
4427192
a72d895
0a0139a
cbdf352
30c0d49
add4c43
3c92b35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v3_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/Stride-Labs/stride/v3/app/apptesting" | ||
) | ||
var ( | ||
airdropIdentifiers = []string{"stride", "gaia", "osmosis", "juno", "stars"} | ||
) | ||
const dummyUpgradeHeight = 5 | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.AppTestHelper | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
s.Setup() | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
testCases := []struct { | ||
msg string | ||
preUpdate func() | ||
update func() | ||
postUpdate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"Test that upgrade does not panic", | ||
func() { | ||
suite.Setup() | ||
}, | ||
func() { | ||
suite.ConfirmUpgradeSucceededs("v3", dummyUpgradeHeight) | ||
|
||
// make sure claim record was set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way to verify authz was properly initialized here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to export module genesis then compare it with defaultGenState. Believe we do not modify the init state There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is what my new computer is for.... I'm going to export-upgrade -- and offer that to every chain that Notional validates before upgrades via ci. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notional consistently proving your value |
||
afterCtx := suite.Ctx().WithBlockHeight(dummyUpgradeHeight) | ||
for _, identifier := range(airdropIdentifiers) { | ||
claimRecords := suite.App.ClaimKeeper.GetClaimRecords(afterCtx, identifier) | ||
suite.Require().NotEqual(0, len(claimRecords)) | ||
} | ||
}, | ||
func() { | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
tc.preUpdate() | ||
tc.update() | ||
tc.postUpdate() | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Upgrade v4 Changelog | ||
|
||
1. Add authz storeKey to StoreLoader | ||
2. Add authz & claim modules to params subspaces | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v4 | ||
|
||
import ( | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// Note: ensure these values are properly set before running upgrade | ||
var ( | ||
UpgradeName = "v4" | ||
) | ||
|
||
// CreateUpgradeHandler creates an SDK upgrade handler for v3 | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
newVm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return newVm, err | ||
} | ||
return newVm, nil | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package v4_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/Stride-Labs/stride/v3/app/apptesting" | ||
authz "github.com/cosmos/cosmos-sdk/x/authz" | ||
) | ||
|
||
const dummyUpgradeHeight = 5 | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.AppTestHelper | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
s.Setup() | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
testCases := []struct { | ||
msg string | ||
preUpdate func() | ||
update func() | ||
postUpdate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"Test that upgrade does not panic", | ||
func() { | ||
suite.Setup() | ||
}, | ||
func() { | ||
suite.ConfirmUpgradeSucceededs("v4", dummyUpgradeHeight) | ||
|
||
// make sure authz module was init | ||
afterCtx := suite.Ctx().WithBlockHeight(dummyUpgradeHeight) | ||
actGenState := suite.App.AuthzKeeper.ExportGenesis(afterCtx) | ||
expGenState := authz.DefaultGenesisState() | ||
suite.Require().NotNil(actGenState) | ||
suite.Require().Equal(&expGenState, &actGenState) | ||
}, | ||
func() { | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
tc.preUpdate() | ||
tc.update() | ||
tc.postUpdate() | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need it to initialize params store for modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike other data, module params are stored differently. The prefixed subspace of the parameter store is manage by
params
module. Some modules need their params private for another, we can modifier itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks for the explanation!