From e4b3b29bc2e5169aadf003773098384ceb25119d Mon Sep 17 00:00:00 2001 From: ValarDragon Date: Fri, 3 Dec 2021 02:23:29 -0400 Subject: [PATCH] Add bech32ibc20 logic to v5 upgrade --- app/app.go | 34 +++++++++++++++++++++++++++++++--- go.mod | 1 + go.sum | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 85e2547a17b..a270e16988f 100644 --- a/app/app.go +++ b/app/app.go @@ -118,6 +118,12 @@ import ( "github.com/osmosis-labs/osmosis/x/txfees" txfeeskeeper "github.com/osmosis-labs/osmosis/x/txfees/keeper" txfeestypes "github.com/osmosis-labs/osmosis/x/txfees/types" + + "github.com/osmosis-labs/bech32-ibc/x/bech32ibc" + bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper" + bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" + "github.com/osmosis-labs/bech32-ibc/x/bech32ics20" + bech32ics20keeper "github.com/osmosis-labs/bech32-ibc/x/bech32ics20/keeper" ) const appName = "OsmosisApp" @@ -159,6 +165,8 @@ var ( poolincentives.AppModuleBasic{}, epochs.AppModuleBasic{}, claim.AppModuleBasic{}, + bech32ibc.AppModuleBasic{}, + bech32ics20.AppModuleBasic{}, ) // module account permissions @@ -227,6 +235,9 @@ type OsmosisApp struct { PoolIncentivesKeeper poolincentiveskeeper.Keeper TxFeesKeeper txfeeskeeper.Keeper + Bech32IBCKeeper bech32ibckeeper.Keeper + Bech32ICS20Keeper bech32ics20keeper.Keeper + // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper @@ -272,6 +283,7 @@ func NewOsmosisApp( evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, gammtypes.StoreKey, lockuptypes.StoreKey, claimtypes.StoreKey, incentivestypes.StoreKey, epochstypes.StoreKey, poolincentivestypes.StoreKey, authzkeeper.StoreKey, txfeestypes.StoreKey, + bech32ibctypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -413,7 +425,7 @@ func NewOsmosisApp( if upgradeInfo.Name == v5UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := store.StoreUpgrades{ - Added: []string{authz.ModuleName, txfees.ModuleName}, + Added: []string{authz.ModuleName, txfees.ModuleName, bech32ibctypes.ModuleName}, } // configure store loader that checks if version == upgradeHeight and applies store upgrades @@ -442,6 +454,19 @@ func NewOsmosisApp( ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) app.IBCKeeper.SetRouter(ibcRouter) + app.Bech32IBCKeeper = *bech32ibckeeper.NewKeeper( + app.IBCKeeper.ChannelKeeper, appCodec, keys[bech32ibctypes.StoreKey], + app.TransferKeeper, + ) + + app.Bech32ICS20Keeper = *bech32ics20keeper.NewKeeper( + app.IBCKeeper.ChannelKeeper, + app.BankKeeper, app.TransferKeeper, + app.Bech32IBCKeeper, + app.TransferKeeper, + appCodec, + ) + // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, keys[evidencetypes.StoreKey], &stakingKeeper, app.SlashingKeeper, @@ -487,7 +512,8 @@ func NewOsmosisApp( AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(poolincentivestypes.RouterKey, poolincentives.NewPoolIncentivesProposalHandler(app.PoolIncentivesKeeper)) + AddRoute(poolincentivestypes.RouterKey, poolincentives.NewPoolIncentivesProposalHandler(app.PoolIncentivesKeeper)). + AddRoute(bech32ibctypes.RouterKey, bech32ibc.NewBech32IBCProposalHandler(app.Bech32IBCKeeper)) govKeeper := govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, @@ -556,7 +582,7 @@ func NewOsmosisApp( ), auth.NewAppModule(appCodec, app.AccountKeeper, nil), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), + bech32ics20.NewAppModule(appCodec, app.Bech32ICS20Keeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), @@ -577,6 +603,7 @@ func NewOsmosisApp( lockup.NewAppModule(appCodec, app.LockupKeeper, app.AccountKeeper, app.BankKeeper), poolincentives.NewAppModule(appCodec, app.PoolIncentivesKeeper), epochs.NewAppModule(appCodec, app.EpochsKeeper), + bech32ibc.NewAppModule(appCodec, app.Bech32IBCKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -609,6 +636,7 @@ func NewOsmosisApp( gammtypes.ModuleName, txfeestypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, + bech32ibctypes.ModuleName, // comes after ibctransfertypes poolincentivestypes.ModuleName, claimtypes.ModuleName, incentivestypes.ModuleName, diff --git a/go.mod b/go.mod index 55d236fbf17..de7b909dc2f 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/osmosis-labs/bech32-ibc v0.0.0-20211129140933-05a182d246f3 github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 diff --git a/go.sum b/go.sum index 51a9aeda300..1185e028a31 100644 --- a/go.sum +++ b/go.sum @@ -621,6 +621,8 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= +github.com/osmosis-labs/bech32-ibc v0.0.0-20211129140933-05a182d246f3 h1:qPpkPrHrIro/9NiYGS+DJd2nUq2YK7oRmP/QXGKoC+c= +github.com/osmosis-labs/bech32-ibc v0.0.0-20211129140933-05a182d246f3/go.mod h1:fwb95yj/poNCO8mfRfWQBclcEIX7hl27AqJc0DE2hRM= github.com/osmosis-labs/cosmos-sdk v0.43.0-rc3.0.20211119062100-2f81f59f3aa1 h1:CxrbRUTLEWeNDQrZXJFIciPOO8YAsp4forPZcCHuMnY= github.com/osmosis-labs/cosmos-sdk v0.43.0-rc3.0.20211119062100-2f81f59f3aa1/go.mod h1:S/sIkCqPuuvRrByglANXeN1eb1aA4lmKSjSG5E8SWsU= github.com/osmosis-labs/tm-db v0.6.5-0.20210911033928-ba9154613417 h1:otchJDd2SjFWfs7Tse3ULblGcVWqMJ50BE02XCaqXOo=