From b4320729c30594f5d7061940b5a192ca701d158c Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Thu, 8 Aug 2024 18:51:33 +0700 Subject: [PATCH] feat: update cosmos-sdk, go-ibc and v4.2.1 handler (#396) * add v4.2.1 handler * update max validator to 45 * update go to 1.22.5 * update comet * chore(dependencies): bump wasmvm from 1.5.2 to 1.5.3 --------- Co-authored-by: Sen Com --- app/app.go | 11 ++++++++++- app/upgrades/v4_2_1/constants.go | 7 +++++++ app/upgrades/v4_2_1/upgrades.go | 25 +++++++++++++++++++++++++ go.mod | 16 +++++++--------- go.sum | 18 ++++++++---------- scripts/upgrade_test.sh | 4 ++-- 6 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 app/upgrades/v4_2_1/constants.go create mode 100644 app/upgrades/v4_2_1/upgrades.go diff --git a/app/app.go b/app/app.go index 97cc6da1..6e48ecf4 100644 --- a/app/app.go +++ b/app/app.go @@ -160,6 +160,7 @@ import ( v45 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_5" v46 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_6" v420 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_0" + v421 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_2_1" "github.com/rakyll/statik/fs" // unnamed import of statik for swagger UI support @@ -1192,6 +1193,14 @@ func (app *MigalooApp) setupUpgradeHandlers() { app.configurator, ), ) + app.UpgradeKeeper.SetUpgradeHandler( + v421.UpgradeName, + v421.CreateUpgradeHandler( + app.mm, + app.StakingKeeper, + app.configurator, + ), + ) // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it @@ -1205,7 +1214,7 @@ func (app *MigalooApp) setupUpgradeHandlers() { return } - if upgradeInfo.Name == v420.UpgradeName { + if upgradeInfo.Name == v421.UpgradeName { storeUpgrades := &storetypes.StoreUpgrades{ Added: []string{}, Deleted: []string{}, diff --git a/app/upgrades/v4_2_1/constants.go b/app/upgrades/v4_2_1/constants.go new file mode 100644 index 00000000..5df08d86 --- /dev/null +++ b/app/upgrades/v4_2_1/constants.go @@ -0,0 +1,7 @@ +package v4 + +// UpgradeName defines the on-chain upgrade name for the Migaloo v4.2.1 upgrade. +// this upgrade includes the fix for pfm +const ( + UpgradeName = "v4.2.1" +) diff --git a/app/upgrades/v4_2_1/upgrades.go b/app/upgrades/v4_2_1/upgrades.go new file mode 100644 index 00000000..9eb1c6f9 --- /dev/null +++ b/app/upgrades/v4_2_1/upgrades.go @@ -0,0 +1,25 @@ +package v4 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// CreateUpgradeHandler that migrates the chain from v4.2.0 to v4.2.1 +func CreateUpgradeHandler( + mm *module.Manager, + sk *stakingKeeper.Keeper, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + stakingParams := sk.GetParams(ctx) + stakingParams.MaxValidators = 45 + err := sk.SetParams(ctx, stakingParams) + if err != nil { + panic(err) + } + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/go.mod b/go.mod index 5f3b9230..fd6b9acc 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,19 @@ module github.com/White-Whale-Defi-Platform/migaloo-chain/v4 -go 1.22.2 - -toolchain go1.22.3 +go 1.22.5 require ( cosmossdk.io/math v1.3.0 cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d cosmossdk.io/tools/rosetta v0.2.1 github.com/CosmWasm/wasmd v0.45.0 - github.com/cometbft/cometbft v0.37.8 + github.com/cometbft/cometbft v0.37.9 github.com/cometbft/cometbft-db v0.12.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.47.12 + github.com/cosmos/cosmos-sdk v0.47.13 github.com/cosmos/gogoproto v1.4.10 github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20231017170841-8fd49ec0f017 - github.com/cosmos/ibc-go/v7 v7.6.0 + github.com/cosmos/ibc-go/v7 v7.7.0 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/prometheus/client_golang v1.18.0 @@ -51,7 +49,7 @@ require ( require ( cosmossdk.io/errors v1.0.1 - github.com/CosmWasm/wasmvm v1.5.2 + github.com/CosmWasm/wasmvm v1.5.3 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1 github.com/golang/protobuf v1.5.4 @@ -146,7 +144,6 @@ require ( github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.2 // indirect github.com/lib/pq v1.10.7 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -211,6 +208,8 @@ require ( replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + + github.com/cosmos/cosmos-sdk => github.com/White-Whale-Defi-Platform/cosmos-sdk v0.47.13-trim-validator // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 @@ -225,5 +224,4 @@ replace ( golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // stick with compatible version of rapid in v0.47.x line pgregory.net/rapid => pgregory.net/rapid v0.5.5 - ) diff --git a/go.sum b/go.sum index b672ceac..4da5c05a 100644 --- a/go.sum +++ b/go.sum @@ -211,8 +211,8 @@ github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRr github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI= github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944= -github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag= -github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= +github.com/CosmWasm/wasmvm v1.5.3 h1:wcmkey/WkTGwCTHGBD+fRS3cbhhipR9q34kbCZUQSsc= +github.com/CosmWasm/wasmvm v1.5.3/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -226,6 +226,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/White-Whale-Defi-Platform/cosmos-sdk v0.47.13-trim-validator h1:MpXBQYbc2hYFq8w2f4uhSum8hnAgZkBqxW44SVuGoJ8= +github.com/White-Whale-Defi-Platform/cosmos-sdk v0.47.13-trim-validator/go.mod h1:pYMzhTfKFn9AJB5X64Epwe9NgYk0y3v7XN8Ks5xqWoo= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -324,8 +326,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1: github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.8 h1:/LLlJd+XilMSGjBGWBGQ1EvLVU//9C5SADWEwvV8cRM= -github.com/cometbft/cometbft v0.37.8/go.mod h1:gFGCFXNGDci6tMLemANPGTfU+j4+oH63PjeLe0iIjJk= +github.com/cometbft/cometbft v0.37.9 h1:zsW0wfjcnV9L+D4y3FkVQFSFPSbNWJneS9p3gCsWx8o= +github.com/cometbft/cometbft v0.37.9/go.mod h1:j0Q3RqrCd+cztWCugs3obbzC4NyHGBPZZjtm/fWV00I= github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0= github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -340,8 +342,6 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.47.12 h1:KOZHAVWrcilHywBN/FabBaXbDFMzoFmtdX0hqy5Ory8= -github.com/cosmos/cosmos-sdk v0.47.12/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -358,8 +358,8 @@ github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1 h1:02RCbih5lQ8aGdDMSvxhTn github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.1.1/go.mod h1:LvVkEXTORVgd87W2Yu7ZY3acKKeTMq/txdTworn8EZI= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20231017170841-8fd49ec0f017 h1:/m++TlQ4CfCZs+7vGFDQNdlnkvSNKFoLbjzmWOT7m10= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20231017170841-8fd49ec0f017/go.mod h1:JwHFbo1oX/ht4fPpnPvmhZr+dCkYK1Vihw+vZE9umR4= -github.com/cosmos/ibc-go/v7 v7.6.0 h1:S1G5hcIVe9go+jQV6F9+I9yy+hylbJeLiVHUmktQNrM= -github.com/cosmos/ibc-go/v7 v7.6.0/go.mod h1:LifBA7JHRHl95ujjHIaBEHmUqy2qCGyqDCXB7qmAsZk= +github.com/cosmos/ibc-go/v7 v7.7.0 h1:/ndLv4GiAkOaHQKpcoQyoGIZpGpT4d+9kjl5n3DsaVQ= +github.com/cosmos/ibc-go/v7 v7.7.0/go.mod h1:zzFhtp9g9RrN/UxXWrdUu5VyonBALCAHujXQCzrZSu8= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= @@ -743,8 +743,6 @@ github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= diff --git a/scripts/upgrade_test.sh b/scripts/upgrade_test.sh index 841c97bc..688ad962 100755 --- a/scripts/upgrade_test.sh +++ b/scripts/upgrade_test.sh @@ -3,13 +3,13 @@ # the upgrade is a fork, "true" otherwise FORK=${FORK:-"false"} -OLD_VERSION=v4.1.3 +OLD_VERSION=v4.2.0 UPGRADE_WAIT=${UPGRADE_WAIT:-20} HOME=mytestnet ROOT=$(pwd) DENOM=uwhale CHAIN_ID=localmigaloo -SOFTWARE_UPGRADE_NAME="v4.2.0" +SOFTWARE_UPGRADE_NAME="v4.2.1" ADDITIONAL_PRE_SCRIPTS=${ADDITIONAL_PRE_SCRIPTS:-""} ADDITIONAL_AFTER_SCRIPTS=${ADDITIONAL_AFTER_SCRIPTS:-""}