diff --git a/l2geth/eth/api_tracer.go b/l2geth/eth/api_tracer.go index d3c3030c7705..0915dda3f272 100755 --- a/l2geth/eth/api_tracer.go +++ b/l2geth/eth/api_tracer.go @@ -72,6 +72,7 @@ type StdTraceConfig struct { // txTraceResult is the result of a single transaction trace. type txTraceResult struct { + TxHash common.Hash `json:"txHash"` // transaction hash Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer Error string `json:"error,omitempty"` // Trace failure produced by the tracer } @@ -209,13 +210,13 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl res, err := api.traceTx(ctx, msg, vmctx, task.statedb, config) if err != nil { - task.results[i] = &txTraceResult{Error: err.Error()} + task.results[i] = &txTraceResult{Error: err.Error(), TxHash: tx.Hash()} log.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err) break } // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect task.statedb.Finalise(api.eth.blockchain.Config().IsEIP158(task.block.Number())) - task.results[i] = &txTraceResult{Result: res} + task.results[i] = &txTraceResult{Result: res, TxHash: tx.Hash()} } // Stream the result back to the user or abort on teardown select { @@ -477,15 +478,16 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block, // Fetch and execute the next transaction trace tasks for task := range jobs { - msg, _ := txs[task.index].AsMessage(signer) + tx := txs[task.index] + msg, _ := tx.AsMessage(signer) vmctx := core.NewEVMContext(msg, block.Header(), api.eth.blockchain, nil) res, err := api.traceTx(ctx, msg, vmctx, task.statedb, config) if err != nil { - results[task.index] = &txTraceResult{Error: err.Error()} + results[task.index] = &txTraceResult{Error: err.Error(), TxHash: tx.Hash()} continue } - results[task.index] = &txTraceResult{Result: res} + results[task.index] = &txTraceResult{Result: res, TxHash: tx.Hash()} } }() }