diff options
author | cdetrio <cdetrio@gmail.com> | 2018-01-02 19:49:17 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-01-02 19:49:17 +0800 |
commit | c495bca4adef24811e92f9dfa5149b32ac81ef65 (patch) | |
tree | 30539eb35ad797cd1b33a8b69e626a30267fc765 | |
parent | 413cc5b0c80733478f1b94a5e9a509fc7bd3fa4d (diff) | |
download | dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar.gz dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar.bz2 dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar.lz dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar.xz dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.tar.zst dexon-c495bca4adef24811e92f9dfa5149b32ac81ef65.zip |
eth: enable preimage recording when tracing (#15787)
-rw-r--r-- | eth/api_tracer.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 0d0e2a73c..8ad664e06 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -667,12 +667,15 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v tracer = vm.NewStructLogger(config.LogConfig) } // Run the transaction with tracing enabled. - vmenv := vm.NewEVM(vmctx, statedb, api.config, vm.Config{Debug: true, Tracer: tracer}) + vmenv := vm.NewEVM(vmctx, statedb, api.config, vm.Config{Debug: true, Tracer: tracer, EnablePreimageRecording: true}) ret, gas, failed, err := core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas())) if err != nil { return nil, fmt.Errorf("tracing failed: %v", err) } + if err := core.WritePreimages(api.eth.ChainDb(), vmctx.BlockNumber.Uint64(), statedb.Preimages()); err != nil { + return nil, fmt.Errorf("Error writing preimage from trace: %v", err) + } // Depending on the tracer type, format and return the output switch tracer := tracer.(type) { case *vm.StructLogger: |