diff options
author | jm <jm.huang@cobinhood.com> | 2019-01-16 17:32:29 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:21 +0800 |
commit | 1810c3af03d3da56d42f93c4521e33332156dcb6 (patch) | |
tree | 1cbcce4df7b1c5c50486c802abe4d37fb7cd70a6 /dex/api_tracer.go | |
parent | d62272c95d13fd4928e5c14794c25f671a71bd95 (diff) | |
download | dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.gz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.bz2 dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.lz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.xz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.zst dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.zip |
core: vm: extract stateDB and contract out
Extract stateDB and contract out from core/vm/evm to core/vm,
such that other vm type can use the common modules.
Diffstat (limited to 'dex/api_tracer.go')
-rw-r--r-- | dex/api_tracer.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/dex/api_tracer.go b/dex/api_tracer.go index 450f0bfab..c4dbf78a5 100644 --- a/dex/api_tracer.go +++ b/dex/api_tracer.go @@ -32,7 +32,8 @@ import ( "github.com/dexon-foundation/dexon/core/rawdb" "github.com/dexon-foundation/dexon/core/state" "github.com/dexon-foundation/dexon/core/types" - 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/eth/tracers" "github.com/dexon-foundation/dexon/internal/ethapi" "github.com/dexon-foundation/dexon/log" @@ -54,7 +55,7 @@ const ( // TraceConfig holds extra parameters to trace functions. type TraceConfig struct { - *vm.LogConfig + *evm.LogConfig Tracer *string Timeout *string Reexec *uint64 @@ -275,7 +276,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl traced += uint64(len(txs)) } // Generate the next state snapshot fast without tracing - _, _, _, err := api.dex.blockchain.Processor().Process(block, statedb, vm.Config{}) + _, _, _, err := api.dex.blockchain.Processor().Process(block, statedb, evm.Config{}) if err != nil { failed = err break @@ -448,7 +449,7 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, msg, _ := tx.AsMessage(signer) vmctx := core.NewEVMContext(msg, block.Header(), api.dex.blockchain, nil) - vmenv := vm.NewEVM(vmctx, statedb, api.config, vm.Config{}) + vmenv := evm.NewEVM(vmctx, statedb, api.config, evm.Config{}) if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil { failed = err break @@ -512,7 +513,7 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (* if block = api.dex.blockchain.GetBlockByNumber(block.NumberU64() + 1); block == nil { return nil, fmt.Errorf("block #%d not found", block.NumberU64()+1) } - _, _, _, err := api.dex.blockchain.Processor().Process(block, statedb, vm.Config{}) + _, _, _, err := api.dex.blockchain.Processor().Process(block, statedb, evm.Config{}) if err != nil { return nil, err } @@ -561,7 +562,7 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { // Assemble the structured logger or the JavaScript tracer var ( - tracer vm.Tracer + tracer evm.Tracer err error ) switch { @@ -586,13 +587,13 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v defer cancel() case config == nil: - tracer = vm.NewStructLogger(nil) + tracer = evm.NewStructLogger(nil) default: - tracer = vm.NewStructLogger(config.LogConfig) + tracer = evm.NewStructLogger(config.LogConfig) } // Run the transaction with tracing enabled. - vmenv := vm.NewEVM(vmctx, statedb, api.config, vm.Config{Debug: true, Tracer: tracer}) + vmenv := evm.NewEVM(vmctx, statedb, api.config, evm.Config{Debug: true, Tracer: tracer}) ret, gas, failed, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) if err != nil { @@ -600,7 +601,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v } // Depending on the tracer type, format and return the output switch tracer := tracer.(type) { - case *vm.StructLogger: + case *evm.StructLogger: return ðapi.ExecutionResult{ Gas: gas, Failed: failed, @@ -642,7 +643,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree return msg, context, statedb, nil } // Not yet the searched for transaction, execute on top of the current state - vmenv := vm.NewEVM(context, statedb, api.config, vm.Config{}) + vmenv := evm.NewEVM(context, statedb, api.config, evm.Config{}) if _, _, _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas())); err != nil { return nil, vm.Context{}, nil, fmt.Errorf("tx %x failed: %v", tx.Hash(), err) } |