native: remove tracers.Context

Signed-off-by: jsvisa <delweng@gmail.com>
pull/30337/head
jsvisa 3 months ago
parent 7670403846
commit 971a5267ac
  1. 2
      eth/tracers/native/4byte.go
  2. 6
      eth/tracers/native/call.go
  3. 12
      eth/tracers/native/call_flat.go
  4. 2
      eth/tracers/native/call_flat_test.go
  5. 4
      eth/tracers/native/mux.go
  6. 2
      eth/tracers/native/noop.go
  7. 2
      eth/tracers/native/prestate.go

@ -56,7 +56,7 @@ type fourByteTracer struct {
// newFourByteTracer returns a native go tracer which collects
// 4 byte-identifiers of a tx, and implements vm.EVMLogger.
func newFourByteTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) {
func newFourByteTracer(_ json.RawMessage) (*tracers.Tracer, error) {
t := &fourByteTracer{
ids: make(map[string]int),
}

@ -125,8 +125,8 @@ type callTracerConfig struct {
// newCallTracer returns a native go tracer which tracks
// call frames of a tx, and implements vm.EVMLogger.
func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
t, err := newCallTracerObject(ctx, cfg)
func newCallTracer(cfg json.RawMessage) (*tracers.Tracer, error) {
t, err := newCallTracerObject(cfg)
if err != nil {
return nil, err
}
@ -143,7 +143,7 @@ func newCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer,
}, nil
}
func newCallTracerObject(ctx *tracers.Context, cfg json.RawMessage) (*callTracer, error) {
func newCallTracerObject(cfg json.RawMessage) (*callTracer, error) {
var config callTracerConfig
if cfg != nil {
if err := json.Unmarshal(cfg, &config); err != nil {

@ -125,7 +125,7 @@ type flatCallTracerConfig struct {
}
// newFlatCallTracer returns a new flatCallTracer.
func newFlatCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
func newFlatCallTracer(cfg json.RawMessage) (*tracers.Tracer, error) {
var config flatCallTracerConfig
if cfg != nil {
if err := json.Unmarshal(cfg, &config); err != nil {
@ -135,12 +135,12 @@ func newFlatCallTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trac
// Create inner call tracer with default configuration, don't forward
// the OnlyTopCall or WithLog to inner for now
t, err := newCallTracerObject(ctx, nil)
t, err := newCallTracerObject(nil)
if err != nil {
return nil, err
}
ft := &flatCallTracer{tracer: t, ctx: ctx, config: config}
ft := &flatCallTracer{tracer: t, config: config}
return &tracers.Tracer{
Hooks: &tracing.Hooks{
OnTxStart: ft.OnTxStart,
@ -211,6 +211,12 @@ func (t *flatCallTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction
}
func (t *flatCallTracer) OnTxEnd(receipt *types.Receipt, err error) {
t.ctx = &tracers.Context{
BlockHash: receipt.BlockHash,
BlockNumber: receipt.BlockNumber,
TxIndex: int(receipt.TransactionIndex),
TxHash: receipt.TxHash,
}
if t.interrupt.Load() {
return
}

@ -31,7 +31,7 @@ import (
)
func TestCallFlatStop(t *testing.T) {
tracer, err := tracers.DefaultDirectory.New("flatCallTracer", &tracers.Context{}, nil)
tracer, err := tracers.DefaultDirectory.New("flatCallTracer", nil)
require.NoError(t, err)
// this error should be returned by GetResult

@ -38,7 +38,7 @@ type muxTracer struct {
}
// newMuxTracer returns a new mux tracer.
func newMuxTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
func newMuxTracer(cfg json.RawMessage) (*tracers.Tracer, error) {
var config map[string]json.RawMessage
if cfg != nil {
if err := json.Unmarshal(cfg, &config); err != nil {
@ -48,7 +48,7 @@ func newMuxTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, e
objects := make([]*tracers.Tracer, 0, len(config))
names := make([]string, 0, len(config))
for k, v := range config {
t, err := tracers.DefaultDirectory.New(k, ctx, v)
t, err := tracers.DefaultDirectory.New(k, v)
if err != nil {
return nil, err
}

@ -35,7 +35,7 @@ func init() {
type noopTracer struct{}
// newNoopTracer returns a new noop tracer.
func newNoopTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) {
func newNoopTracer(_ json.RawMessage) (*tracers.Tracer, error) {
t := &noopTracer{}
return &tracers.Tracer{
Hooks: &tracing.Hooks{

@ -74,7 +74,7 @@ type prestateTracerConfig struct {
DiffMode bool `json:"diffMode"` // If true, this tracer will return state modifications
}
func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Tracer, error) {
func newPrestateTracer(cfg json.RawMessage) (*tracers.Tracer, error) {
var config prestateTracerConfig
if cfg != nil {
if err := json.Unmarshal(cfg, &config); err != nil {

Loading…
Cancel
Save