diff --git a/.golangci.yml b/.golangci.yml index 856aa6a317..e450610dc6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - timeout: 5m + timeout: 10m disable-all: true enable: - asasalint diff --git a/CHANGELOG.md b/CHANGELOG.md index 2429fb4ddc..af23a5a03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/app.go b/app/app.go index 94b2051b08..2027efd15e 100644 --- a/app/app.go +++ b/app/app.go @@ -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 @@ -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 } diff --git a/app/apptesting/test_helpers.go b/app/apptesting/test_helpers.go index 4c29f02744..f34c6ac090 100644 --- a/app/apptesting/test_helpers.go +++ b/app/apptesting/test_helpers.go @@ -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" @@ -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) + }) +} diff --git a/app/upgrades.go b/app/upgrades.go index 7d174a7818..31281a6d45 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -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" ) @@ -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)) @@ -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}, diff --git a/app/upgrades/README.md b/app/upgrades/README.md index 500342a5bf..2fd181429a 100644 --- a/app/upgrades/README.md +++ b/app/upgrades/README.md @@ -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) diff --git a/app/upgrades/v3/upgrades_test.go b/app/upgrades/v3/upgrades_test.go new file mode 100644 index 0000000000..b662896f27 --- /dev/null +++ b/app/upgrades/v3/upgrades_test.go @@ -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() + }) + } +} diff --git a/app/upgrades/v4/README.md b/app/upgrades/v4/README.md new file mode 100644 index 0000000000..0f3fd4a1b3 --- /dev/null +++ b/app/upgrades/v4/README.md @@ -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)) \ No newline at end of file diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go new file mode 100644 index 0000000000..7ef9bc46f5 --- /dev/null +++ b/app/upgrades/v4/upgrades.go @@ -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) + } +} diff --git a/app/upgrades/v4/upgrades_test.go b/app/upgrades/v4/upgrades_test.go new file mode 100644 index 0000000000..2daa8d5350 --- /dev/null +++ b/app/upgrades/v4/upgrades_test.go @@ -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() + }) + } +} diff --git a/cmd/strided/config/config.go b/cmd/strided/config/config.go index e10f06ec97..e249bfb011 100644 --- a/cmd/strided/config/config.go +++ b/cmd/strided/config/config.go @@ -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. diff --git a/dockernet/src/init_chain.sh b/dockernet/src/init_chain.sh index a2b5d36a6e..94255f8dcd 100644 --- a/dockernet/src/init_chain.sh +++ b/dockernet/src/init_chain.sh @@ -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 diff --git a/go.mod b/go.mod index 4302cf4381..ac0fbd146f 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 376eaa3e13..78c46cf080 100644 --- a/go.sum +++ b/go.sum @@ -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=