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 ¶
- type API
- func (api *API) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *API) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *API) TraceBadBlock(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)
- func (api *API) TraceBlock(ctx context.Context, blob hexutil.Bytes, config *TraceConfig) ([]*txTraceResult, error)
- func (api *API) TraceBlockByHash(ctx context.Context, hash common.Hash, config *TraceConfig) ([]*txTraceResult, error)
- func (api *API) TraceBlockByNumber(ctx context.Context, number rpc.BlockNumber, config *TraceConfig) ([]*txTraceResult, error)
- func (api *API) TraceBlockByNumberRange(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (map[uint64]*blockTraceResult, error)
- func (api *API) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)
- func (api *API) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)
- func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)
- type Backend
- type StdTraceConfig
- type TraceConfig
- type Tracer
- func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error
- func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, ...) error
- func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, ...) error
- func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, ...) error
- func (jst *Tracer) GetResult() (json.RawMessage, error)
- func (jst *Tracer) Stop(err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶ added in v1.9.1
type API struct {
// contains filtered or unexported fields
}
API is the collection of tracing APIs exposed over the private debugging endpoint.
func NewAPI ¶ added in v1.9.1
NewAPI creates a new API definition for the tracing methods of the CN service, allowing both predefined tracers and Javascript snippet based tracing.
func NewAPIUnsafeDisabled ¶ added in v1.10.0
NewAPIUnsafeDisabled creates a new API definition for the tracing methods of the CN service, only allowing predefined tracers.
func (*API) StandardTraceBadBlockToFile ¶ added in v1.9.1
func (api *API) 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 (*API) StandardTraceBlockToFile ¶ added in v1.9.1
func (api *API) 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 (*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) TraceBlock ¶ added in v1.9.1
func (api *API) 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 (*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.
func (*API) TraceBlockByNumberRange ¶ added in v1.9.1
func (api *API) 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 (*API) TraceBlockFromFile ¶ added in v1.9.1
func (api *API) 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 (*API) TraceChain ¶ added in v1.9.1
func (api *API) 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.
func (*API) TraceTransaction ¶ added in v1.9.1
func (api *API) 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 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.Context, *state.StateDB, error) }
Backend interface provides the common API services with access to necessary functions.
type StdTraceConfig ¶ added in v1.9.1
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 ¶
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 ¶
CaptureEnd is called after the call finishes to finalize the tracing.
func (*Tracer) CaptureFault ¶
func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error
CaptureFault implements the Tracer interface to trace an execution fault while running an opcode.
func (*Tracer) CaptureStart ¶
func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error
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, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error
CaptureState implements the Tracer interface to trace a single step of VM execution.