From 92f20ec18a767ff6d1868f3ca667999988552ef7 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Thu, 11 Oct 2018 15:06:49 +0200 Subject: [PATCH] core/vm: tweak the `--vm.ewasm=` option format --- core/vm/interpreter.go | 2 +- eth/backend.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 952d96dd4d..37b561f1de 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -43,7 +43,7 @@ type Config struct { JumpTable [256]operation // Type of the EWASM interpreter - EWASMInterpreter string + EWASMInterpreter map[string]string // Type of the EVM interpreter EVMInterpreter string } diff --git a/eth/backend.go b/eth/backend.go index b555b064ad..cfca5859bc 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -22,6 +22,7 @@ import ( "fmt" "math/big" "runtime" + "strings" "sync" "sync/atomic" @@ -148,10 +149,22 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion) } + + ewasmOptions := make(map[string]string) + if len(config.EWASMInterpreter) > 0 { + for _, option := range strings.Split(config.EWASMInterpreter, ",") { + opt := strings.Split(option, ":") + if len(opt) != 2 || len(opt[0]) == 0 { + panic(fmt.Sprintf("Invalid ewasm option: expected a format of name:value, got: %s", option)) + } + ewasmOptions[opt[0]] = opt[1] + } + } + var ( vmConfig = vm.Config{ EnablePreimageRecording: config.EnablePreimageRecording, - EWASMInterpreter: config.EWASMInterpreter, + EWASMInterpreter: ewasmOptions, EVMInterpreter: config.EVMInterpreter, } cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieNodeLimit: config.TrieCache, TrieTimeLimit: config.TrieTimeout}