tracers

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tracers is a manager for transaction tracing engines.

Index

Constants

View Source
const (
	TracerAccessList = "access_list"
	TracerJSON       = "json"
	TracerStruct     = "struct"
	TracerMarkdown   = "markdown"
)

Variables

This section is empty.

Functions

func NewTracer

func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.EVMLogger

NewTracer creates a new Logger tracer to collect execution traces from an EVM transaction.

func RegisterLookup

func RegisterLookup(wildcard bool, lookup lookupFunc)

RegisterLookup registers a method as a lookup for tracers, meaning that users can invoke a named tracer through that lookup. If 'wildcard' is true, then the lookup will be placed last. This is typically meant for interpreted engines (js) which can evaluate dynamic user-supplied code.

Types

type Context

type Context struct {
	BlockHash common.Hash // Hash of the block the tx is contained within (zero if dangling tx or call)
	TxIndex   int         // Index of the transaction within a block (zero if dangling tx or call)
	TxHash    common.Hash // Hash of the transaction being traced (zero if dangling call)
}

Context contains some contextual infos for a transaction execution that is not available from within the EVM object.

type ExecutionResult

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value

type NoOpTracer

type NoOpTracer struct{}

NoOpTracer is an empty implementation of vm.Tracer interface

func NewNoOpTracer

func NewNoOpTracer() *NoOpTracer

NewNoOpTracer creates a no-op vm.Tracer

func (NoOpTracer) CaptureEnd

func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error)

CaptureEnd implements vm.Tracer interface

func (NoOpTracer) CaptureEnter

func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

CaptureEnter implements vm.Tracer interface

func (NoOpTracer) CaptureExit

func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error)

CaptureExit implements vm.Tracer interface

func (NoOpTracer) CaptureFault

func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)

CaptureFault implements vm.Tracer interface

func (NoOpTracer) CaptureStart

func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)

CaptureStart implements vm.Tracer interface

func (NoOpTracer) CaptureState

func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error)

CaptureState implements vm.Tracer interface

func (NoOpTracer) CaptureTxEnd

func (dt NoOpTracer) CaptureTxEnd(restGas uint64)

CaptureTxEnd implements vm.Tracer interface

func (NoOpTracer) CaptureTxStart

func (dt NoOpTracer) CaptureTxStart(gasLimit uint64)

CaptureTxStart implements vm.Tracer interface

type StructLogRes

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   string             `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode. Taken from go-ethereum

func FormatLogs

func FormatLogs(logs []logger.StructLog) []StructLogRes

FormatLogs formats EVM returned structured logs for json output

type TraceConfig

type TraceConfig struct {
	*logger.Config
	Tracer  *string
	Timeout *string
	Reexec  *uint64
	// Config specific to given tracer. Note struct logger
	// config are historically embedded in main object.
	TracerConfig json.RawMessage
}

type Tracer

type Tracer interface {
	vm.EVMLogger
	GetResult() (json.RawMessage, error)
	// Stop terminates execution of the tracer at the first opportune moment.
	Stop(err error)
}

Tracer interface extends vm.EVMLogger and additionally allows collecting the tracing result.

func New

func New(code string, ctx *Context, cfg json.RawMessage) (Tracer, error)

New returns a new instance of a tracer, by iterating through the registered lookups.

type TxTraceResult

type TxTraceResult struct {
	Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
	Error  string      `json:"error,omitempty"`  // Trace failure produced by the tracer
}

TxTraceResult is the result of a single transaction trace during a block trace.

type TxTraceTask

type TxTraceTask struct {
	Index int // Transaction offset in the block
}

TxTraceTask represents a single transaction trace task when an entire block is being traced.

Directories

Path Synopsis
js
internal/tracers
Package tracers contains the actual JavaScript tracer assets.
Package tracers contains the actual JavaScript tracer assets.
Package native is a collection of tracers written in go.
Package native is a collection of tracers written in go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL