diff --git a/.gitignore b/.gitignore index fa058ff4..c646b43c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ bin .vscode .ash_history - +*/.DS_Store diff --git a/app/app.go b/app/app.go index ac320552..48818ca6 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,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 ( @@ -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 @@ -227,6 +232,7 @@ var ( ica.AppModuleBasic{}, intertx.AppModuleBasic{}, ibcfee.AppModuleBasic{}, + ibchooks.AppModuleBasic{}, ) // module account permissions @@ -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 @@ -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, @@ -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) @@ -516,6 +528,19 @@ func NewMigalooApp( app.IBCKeeper.ChannelKeeper, ) + // Configure the hooks keeper + hooksKeeper := ibchookskeeper.NewKeeper( + keys[ibchookstypes.StoreKey], + ) + app.IBCHooksKeeper = &hooksKeeper + 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, + app.Ics20WasmHooks, + ) + // IBC Fee Module keeper app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( appCodec, keys[ibcfeetypes.StoreKey], @@ -537,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), @@ -598,6 +625,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)) @@ -607,6 +637,16 @@ 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 // Create Interchain Accounts Stack // SendPacket, since it is originating from the application to core IBC: @@ -705,6 +745,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 +777,7 @@ func NewMigalooApp( icatypes.ModuleName, ibcfeetypes.ModuleName, intertxtypes.ModuleName, + ibchookstypes.ModuleName, wasm.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, @@ -765,6 +807,7 @@ func NewMigalooApp( icatypes.ModuleName, ibcfeetypes.ModuleName, intertxtypes.ModuleName, + ibchookstypes.ModuleName, wasm.ModuleName, tokenfactorytypes.ModuleName, alliancemoduletypes.ModuleName, @@ -803,6 +846,7 @@ func NewMigalooApp( intertxtypes.ModuleName, tokenfactorytypes.ModuleName, // wasm after ibc transfer + ibchookstypes.ModuleName, wasm.ModuleName, routertypes.ModuleName, alliancemoduletypes.ModuleName, 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..7a56d2d1 --- /dev/null +++ b/app/upgrades/v3/constants.go @@ -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 v3 upgrade. +const UpgradeName = "v3.0.0" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{ibchookstypes.StoreKey}, + }, +} diff --git a/app/upgrades/v3/upgrades.go b/app/upgrades/v3/upgrades.go new file mode 100644 index 00000000..8210dda9 --- /dev/null +++ b/app/upgrades/v3/upgrades.go @@ -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) + } +} 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 c8d0dda6..3bcf4acf 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 1fa6f282..c8727d93 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= diff --git a/networks/.DS_Store b/networks/.DS_Store deleted file mode 100644 index 48aacd8f..00000000 Binary files a/networks/.DS_Store and /dev/null differ