eth/tracers, core/vm: rename vm.Tracer to vm.EVMLogger for clarity

This commit is contained in:
Martin Holst Swende
2021-11-03 20:58:50 +01:00
parent 2a69a3707e
commit 4e2de461d7
9 changed files with 25 additions and 25 deletions

View File

@ -96,7 +96,7 @@ type rejectedTx struct {
// Apply applies a set of transactions to a pre-state // Apply applies a set of transactions to a pre-state
func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
txs types.Transactions, miningReward int64, txs types.Transactions, miningReward int64,
getTracerFn func(txIndex int, txHash common.Hash) (tracer vm.Tracer, err error)) (*state.StateDB, *ExecutionResult, error) { getTracerFn func(txIndex int, txHash common.Hash) (tracer vm.EVMLogger, err error)) (*state.StateDB, *ExecutionResult, error) {
// Capture errors for BLOCKHASH operation, if we haven't been supplied the // Capture errors for BLOCKHASH operation, if we haven't been supplied the
// required blockhashes // required blockhashes

View File

@ -89,10 +89,10 @@ func Transition(ctx *cli.Context) error {
var ( var (
err error err error
tracer vm.Tracer tracer vm.EVMLogger
baseDir = "" baseDir = ""
) )
var getTracer func(txIndex int, txHash common.Hash) (vm.Tracer, error) var getTracer func(txIndex int, txHash common.Hash) (vm.EVMLogger, error)
// If user specified a basedir, make sure it exists // If user specified a basedir, make sure it exists
if ctx.IsSet(OutputBasedir.Name) { if ctx.IsSet(OutputBasedir.Name) {
@ -119,7 +119,7 @@ func Transition(ctx *cli.Context) error {
prevFile.Close() prevFile.Close()
} }
}() }()
getTracer = func(txIndex int, txHash common.Hash) (vm.Tracer, error) { getTracer = func(txIndex int, txHash common.Hash) (vm.EVMLogger, error) {
if prevFile != nil { if prevFile != nil {
prevFile.Close() prevFile.Close()
} }
@ -131,7 +131,7 @@ func Transition(ctx *cli.Context) error {
return vm.NewJSONLogger(logConfig, traceFile), nil return vm.NewJSONLogger(logConfig, traceFile), nil
} }
} else { } else {
getTracer = func(txIndex int, txHash common.Hash) (tracer vm.Tracer, err error) { getTracer = func(txIndex int, txHash common.Hash) (tracer vm.EVMLogger, err error) {
return nil, nil return nil, nil
} }
} }

View File

