Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nguyen/v3 minor fix #245

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ import (
ibcmock "github.com/cosmos/ibc-go/v6/testing/mock"
bank "github.com/terra-money/alliance/custom/bank"
custombankkeeper "github.com/terra-money/alliance/custom/bank/keeper"

// use TFL's ibc-hooks from Osmosis' ibc-hooks
ibchooks "github.com/terra-money/core/v2/x/ibc-hooks"
ibchookskeeper "github.com/terra-money/core/v2/x/ibc-hooks/keeper"
ibchookstypes "github.com/terra-money/core/v2/x/ibc-hooks/types"

alliancemodule "github.com/terra-money/alliance/x/alliance"
alliancemoduleclient "github.com/terra-money/alliance/x/alliance/client"
alliancemodulekeeper "github.com/terra-money/alliance/x/alliance/keeper"
Expand Down Expand Up @@ -131,15 +137,14 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmappparams "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/params"
appparams "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

// Upgrade Handler
upgrades "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades"
v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades/v2"
v2_2_5 "github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades/v2_2_5"
upgrades "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades"
v3 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v3"
)

const (
Expand All @@ -158,7 +163,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v2.Upgrade, v2_2_5.Upgrade}
Upgrades = []upgrades.Upgrade{v3.Upgrade}
)

// GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to
Expand Down Expand Up @@ -227,6 +232,7 @@ var (
ica.AppModuleBasic{},
intertx.AppModuleBasic{},
ibcfee.AppModuleBasic{},
ibchooks.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -292,6 +298,12 @@ type MigalooApp struct {
WasmKeeper wasm.Keeper
RouterKeeper routerkeeper.Keeper

// IBC hooks
IBCHooksKeeper *ibchookskeeper.Keeper
TransferStack *ibchooks.IBCMiddleware
Ics20WasmHooks *ibchooks.WasmHooks
HooksICS4Wrapper ibchooks.ICS4Middleware

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -319,7 +331,7 @@ func NewMigalooApp(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig wasmappparams.EncodingConfig,
encodingConfig appparams.EncodingConfig,
enabledProposals []wasm.ProposalType,
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
Expand All @@ -339,7 +351,7 @@ func NewMigalooApp(
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey, wasm.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, intertxtypes.StoreKey, ibcfeetypes.StoreKey, tokenfactorytypes.StoreKey,
alliancemoduletypes.StoreKey,
alliancemoduletypes.StoreKey, ibchookstypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -516,6 +528,18 @@ func NewMigalooApp(
app.IBCKeeper.ChannelKeeper,
)

// Configure the hooks keeper
hooksKeeper := ibchookskeeper.NewKeeper(
keys[ibchookstypes.StoreKey],
)
app.IBCHooksKeeper = &hooksKeeper
wasmHooks := ibchooks.NewWasmHooks(&hooksKeeper, nil, "whale") // The contract keeper needs to be set later
app.Ics20WasmHooks = &wasmHooks
app.HooksICS4Wrapper = ibchooks.NewICS4Middleware(
app.IBCKeeper.ChannelKeeper,
app.Ics20WasmHooks,
)

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
Expand Down Expand Up @@ -608,6 +632,10 @@ func NewMigalooApp(
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)

// Hooks Middleware
hooksTransferStack := ibchooks.NewIBCMiddleware(transferStack, &app.HooksICS4Wrapper)
app.TransferStack = &hooksTransferStack

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
// icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket
Expand Down Expand Up @@ -705,6 +733,7 @@ func NewMigalooApp(
intertx.NewAppModule(appCodec, app.InterTxKeeper),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
router.NewAppModule(&app.RouterKeeper),
ibchooks.NewAppModule(app.AccountKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), // always be last to make sure that it checks for all invariants and not only part of them
)

Expand Down Expand Up @@ -736,6 +765,7 @@ func NewMigalooApp(
icatypes.ModuleName,
ibcfeetypes.ModuleName,
intertxtypes.ModuleName,
ibchookstypes.ModuleName,
wasm.ModuleName,
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,
Expand Down Expand Up @@ -765,6 +795,7 @@ func NewMigalooApp(
icatypes.ModuleName,
ibcfeetypes.ModuleName,
intertxtypes.ModuleName,
ibchookstypes.ModuleName,
wasm.ModuleName,
tokenfactorytypes.ModuleName,
alliancemoduletypes.ModuleName,
Expand Down Expand Up @@ -803,6 +834,7 @@ func NewMigalooApp(
intertxtypes.ModuleName,
tokenfactorytypes.ModuleName,
// wasm after ibc transfer
ibchookstypes.ModuleName,
wasm.ModuleName,
routertypes.ModuleName,
alliancemoduletypes.ModuleName,
Expand Down
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app
import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/params"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"
)

// MakeEncodingConfig creates a new EncodingConfig with all modules registered
Expand Down
2 changes: 1 addition & 1 deletion app/test_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/params"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"

"github.com/cosmos/cosmos-sdk/codec"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v2/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v2

import (
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
alliancetypes "github.com/terra-money/alliance/x/alliance/types"
)
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v2_2_5/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v2_2_5 //nolint:revive // skip linter for this package name

import (
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/upgrades"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
)

Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v3/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v3

import (
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
ibchookstypes "github.com/terra-money/core/v2/x/ibc-hooks/types"
)

// UpgradeName defines the on-chain upgrade name for the Migaloo v2 upgrade.
const UpgradeName = "v2.2.5"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{ibchookstypes.StoreKey},
},
}
19 changes: 19 additions & 0 deletions app/upgrades/v3/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v3

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// We set the app version to pre-upgrade because it will be incremented by one
// after the upgrade is applied by the handler.

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
4 changes: 2 additions & 2 deletions cmd/migalood/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/cmd/migalood/cmd"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/cmd/migalood/cmd"
"github.com/cosmos/cosmos-sdk/client/flags"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/simapp"
Expand Down
4 changes: 2 additions & 2 deletions cmd/migalood/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app/params"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/params"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down
4 changes: 2 additions & 2 deletions cmd/migalood/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"os"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v2/cmd/migalood/cmd"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v3/cmd/migalood/cmd"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
)
Expand Down
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/White-Whale-Defi-Platform/migaloo-chain/v2
module github.com/White-Whale-Defi-Platform/migaloo-chain/v3

go 1.21

Expand All @@ -19,6 +19,7 @@ require (
github.com/tendermint/tendermint v0.34.29
github.com/tendermint/tm-db v0.6.8-0.20221109095132-774cdfe7e6b0
github.com/terra-money/alliance v0.1.2
github.com/terra-money/core/v2 v2.4.1
)

require (
Expand Down Expand Up @@ -64,7 +65,7 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
Expand Down Expand Up @@ -186,6 +187,3 @@ replace (
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.29

)

// subject to a bug in the group module and gov module migration
retract [v2.0.0, v2.2.2]
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
Expand Down Expand Up @@ -945,8 +945,9 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
Expand Down Expand Up @@ -1141,6 +1142,8 @@ github.com/tendermint/tm-db v0.6.8-0.20221109095132-774cdfe7e6b0 h1:mQuaSKG8GtmA
github.com/tendermint/tm-db v0.6.8-0.20221109095132-774cdfe7e6b0/go.mod h1:J/0Izsq+rOsOHxSD2dirEhtpB576Fo5iyz0eTn26TBs=
github.com/terra-money/alliance v0.1.2 h1:njhEhK0om+ODx+KuwuAS5vtgGM8PAv4pdDdHAXMQI84=
github.com/terra-money/alliance v0.1.2/go.mod h1:trkbLiiHCx4CD5nlBVD9DjubDDL6437zO8/O3zB3efk=
github.com/terra-money/core/v2 v2.4.1 h1:r90bEXWai2hBs+8KP2ZyT7CBRsEHLb35qgsx1+lc2Fs=
github.com/terra-money/core/v2 v2.4.1/go.mod h1:WSFA0LWlni0X2Lj01gFAP7z/A3H92D/j7JkFZ4CXOn4=
github.com/tidwall/btree v1.5.0 h1:iV0yVY/frd7r6qGBXfEYs7DH0gTDgrKTrDjS7xt/IyQ=
github.com/tidwall/btree v1.5.0/go.mod h1:LGm8L/DZjPLmeWGjv5kFrY8dL4uVhMmzmmLYmsObdKE=
github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
Expand Down
Loading