Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 08-wasm global store key #4185

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/light-clients/08-wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions modules/light-clients/08-wasm/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion modules/light-clients/08-wasm/types/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ 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"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
)

var (
WasmVM *cosmwasm.VM
WasmVM *cosmwasm.VM
// Store key for 08-wasm module, so that the KV store can be retrieve
// in ClientState Initialize function to check the code hash of the
// contract and determine if the light client is allowed to be instantiated.
WasmStoreKey storetypes.StoreKey
VMGasRegister = NewDefaultWasmGasRegister()
)

Expand Down