@ -116,7 +116,7 @@ func runCmd(ctx *cli.Context) error {
} }
var ( var (
tracer vm.Tracer tracer vm.EVMLogger
debugLogger *vm.StructLogger debugLogger *vm.StructLogger
statedb *state.StateDB statedb *state.StateDB
chainConfig *params.ChainConfig chainConfig *params.ChainConfig

View File

@ -65,7 +65,7 @@ func stateTestCmd(ctx *cli.Context) error {
EnableReturnData: !ctx.GlobalBool(DisableReturnDataFlag.Name), EnableReturnData: !ctx.GlobalBool(DisableReturnDataFlag.Name),
} }
var ( var (
tracer vm.Tracer tracer vm.EVMLogger
debugger *vm.StructLogger debugger *vm.StructLogger
) )
switch { switch {

View File

@ -27,11 +27,11 @@ import (
// Config are the configuration options for the Interpreter // Config are the configuration options for the Interpreter
type Config struct { type Config struct {
Debug bool // Enables debugging Debug bool // Enables debugging
Tracer Tracer // Opcode logger Tracer EVMLogger // Opcode logger
NoRecursion bool // Disables call, callcode, delegate call and create NoRecursion bool // Disables call, callcode, delegate call and create
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls) NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
JumpTable [256]*operation // EVM instruction table, automatically populated if unset JumpTable [256]*operation // EVM instruction table, automatically populated if unset
@ -152,9 +152,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
pc = uint64(0) // program counter pc = uint64(0) // program counter
cost uint64 cost uint64
// copies used by tracer // copies used by tracer
pcCopy uint64 // needed for the deferred Tracer pcCopy uint64 // needed for the deferred EVMLogger
gasCopy uint64 // for Tracer to log gas remaining before execution gasCopy uint64 // for EVMLogger to log gas remaining before execution
logged bool // deferred Tracer should ignore already logged steps logged bool // deferred EVMLogger should ignore already logged steps
res []byte // result of the opcode execution function res []byte // result of the opcode execution function
) )
// Don't move this deferrred function, it's placed before the capturestate-deferred method, // Don't move this deferrred function, it's placed before the capturestate-deferred method,

View File

@ -98,12 +98,12 @@ func (s *StructLog) ErrorString() string {
return "" return ""
} }
// Tracer is used to collect execution traces from an EVM transaction // EVMLogger is used to collect execution traces from an EVM transaction
// execution. CaptureState is called for each step of the VM with the // execution. CaptureState is called for each step of the VM with the
// current VM state. // current VM state.
// Note that reference types are actual VM data structures; make copies // Note that reference types are actual VM data structures; make copies
// if you need to retain them beyond the current call. // if you need to retain them beyond the current call.
type Tracer interface { type EVMLogger interface {
CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)
CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error)
CaptureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) CaptureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)
@ -112,7 +112,7 @@ type Tracer interface {
CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)
} }
// StructLogger is an EVM state logger and implements Tracer. // StructLogger is an EVM state logger and implements EVMLogger.
// //
// StructLogger can capture state based on the given Log configuration and also keeps // 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 // a track record of modified storage which is used in reporting snapshots of the
@ -145,7 +145,7 @@ func (l *StructLogger) Reset() {
l.err = nil l.err = nil
} }
// CaptureStart implements the Tracer interface to initialize the tracing operation. // CaptureStart implements the EVMLogger interface to initialize the tracing operation.
func (l *StructLogger) CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { func (l *StructLogger) CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
} }
@ -210,7 +210,7 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
l.logs = append(l.logs, log) l.logs = append(l.logs, log)
} }
// CaptureFault implements the Tracer interface to trace an execution fault // CaptureFault implements the EVMLogger interface to trace an execution fault
// while running an opcode. // while running an opcode.
func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, depth int, err error) { func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, depth int, err error) {
} }

View File

@ -845,7 +845,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) { func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Context, vmctx vm.BlockContext, statedb *state.StateDB, config *TraceConfig) (interface{}, error) {
// Assemble the structured logger or the JavaScript tracer // Assemble the structured logger or the JavaScript tracer
var ( var (
tracer vm.Tracer tracer vm.EVMLogger
err error err error
txContext = core.NewEVMTxContext(message) txContext = core.NewEVMTxContext(message)
) )

View File

@ -54,7 +54,7 @@ type callTracer struct {
} }
// NewCallTracer returns a native go tracer which tracks // NewCallTracer returns a native go tracer which tracks
// call frames of a tx, and implements vm.Tracer. // call frames of a tx, and implements vm.EVMLogger.
func NewCallTracer() tracers.Tracer { func NewCallTracer() tracers.Tracer {
// First callframe contains tx context info // First callframe contains tx context info
// and is populated on start and end. // and is populated on start and end.

View File

@ -26,10 +26,10 @@ import (
"github.com/ethereum/go-ethereum/eth/tracers/internal/tracers" "github.com/ethereum/go-ethereum/eth/tracers/internal/tracers"
) )
// Tracer interface extends vm.Tracer and additionally // Tracer interface extends vm.EVMLogger and additionally
// allows collecting the tracing result. // allows collecting the tracing result.
type Tracer interface { type Tracer interface {
vm.Tracer vm.EVMLogger
GetResult() (json.RawMessage, error) GetResult() (json.RawMessage, error)
// Stop terminates execution of the tracer at the first opportune moment. // Stop terminates execution of the tracer at the first opportune moment.
Stop(err error) Stop(err error)
@ -41,7 +41,7 @@ var (
) )
// RegisterNativeTracer makes native tracers which adhere // RegisterNativeTracer makes native tracers which adhere
// to the `Tracer` interface available to the rest of the codebase. // to the `EVMLogger` interface available to the rest of the codebase.
// It is typically invoked in the `init()` function, e.g. see the `native/call.go`. // It is typically invoked in the `init()` function, e.g. see the `native/call.go`.
func RegisterNativeTracer(name string, ctor func() Tracer) { func RegisterNativeTracer(name string, ctor func() Tracer) {
nativeTracers[name] = ctor nativeTracers[name] = ctor