Skip to content

Commit

Permalink
l2geth: add txHash to txTraceResult
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlee42 committed Mar 28, 2024
1 parent 232778e commit 4035339
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions l2geth/eth/api_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()}
}
}()
}
Expand Down

0 comments on commit 4035339

Please sign in to comment.