Skip to content

Commit

Permalink
Allow better override of wasmVM in x/wasm keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jul 10, 2023
1 parent 52a7a6a commit 3fbb758
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions x/wasm/keeper/keeper_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ func NewKeeper(
authority string,
opts ...Option,
) Keeper {
wasmer, err := wasmvm.NewVM(filepath.Join(homeDir, "wasm"), availableCapabilities, contractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize)
if err != nil {
panic(err)
}

keeper := &Keeper{
storeKey: storeKey,
cdc: cdc,
wasmVM: wasmer,
wasmVM: nil,
accountKeeper: accountKeeper,
bank: NewBankCoinTransferrer(bankKeeper),
accountPruner: NewVestingCoinBurner(bankKeeper),
Expand All @@ -63,6 +59,16 @@ func NewKeeper(
for _, o := range opts {
o.apply(keeper)
}
// only set the wasmvm if no one set this in the options
// NewVM does a lot, so better not to create it and silently drop it.
if keeper.wasmVM == nil {
var err error
keeper.wasmVM, err = wasmvm.NewVM(filepath.Join(homeDir, "wasm"), availableCapabilities, contractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize)
if err != nil {
panic(err)
}
}

// not updateable, yet
keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper))
return *keeper
Expand Down

0 comments on commit 3fbb758

Please sign in to comment.