Skip to content

Commit

Permalink
continue updating wasm hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Mar 6, 2024
1 parent 76b1242 commit 83a62da
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 330 deletions.
3 changes: 2 additions & 1 deletion modules/ibc-hooks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ require (
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.2.0
cosmossdk.io/store v1.0.2
cosmossdk.io/x/circuit v0.1.0
cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/feegrant v0.1.0
cosmossdk.io/x/nft v0.1.0
cosmossdk.io/x/tx v0.13.0
cosmossdk.io/x/upgrade v0.1.0
github.com/CosmWasm/wasmd v0.50.0
github.com/cometbft/cometbft v0.38.5
github.com/cometbft/cometbft-db v0.11.0
github.com/cosmos/cosmos-db v1.0.0
github.com/cosmos/cosmos-sdk v0.50.4
github.com/cosmos/gogoproto v1.4.11
Expand Down Expand Up @@ -63,6 +63,7 @@ require (
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.11.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion modules/ibc-hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ibc_hooks
import (
// external libraries
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
// ibc-go
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
Expand Down
2 changes: 1 addition & 1 deletion modules/ibc-hooks/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ibc_hooks
import (
// external libraries
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
// ibc-go
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
Expand Down
2 changes: 1 addition & 1 deletion modules/ibc-hooks/ics4_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ibc_hooks
import (
// external libraries
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
// ibc-go
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
Expand Down
4 changes: 2 additions & 2 deletions modules/ibc-hooks/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/types"

"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"

"github.com/cometbft/cometbft/libs/log"
)

type (
Expand Down
55 changes: 32 additions & 23 deletions modules/ibc-hooks/simapp/ante.go
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
package simapp

Check failure on line 1 in modules/ibc-hooks/simapp/ante.go

View workflow job for this annotation

GitHub Actions / Linter

: # github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/simapp [github.com/cosmos/ibc-apps/modules/ibc-hooks/v8/simapp.test]

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
"errors"

ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"

errors "cosmossdk.io/errors"
corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
circuitkeeper "cosmossdk.io/x/circuit/keeper"

storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
)

// HandlerOptions extends the SDK's AnteHandler options by requiring the IBC
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
Cdc codec.BinaryCodec
IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
// NewAnteHandler constructor
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
return nil, errors.New("account keeper is required for ante builder")
}

if options.BankKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
return nil, errors.New("bank keeper is required for ante builder")
}

if options.SignModeHandler == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errors.New("sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
return nil, errors.New("wasm config is required for ante builder")
}
if options.TXCounterStoreService == nil {
return nil, errors.New("wasm store service is required for ante builder")
}
if options.CircuitKeeper == nil {
return nil, errors.New("circuit keeper is required for ante builder")
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
33 changes: 20 additions & 13 deletions modules/ibc-hooks/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"cosmossdk.io/api/tendermint/abci"
"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"

storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -432,21 +431,22 @@ func NewSimApp(
// 2. 'auth'
// 3. 'bank'
app.MintKeeper = mintkeeper.NewKeeper(
cdc,
app.keys[minttypes.StoreKey],
appCodec,
runtime.NewKVStoreService(keys[minttypes.StoreKey]),
app.StakingKeeper,
app.AuthKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName, // TODO: Find out what this is
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.NftKeeper = nftkeeper.NewKeeper(
app.keys[nftkeeper.StoreKey],
cdc,
app.AuthKeeper,
app.NFTKeeper = nftkeeper.NewKeeper(
runtime.NewKVStoreService(keys[nftkeeper.StoreKey]),
appCodec,
app.AccountKeeper,
app.BankKeeper,
)

app.SlashingKeeper = slashingkeeper.NewKeeper(
cdc,
encodingConfig.Amino,
Expand Down Expand Up @@ -882,12 +882,12 @@ func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}

if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()); err != nil {
err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap())
if err != nil {
panic(err)
}

return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
response, err := app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
return response, err
}

// LoadHeight loads a particular height
Expand Down Expand Up @@ -1017,3 +1017,10 @@ func (app *App) ModuleAccountAddrs() map[string]bool {

return modAccAddrs
}

// GetKey returns the KVStoreKey for the provided store key.
//
// NOTE: This is solely to be used for testing purposes.
func (app *App) GetKey(storeKey string) *storetypes.KVStoreKey {
return app.keys[storeKey]
}
Loading

0 comments on commit 83a62da

Please sign in to comment.