diff options
author | Guillaume Ballet <gballet@gmail.com> | 2018-09-20 15:44:35 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-09-20 15:44:35 +0800 |
commit | da29332c5f4c368ff03ec4e7132eefac48fed1ae (patch) | |
tree | fc9a9d2bd594ef22f7b9d9fca8bd410c28304f99 /core | |
parent | 3fec73500b60c82a827b36bb03f8ae011b861e72 (diff) | |
download | dexon-da29332c5f4c368ff03ec4e7132eefac48fed1ae.tar.gz dexon-da29332c5f4c368ff03ec4e7132eefac48fed1ae.tar.zst dexon-da29332c5f4c368ff03ec4e7132eefac48fed1ae.zip |
core/vm: add switches to select evm+ewasm interpreters (#17687)
Interpreter initialization is left to the PRs implementing them.
Options for external interpreters are passed after a colon in the
`--vm.ewasm` and `--vm.evm` switches.
Diffstat (limited to 'core')
-rw-r--r-- | core/vm/evm.go | 22 | ||||
-rw-r--r-- | core/vm/interpreter.go | 5 |
2 files changed, 25 insertions, 2 deletions
diff --git a/core/vm/evm.go b/core/vm/evm.go index 58618f811..fc040c621 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -136,10 +136,28 @@ func NewEVM(ctx Context, statedb StateDB, chainConfig *params.ChainConfig, vmCon vmConfig: vmConfig, chainConfig: chainConfig, chainRules: chainConfig.Rules(ctx.BlockNumber), - interpreters: make([]Interpreter, 1), + interpreters: make([]Interpreter, 0, 1), } - evm.interpreters[0] = NewEVMInterpreter(evm, vmConfig) + if chainConfig.IsEWASM(ctx.BlockNumber) { + // to be implemented by EVM-C and Wagon PRs. + // if vmConfig.EWASMInterpreter != "" { + // extIntOpts := strings.Split(vmConfig.EWASMInterpreter, ":") + // path := extIntOpts[0] + // options := []string{} + // if len(extIntOpts) > 1 { + // options = extIntOpts[1..] + // } + // evm.interpreters = append(evm.interpreters, NewEVMVCInterpreter(evm, vmConfig, options)) + // } else { + // evm.interpreters = append(evm.interpreters, NewEWASMInterpreter(evm, vmConfig)) + // } + panic("No supported ewasm interpreter yet.") + } + + // vmConfig.EVMInterpreter will be used by EVM-C, it won't be checked here + // as we always want to have the built-in EVM as the failover option. + evm.interpreters = append(evm.interpreters, NewEVMInterpreter(evm, vmConfig)) evm.interpreter = evm.interpreters[0] return evm diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 0f1b07342..8e934f60e 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -39,6 +39,11 @@ type Config struct { // may be left uninitialised and will be set to the default // table. JumpTable [256]operation + + // Type of the EWASM interpreter + EWASMInterpreter string + // Type of the EVM interpreter + EVMInterpreter string } // Interpreter is used to run Ethereum based contracts and will utilise the |