Skip to content

Commit

Permalink
feat: add v4.1.4 handler (#358)
Browse files Browse the repository at this point in the history
* feat: add v4.1.4 handler

* bump comet

* lint

* use latest golang

* bump go

* refactor: refactor keeper

* fix: null ScopedWasmKeeper

* refactor: still use go 1.21, will upgrade go 1.22 in next version

* refactor: still use comet v0.37.4, v0.37.5 have some problem when init chain

* refactor: use cometbft v0.37.5

* refactor: use cometbft v0.37.5 and upgrade viper to v1.18.2

---------

Co-authored-by: Jacob Gadikian <[email protected]>
  • Loading branch information
hoank101 and faddat authored Mar 25, 2024
1 parent 0de1016 commit 9c8d56b
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 154 deletions.
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.21"
- 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.21"
- 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.21"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: "1.21"
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "go"
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality

- name: Build
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v3
3 changes: 1 addition & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: "1.21"
- uses: actions/checkout@v4


- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
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.21"
- 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
Expand Up @@ -34,7 +34,7 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build \
&& (file /code/bin/migalood | grep "statically linked")

# --------------------------------------------------------
FROM alpine:3.16
FROM alpine

COPY --from=go-builder /code/bin/migalood /usr/bin/migalood
ENV HOME /.migalood
Expand Down
71 changes: 25 additions & 46 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ import (
// unnamed import of statik for swagger UI support
"github.com/rakyll/statik/fs"

v3_0_2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v3_0_2"
v4 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_3"
v4 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_4"

// unnamed import of statik for swagger UI support
_ "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/client/docs/statik"
Expand Down Expand Up @@ -400,7 +399,6 @@ func NewMigalooApp(
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
app.CapabilityKeeper.Seal()

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
Expand Down Expand Up @@ -539,18 +537,6 @@ func NewMigalooApp(
AddRoute(alliancemoduletypes.RouterKey, alliancemodule.NewAllianceProposalHandler(app.AllianceKeeper)).
AddRoute(feeburnmoduletypes.RouterKey, feeburnmodule.NewFeeBurnProposalHandler(app.FeeBurnKeeper))

// RouterKeeper must be created before TransferKeeper
app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
appCodec,
app.keys[packetforwardtypes.StoreKey],
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Configure the hooks keeper
hooksKeeper := ibchookskeeper.NewKeeper(
app.keys[ibchookstypes.StoreKey],
Expand All @@ -567,26 +553,38 @@ func NewMigalooApp(

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
app.HooksICS4Wrapper, // may be replaced with IBC middleware
appCodec,
keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.HooksICS4Wrapper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)

app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper)
app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
appCodec,
app.keys[packetforwardtypes.StoreKey],
app.TransferKeeper, // Will be zero-value here. Reference is set later on with SetTransferKeeper.
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// ICA Host keeper
app.ICAHostKeeper = icahostkeeper.NewKeeper(
Expand Down Expand Up @@ -635,10 +633,10 @@ func NewMigalooApp(
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCKeeper.ChannelKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.ScopedWasmKeeper,
scopedWasmKeeper,
app.TransferKeeper,
bApp.MsgServiceRouter(),
bApp.GRPCQueryRouter(),
Expand Down Expand Up @@ -716,6 +714,7 @@ func NewMigalooApp(
app.IBCKeeper.SetRouter(ibcRouter)

govConfig := govtypes.DefaultConfig()
govConfig.MaxMetadataLen = 5100 // define the length of the governance proposal's title and description
/*
Example of setting gov params:
govConfig.MaxMetadataLen = 10000
Expand Down Expand Up @@ -973,6 +972,8 @@ func NewMigalooApp(
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
tmos.Exit(fmt.Sprintf("failed initialize pinned codes %s", err))
}

app.CapabilityKeeper.Seal()
}

return app
Expand Down Expand Up @@ -1133,25 +1134,11 @@ func RegisterSwaggerAPI(rtr *mux.Router) {

// Setup Upgrade Handler
func (app *MigalooApp) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
v3_0_2.UpgradeName,
v3_0_2.CreateUpgradeHandler(app.mm, app.configurator),
)

// !! ATTENTION !!
// v4 upgrade handler
// !! WHEN UPGRADING TO SDK v0.47 MAKE SURE TO INCLUDE THIS
// source: https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/UPGRADING.md#xconsensus
app.UpgradeKeeper.SetUpgradeHandler(
v4.UpgradeName,
v4.CreateUpgradeHandler(
app.mm,
app.configurator,
app.IBCKeeper.ClientKeeper,
app.ParamsKeeper,
app.ConsensusParamsKeeper,
app.ICAControllerKeeper,
app.AccountKeeper,
),
)

Expand All @@ -1172,16 +1159,8 @@ func (app *MigalooApp) setupUpgradeHandlers() {
// !! WHEN UPGRADING TO SDK v0.47 MAKE SURE TO INCLUDE THIS
// source: https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/UPGRADING.md
storeUpgrades := &storetypes.StoreUpgrades{
Added: []string{
consensusparamtypes.StoreKey,
crisistypes.StoreKey,
icqtypes.StoreKey,
feeburnmoduletypes.StoreKey,
authtypes.FeeCollectorName,
},
Deleted: []string{
"intertx",
},
Added: []string{},
Deleted: []string{},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades))
Expand Down
7 changes: 7 additions & 0 deletions app/upgrades/v4_1_4/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.1.2 upgrade.
// this upgrade includes the fix for pfm
const (
UpgradeName = "v4.1.4"
)
17 changes: 17 additions & 0 deletions app/upgrades/v4_1_4/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.3 to v4.1.4
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)
}
}
2 changes: 1 addition & 1 deletion contrib/migalood-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu

RUN apt-get update && \
apt-get -y upgrade && \
Expand Down
35 changes: 21 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cosmossdk.io/simapp v0.0.0-20230602123434-616841b9704d
cosmossdk.io/tools/rosetta v0.2.1
github.com/CosmWasm/wasmd v0.45.0
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft v0.37.5
github.com/cometbft/cometbft-db v0.11.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
github.com/cosmos/cosmos-sdk v0.47.10
Expand All @@ -18,9 +18,9 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/prometheus/client_golang v1.18.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.16.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
github.com/terra-money/alliance v0.3.4
github.com/terra-money/core/v2 v2.5.0
Expand Down Expand Up @@ -49,7 +49,7 @@ require (

require (
cosmossdk.io/errors v1.0.1
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3-0.20240228213828-cce7f56d000b
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
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -94,7 +94,7 @@ require (
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
github.com/creachadair/taskgroup v0.4.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
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
Expand All @@ -104,7 +104,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
Expand Down Expand Up @@ -142,7 +142,7 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/compress v1.17.0 // 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
Expand All @@ -156,20 +156,22 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.6.0 // indirect
Expand All @@ -183,8 +185,10 @@ require (
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
Expand All @@ -211,10 +215,13 @@ replace (
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// Downgraded to avoid bugs in following commits which caused simulations to fail.
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

// use terra core 2.5.0
github.com/terra-money/core/v2 => github.com/notional-labs/terra-core/v2 v2.5.1-pfm
// 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
pgregory.net/rapid => pgregory.net/rapid v0.5.5
)
Loading

0 comments on commit 9c8d56b

Please sign in to comment.