Add tracer logs

This commit is contained in:
greg 2018-06-08 14:08:04 -04:00
parent ede486a68a
commit 3f957e6ad1
2 changed files with 14 additions and 0 deletions

View file

@ -532,6 +532,11 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
// TraceTransaction returns the structured logs created during the execution of EVM // TraceTransaction returns the structured logs created during the execution of EVM
// and returns them as a JSON object. // and returns them as a JSON object.
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) { func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
fmt.Println("\n\n\t[API LOG]", api, "\n")
fmt.Printf("%+v\n", api.config)
fmt.Println("\n")
fmt.Printf("%+v\n", api.eth)
fmt.Println("\n")
// Retrieve the transaction and assemble its EVM context // Retrieve the transaction and assemble its EVM context
tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash) tx, blockHash, _, index := core.GetTransaction(api.eth.ChainDb(), hash)
if tx == nil { if tx == nil {
@ -546,6 +551,9 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha
return nil, err return nil, err
} }
// Trace the transaction and return // Trace the transaction and return
//fmt.Println("\n\n\t\tRETURN")
//fmt.Println(api.traceTx(ctx, msg, vmctx, statedb, config))
//fmt.Println("RETURN FINISHED")
return api.traceTx(ctx, msg, vmctx, statedb, config) return api.traceTx(ctx, msg, vmctx, statedb, config)
} }

View file

@ -496,6 +496,9 @@ func wrapError(context string, err error) error {
// CaptureStart implements the Tracer interface to initialize the tracing operation. // CaptureStart implements the Tracer interface to initialize the tracing operation.
func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error { func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {
//fmt.Println("\n\n\t\t type: ", reflect.TypeOf(input))
fmt.Println("\t\t [TRACER INPUT]:", input)
fmt.Println("\t\t [TRACER INPUT STRING]:", string(input[:len(input)]), "\n\n")
jst.ctx["type"] = "CALL" jst.ctx["type"] = "CALL"
if create { if create {
jst.ctx["type"] = "CREATE" jst.ctx["type"] = "CREATE"
@ -564,6 +567,9 @@ func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost
// CaptureEnd is called after the call finishes to finalize the tracing. // CaptureEnd is called after the call finishes to finalize the tracing.
func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
//fmt.Println("\n\n\t\t", reflect.TypeOf(output))
fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)])
fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n")
jst.ctx["output"] = output jst.ctx["output"] = output
jst.ctx["gasUsed"] = gasUsed jst.ctx["gasUsed"] = gasUsed
jst.ctx["time"] = t.String() jst.ctx["time"] = t.String()