tracers

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: GPL-3.0 Imports: 32 Imported by: 7

Documentation

Overview

Package tracers provides implementation of Tracer that evaluates a Javascript function for each VM execution step.

Source Files

  • tracer.go : implementation of Tracer
  • tracers.go : provides managing functions of tracers
  • api.go : provides private debug API related to trace chain, block and state

Package tracers is a collection of JavaScript transaction tracers.

Index

Constants

This section is empty.

Variables

View Source
var (
	HeavyAPIRequestLimit int32 = 500
)

Functions

This section is empty.

Types

type API added in v1.9.1

type API struct {
	CommonAPI
}

API contains public methods that are considered "safe" to expose in public RPC.

func NewAPI added in v1.9.1

func NewAPI(backend Backend) *API

NewAPI creates a new API definition

func (*API) TraceBadBlock added in v1.9.1

func (api *API) TraceBadBlock(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)

TraceBadBlock returns the structured logs created during the execution of EVM against a block pulled from the pool of bad ones and returns them as a JSON object.

func (*API) TraceBlockByHash added in v1.9.1

func (api *API) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByHash returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*API) TraceBlockByNumber added in v1.9.1

func (api *API) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockByNumber returns the structured logs created during the execution of EVM and returns them as a JSON object.

type Backend added in v1.9.1

type Backend interface {
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
	HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
	BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
	BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error)
	GetTxAndLookupInfo(txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)
	RPCGasCap() *big.Int
	ChainConfig() *params.ChainConfig
	ChainDB() database.DBManager
	Engine() consensus.Engine
	// StateAtBlock returns the state corresponding to the stateroot of the block.
	// N.B: For executing transactions on block N, the required stateRoot is block N-1,
	// so this method should be called with the parent.
	StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base *state.StateDB, checkLive bool, preferDisk bool) (*state.StateDB, error)
	StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (blockchain.Message, vm.BlockContext, vm.TxContext, *state.StateDB, error)
}

Backend interface provides the common API services with access to necessary functions.

type CommonAPI added in v1.12.1

type CommonAPI struct {
	// contains filtered or unexported fields
}

CommonAPI contains - public methods that change behavior depending on `.unsafeTrace` flag. For instance, TraceTransaction and TraceCall may or may not support custom tracers. - private helper methods such as traceTx

func (*CommonAPI) TraceBlock added in v1.12.1

func (api *CommonAPI) TraceBlock(ctx context.Context, blob hexutil.Bytes, config *TraceConfig) ([]*txTraceResult, error)

TraceBlock returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*CommonAPI) TraceCall added in v1.12.1

func (api *CommonAPI) TraceCall(ctx context.Context, args klaytnapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (interface{}, error)

TraceCall lets you trace a given klay_call. It collects the structured logs created during the execution of EVM if the given transaction was added on top of the provided block and returns them as a JSON object.

func (*CommonAPI) TraceTransaction added in v1.12.1

func (api *CommonAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)

TraceTransaction returns the structured logs created during the execution of EVM and returns them as a JSON object.

type Context added in v1.12.0

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 StdTraceConfig added in v1.9.1

type StdTraceConfig struct {
	*vm.LogConfig
	Reexec *uint64
	TxHash common.Hash
}

StdTraceConfig holds extra parameters to standard-json trace functions.

type TraceConfig added in v1.9.1

type TraceConfig struct {
	*vm.LogConfig
	Tracer        *string
	Timeout       *string
	LoggerTimeout *string
	Reexec        *uint64
}

TraceConfig holds extra parameters to trace functions.

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

Tracer provides an implementation of Tracer that evaluates a Javascript function for each VM execution step.

func New

func New(code string, ctx *Context, unsafeTrace bool) (*Tracer, error)

New instantiates a new tracer instance. code specifies either a predefined tracer name or a Javascript snippet, which must evaluate to an expression returning an object with 'step', 'fault' and 'result' functions. However, if unsafeTrace is false, code should specify predefined tracer name, otherwise error is returned.

func (*Tracer) CaptureEnd

func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, err error)

CaptureEnd is called after the call finishes to finalize the tracing.

func (*Tracer) CaptureEnter added in v1.12.0

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

CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).

func (*Tracer) CaptureExit added in v1.12.0

func (jst *Tracer) CaptureExit(output []byte, gasUsed uint64, err error)

CaptureExit is called when EVM exits a scope, even if the scope didn't execute any code.

func (*Tracer) CaptureFault

func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)

CaptureFault implements the Tracer interface to trace an execution fault while running an opcode.

func (*Tracer) CaptureStart

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

CaptureStart implements the Tracer interface to initialize the tracing operation.

func (*Tracer) CaptureState

func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)

CaptureState implements the Tracer interface to trace a single step of VM execution.

func (*Tracer) CaptureTxEnd added in v1.12.0

func (jst *Tracer) CaptureTxEnd(restGas uint64)

func (*Tracer) CaptureTxStart added in v1.12.0

func (jst *Tracer) CaptureTxStart(gasLimit uint64)

func (*Tracer) GetResult

func (jst *Tracer) GetResult() (json.RawMessage, error)

GetResult calls the Javascript 'result' function and returns its value, or any accumulated error

func (*Tracer) Stop

func (jst *Tracer) Stop(err error)

Stop terminates execution of the tracer at the first opportune moment.

type UnsafeAPI added in v1.12.1

type UnsafeAPI struct {
	CommonAPI
}

UnsafeAPI contains public methods that are considered "unsafe" to expose in public RPC.

func NewUnsafeAPI added in v1.12.1

func NewUnsafeAPI(backend Backend) *UnsafeAPI

NewUnsafeAPI creates a new UnsafeAPI definition

func (*UnsafeAPI) StandardTraceBadBlockToFile added in v1.12.1

func (api *UnsafeAPI) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)

StandardTraceBadBlockToFile dumps the structured logs created during the execution of EVM against a block pulled from the pool of bad ones to the local file system and returns a list of files to the caller.

func (*UnsafeAPI) StandardTraceBlockToFile added in v1.12.1

func (api *UnsafeAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)

StandardTraceBlockToFile dumps the structured logs created during the execution of EVM to the local file system and returns a list of files to the caller.

func (*UnsafeAPI) TraceBlockByNumberRange added in v1.12.1

func (api *UnsafeAPI) TraceBlockByNumberRange(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (map[uint64]*blockTraceResult, error)

TraceBlockByNumberRange returns the ranged blocks tracing results TODO-tracer: limit the result by the size of the return

func (*UnsafeAPI) TraceBlockFromFile added in v1.12.1

func (api *UnsafeAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)

TraceBlockFromFile returns the structured logs created during the execution of EVM and returns them as a JSON object.

func (*UnsafeAPI) TraceChain added in v1.12.1

func (api *UnsafeAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)

TraceChain returns the structured logs created during the execution of EVM between two blocks (excluding start) and returns them as a JSON object.

Directories

Path Synopsis
internal
tracers
Code generated for package tracers by go-bindata DO NOT EDIT.
Code generated for package tracers by go-bindata DO NOT EDIT.

Jump to

Keyboard shortcuts

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