diff --git a/eth/filters/trace_api.go b/eth/filters/trace_api.go index 4059cc07eb6c..b2f83d6e6497 100644 --- a/eth/filters/trace_api.go +++ b/eth/filters/trace_api.go @@ -236,9 +236,11 @@ func (api *FilterAPI) NewFullBlocksWithTrace(ctx context.Context, tracerOptsJSON return rpcSub, nil } +var txTraceOpts = []byte(`{"withLog": true}`) + // traceTx traces a transaction with the given contexts. func traceTx(message *core.Message, txCtx *tracers.Context, vmctx vm.BlockContext, chainConfig *params.ChainConfig, statedb *state.StateDB, tracerOpts blocknative.TracerOpts) (*blocknative.Trace, error) { - tracer, err := blocknative.NewTracerWithOpts(tracerOpts) + tracer, err := tracers.DefaultDirectory.New("callTracer", txCtx, txTraceOpts) if err != nil { return nil, err } @@ -248,7 +250,13 @@ func traceTx(message *core.Message, txCtx *tracers.Context, vmctx vm.BlockContex if _, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.GasLimit)); err != nil { return nil, fmt.Errorf("tracing failed: %w", err) } - trace, err := tracer.GetTrace() + traceJSON, err := tracer.GetResult() + if err != nil { + return nil, err + } + + trace := &blocknative.Trace{} + err = json.Unmarshal(traceJSON, trace) if err != nil { return nil, err } @@ -258,9 +266,7 @@ func traceTx(message *core.Message, txCtx *tracers.Context, vmctx vm.BlockContex // traceBlockTx traces a transaction with the given contexts. func traceBlockTx(message *core.Message, txCtx *tracers.Context, vmctx vm.BlockContext, chainConfig *params.ChainConfig, statedb *state.StateDB, tracerOpts blocknative.TracerOpts) (*core.ExecutionResult, *blocknative.Trace, error) { - - tracerOpts.DisableBlockContext = false - tracer, err := blocknative.NewTracerWithOpts(tracerOpts) + tracer, err := tracers.DefaultDirectory.New("callTracer", txCtx, nil) if err != nil { return nil, nil, err } @@ -272,7 +278,13 @@ func traceBlockTx(message *core.Message, txCtx *tracers.Context, vmctx vm.BlockC if err != nil { return result, nil, fmt.Errorf("tracing failed: %w", err) } - trace, err := tracer.GetTrace() + traceJSON, err := tracer.GetResult() + if err != nil { + return nil, nil, err + } + + trace := &blocknative.Trace{} + err = json.Unmarshal(traceJSON, trace) if err != nil { return nil, nil, err } diff --git a/eth/tracers/blocknative/blocknative.go b/eth/tracers/blocknative/blocknative.go index c67fe0ba8894..a772e043382f 100644 --- a/eth/tracers/blocknative/blocknative.go +++ b/eth/tracers/blocknative/blocknative.go @@ -63,6 +63,7 @@ type CallFrame struct { ErrorReason string `json:"errorReason,omitempty"` Calls []CallFrame `json:"calls,omitempty"` Decoded *decoder.CallFrame `json:"decoded,omitempty"` + Logs []CallLog `json:"logs,omitempty"` } // CallLog represents a single log entry from the receipt of a transaction.