diff --git a/modules/light-clients/08-wasm/keeper/keeper.go b/modules/light-clients/08-wasm/keeper/keeper.go index 486f0e2d063..5e8a8f5c674 100644 --- a/modules/light-clients/08-wasm/keeper/keeper.go +++ b/modules/light-clients/08-wasm/keeper/keeper.go @@ -43,6 +43,7 @@ func NewKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, authority string) panic(err) } types.WasmVM = vm + types.WasmStoreKey = key return Keeper{ cdc: cdc, diff --git a/modules/light-clients/08-wasm/types/client_state.go b/modules/light-clients/08-wasm/types/client_state.go index d1d18ccb06b..d11e73d5c1d 100644 --- a/modules/light-clients/08-wasm/types/client_state.go +++ b/modules/light-clients/08-wasm/types/client_state.go @@ -122,6 +122,9 @@ func (cs ClientState) Initialize(ctx sdk.Context, marshaler codec.BinaryCodec, c setClientState(clientStore, marshaler, &cs) setConsensusState(clientStore, marshaler, consensusState, cs.GetLatestHeight()) + // The global store key can be used here to implement #4085 + // wasmStore := ctx.KVStore(WasmStoreKey) + _, err := initContract(ctx, clientStore, cs.CodeHash) if err != nil { return errorsmod.Wrapf(err, "failed to initialize contract") diff --git a/modules/light-clients/08-wasm/types/vm.go b/modules/light-clients/08-wasm/types/vm.go index 9e128296e73..1486e5acc67 100644 --- a/modules/light-clients/08-wasm/types/vm.go +++ b/modules/light-clients/08-wasm/types/vm.go @@ -4,6 +4,7 @@ import ( cosmwasm "github.com/CosmWasm/wasmvm" wasmvmtypes "github.com/CosmWasm/wasmvm/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" @@ -11,7 +12,12 @@ import ( ) var ( - WasmVM *cosmwasm.VM + WasmVM *cosmwasm.VM + // Store key for 08-wasm module, required as a global so that the KV store can be retrieved + // in the ClientState Initialize function which doesn't have access to the keeper. + // The storeKey is used to check the code hash of the contract and determine if the light client + // is allowed to be instantiated. + WasmStoreKey storetypes.StoreKey VMGasRegister = NewDefaultWasmGasRegister() )