structlogger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteLogs

func WriteLogs(writer io.Writer, logs []*types.Log)

WriteLogs writes vm logs in a readable format to the given writer

func WriteTrace

func WriteTrace(writer io.Writer, logs []StructLog)

WriteTrace writes a formatted trace to the given writer

Types

type Storage

type Storage map[types.Hash]types.Hash

Storage represents a contract's storage.

func (Storage) Copy

func (s Storage) Copy() Storage

Copy duplicates the current storage.

type StructLog

type StructLog struct {
	Pc            uint64                    `json:"pc"`
	Op            int                       `json:"op"`
	Gas           uint64                    `json:"gas"`
	GasCost       uint64                    `json:"gasCost"`
	Memory        []byte                    `json:"memory"`
	MemorySize    int                       `json:"memSize"`
	Stack         []*big.Int                `json:"stack"`
	ReturnData    []byte                    `json:"returnData"`
	Storage       map[types.Hash]types.Hash `json:"-"`
	Depth         int                       `json:"depth"`
	RefundCounter uint64                    `json:"refund"`
	Err           error                     `json:"-"`
	OpName        string                    `json:"opName"`
	ErrorString   string                    `json:"error"`
}

StructLog is emitted to the EVM each cycle and lists information about the current internal state prior to the execution of the statement.

func (*StructLog) GetErrorString

func (s *StructLog) GetErrorString() string

GetErrorString formats the log's error as a string.

func (*StructLog) GetOpName

func (s *StructLog) GetOpName() string

GetOpName formats the operand name in a human-readable format.

func (StructLog) MarshalJSON

func (s StructLog) MarshalJSON() ([]byte, error)

type StructLogger

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

StructLogger is an EVM state logger and implements EVMLogger.

StructLogger can capture state based on the given Log configuration and also keeps a track record of modified storage which is used in reporting snapshots of the contract their storage.

func NewStructLogger

func NewStructLogger(txn runtime.Txn) *StructLogger

NewStructLogger returns a new logger

func (*StructLogger) CaptureEnd

func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)

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

func (*StructLogger) CaptureEnter

func (l *StructLogger) CaptureEnter(opCode int, from, to types.Address,
	input []byte, gas uint64, value *big.Int)

func (*StructLogger) CaptureExit

func (l *StructLogger) CaptureExit(output []byte, gasUsed uint64, err error)

func (*StructLogger) CaptureFault

func (l *StructLogger) CaptureFault(ctx *runtime.ScopeContext, pc uint64, opCode int, gas, cost uint64,
	depth int, err error)

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

func (*StructLogger) CaptureStart

func (l *StructLogger) CaptureStart(txn runtime.Txn, from, to types.Address,
	create bool, input []byte, gas uint64, value *big.Int)

CaptureStart implements the EVMLogger interface to initialize the tracing operation.

func (*StructLogger) CaptureState

func (l *StructLogger) CaptureState(
	ctx *runtime.ScopeContext,
	pc uint64,
	opCode int,
	gas, cost uint64,
	rData []byte,
	depth int,
	err error,
)

CaptureState logs a new structured log message and pushes it out to the environment

CaptureState also tracks SLOAD/SSTORE ops to track storage change.

func (*StructLogger) Error

func (l *StructLogger) Error() error

Error returns the VM error captured by the trace.

func (*StructLogger) Output

func (l *StructLogger) Output() []byte

Output returns the VM return value captured by the trace.

func (*StructLogger) Reset

func (l *StructLogger) Reset()

Reset clears the data held by the logger.

func (*StructLogger) StructLogs

func (l *StructLogger) StructLogs() []*StructLog

StructLogs returns the captured log entries.

Jump to

Keyboard shortcuts

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