aboutsummaryrefslogtreecommitdiffstats
path: root/dex/backend.go
diff options
context:
space:
mode:
authorJhih-Ming Huang <jm.huang@cobinhood.com>2019-03-27 18:49:38 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:50:26 +0800
commite715414cae9b4654b4784dfb924880a0787d1d55 (patch)
treea0772b2a0ef3be4ac03fc608a21ee0b7ccbd167a /dex/backend.go
parent996310cbd484b5ff1ea76068578314d71973770f (diff)
downloaddexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar.gz
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar.bz2
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar.lz
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar.xz
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.tar.zst
dexon-e715414cae9b4654b4784dfb924880a0787d1d55.zip
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.
Diffstat (limited to 'dex/backend.go')
-rw-r--r--dex/backend.go7
1 files changed, 5 insertions, 2 deletions
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.