Skip to content

Commit

Permalink
nit(08-wasm): export expected interfaces used as args in functions. (#…
Browse files Browse the repository at this point in the history
…6889) (#6900)

(cherry picked from commit b9681af)

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
  • Loading branch information
mergify[bot] and DimitrisJim authored Jul 22, 2024
1 parent 8611530 commit 76c1370
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 26 deletions.
5 changes: 2 additions & 3 deletions modules/light-clients/08-wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
Expand All @@ -29,7 +28,7 @@ type Keeper struct {
cdc codec.BinaryCodec
clientKeeper types.ClientKeeper

vm ibcwasm.WasmEngine
vm types.WasmEngine

checksums collections.KeySet[[]byte]
storeService store.KVStoreService
Expand Down Expand Up @@ -59,7 +58,7 @@ func moduleLogger(ctx sdk.Context) log.Logger {
}

// GetVM returns the keeper's vm engine.
func (k Keeper) GetVM() ibcwasm.WasmEngine {
func (k Keeper) GetVM() types.WasmEngine {
return k.vm
}

Expand Down
7 changes: 3 additions & 4 deletions modules/light-clients/08-wasm/keeper/keeper_no_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

Expand All @@ -20,8 +19,8 @@ func NewKeeperWithVM(
_ storetypes.KVStoreService,
_ types.ClientKeeper,
_ string,
_ ibcwasm.WasmEngine,
_ ibcwasm.QueryRouter,
_ types.WasmEngine,
_ types.QueryRouter,
_ ...Option,
) Keeper {
panic("not implemented, please build with cgo enabled or nolink_libwasmvm disabled")
Expand All @@ -37,7 +36,7 @@ func NewKeeperWithConfig(
_ types.ClientKeeper,
_ string,
_ types.WasmConfig,
_ ibcwasm.QueryRouter,
_ types.QueryRouter,
_ ...Option,
) Keeper {
panic("not implemented, please build with cgo enabled or nolink_libwasmvm disabled")
Expand Down
7 changes: 3 additions & 4 deletions modules/light-clients/08-wasm/keeper/keeper_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/cosmos/cosmos-sdk/codec"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

Expand All @@ -26,8 +25,8 @@ func NewKeeperWithVM(
storeService store.KVStoreService,
clientKeeper types.ClientKeeper,
authority string,
vm ibcwasm.WasmEngine,
queryRouter ibcwasm.QueryRouter,
vm types.WasmEngine,
queryRouter types.QueryRouter,
opts ...Option,
) Keeper {
if clientKeeper == nil {
Expand Down Expand Up @@ -86,7 +85,7 @@ func NewKeeperWithConfig(
clientKeeper types.ClientKeeper,
authority string,
wasmConfig types.WasmConfig,
queryRouter ibcwasm.QueryRouter,
queryRouter types.QueryRouter,
opts ...Option,
) Keeper {
vm, err := wasmvm.NewVM(wasmConfig.DataDir, wasmConfig.SupportedCapabilities, types.ContractMemoryLimit, wasmConfig.ContractDebugMode, types.MemoryCacheSize)
Expand Down
8 changes: 4 additions & 4 deletions modules/light-clients/08-wasm/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

/*
Expand All @@ -23,7 +23,7 @@ to handle queries. The global `ibcwasm.QueryPluginsI` points to a `types.QueryPl
contains two sub-queriers: `types.CustomQuerier` and `types.StargateQuerier`. These sub-queriers
can be replaced by the user through the options api in the keeper.
In addition, the `types.StargateQuerier` references a global `ibcwasm.QueryRouter` which points
In addition, the `types.StargateQuerier` references a global `types.QueryRouter` which points
to `baseapp.GRPCQueryRouter`.
This design is based on wasmd's (v0.50.0) querier plugin design.
Expand Down Expand Up @@ -122,7 +122,7 @@ func (e QueryPlugins) HandleQuery(ctx sdk.Context, caller string, request wasmvm
}

// NewDefaultQueryPlugins returns the default set of query plugins
func NewDefaultQueryPlugins(queryRouter ibcwasm.QueryRouter) QueryPlugins {
func NewDefaultQueryPlugins(queryRouter types.QueryRouter) QueryPlugins {
return QueryPlugins{
Custom: RejectCustomQuerier(),
Stargate: AcceptListStargateQuerier([]string{}, queryRouter),
Expand All @@ -131,7 +131,7 @@ func NewDefaultQueryPlugins(queryRouter ibcwasm.QueryRouter) QueryPlugins {

// AcceptListStargateQuerier allows all queries that are in the provided accept list.
// This function returns protobuf encoded responses in bytes.
func AcceptListStargateQuerier(acceptedQueries []string, queryRouter ibcwasm.QueryRouter) func(sdk.Context, *wasmvmtypes.StargateQuery) ([]byte, error) {
func AcceptListStargateQuerier(acceptedQueries []string, queryRouter types.QueryRouter) func(sdk.Context, *wasmvmtypes.StargateQuery) ([]byte, error) {
return func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error) {
// append user defined accepted queries to default list defined above.
acceptedQueries = append(defaultAcceptList, acceptedQueries...)
Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/08-wasm/testing/mock_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import (
wasmvm "github.com/CosmWasm/wasmvm/v2"
wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

const DefaultGasUsed = uint64(1)

var (
_ ibcwasm.WasmEngine = (*MockWasmEngine)(nil)
_ types.WasmEngine = (*MockWasmEngine)(nil)

// queryTypes contains all the possible query message types.
queryTypes = [...]any{types.StatusMsg{}, types.TimestampAtHeightMsg{}, types.VerifyClientMessageMsg{}, types.CheckForMisbehaviourMsg{}}
Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/08-wasm/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ import (
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
wasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
wasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper"
wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
ica "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts"
Expand Down Expand Up @@ -250,7 +249,7 @@ func NewSimApp(
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
mockVM ibcwasm.WasmEngine,
mockVM wasmtypes.WasmEngine,
baseAppOptions ...func(*baseapp.BaseApp),
) *SimApp {
interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/08-wasm/testing/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, mockVM ibcwasm.WasmEngine) (*SimApp, GenesisState) {
func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, mockVM wasmtypes.WasmEngine) (*SimApp, GenesisState) {
tb.Helper()

db := dbm.NewMemDB()
Expand All @@ -54,7 +54,7 @@ func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint,
}

// SetupWithEmptyStore set up a simapp instance with empty DB
func SetupWithEmptyStore(tb testing.TB, mockVM ibcwasm.WasmEngine) *SimApp {
func SetupWithEmptyStore(tb testing.TB, mockVM wasmtypes.WasmEngine) *SimApp {
tb.Helper()

app, _ := setup(tb, "", false, 0, mockVM)
Expand All @@ -65,7 +65,7 @@ func SetupWithEmptyStore(tb testing.TB, mockVM ibcwasm.WasmEngine) *SimApp {
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit in the default token of the simapp from first genesis
// account. A Nop logger is set in SimApp.
func SetupWithGenesisValSetSnapshotter(t *testing.T, mockVM ibcwasm.WasmEngine, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
func SetupWithGenesisValSetSnapshotter(t *testing.T, mockVM wasmtypes.WasmEngine, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
t.Helper()

app, genesisState := setup(t, "", true, 5, mockVM)
Expand All @@ -87,7 +87,7 @@ func SetupWithGenesisValSetSnapshotter(t *testing.T, mockVM ibcwasm.WasmEngine,
}

// SetupWithSnapshotter initializes a new SimApp with a configured snapshot db. A Nop logger is set in SimApp.
func SetupWithSnapshotter(t *testing.T, mockVM ibcwasm.WasmEngine) *SimApp {
func SetupWithSnapshotter(t *testing.T, mockVM wasmtypes.WasmEngine) *SimApp {
t.Helper()

privVal := cmttypes.NewMockPV()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ibcwasm
package types

import (
wasmvm "github.com/CosmWasm/wasmvm/v2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build cgo && !nolink_libwasmvm

package ibcwasm
package types

import wasmvm "github.com/CosmWasm/wasmvm/v2"

Expand Down

0 comments on commit 76c1370

Please sign in to comment.