Skip to content

Commit

Permalink
feat: bump terra core (#390)
Browse files Browse the repository at this point in the history
* feat: bump terra core

* feat: add upgrade handler

* bump ibc, sdk, comet

* tidy

* update go

* update Dockerfile

* update version

* fix miss query router

* fix: add mising query router

* chore: remove dup query router registration

---------

Co-authored-by: Jacob Gadikian <[email protected]>
Co-authored-by: Khanh Hoa <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent 1d4b1a6 commit 076c6d1
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 75 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- run: go build ./...

tidy:
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-cosmos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- uses: actions/checkout@v4

- name: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- name: Checkout code
uses: actions/checkout@v4
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine AS go-builder
FROM golang:1.22-alpine AS go-builder

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
Expand Down
23 changes: 17 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ import (
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"

terracustombank "github.com/terra-money/core/v2/custom/bank"
custombankkeeper "github.com/terra-money/core/v2/custom/bank/keeper"
terracustombank "github.com/terra-money/core/v2/x/bank"
custombankkeeper "github.com/terra-money/core/v2/x/bank/keeper"

ibchooks "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7"
ibchookskeeper "github.com/cosmos/ibc-apps/modules/ibc-hooks/v7/keeper"
Expand All @@ -127,8 +127,8 @@ import (
alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper"
alliancemoduletypes "github.com/terra-money/alliance/x/alliance/types"

customquerier "github.com/terra-money/core/v2/app/custom_queriers"
"github.com/terra-money/core/v2/x/tokenfactory"
bindings "github.com/terra-money/core/v2/x/tokenfactory/bindings"
tokenfactorykeeper "github.com/terra-money/core/v2/x/tokenfactory/keeper"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"

Expand Down Expand Up @@ -159,6 +159,7 @@ import (
v42 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_2"
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"
"github.com/rakyll/statik/fs"

// unnamed import of statik for swagger UI support
Expand Down Expand Up @@ -472,7 +473,7 @@ func NewMigalooApp(
keys[tokenfactorytypes.StoreKey],
maccPerms,
app.AccountKeeper,
app.BankKeeper,
&app.BankKeeper,
app.DistrKeeper,
appCodec,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand Down Expand Up @@ -600,7 +601,9 @@ func NewMigalooApp(
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(),
)

icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
app.ICAHostKeeper.WithQueryRouter(app.GRPCQueryRouter())

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -631,7 +634,7 @@ func NewMigalooApp(
// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,token_factory"
wasmOpts = append(bindings.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper), wasmOpts...)
wasmOpts = append(customquerier.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper, &app.AllianceKeeper), wasmOpts...)

app.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -1182,6 +1185,14 @@ func (app *MigalooApp) setupUpgradeHandlers() {
),
)

app.UpgradeKeeper.SetUpgradeHandler(
v420.UpgradeName,
v420.CreateUpgradeHandler(
app.mm,
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
// This will read that value, and execute the preparations for the upgrade.
Expand All @@ -1194,7 +1205,7 @@ func (app *MigalooApp) setupUpgradeHandlers() {
return
}

if upgradeInfo.Name == v46.UpgradeName {
if upgradeInfo.Name == v420.UpgradeName {
storeUpgrades := &storetypes.StoreUpgrades{
Added: []string{},
Deleted: []string{},
Expand Down
7 changes: 7 additions & 0 deletions app/upgrades/v4_2_0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package v4

// UpgradeName defines the on-chain upgrade name for the Migaloo v4.2.0 upgrade.
// this upgrade includes the fix for pfm
const (
UpgradeName = "v4.2.0"
)
17 changes: 17 additions & 0 deletions app/upgrades/v4_2_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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"
)

// CreateUpgradeHandler that migrates the chain from v4.1.5 to v4.2.0
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, fromVM)
}
}
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
module github.com/White-Whale-Defi-Platform/migaloo-chain/v4

go 1.21
go 1.22.2

toolchain go1.22.3

require (
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d
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.5
github.com/cometbft/cometbft-db v0.11.0
github.com/cometbft/cometbft v0.37.8
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.11
github.com/cosmos/cosmos-sdk v0.47.12
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.4.0
github.com/cosmos/ibc-go/v7 v7.6.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
Expand All @@ -23,7 +25,7 @@ require (
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/terra-money/alliance v0.3.6
github.com/terra-money/core/v2 v2.5.0
github.com/terra-money/core/v2 v2.11.4
google.golang.org/grpc v1.64.0
)

Expand All @@ -38,7 +40,7 @@ require (
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/linxGnu/grocksdb v1.8.12 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.32.0 // indirect
Expand Down Expand Up @@ -77,7 +79,6 @@ require (
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
Expand All @@ -97,9 +98,8 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
Expand All @@ -117,6 +117,7 @@ require (
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
Expand All @@ -135,6 +136,7 @@ require (
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
Expand Down Expand Up @@ -178,7 +180,7 @@ require (
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
Expand Down Expand Up @@ -219,8 +221,6 @@ replace (
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/terra-money/alliance => github.com/terra-money/alliance v0.3.7-0.20240523140934-a8125ca364d6

// use terra core 2.5.0
github.com/terra-money/core/v2 => github.com/notional-labs/terra-core/v2 v2.5.3
// stick with compatible version or x/exp in v0.47.x line
golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb
// stick with compatible version of rapid in v0.47.x line
Expand Down
Loading

0 comments on commit 076c6d1

Please sign in to comment.