Skip to content

Commit

Permalink
core/vm: Add EVMC support
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jan 16, 2019
1 parent 00ae575 commit c212f32
Show file tree
Hide file tree
Showing 2 changed files with 386 additions and 17 deletions.
31 changes: 14 additions & 17 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,21 @@ func NewEVM(ctx Context, statedb StateDB, chainConfig *params.ChainConfig, vmCon
}

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.
if vmConfig.EWASMInterpreter != "" {
evm.interpreters = append(evm.interpreters, NewEVMC(vmConfig.EWASMInterpreter, evm))
} else {
panic("The default ewasm interpreter not supported yet.")
}
}

if vmConfig.EVMInterpreter != "" {
// Create custom EVM.
evm.interpreters = append(evm.interpreters, NewEVMC(vmConfig.EVMInterpreter, evm))
}

// Keep the built-in EVM as the failover option.
evm.interpreters = append(evm.interpreters, NewEVMInterpreter(evm, vmConfig))

evm.interpreter = evm.interpreters[0]

return evm
Expand Down
Loading

0 comments on commit c212f32

Please sign in to comment.