Skip to content

Commit

Permalink
Do not enable enclave when creating tempApp
Browse files Browse the repository at this point in the history
  • Loading branch information
iKapitonau committed Sep 26, 2024
1 parent be97d92 commit 79fb4fc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cmd/secretd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
return dir
}

tempApp := app.NewSecretNetworkApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, true, simtestutil.NewAppOptionsWithFlagHome(tempDir()), compute.DefaultWasmConfig())
wasmConfig := compute.DefaultWasmConfig()
wasmConfig.InitEnclave = false
tempApp := app.NewSecretNetworkApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, true, simtestutil.NewAppOptionsWithFlagHome(tempDir()), wasmConfig)

encodingConfig := app.EncodingConfig{
InterfaceRegistry: tempApp.GetInterfaceRegistry(),
Expand Down
2 changes: 1 addition & 1 deletion go-cosmwasm/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func main() {
panic(err)
}

wasmer, err := wasm.NewWasmer("tmp", "staking,stargate,ibc3", 0, 15)
wasmer, err := wasm.NewWasmer("tmp", "staking,stargate,ibc3", 0, 15, true)
if err != nil {
panic(err)
}
Expand Down
10 changes: 6 additions & 4 deletions go-cosmwasm/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ type Wasmer struct {
// cacheSize sets the size of an optional in-memory LRU cache for prepared VMs.
// They allow popular contracts to be executed very rapidly (no loading overhead),
// but require ~32-64MB each in memory usage.
func NewWasmer(dataDir string, supportedFeatures string, cacheSize uint64, moduleCacheSize uint16) (*Wasmer, error) {
func NewWasmer(dataDir string, supportedFeatures string, cacheSize uint64, moduleCacheSize uint16, initEnclave bool) (*Wasmer, error) {
cache, err := api.InitCache(dataDir, supportedFeatures, cacheSize)
if err != nil {
return nil, err
}
err = api.InitEnclaveRuntime(moduleCacheSize)
if err != nil {
return nil, err
if initEnclave {
err = api.InitEnclaveRuntime(moduleCacheSize)
if err != nil {
return nil, err
}
}

return &Wasmer{cache: cache}, nil
Expand Down
2 changes: 1 addition & 1 deletion x/compute/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewKeeper(
customPlugins *QueryPlugins,
lastMsgManager *baseapp.LastMsgMarkerContainer,
) Keeper {
wasmer, err := wasm.NewWasmer(filepath.Join(homeDir, "wasm"), supportedFeatures, wasmConfig.CacheSize, wasmConfig.EnclaveCacheSize)
wasmer, err := wasm.NewWasmer(filepath.Join(homeDir, "wasm"), supportedFeatures, wasmConfig.CacheSize, wasmConfig.EnclaveCacheSize, wasmConfig.InitEnclave)
if err != nil {
panic(err)
}
Expand Down
4 changes: 4 additions & 0 deletions x/compute/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ type WasmConfig struct {
SmartQueryGasLimit uint64
CacheSize uint64
EnclaveCacheSize uint16
// It must always be true except the case when we create temporary app to
// extract autoCLIOpts from it
InitEnclave bool
}

// DefaultWasmConfig returns the default settings for WasmConfig
Expand All @@ -253,6 +256,7 @@ func DefaultWasmConfig() *WasmConfig {
SmartQueryGasLimit: defaultQueryGasLimit,
CacheSize: defaultLRUCacheSize,
EnclaveCacheSize: defaultEnclaveLRUCacheSize,
InitEnclave: true,
}
}

Expand Down

0 comments on commit 79fb4fc

Please sign in to comment.