Skip to content

Commit

Permalink
feat: wasm deprecation and usage fixes in app (#1039)
Browse files Browse the repository at this point in the history
* updated wasm deprecated usage in app.go

* mod file updated

* added go.sum changes

* chore: go mod tidy

---------

Co-authored-by: aleem1314 <[email protected]>
  • Loading branch information
deepan95dev and aleem1314 authored Nov 24, 2023
1 parent f916992 commit 403c80d
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 706 deletions.
124 changes: 61 additions & 63 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import (
"path/filepath"
"strings"

// "github.com/CosmWasm/wasmd/x/wasm"
// wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

"cosmossdk.io/log"
// "github.com/CosmWasm/wasmd/x/wasm"
// "github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"

Expand Down Expand Up @@ -279,13 +277,13 @@ type App struct {
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper
// ScopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedConsensusKeeper capabilitykeeper.ScopedKeeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
ScopedWasmKeeper capabilitykeeper.ScopedKeeper
ScopedConsensusKeeper capabilitykeeper.ScopedKeeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper

// SchedulerKeeper schedulermodulekeeper.Keeper
// ConsensusKeeper consensusmodulekeeper.Keeper
Expand All @@ -294,7 +292,7 @@ type App struct {
// TreasuryKeeper treasurymodulekeeper.Keeper
// EvmKeeper evmmodulekeeper.Keeper
// GravityKeeper gravitymodulekeeper.Keeper
// wasmKeeper wasm.Keeper
wasmKeeper wasmkeeper.Keeper

// mm is the module manager
mm *module.Manager
Expand Down Expand Up @@ -369,7 +367,7 @@ func New(
// consensusmoduletypes.StoreKey,
// valsetmoduletypes.StoreKey,
// treasurymoduletypes.StoreKey,
// // wasm.StoreKey,
wasmtypes.StoreKey,
// evmmoduletypes.StoreKey,
// gravitymoduletypes.StoreKey,
// consensusparamtypes.StoreKey,
Expand Down Expand Up @@ -417,7 +415,7 @@ func New(
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
// scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasm.ModuleName)
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
// scopedConsensusKeeper := app.CapabilityKeeper.ScopeToModule(consensusmoduletypes.ModuleName)

app.CapabilityKeeper.Seal()
Expand Down Expand Up @@ -696,37 +694,37 @@ func New(
),
)

// wasmDir := filepath.Join(homePath, "data")
// wasmConfig, err := wasm.ReadWasmConfig(appOpts)
// if err != nil {
// panic("error while reading wasm config: " + err.Error())
// }
wasmDir := filepath.Join(homePath, "data")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
panic("error while reading wasm config: " + err.Error())
}

// app.wasmKeeper = wasm.NewKeeper(
// appCodec,
// keys[wasm.StoreKey],
// app.AccountKeeper,
// app.BankKeeper,
// app.StakingKeeper,
// distrkeeper.NewQuerier(app.DistrKeeper),
// // app.IBCKeeper.ChannelKeeper,
// // app.IBCKeeper.ChannelKeeper,
// // &app.IBCKeeper.PortKeeper,
// scopedWasmKeeper,
// // app.TransferKeeper,
// app.MsgServiceRouter(),
// app.GRPCQueryRouter(),
// wasmDir,
// wasmConfig,
// wasmAvailableCapabilities,
// authtypes.NewModuleAddress(govtypes.ModuleName).String(),
// wasmkeeper.WithMessageHandlerDecorator(func(old wasmkeeper.Messenger) wasmkeeper.Messenger {
// return wasmkeeper.NewMessageHandlerChain(
// old,
// app.SchedulerKeeper.ExecuteWasmJobEventListener(),
// )
// }),
// )
app.wasmKeeper = wasmkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
app.TransferKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
wasmAvailableCapabilities,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
//wasmkeeper.WithMessageHandlerDecorator(func(old wasmkeeper.Messenger) wasmkeeper.Messenger {
// return wasmkeeper.NewMessageHandlerChain(
// old,
// app.SchedulerKeeper.ExecuteWasmJobEventListener(),
// )
//}),
)

// register wasm gov proposal types
// enabledProposals := GetEnabledProposals()
Expand Down Expand Up @@ -757,21 +755,21 @@ func New(
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create fee enabled wasm ibc Stack
// var wasmStack porttypes.IBCModule
// wasmStack = wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
// wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper)
var wasmStack porttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper)

// Create static IBC router, add app routes, then set and seal it
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferStack).
// AddRoute(wasm.ModuleName, wasmStack).
AddRoute(wasmtypes.ModuleName, wasmStack).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostStack)
app.IBCKeeper.SetRouter(ibcRouter)

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
// app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper

Expand Down Expand Up @@ -815,7 +813,7 @@ func New(
// gravityModule,
// palomaModule,
// treasuryModule,
// wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasm.ModuleName)),
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasm.ModuleName)),
ibc.NewAppModule(app.IBCKeeper),
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
Expand Down Expand Up @@ -847,7 +845,7 @@ func New(
genutiltypes.ModuleName,
// valsetmoduletypes.ModuleName,
// palomamoduletypes.ModuleName,
// wasm.ModuleName,
wasmtypes.ModuleName,
// evmmoduletypes.ModuleName,
// gravitymoduletypes.ModuleName,
// treasurymoduletypes.ModuleName,
Expand Down Expand Up @@ -879,7 +877,7 @@ func New(
genutiltypes.ModuleName,
// valsetmoduletypes.ModuleName,
// palomamoduletypes.ModuleName,
// wasm.ModuleName,
wasmtypes.ModuleName,
// evmmoduletypes.ModuleName,
// gravitymoduletypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -920,7 +918,7 @@ func New(
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
// wasm.ModuleName,
wasmtypes.ModuleName,
// evmmoduletypes.ModuleName,
// gravitymoduletypes.ModuleName,
// treasurymoduletypes.ModuleName,
Expand Down Expand Up @@ -959,7 +957,7 @@ func New(
app.SetBeginBlocker(app.BeginBlocker)

/*baseAnteHandler*/
_, err := ante.NewAnteHandler(
_, err = ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
Expand Down Expand Up @@ -987,16 +985,16 @@ func New(

app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
// app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedWasmKeeper = scopedWasmKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper
app.ScopedICAControllerKeeper = scopedICAControllerKeeper

// if mngr := app.SnapshotManager(); mngr != nil {
// err := mngr.RegisterExtensions(wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.wasmKeeper))
// if err != nil {
// panic(fmt.Errorf("failed to register snapshot extension: %w", err))
// }
// }
if mngr := app.SnapshotManager(); mngr != nil {
err := mngr.RegisterExtensions(wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.wasmKeeper))
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
}
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -1167,7 +1165,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// paramsKeeper.Subspace(schedulermoduletypes.ModuleName)
// paramsKeeper.Subspace(consensusmoduletypes.ModuleName)
// paramsKeeper.Subspace(valsetmoduletypes.ModuleName)
// paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(wasmtypes.ModuleName)
// paramsKeeper.Subspace(evmmoduletypes.ModuleName)
// paramsKeeper.Subspace(gravitymoduletypes.ModuleName)

Expand Down
Loading

0 comments on commit 403c80d

Please sign in to comment.