Skip to content

Commit

Permalink
v4 upgrade (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Co-authored-by: sampocs <sam.pochyly@gmail.com>
Co-authored-by: khanh-notional <50263489+catShaark@users.noreply.github.com>
Co-authored-by: sampocs <sam@stridelabs.co>
  • Loading branch information
6 people authored Dec 3, 2022
1 parent 0b07a6b commit 928618b
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
timeout: 5m
timeout: 10m
disable-all: true
enable:
- asasalint
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ 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
1. Dependency bumps ([384178b2c](https://github.com/Stride-Labs/stride/commit/384178b2cf98e9af0815ffaf3c29649f41784f3e)), ([0a2297ea](https://github.com/Stride-Labs/stride/commit/0a2297eabe287d38723ab8213d5256ce34d2bb2d))
2. Add max claimable tokens query ([613e8571](https://github.com/Stride-Labs/stride/commit/613e85711485d3bebeeb5777ba35e701cc795a43))
3. Interchain query proto cleanup ([9d5e1f6d](https://github.com/Stride-Labs/stride/commit/9d5e1f6d9e24113afa5b7f21e72a736bc8059b7f))
4. Add undelegation logging ([e74c34d12](https://github.com/Stride-Labs/stride/commit/e74c34d12a462e2d23463d717abfe01db9490d8f))
5. v4 upgrade changes
6. Revert HostZoneUnbonding status upon channel restoration ([730cf3d38](https://github.com/Stride-Labs/stride/commit/730cf3d38589887b57dfe3dd5de071273d5a9b73))

### Off-Chain changes

These changes do not affect any on-chain functionality, but have been implemented since `v4.0.0`.
1. Update Go Relayer to use Stride v3 ([faf3e7b2](https://github.com/Stride-Labs/stride/commit/faf3e7b21f4213b64a61bc2de5b400964cb61963))
2. Generalized Integration Tests ([80e8e2a4](https://github.com/Stride-Labs/stride/commit/80e8e2a49c3d63d8deabf4235e8e00151fcd8747))
3. Add localstride ([46a54f6c2](https://github.com/Stride-Labs/stride/commit/80e8e2a49c3d63d8deabf4235e8e00151fcd8747))
## [v3.0.0](https://github.com/Stride-Labs/stride/releases/tag/v3.0.0) - 2022-11-18
### On-Chain changes

Expand Down
3 changes: 2 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,7 @@ 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)
return paramsKeeper
}

Expand Down
19 changes: 19 additions & 0 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"strings"

ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
abci "github.com/tendermint/tendermint/abci/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 @@ -297,3 +299,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)

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

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

v2 "github.com/Stride-Labs/stride/v4/app/upgrades/v2"
v3 "github.com/Stride-Labs/stride/v4/app/upgrades/v3"
v4 "github.com/Stride-Labs/stride/v4/app/upgrades/v4"
claimtypes "github.com/Stride-Labs/stride/v4/x/claim/types"
)

Expand All @@ -24,6 +25,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 @@ -36,7 +43,6 @@ func (app *StrideApp) setupUpgradeHandlers() {
var storeUpgrades *storetypes.StoreUpgrades

switch upgradeInfo.Name {
// no store upgrades
case "v3":
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{claimtypes.StoreKey},
Expand Down
9 changes: 9 additions & 0 deletions app/upgrades/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ func (app *StrideApp) setupUpgradeHandlers() {
panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err))
}
...

// If adding a new module, add the new store keys
switch upgradeInfo.Name {
...
case {upgradeVersion}:
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{newmoduletypes.StoreKey},
}
}
```
# Migrations (Only required if the state changed)
Expand Down
66 changes: 66 additions & 0 deletions app/upgrades/v3/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package v3_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

"github.com/Stride-Labs/stride/v4/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()
})
}
}
8 changes: 8 additions & 0 deletions app/upgrades/v4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Upgrade v4 Changelog

1. Dependency bumps ([384178b2c](https://github.com/Stride-Labs/stride/commit/384178b2cf98e9af0815ffaf3c29649f41784f3e)), ([0a2297ea](https://github.com/Stride-Labs/stride/commit/0a2297eabe287d38723ab8213d5256ce34d2bb2d))
2. Add max claimable tokens query ([613e8571](https://github.com/Stride-Labs/stride/commit/613e85711485d3bebeeb5777ba35e701cc795a43))
3. Interchain query proto cleanup ([9d5e1f6d](https://github.com/Stride-Labs/stride/commit/9d5e1f6d9e24113afa5b7f21e72a736bc8059b7f))
4. Add undelegation logging ([e74c34d12](https://github.com/Stride-Labs/stride/commit/e74c34d12a462e2d23463d717abfe01db9490d8f))
5. v4 upgrade changes
6. Revert HostZoneUnbonding status upon channel restoration ([730cf3d38](https://github.com/Stride-Labs/stride/commit/730cf3d38589887b57dfe3dd5de071273d5a9b73))
22 changes: 22 additions & 0 deletions app/upgrades/v4/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 v4
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
55 changes: 55 additions & 0 deletions app/upgrades/v4/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package v4_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

"github.com/Stride-Labs/stride/v4/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)
},
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
1 change: 1 addition & 0 deletions dockernet/src/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ for (( i=1; i <= $NUM_NODES; i++ )); do
sed -i -E "s|minimum-gas-prices = \".*\"|minimum-gas-prices = \"0${DENOM}\"|g" $app_toml
sed -i -E '/\[api\]/,/^enable = .*$/ s/^enable = .*$/enable = true/' $app_toml
sed -i -E 's|unsafe-cors = .*|unsafe-cors = true|g' $app_toml
sed -i -E "s|snapshot-interval = 0|snapshot-interval = 100|g" $app_toml

sed -i -E "s|chain-id = \"\"|chain-id = \"${CHAIN_ID}\"|g" $client_toml
sed -i -E "s|keyring-backend = \"os\"|keyring-backend = \"test\"|g" $client_toml
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ require (
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
github.com/zondax/ledger-go v0.12.2 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,10 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/ledger-go v0.12.2 h1:HnuUEKylJ6GqNrLMwghCTHRRAsnr8NlriawMVaFZ7w0=
github.com/zondax/ledger-go v0.12.2/go.mod h1:KatxXrVDzgWwbssUWsF5+cOJHXPvzQ09YSlzGNuhOEo=
github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo=
github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/ledger-go v0.14.0 h1:dlMC7aO8Wss1CxBq2I96kZ69Nh1ligzbs8UWOtq/AsA=
github.com/zondax/ledger-go v0.14.0/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
Expand Down

0 comments on commit 928618b

Please sign in to comment.