Skip to content

Commit

Permalink
eth: enable preimage recording when tracing (ethereum#15787)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdetrio authored and mariameda committed Aug 19, 2018
1 parent 8503062 commit b26baac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eth/api_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b26baac

Please sign in to comment.