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

v4 upgrade #393

Merged
merged 34 commits into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7c9a5bf
Hieu/upgrade handler (#392)
asalzmann Nov 25, 2022
b52ac1a
Merge branch 'main' into v4
asalzmann Nov 26, 2022
917b9ec
Merge branch 'main' into v4
faddat Nov 27, 2022
a547c6a
V4 updated (#399)
asalzmann Nov 27, 2022
77379a9
v4.0.0 and changelog
asalzmann Nov 27, 2022
1d435b4
Merge branch 'v4' of github.com:Stride-Labs/stride into v4
asalzmann Nov 27, 2022
eca40f4
added store key instructions to readme
sampocs Nov 27, 2022
1d328c1
Merge branch 'main' into v4
faddat Nov 28, 2022
d676275
fix linter
faddat Nov 28, 2022
7790f15
fix nits
faddat Nov 28, 2022
5a6f5ff
increase timeout for golangci-lint
faddat Nov 28, 2022
1c62630
changed snapshot-interval in dockernet to detect pruning issues
sampocs Nov 28, 2022
0bd774a
fixed typo in test scripts
sampocs Nov 28, 2022
56b41e6
v3 -> v4
asalzmann Nov 29, 2022
4b89d37
v3 -> v4
asalzmann Nov 29, 2022
c0937f3
bump ledger
asalzmann Nov 29, 2022
2b5b737
go mod tidy
asalzmann Nov 29, 2022
f0fd738
changelog
asalzmann Nov 29, 2022
b3d18cf
use custom storeloader to adjust authz store height (#405)
catShaark Nov 29, 2022
d95face
fixed typo in upgrade handler docstring
sampocs Nov 29, 2022
9d5935c
added return nil to custom authz store loader
sampocs Nov 29, 2022
cc899e1
Revert "v3 -> v4"
sampocs Nov 29, 2022
1a5de7d
Revert "v3 -> v4"
sampocs Nov 29, 2022
b0ddeb1
go mod tidy
sampocs Nov 29, 2022
d9a2054
Merge branch 'main' into v4
faddat Dec 2, 2022
77ccbcc
Merge branch 'main' into v4
sampocs Dec 3, 2022
5a990e1
removed authz store removal from upgrade
sampocs Dec 3, 2022
1d2b8f3
Update CHANGELOG.md
sampocs Dec 3, 2022
a291585
fixed upgrade unit tests
sampocs Dec 3, 2022
4735226
Merge branch 'v4' of github.com:Stride-Labs/stride into v4
sampocs Dec 3, 2022
76c5ebf
removed authz from params init
sampocs Dec 3, 2022
30cf02d
updated v4 changelog in upgrades directory
sampocs Dec 3, 2022
32b585d
revert store loader in upgrades
sampocs Dec 3, 2022
6160c14
trimmed upgrade handler
sampocs Dec 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v4.0.0](https://github.com/Stride-Labs/stride/releases/tag/v4.0.0) - 2022-11-27
### On-Chain changes



### Off-Chain changes

These changes do not affect any on-chain functionality, but have been implemented since `v4.0.0`.



## [v3.0.0](https://github.com/Stride-Labs/stride/releases/tag/v3.0.0) - 2022-11-18
### On-Chain changes

Expand Down
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ import (
const (
AccountAddressPrefix = "stride"
Name = "stride"
Version = "3.0.0"
Version = "4.0.0"
)

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down Expand Up @@ -1002,6 +1002,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icacallbacksmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

paramsKeeper.Subspace(claimtypes.ModuleName)
paramsKeeper.Subspace(authz.ModuleName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's leave this out of this upgrade

return paramsKeeper
}

Expand Down
22 changes: 22 additions & 0 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package apptesting

import (
"strings"
"time"

abci "github.com/tendermint/tendermint/abci/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
Expand Down Expand Up @@ -36,6 +39,7 @@ var (
type AppTestHelper struct {
suite.Suite

Context sdk.Context
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: rm

App *app.StrideApp
HostApp *simapp.SimApp

Expand All @@ -57,6 +61,7 @@ func (s *AppTestHelper) Setup() {
GRPCQueryRouter: s.App.GRPCQueryRouter(),
Ctx: s.Ctx(),
}
s.Context = s.App.BaseApp.NewContext(false, tmtypes.Header{Height: 1, ChainID: StrideChainID, Time: time.Now().UTC()})
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: rm

s.TestAccs = CreateRandomAccounts(3)
s.IbcEnabled = false
s.IcaAddresses = make(map[string]string)
Expand Down Expand Up @@ -311,3 +316,20 @@ func (s *AppTestHelper) ICS20PacketAcknowledgement() channeltypes.Acknowledgemen
ack := channeltypes.NewResultAcknowledgement(s.MarshalledICS20PacketData())
return ack
}

func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeight int64) {
contextBeforeUpgrade := s.Ctx().WithBlockHeight(upgradeHeight - 1)
contextAtUpgrade := s.Ctx().WithBlockHeight(upgradeHeight)

plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight}
err := s.App.UpgradeKeeper.ScheduleUpgrade(contextBeforeUpgrade, plan)
s.Require().NoError(err)

plan, exists := s.App.UpgradeKeeper.GetUpgradePlan(contextBeforeUpgrade)
s.Require().True(exists)

s.Require().NotPanics(func() {
beginBlockRequest := abci.RequestBeginBlock{}
s.App.BeginBlocker(contextAtUpgrade, beginBlockRequest)
})
}
12 changes: 12 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (

v2 "github.com/Stride-Labs/stride/v3/app/upgrades/v2"
v3 "github.com/Stride-Labs/stride/v3/app/upgrades/v3"
v4 "github.com/Stride-Labs/stride/v3/app/upgrades/v4"
claimtypes "github.com/Stride-Labs/stride/v3/x/claim/types"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
)

func (app *StrideApp) setupUpgradeHandlers() {
Expand All @@ -24,6 +26,12 @@ func (app *StrideApp) setupUpgradeHandlers() {
v3.CreateUpgradeHandler(app.mm, app.configurator, app.ClaimKeeper),
)

// v4 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v4.UpgradeName,
v4.CreateUpgradeHandler(app.mm, app.configurator),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err))
Expand All @@ -41,6 +49,10 @@ func (app *StrideApp) setupUpgradeHandlers() {
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{claimtypes.StoreKey},
}
case "v4":
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{authzkeeper.StoreKey},
}
}

if storeUpgrades != nil {
Expand Down
64 changes: 64 additions & 0 deletions app/upgrades/v3/upgrades_test.go
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
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()
})
}
}
6 changes: 6 additions & 0 deletions app/upgrades/v4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Upgrade v4 Changelog
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rm this file

Copy link
Collaborator

@sampocs sampocs Dec 3, 2022

Choose a reason for hiding this comment

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

chatted offline, leaving this in


1. Add authz storeKey to StoreLoader
2. Add authz & claim modules to params subspaces


27 changes: 27 additions & 0 deletions app/upgrades/v4/upgrades.go
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
}
}
64 changes: 64 additions & 0 deletions app/upgrades/v4/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package v4_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

authz "github.com/cosmos/cosmos-sdk/x/authz"

"github.com/Stride-Labs/stride/v3/app/apptesting"
)

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()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rm

Copy link
Collaborator

Choose a reason for hiding this comment

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

done

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()
})
}
}
2 changes: 1 addition & 1 deletion cmd/strided/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func SetupConfig() {

version.AppName = "stride"
version.Name = "strided"
version.Version = "v3.0.0"
version.Version = "v4.0.0"
}

// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
Expand Down