From e715414cae9b4654b4784dfb924880a0787d1d55 Mon Sep 17 00:00:00 2001 From: Jhih-Ming Huang Date: Wed, 27 Mar 2019 18:49:38 +0800 Subject: core: vm: refactor vm config and context To support multiple VMs, there must be a shared execution environment for each VM, so this pull request moved some shared component to vm.Context and implemented the vm.ExecPack to hold the list of VM, list of VM configures, context and some shared resources. The adjustment includes: * Move NoRecursion, Depth, ReadOnly, RandCallIndex, IntPool and CallGasTemp to Context. * Adjust VM enumeration from byte to uint8, and the VMList from map to array. * Register VM constructor in each VM package's init function. * Initialize all VM instance in NewExecPack. * Remove EVMImplement, and modify EVM, such that EVM can do the same functions with EVMImplement. --- dex/backend.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'dex/backend.go') diff --git a/dex/backend.go b/dex/backend.go index 8344c7973..97838750c 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -28,7 +28,8 @@ import ( "github.com/dexon-foundation/dexon/core" "github.com/dexon-foundation/dexon/core/bloombits" "github.com/dexon-foundation/dexon/core/rawdb" - vm "github.com/dexon-foundation/dexon/core/vm/evm" + "github.com/dexon-foundation/dexon/core/vm" + "github.com/dexon-foundation/dexon/core/vm/evm" "github.com/dexon-foundation/dexon/dex/downloader" "github.com/dexon-foundation/dexon/eth/filters" "github.com/dexon-foundation/dexon/eth/gasprice" @@ -118,7 +119,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { } var ( - vmConfig = vm.Config{ + evmConfig = evm.Config{ EnablePreimageRecording: config.EnablePreimageRecording, EWASMInterpreter: config.EWASMInterpreter, EVMInterpreter: config.EVMInterpreter, @@ -126,6 +127,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { } cacheConfig = &core.CacheConfig{Disabled: config.NoPruning, TrieCleanLimit: config.TrieCleanCache, TrieDirtyLimit: config.TrieDirtyCache, TrieTimeLimit: config.TrieTimeout} ) + vmConfig := [vm.NUMS]interface{}{} + vmConfig[vm.EVM] = evmConfig dex.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, dex.chainConfig, dex.engine, vmConfig, nil) // Rewind the chain in case of an incompatible config upgrade. -- cgit v1.2.3