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 ¶
- Variables
- type API
- func (api *API) TraceBadBlock(ctx context.Context, hash common.Hash, 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)
- type Backend
- type CommonAPI
- func (api *CommonAPI) TraceBlock(ctx context.Context, blob hexutil.Bytes, config *TraceConfig) ([]*txTraceResult, error)
- func (api *CommonAPI) TraceCall(ctx context.Context, args kaiaapi.CallArgs, ...) (interface{}, error)
- func (api *CommonAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error)
- type Context
- type StateReleaseFunc
- type StdTraceConfig
- type TraceConfig
- type Tracer
- func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, err error)
- func (jst *Tracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, ...)
- func (jst *Tracer) CaptureExit(output []byte, gasUsed uint64, err error)
- func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost, ccLeft, ccOpcode uint64, ...)
- func (jst *Tracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, ...)
- func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost, ccLeft, ccOpcode uint64, ...)
- func (jst *Tracer) CaptureTxEnd(restGas uint64)
- func (jst *Tracer) CaptureTxStart(gasLimit uint64)
- func (jst *Tracer) GetResult() (json.RawMessage, error)
- func (jst *Tracer) Stop(err error)
- type UnsafeAPI
- func (api *UnsafeAPI) StandardTraceBadBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *UnsafeAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error)
- func (api *UnsafeAPI) TraceBlockByNumberRange(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (map[uint64]*blockTraceResult, error)
- func (api *UnsafeAPI) TraceBlockFromFile(ctx context.Context, file string, config *TraceConfig) ([]*txTraceResult, error)
- func (api *UnsafeAPI) TraceChain(ctx context.Context, start, end rpc.BlockNumber, config *TraceConfig) (*rpc.Subscription, error)
Constants ¶
This section is empty.
Variables ¶
var (
HeavyAPIRequestLimit int32 = 500 // WARN: changing this value will have no effect. This value is for test. See HeavyDebugRequestLimitFlag
)
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
CommonAPI
}
API contains public methods that are considered "safe" to expose in public RPC.
func (*API) TraceBadBlock ¶
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 ¶
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 ¶
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 ¶
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, readOnly bool, preferDisk bool) (*state.StateDB, StateReleaseFunc, error) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (blockchain.Message, vm.BlockContext, vm.TxContext, *state.StateDB, StateReleaseFunc, error) }
Backend interface provides the common API services with access to necessary functions.
type CommonAPI ¶
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 ¶
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 ¶
func (api *CommonAPI) TraceCall(ctx context.Context, args kaiaapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *TraceConfig) (interface{}, error)
TraceCall lets you trace a given kaia_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 ¶
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 ¶
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 StateReleaseFunc ¶ added in v1.0.3
type StateReleaseFunc func()
StateReleaseFunc is used to deallocate resources held by constructing a historical state for tracing purposes.
type StdTraceConfig ¶
StdTraceConfig holds extra parameters to standard-json trace functions.
type TraceConfig ¶
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) CaptureEnter ¶
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 ¶
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, ccLeft, ccOpcode 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, ccLeft, ccOpcode uint64, scope *vm.ScopeContext, depth int, err error)
CaptureState implements the Tracer interface to trace a single step of VM execution.
func (*Tracer) CaptureTxEnd ¶
func (*Tracer) CaptureTxStart ¶
type UnsafeAPI ¶
type UnsafeAPI struct {
CommonAPI
}
UnsafeAPI contains public methods that are considered "unsafe" to expose in public RPC.
func NewUnsafeAPI ¶
NewUnsafeAPI creates a new UnsafeAPI definition
func (*UnsafeAPI) StandardTraceBadBlockToFile ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.