From 36d1bcbc81e1e59c7b9533bb381a8d41484e9c84 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 6 Sep 2023 12:44:42 +0800 Subject: [PATCH 01/11] add ibc hooks and begin upgrade prep --- app/app.go | 54 +++++++++++++++++++++++++++++--- app/encoding.go | 2 +- app/test_access.go | 2 +- app/upgrades/v2/constants.go | 2 +- app/upgrades/v2_2_5/constants.go | 2 +- app/upgrades/v3/constants.go | 15 +++++++++ app/upgrades/v3/upgrades.go | 19 +++++++++++ cmd/migalood/cmd/cmd_test.go | 4 +-- cmd/migalood/cmd/root.go | 4 +-- cmd/migalood/main.go | 4 +-- go.mod | 8 ++--- go.sum | 9 ++++-- 12 files changed, 102 insertions(+), 23 deletions(-) create mode 100644 app/upgrades/v3/constants.go create mode 100644 app/upgrades/v3/upgrades.go diff --git a/app/app.go b/app/app.go index ac320552..e248b321 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -131,15 +137,15 @@ 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" + wasmappparams "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" + v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2" + v2_2_5 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2_2_5" ) const ( @@ -227,6 +233,7 @@ var ( ica.AppModuleBasic{}, intertx.AppModuleBasic{}, ibcfee.AppModuleBasic{}, + ibchooks.AppModuleBasic{}, ) // module account permissions @@ -292,6 +299,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 @@ -339,7 +352,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) @@ -516,6 +529,22 @@ 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, + ) + + // Hooks Middleware + hooksTransferStack := ibchooks.NewIBCMiddleware(&transferIBCModule, &app.HooksICS4Wrapper) + app.TransferStack = &hooksTransferStack + // IBC Fee Module keeper app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( appCodec, keys[ibcfeetypes.StoreKey], @@ -705,6 +734,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 ) @@ -736,6 +766,7 @@ func NewMigalooApp( icatypes.ModuleName, ibcfeetypes.ModuleName, intertxtypes.ModuleName, + ibchookstypes.ModuleName, wasm.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, @@ -765,6 +796,7 @@ func NewMigalooApp( icatypes.ModuleName, ibcfeetypes.ModuleName, intertxtypes.ModuleName, + ibchookstypes.ModuleName, wasm.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, @@ -803,6 +835,7 @@ func NewMigalooApp( intertxtypes.ModuleName, tokenfactorytypes.ModuleName, // wasm after ibc transfer + ibchookstypes.ModuleName, wasm.ModuleName, routertypes.ModuleName, alliancemoduletypes.ModuleName, @@ -1071,6 +1104,17 @@ func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) { } } +// TODO: ensure that we include this or its equivalent in the actual upgrade, referencing our v3 upgrade +// Add stores for new modules +// if upgradeInfo.Name == terraappconfig.Upgrade2_3_0 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { +// storeUpgrades := storetypes.StoreUpgrades{ +// Added: []string{ +// ibchookstypes.StoreKey, +// }, +// } +// app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) +// } + // GetMaccPerms returns a copy of the module account permissions func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) diff --git a/app/encoding.go b/app/encoding.go index b3cee7a1..29c80f5b 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -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 diff --git a/app/test_access.go b/app/test_access.go index 0e643ba5..0d52b4df 100644 --- a/app/test_access.go +++ b/app/test_access.go @@ -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" diff --git a/app/upgrades/v2/constants.go b/app/upgrades/v2/constants.go index ba8a213e..de3950cd 100644 --- a/app/upgrades/v2/constants.go +++ b/app/upgrades/v2/constants.go @@ -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" ) diff --git a/app/upgrades/v2_2_5/constants.go b/app/upgrades/v2_2_5/constants.go index 92300d93..3b71041c 100644 --- a/app/upgrades/v2_2_5/constants.go +++ b/app/upgrades/v2_2_5/constants.go @@ -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" ) diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go new file mode 100644 index 00000000..4f3817d1 --- /dev/null +++ b/app/upgrades/v3/constants.go @@ -0,0 +1,15 @@ +package v3 //nolint:revive // skip linter for this package name + +import ( + "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades" + store "github.com/cosmos/cosmos-sdk/store/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{}, +} diff --git a/app/upgrades/v3/upgrades.go b/app/upgrades/v3/upgrades.go new file mode 100644 index 00000000..e8ab8fbe --- /dev/null +++ b/app/upgrades/v3/upgrades.go @@ -0,0 +1,19 @@ +package v3 //nolint:revive // skip linter for this package name + +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) + } +} diff --git a/cmd/migalood/cmd/cmd_test.go b/cmd/migalood/cmd/cmd_test.go index 597c8809..f27fd8bf 100644 --- a/cmd/migalood/cmd/cmd_test.go +++ b/cmd/migalood/cmd/cmd_test.go @@ -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" diff --git a/cmd/migalood/cmd/root.go b/cmd/migalood/cmd/root.go index 3f65d434..e7763650 100644 --- a/cmd/migalood/cmd/root.go +++ b/cmd/migalood/cmd/root.go @@ -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" diff --git a/cmd/migalood/main.go b/cmd/migalood/main.go index b0e90693..5278e631 100644 --- a/cmd/migalood/main.go +++ b/cmd/migalood/main.go @@ -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" ) diff --git a/go.mod b/go.mod index c2726d4e..1fcbc690 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 ( @@ -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 @@ -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] diff --git a/go.sum b/go.sum index 5bdbe0b3..adf5f8be 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= @@ -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= From c2ee82a471fad6c7f20476ec64c19bb496e013b8 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Fri, 8 Sep 2023 11:23:36 +0800 Subject: [PATCH 02/11] fixup pr --- app/app.go | 8 ++++---- app/upgrades/v3/constants.go | 2 +- app/upgrades/v3/upgrades.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index e248b321..bf747994 100644 --- a/app/app.go +++ b/app/app.go @@ -541,10 +541,6 @@ func NewMigalooApp( app.Ics20WasmHooks, ) - // Hooks Middleware - hooksTransferStack := ibchooks.NewIBCMiddleware(&transferIBCModule, &app.HooksICS4Wrapper) - app.TransferStack = &hooksTransferStack - // IBC Fee Module keeper app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( appCodec, keys[ibcfeetypes.StoreKey], @@ -637,6 +633,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 diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index 4f3817d1..1eefc8ce 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -1,4 +1,4 @@ -package v3 //nolint:revive // skip linter for this package name +package v3 import ( "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades" diff --git a/app/upgrades/v3/upgrades.go b/app/upgrades/v3/upgrades.go index e8ab8fbe..8210dda9 100644 --- a/app/upgrades/v3/upgrades.go +++ b/app/upgrades/v3/upgrades.go @@ -1,4 +1,4 @@ -package v3 //nolint:revive // skip linter for this package name +package v3 import ( sdk "github.com/cosmos/cosmos-sdk/types" From c4b80d0af08cfdf235360cae94ad39f02ef81574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Tue, 12 Sep 2023 15:52:20 +0700 Subject: [PATCH 03/11] add pfm to ibc stack --- app/app.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index bf747994..ffa1c46d 100644 --- a/app/app.go +++ b/app/app.go @@ -534,7 +534,8 @@ func NewMigalooApp( keys[ibchookstypes.StoreKey], ) app.IBCHooksKeeper = &hooksKeeper - wasmHooks := ibchooks.NewWasmHooks(&hooksKeeper, nil, "whale") // The contract keeper needs to be set later + migalooPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() + wasmHooks := ibchooks.NewWasmHooks(&hooksKeeper, nil, migalooPrefix) // The contract keeper needs to be set later app.Ics20WasmHooks = &wasmHooks app.HooksICS4Wrapper = ibchooks.NewICS4Middleware( app.IBCKeeper.ChannelKeeper, @@ -632,7 +633,13 @@ func NewMigalooApp( var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) - + transferStack = router.NewIBCMiddleware( + transferStack, + &app.RouterKeeper, + 0, + routerkeeper.DefaultForwardTransferPacketTimeoutTimestamp, + routerkeeper.DefaultRefundTransferPacketTimeoutTimestamp, + ) // Hooks Middleware hooksTransferStack := ibchooks.NewIBCMiddleware(transferStack, &app.HooksICS4Wrapper) app.TransferStack = &hooksTransferStack From d822be03a0e6e8b6e2d35e5e5c5e563703a8e56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Thu, 14 Sep 2023 11:45:34 +0700 Subject: [PATCH 04/11] add ibchooks store key to upgrade --- app/upgrades/v3/constants.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index 1eefc8ce..bdc29205 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -3,6 +3,7 @@ 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. @@ -11,5 +12,7 @@ const UpgradeName = "v2.2.5" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{}, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{ibchookstypes.StoreKey}, + }, } From e8d5c69c36bf411718f597ccbd3e3636f3329857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Thu, 14 Sep 2023 15:26:57 +0700 Subject: [PATCH 05/11] add v3 upgrade to app --- app/app.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index bf747994..f6848d38 100644 --- a/app/app.go +++ b/app/app.go @@ -146,6 +146,7 @@ import ( upgrades "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades" v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2" v2_2_5 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2_2_5" + v3 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v3" ) const ( @@ -164,7 +165,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{v2.Upgrade, v2_2_5.Upgrade, v3.Upgrade} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to From 58f4e8df940801b33ef1a256d6ad46c667e37e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Tue, 19 Sep 2023 10:29:20 +0700 Subject: [PATCH 06/11] remove unused upgrades and comment --- app/app.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/app/app.go b/app/app.go index f6848d38..5f6d80b2 100644 --- a/app/app.go +++ b/app/app.go @@ -137,15 +137,13 @@ 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/v3/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/v3/app/upgrades" - v2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2" - v2_2_5 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v2_2_5" v3 "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app/upgrades/v3" ) @@ -165,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, v3.Upgrade} + Upgrades = []upgrades.Upgrade{v3.Upgrade} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to @@ -333,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, @@ -1105,17 +1103,6 @@ func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) { } } -// TODO: ensure that we include this or its equivalent in the actual upgrade, referencing our v3 upgrade -// Add stores for new modules -// if upgradeInfo.Name == terraappconfig.Upgrade2_3_0 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { -// storeUpgrades := storetypes.StoreUpgrades{ -// Added: []string{ -// ibchookstypes.StoreKey, -// }, -// } -// app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) -// } - // GetMaccPerms returns a copy of the module account permissions func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) From 89ce3a7efd5e92a244d625c30e0fd8a2ba166808 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 20 Sep 2023 17:19:56 +0000 Subject: [PATCH 07/11] Update constants.go --- app/upgrades/v3/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index bdc29205..6d30dc05 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -7,7 +7,7 @@ import ( ) // UpgradeName defines the on-chain upgrade name for the Migaloo v2 upgrade. -const UpgradeName = "v2.2.5" +const UpgradeName = "v3.0.0" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, From c5b9bd77439e8d03412c4296759fe951e0ade802 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Thu, 21 Sep 2023 01:30:56 +0800 Subject: [PATCH 08/11] remove DS_Store, update .gitignore, set the contract Keeper for ibc hooks --- .gitignore | 2 +- app/app.go | 3 +++ networks/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 networks/.DS_Store diff --git a/.gitignore b/.gitignore index fa058ff4..853cf226 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ bin .vscode .ash_history - +*/.DS_Sore diff --git a/app/app.go b/app/app.go index 18672cf3..7914e0ad 100644 --- a/app/app.go +++ b/app/app.go @@ -623,6 +623,9 @@ func NewMigalooApp( wasmOpts..., ) + contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper) + app.Ics20WasmHooks.ContractKeeper = contractKeeper + // The gov proposal types can be individually enabled if len(enabledProposals) != 0 { govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) diff --git a/networks/.DS_Store b/networks/.DS_Store deleted file mode 100644 index 48aacd8f74dc1dda3c51af606668332559e40bb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}N6?5T4YkDI)Zs;4$E}Xsc2YFKg9~si)&K)V-KaUXMG``#MjZ8 zBo(Fgs92eS$u~PcyPGddvI793)^Ah*iU1%{33CM;rU=DJCnV=RbBMy;Lqh@@S|_Qw zoyca#Uu1yRPC^?}h;ZdTtzVp)7-RHd9H4HzSwU+`emv;5ef~?_PLpo0Tz(a~x%~XX zqFj_q@;baTgRmF%`rTU8xumNzW72qRNAY>m9Mp>|her3JL^nIOAZau)4+HhFet(4UEUUgJb!@aF?N$qS`N27vVUEkb4t>32)+C14e2Z7(I zm1U1(ct&G_hsUs^Q=?lL8`q8V8JPiQfEk!&2K=5Tmu7hq{O-&EGw>q}(EgxM2?LLr zL%Vh0U|RshJi4u*O}~s(qdW#4Glv*K5v~-`l?vZt2v?4NJ2IhhRJt+JmU}@li8TeHO-T|gMS=s;q From 5db5e61efa8713d494815309d1a94d1d9ea3912b Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 20 Sep 2023 18:05:03 +0000 Subject: [PATCH 09/11] Update constants.go --- app/upgrades/v3/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v3/constants.go b/app/upgrades/v3/constants.go index 6d30dc05..7a56d2d1 100644 --- a/app/upgrades/v3/constants.go +++ b/app/upgrades/v3/constants.go @@ -6,7 +6,7 @@ import ( ibchookstypes "github.com/terra-money/core/v2/x/ibc-hooks/types" ) -// UpgradeName defines the on-chain upgrade name for the Migaloo v2 upgrade. +// UpgradeName defines the on-chain upgrade name for the Migaloo v3 upgrade. const UpgradeName = "v3.0.0" var Upgrade = upgrades.Upgrade{ From 9190ab96455c9e0590e900fa42230d64cca78103 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Thu, 21 Sep 2023 01:14:39 +0700 Subject: [PATCH 10/11] set transfer keeper for pfm --- app/app.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/app.go b/app/app.go index 7914e0ad..48818ca6 100644 --- a/app/app.go +++ b/app/app.go @@ -562,6 +562,8 @@ func NewMigalooApp( scopedTransferKeeper, ) + app.RouterKeeper.SetTransferKeeper(app.TransferKeeper) + // ICA Host keeper app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), From 22659f8ddf87397374fb3a8a66c681672fda4219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Mon, 25 Sep 2023 10:17:59 +0700 Subject: [PATCH 11/11] gitignore typo --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 853cf226..c646b43c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ bin .vscode .ash_history -*/.DS_Sore +*/.DS_Store