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

core/vm: tweak the --vm.ewasm= option format #17895

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Config struct {
JumpTable [256]operation

// Type of the EWASM interpreter
EWASMInterpreter string
EWASMInterpreter map[string]string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interpreter config should remain a string. There's no point in expanding it in eth/backend. Just split it where you actually need it (in the EWASM's constructor inside core/vm).

// Type of the EVM interpreter
EVMInterpreter string
}
Expand Down
15 changes: 14 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math/big"
"runtime"
"strings"
"sync"
"sync/atomic"

Expand Down Expand Up @@ -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}
Expand Down