Skip to content

Commit

Permalink
Add bech32ibc20 logic to v5 upgrade (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon committed Dec 7, 2021
1 parent 20e9675 commit 827c9e0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
34 changes: 31 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -159,6 +165,8 @@ var (
poolincentives.AppModuleBasic{},
epochs.AppModuleBasic{},
claim.AppModuleBasic{},
bech32ibc.AppModuleBasic{},
bech32ics20.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -403,7 +415,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
Expand Down Expand Up @@ -432,6 +444,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,
Expand Down Expand Up @@ -477,7 +502,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,
Expand Down Expand Up @@ -546,7 +572,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),
Expand All @@ -567,6 +593,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
Expand Down Expand Up @@ -599,6 +626,7 @@ func NewOsmosisApp(
gammtypes.ModuleName,
txfeestypes.ModuleName,
genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
bech32ibctypes.ModuleName, // comes after ibctransfertypes
poolincentivestypes.ModuleName,
claimtypes.ModuleName,
incentivestypes.ModuleName,
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 827c9e0

Please sign in to comment.