Skip to content

Commit

Permalink
Update cosmos-sdk 0.45 (#80)
Browse files Browse the repository at this point in the history
* Upgrade to Cosmos SDK v0.45.5

* Specify cosmos sdk v0.45.5 at require list

Ref oursky/likecoin-chain

Previously only updated the replace list

Checked we aligned with sdk 0.45.5 replace list as well.

* Bump ibc-go to v2.3.0

Ref oursky#309

* Update upgrade handler for v3.0.0 migrations

Ref oursky#309

- Add migrations for ibc-go v2.3.0
- Add todo for registering store changes for x/nft and x/likenft

* Bump go module version suffix to v3

Ref oursky#305

* Bump go version to 1.18.3 at ci and tool versions file

Ref oursky#306

* Update docker image tag to use go 1.18.3 and debian bullseye

Ref oursky#306

(We missed updating the root dockerfile when releasing v2.0.0)

* Update ci library actions/checkout & actions/setup-go to v3

Ref oursky#306

* Upgrade to Cosmos SDK v0.45.6

* Update cosmos sdk version in go mod require list

Follow up oursky#324

Also update replace list comment, checked no change on upstream

Co-authored-by: Chung Wu <[email protected]>
Co-authored-by: Elliot Ng <[email protected]>
  • Loading branch information
3 people authored Jun 30, 2022
1 parent 874c89a commit ab793e4
Show file tree
Hide file tree
Showing 52 changed files with 260 additions and 284 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.18.3
- name: Build binary file
run: |
make build
6 changes: 3 additions & 3 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.18.3
- name: Setup release env
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.18.3
- name: Install golint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0
# TODO: Remove after fixing lint
Expand All @@ -27,10 +27,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.18.3
# TODO: Remove after fixing format
- name: Run format check
if: ${{ false }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3
- name: update proto dependency
run: make proto-update-deps
- name: format-check
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.18.3
- name: Run go test
run: make test
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.18
golang 1.18.3
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM likecoin/rbuilder:cf0d1a9f3731e30540bbfa36a36d13e4dcccf5eb as builder
FROM likecoin/rbuilder:go1.18.3 as builder

USER root
ARG LIKED_VERSION=unknown
Expand All @@ -20,7 +20,7 @@ ENV COMMIT=$LIKED_COMMIT
RUN rm -rf /sources/artifacts
RUN /bin/bash -c /sources/.build.sh

FROM debian:buster
FROM debian:bullseye

RUN groupadd --gid 1000 likechain \
&& useradd --uid 1000 --gid likechain --shell /bin/bash likechain
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
LIKE_HOME := '$(HOME)/.liked'
IMAGE_TAG = likecoin/likecoin-chain:$(VERSION)
RBUILDER_IMAGE_TAG = likecoin/rbuilder:go1.18
RBUILDER_IMAGE_TAG = likecoin/rbuilder:go1.18.3
BUILDDIR ?= $(CURDIR)/build
GOPATH ?= '$(HOME)/go'
GOLANG_VERSION ?= 1.18
GOLANG_VERSION ?= 1.18.3
GOLANG_CROSS_VERSION := v$(GOLANG_VERSION)

###############################################################################
Expand Down
65 changes: 31 additions & 34 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ import (
ibcclient "github.com/cosmos/ibc-go/v2/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v2/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper"

"github.com/likecoin/likecoin-chain/v2/x/iscn"
iscnkeeper "github.com/likecoin/likecoin-chain/v2/x/iscn/keeper"
iscntypes "github.com/likecoin/likecoin-chain/v2/x/iscn/types"

bech32authmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/auth"
bech32govmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/gov"
bech32slashingmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/slashing"
bech32stakingmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/staking"
"github.com/likecoin/likecoin-chain/v3/x/iscn"
iscnkeeper "github.com/likecoin/likecoin-chain/v3/x/iscn/keeper"
iscntypes "github.com/likecoin/likecoin-chain/v3/x/iscn/types"
)

var (
Expand Down Expand Up @@ -512,42 +506,45 @@ func NewLikeApp(

// Upgrade Handler
func (app *LikeApp) registerUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler("v2.0.0", func(ctx sdk.Context, plan upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) {
app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams())

ctx.Logger().Info("First step: Migrate sdk modules")
// using 1 as fromVersion to avoid running InitGenesis for existing modules
// note newer sdk already guarantees auth module is migrated last
fromVM := make(map[string]uint64)
for moduleName := range app.mm.Modules {
fromVM[moduleName] = 1
app.UpgradeKeeper.SetUpgradeHandler("v3.0.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Migration for ibc-go v2.1.0 to v2.3.0: Support base denoms with slashes
// Ref: https://github.com/cosmos/ibc-go/blob/main/docs/migrations/support-denoms-with-slashes.md

// list of traces that must replace the old traces in store
var newTraces []ibctransfertypes.DenomTrace
equalTraces := func(dtA, dtB ibctransfertypes.DenomTrace) bool {
return dtA.BaseDenom == dtB.BaseDenom && dtA.Path == dtB.Path
}
// exclude new modules to not skip InitGenesis
delete(fromVM, authz.ModuleName)
delete(fromVM, feegrant.ModuleName)
// run
newVM, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return nil, err
app.TransferKeeper.IterateDenomTraces(ctx,
func(dt ibctransfertypes.DenomTrace) bool {
// check if the new way of splitting FullDenom
// into Trace and BaseDenom passes validation and
// is the same as the current DenomTrace.
// If it isn't then store the new DenomTrace in the list of new traces.
newTrace := ibctransfertypes.ParseDenomTrace(dt.GetFullDenomPath())
if err := newTrace.Validate(); err == nil && !equalTraces(newTrace, dt) {
newTraces = append(newTraces, newTrace)
}
return false
})

// replace the outdated traces with the new trace information
for _, nt := range newTraces {
app.TransferKeeper.SetDenomTrace(ctx, nt)
}

ctx.Logger().Info("Second step: Migrate addresses stored in bech32 form to use new prefix")
bech32stakingmigration.MigrateAddressBech32(ctx, app.keys[stakingtypes.StoreKey], app.appCodec)
bech32slashingmigration.MigrateAddressBech32(ctx, app.keys[slashingtypes.StoreKey], app.appCodec)
bech32govmigration.MigrateAddressBech32(ctx, app.keys[govtypes.StoreKey], app.appCodec)
bech32authmigration.MigrateAddressBech32(ctx, app.keys[authtypes.StoreKey], app.appCodec)

return newVM, nil
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == "v2.0.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == "v3.0.0" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{authz.ModuleName, feegrant.ModuleName},
// TODO: register x/nft and x/likenft here after rebase
// Added: []string{},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/gov/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/slashing/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/slashing/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/staking/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) {
Expand Down
12 changes: 6 additions & 6 deletions bech32-migration/test/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
"github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/likecoin/likecoin-chain/v2/testutil"
"github.com/likecoin/likecoin-chain/v3/testutil"

bech32migrationtestutil "github.com/likecoin/likecoin-chain/v2/bech32-migration/testutil"
bech32migrationtestutil "github.com/likecoin/likecoin-chain/v3/bech32-migration/testutil"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

bech32authmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/auth"
bech32govmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/gov"
bech32slashingmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/slashing"
bech32stakingmigration "github.com/likecoin/likecoin-chain/v2/bech32-migration/staking"
bech32authmigration "github.com/likecoin/likecoin-chain/v3/bech32-migration/auth"
bech32govmigration "github.com/likecoin/likecoin-chain/v3/bech32-migration/gov"
bech32slashingmigration "github.com/likecoin/likecoin-chain/v3/bech32-migration/slashing"
bech32stakingmigration "github.com/likecoin/likecoin-chain/v3/bech32-migration/staking"
)

type MTAppOptions struct{}
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/testutil/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func AssertAuthAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) bool {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/testutil/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func AssertGovAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) bool {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/testutil/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/slashing/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func AssertSlashingAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) bool {
Expand Down
2 changes: 1 addition & 1 deletion bech32-migration/testutil/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/likecoin/likecoin-chain/v2/bech32-migration/utils"
"github.com/likecoin/likecoin-chain/v3/bech32-migration/utils"
)

func AssertStakingAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) bool {
Expand Down
4 changes: 2 additions & 2 deletions cmd/liked/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/likecoin/likecoin-chain/v2/app"
"github.com/likecoin/likecoin-chain/v3/app"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -44,7 +44,7 @@ import (

simappcli "github.com/cosmos/cosmos-sdk/simapp/simd/cmd"

"github.com/likecoin/likecoin-chain/v2/ip"
"github.com/likecoin/likecoin-chain/v3/ip"

serverconfig "github.com/cosmos/cosmos-sdk/server/config"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/liked/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/likecoin/likecoin-chain/v2/cmd/liked/cmd"
import "github.com/likecoin/likecoin-chain/v3/cmd/liked/cmd"

func main() {
cmd.Execute()
Expand Down
2 changes: 1 addition & 1 deletion deploy/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.18
golang 1.18.3
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine AS base
FROM golang:1.18.3-alpine AS base

RUN apk update && apk add --no-cache build-base git bash curl linux-headers ca-certificates
WORKDIR /
Expand Down
2 changes: 1 addition & 1 deletion dual_prefix_tests/bank_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/likecoin/likecoin-chain/v2/testutil"
"github.com/likecoin/likecoin-chain/v3/testutil"
"github.com/stretchr/testify/require"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down
4 changes: 2 additions & 2 deletions dual_prefix_tests/iscn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/likecoin/likecoin-chain/v2/testutil"
iscntypes "github.com/likecoin/likecoin-chain/v2/x/iscn/types"
"github.com/likecoin/likecoin-chain/v3/testutil"
iscntypes "github.com/likecoin/likecoin-chain/v3/x/iscn/types"
"github.com/stretchr/testify/require"
)

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/likecoin/likecoin-chain/v2
module github.com/likecoin/likecoin-chain/v3

go 1.18

require (
github.com/cosmos/cosmos-sdk v0.44.8
github.com/cosmos/ibc-go/v2 v2.1.0
github.com/cosmos/cosmos-sdk v0.45.6
github.com/cosmos/ibc-go/v2 v2.3.0
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
Expand All @@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.7.1
github.com/tendermint/tendermint v0.34.19
github.com/tendermint/tm-db v0.6.6
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb
google.golang.org/grpc v1.45.0
)

Expand Down Expand Up @@ -128,10 +128,10 @@ require (
nhooyr.io/websocket v1.8.6 // indirect
)

// point sdk to fork and follow replaces at https://github.com/cosmos/cosmos-sdk/blob/v0.44.8/go.mod
// point sdk to fork and follow replaces at https://github.com/cosmos/cosmos-sdk/blob/v0.45.6/go.mod
replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/cosmos/cosmos-sdk => github.com/likecoin/cosmos-sdk v0.44.8-dual-prefix-hotfix-3
github.com/cosmos/cosmos-sdk => github.com/likecoin/cosmos-sdk v0.45.6-dual-prefix
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
Loading

0 comments on commit ab793e4

Please sign in to comment.