mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-13 15:33:47 +00:00
rename tracer methods to On pattern
This commit is contained in:
parent
37ce159500
commit
8b3cddabb5
13 changed files with 142 additions and 193 deletions
|
|
@ -178,8 +178,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
res []byte // result of the opcode execution function
|
res []byte // result of the opcode execution function
|
||||||
debug = in.evm.Config.Tracer != nil
|
debug = in.evm.Config.Tracer != nil
|
||||||
)
|
)
|
||||||
// Don't move this deferred function, it's placed before the capturestate-deferred method,
|
// Don't move this deferred function, it's placed before the OnOpcode-deferred method,
|
||||||
// so that it gets executed _after_: the capturestate needs the stacks before
|
// so that it gets executed _after_: the OnOpcode needs the stacks before
|
||||||
// they are returned to the pools
|
// they are returned to the pools
|
||||||
defer func() {
|
defer func() {
|
||||||
returnStack(stack)
|
returnStack(stack)
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,13 @@ func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
|
||||||
t := &NoopTracer{}
|
t := &NoopTracer{}
|
||||||
return &Tracer{
|
return &Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
OnFault: t.CaptureFault,
|
OnFault: t.OnFault,
|
||||||
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.OnKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBalanceChange: t.OnBalanceChange,
|
OnBalanceChange: t.OnBalanceChange,
|
||||||
OnNonceChange: t.OnNonceChange,
|
OnNonceChange: t.OnNonceChange,
|
||||||
|
|
@ -57,41 +57,26 @@ func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
func (t *NoopTracer) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
func (t *NoopTracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
func (t *NoopTracer) OnFault(pc uint64, op tracing.OpCode, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
|
||||||
func (t *NoopTracer) CaptureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
func (t *NoopTracer) OnKeccakPreimage(hash common.Hash, data []byte) {}
|
||||||
func (t *NoopTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
|
||||||
func (t *NoopTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// CaptureKeccakPreimage is called during the KECCAK256 opcode.
|
|
||||||
func (t *NoopTracer) CaptureKeccakPreimage(hash common.Hash, data []byte) {}
|
|
||||||
|
|
||||||
// OnGasChange is called when gas is either consumed or refunded.
|
|
||||||
func (t *NoopTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {}
|
func (t *NoopTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {}
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
func (t *NoopTracer) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
func (t *NoopTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
func (t *NoopTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
// execute any code.
|
|
||||||
func (t *NoopTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*NoopTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (*NoopTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*NoopTracer) CaptureTxEnd(receipt *types.Receipt, err error) {}
|
func (*NoopTracer) OnTxEnd(receipt *types.Receipt, err error) {}
|
||||||
|
|
||||||
func (*NoopTracer) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
|
func (*NoopTracer) OnBalanceChange(a common.Address, prev, new *big.Int, reason tracing.BalanceChangeReason) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,21 +224,21 @@ func newJsTracer(code string, ctx *directory.Context, cfg json.RawMessage) (*dir
|
||||||
|
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
OnFault: t.CaptureFault,
|
OnFault: t.OnFault,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureTxStart implements the Tracer interface and is invoked at the beginning of
|
// OnTxStart implements the Tracer interface and is invoked at the beginning of
|
||||||
// transaction processing.
|
// transaction processing.
|
||||||
func (t *jsTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *jsTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
t.env = env
|
t.env = env
|
||||||
// Need statedb access for db object
|
// Need statedb access for db object
|
||||||
db := &dbObj{db: env.StateDB, vm: t.vm, toBig: t.toBig, toBuf: t.toBuf, fromBuf: t.fromBuf}
|
db := &dbObj{db: env.StateDB, vm: t.vm, toBig: t.toBig, toBuf: t.toBuf, fromBuf: t.fromBuf}
|
||||||
|
|
@ -257,9 +257,9 @@ func (t *jsTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction,
|
||||||
t.ctx["gasPrice"] = gasPriceBig
|
t.ctx["gasPrice"] = gasPriceBig
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureTxEnd implements the Tracer interface and is invoked at the end of
|
// OnTxEnd implements the Tracer interface and is invoked at the end of
|
||||||
// transaction processing.
|
// transaction processing.
|
||||||
func (t *jsTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *jsTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Don't override vm error
|
// Don't override vm error
|
||||||
if _, ok := t.ctx["error"]; !ok {
|
if _, ok := t.ctx["error"]; !ok {
|
||||||
|
|
@ -270,8 +270,8 @@ func (t *jsTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
||||||
t.ctx["gasUsed"] = t.vm.ToValue(receipt.GasUsed)
|
t.ctx["gasUsed"] = t.vm.ToValue(receipt.GasUsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureStart implements the Tracer interface to initialize the tracing operation.
|
// onStart implements the Tracer interface to initialize the tracing operation.
|
||||||
func (t *jsTracer) captureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
func (t *jsTracer) onStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||||
cancel := func(err error) {
|
cancel := func(err error) {
|
||||||
t.err = err
|
t.err = err
|
||||||
t.env.VM.Cancel()
|
t.env.VM.Cancel()
|
||||||
|
|
@ -307,8 +307,8 @@ func (t *jsTracer) captureStart(from common.Address, to common.Address, create b
|
||||||
t.ctx["value"] = valueBig
|
t.ctx["value"] = valueBig
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the Tracer interface to trace a single step of VM execution.
|
// OnOpcode implements the Tracer interface to trace a single step of VM execution.
|
||||||
func (t *jsTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (t *jsTracer) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
if !t.traceStep {
|
if !t.traceStep {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -332,8 +332,8 @@ func (t *jsTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureFault implements the Tracer interface to trace an execution fault
|
// OnFault implements the Tracer interface to trace an execution fault
|
||||||
func (t *jsTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
func (t *jsTracer) OnFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||||
if t.err != nil {
|
if t.err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -344,8 +344,8 @@ func (t *jsTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
// onEnd is called after the call finishes to finalize the tracing.
|
||||||
func (t *jsTracer) captureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *jsTracer) onEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.ctx["error"] = t.vm.ToValue(err.Error())
|
t.ctx["error"] = t.vm.ToValue(err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -357,10 +357,10 @@ func (t *jsTracer) captureEnd(output []byte, gasUsed uint64, err error, reverted
|
||||||
t.ctx["output"] = outputVal
|
t.ctx["output"] = outputVal
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
// OnEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||||
func (t *jsTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *jsTracer) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.captureStart(from, to, vm.OpCode(typ) == vm.CREATE, input, gas, value)
|
t.onStart(from, to, vm.OpCode(typ) == vm.CREATE, input, gas, value)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !t.traceFrame {
|
if !t.traceFrame {
|
||||||
|
|
@ -385,11 +385,11 @@ func (t *jsTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Addre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
// OnExit is called when EVM exits a scope, even if the scope didn't
|
||||||
// execute any code.
|
// execute any code.
|
||||||
func (t *jsTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *jsTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.captureEnd(output, gasUsed, err, reverted)
|
t.onEnd(output, gasUsed, err, reverted)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !t.traceFrame {
|
if !t.traceFrame {
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ type noop struct{}
|
||||||
func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
|
func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
|
||||||
t := &noop{}
|
t := &noop{}
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
OnFault: t.CaptureFault,
|
OnFault: t.OnFault,
|
||||||
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.OnKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBlockchainInit: t.OnBlockchainInit,
|
OnBlockchainInit: t.OnBlockchainInit,
|
||||||
OnBlockStart: t.OnBlockStart,
|
OnBlockStart: t.OnBlockStart,
|
||||||
|
|
@ -45,38 +45,24 @@ func newNoopTracer(_ json.RawMessage) (*tracing.Hooks, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
func (t *noop) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
func (t *noop) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
func (t *noop) OnFault(pc uint64, op tracing.OpCode, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
|
||||||
func (t *noop) CaptureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
func (t *noop) OnKeccakPreimage(hash common.Hash, data []byte) {}
|
||||||
func (t *noop) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
|
||||||
|
func (t *noop) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
func (t *noop) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
func (t *noop) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, _ tracing.OpContext, depth int, err error) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureKeccakPreimage is called during the KECCAK256 opcode.
|
func (t *noop) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
func (t *noop) CaptureKeccakPreimage(hash common.Hash, data []byte) {}
|
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
|
||||||
func (t *noop) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
func (t *noop) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
// execute any code.
|
|
||||||
func (t *noop) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *noop) CaptureTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *noop) CaptureTxEnd(receipt *types.Receipt, err error) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *noop) OnBlockStart(ev tracing.BlockEvent) {
|
func (t *noop) OnBlockStart(ev tracing.BlockEvent) {
|
||||||
|
|
|
||||||
|
|
@ -135,12 +135,12 @@ func NewAccessListTracer(acl types.AccessList, from, to common.Address, precompi
|
||||||
|
|
||||||
func (a *AccessListTracer) Hooks() *tracing.Hooks {
|
func (a *AccessListTracer) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnOpcode: a.CaptureState,
|
OnOpcode: a.OnOpcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState captures all opcodes that touch storage or addresses and adds them to the accesslist.
|
// OnOpcode captures all opcodes that touch storage or addresses and adds them to the accesslist.
|
||||||
func (a *AccessListTracer) CaptureState(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (a *AccessListTracer) OnOpcode(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
stackData := scope.StackData()
|
stackData := scope.StackData()
|
||||||
stackLen := len(stackData)
|
stackLen := len(stackData)
|
||||||
op := vm.OpCode(opcode)
|
op := vm.OpCode(opcode)
|
||||||
|
|
|
||||||
|
|
@ -136,10 +136,10 @@ func NewStructLogger(cfg *Config) *StructLogger {
|
||||||
|
|
||||||
func (l *StructLogger) Hooks() *tracing.Hooks {
|
func (l *StructLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: l.CaptureTxStart,
|
OnTxStart: l.OnTxStart,
|
||||||
OnTxEnd: l.CaptureTxEnd,
|
OnTxEnd: l.OnTxEnd,
|
||||||
OnExit: l.CaptureExit,
|
OnExit: l.OnExit,
|
||||||
OnOpcode: l.CaptureState,
|
OnOpcode: l.OnOpcode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,10 +159,10 @@ func (l *StructLogger) Reset() {
|
||||||
l.err = nil
|
l.err = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState logs a new structured log message and pushes it out to the environment
|
// OnOpcode logs a new structured log message and pushes it out to the environment
|
||||||
//
|
//
|
||||||
// CaptureState also tracks SLOAD/SSTORE ops to track storage change.
|
// OnOpcode also tracks SLOAD/SSTORE ops to track storage change.
|
||||||
func (l *StructLogger) CaptureState(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (l *StructLogger) OnOpcode(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
// If tracing was interrupted, set the error and stop
|
// If tracing was interrupted, set the error and stop
|
||||||
if l.interrupt.Load() {
|
if l.interrupt.Load() {
|
||||||
return
|
return
|
||||||
|
|
@ -227,8 +227,8 @@ func (l *StructLogger) CaptureState(pc uint64, opcode tracing.OpCode, gas, cost
|
||||||
l.logs = append(l.logs, log)
|
l.logs = append(l.logs, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called a call frame finishes processing.
|
// OnExit is called a call frame finishes processing.
|
||||||
func (l *StructLogger) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (l *StructLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth != 0 {
|
if depth != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -268,11 +268,11 @@ func (l *StructLogger) Stop(err error) {
|
||||||
l.interrupt.Store(true)
|
l.interrupt.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *StructLogger) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (l *StructLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
l.env = env
|
l.env = env
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *StructLogger) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Don't override vm error
|
// Don't override vm error
|
||||||
if l.err == nil {
|
if l.err == nil {
|
||||||
|
|
@ -358,19 +358,19 @@ func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger {
|
||||||
|
|
||||||
func (t *mdLogger) Hooks() *tracing.Hooks {
|
func (t *mdLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
OnFault: t.CaptureFault,
|
OnFault: t.OnFault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *mdLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
t.env = env
|
t.env = env
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *mdLogger) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
if depth != 0 {
|
if depth != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -391,15 +391,15 @@ func (t *mdLogger) CaptureEnter(depth int, typ tracing.OpCode, from common.Addre
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *mdLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
fmt.Fprintf(t.out, "\nOutput: `%#x`\nConsumed gas: `%d`\nError: `%v`\n",
|
fmt.Fprintf(t.out, "\nOutput: `%#x`\nConsumed gas: `%d`\nError: `%v`\n",
|
||||||
output, gasUsed, err)
|
output, gasUsed, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState also tracks SLOAD/SSTORE ops to track storage change.
|
// OnOpcode also tracks SLOAD/SSTORE ops to track storage change.
|
||||||
func (t *mdLogger) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (t *mdLogger) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
stack := scope.StackData()
|
stack := scope.StackData()
|
||||||
fmt.Fprintf(t.out, "| %4d | %10v | %3d |", pc, op, cost)
|
fmt.Fprintf(t.out, "| %4d | %10v | %3d |", pc, op, cost)
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ func (t *mdLogger) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *mdLogger) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
func (t *mdLogger) OnFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||||
fmt.Fprintf(t.out, "\nError: at pc=%d, op=%v: %v\n", pc, op, err)
|
fmt.Fprintf(t.out, "\nError: at pc=%d, op=%v: %v\n", pc, op, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,20 +47,19 @@ func NewJSONLogger(cfg *Config, writer io.Writer) *JSONLogger {
|
||||||
|
|
||||||
func (l *JSONLogger) Hooks() *tracing.Hooks {
|
func (l *JSONLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
OnTxStart: l.CaptureTxStart,
|
OnTxStart: l.OnTxStart,
|
||||||
OnExit: l.CaptureExit,
|
OnExit: l.OnExit,
|
||||||
OnOpcode: l.CaptureState,
|
OnOpcode: l.OnOpcode,
|
||||||
OnFault: l.CaptureFault,
|
OnFault: l.OnFault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *JSONLogger) CaptureFault(pc uint64, op tracing.OpCode, gas uint64, cost uint64, scope tracing.OpContext, depth int, err error) {
|
func (l *JSONLogger) OnFault(pc uint64, op tracing.OpCode, gas uint64, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||||
// TODO: Add rData to this interface as well
|
// TODO: Add rData to this interface as well
|
||||||
l.CaptureState(pc, op, gas, cost, scope, nil, depth, err)
|
l.OnOpcode(pc, op, gas, cost, scope, nil, depth, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState outputs state information on the logger.
|
func (l *JSONLogger) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
func (l *JSONLogger) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
|
||||||
memory := scope.MemoryData()
|
memory := scope.MemoryData()
|
||||||
stack := scope.StackData()
|
stack := scope.StackData()
|
||||||
|
|
||||||
|
|
@ -86,8 +85,7 @@ func (l *JSONLogger) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64
|
||||||
l.encoder.Encode(log)
|
l.encoder.Encode(log)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnd is triggered at end of execution.
|
func (l *JSONLogger) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
func (l *JSONLogger) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
if depth > 0 {
|
if depth > 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +101,6 @@ func (l *JSONLogger) CaptureExit(depth int, output []byte, gasUsed uint64, err e
|
||||||
l.encoder.Encode(endLog{common.Bytes2Hex(output), math.HexOrDecimal64(gasUsed), errMsg})
|
l.encoder.Encode(endLog{common.Bytes2Hex(output), math.HexOrDecimal64(gasUsed), errMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *JSONLogger) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (l *JSONLogger) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
l.env = env
|
l.env = env
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,7 @@ func TestStoreCapture(t *testing.T) {
|
||||||
)
|
)
|
||||||
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x0, byte(vm.SSTORE)}
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x0, byte(vm.SSTORE)}
|
||||||
var index common.Hash
|
var index common.Hash
|
||||||
logger.CaptureTxStart(env.GetVMContext(), nil, common.Address{})
|
logger.OnTxStart(env.GetVMContext(), nil, common.Address{})
|
||||||
logger.CaptureStart(common.Address{}, contract.Address(), false, nil, 0, nil)
|
|
||||||
_, err := env.Interpreter().Run(contract, []byte{}, false)
|
_, err := env.Interpreter().Run(contract, []byte{}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ type fourByteTracer struct {
|
||||||
ids map[string]int // ids aggregates the 4byte ids found
|
ids map[string]int // ids aggregates the 4byte ids found
|
||||||
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
interrupt atomic.Bool // Atomic flag to signal execution interruption
|
||||||
reason error // Textual reason for the interruption
|
reason error // Textual reason for the interruption
|
||||||
activePrecompiles []common.Address // Updated on CaptureStart based on given rules
|
activePrecompiles []common.Address // Updated on tx start based on given rules
|
||||||
}
|
}
|
||||||
|
|
||||||
// newFourByteTracer returns a native go tracer which collects
|
// newFourByteTracer returns a native go tracer which collects
|
||||||
|
|
@ -63,8 +63,8 @@ func newFourByteTracer(ctx *directory.Context, _ json.RawMessage) (*directory.Tr
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
@ -87,14 +87,14 @@ func (t *fourByteTracer) store(id []byte, size int) {
|
||||||
t.ids[key] += 1
|
t.ids[key] += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *fourByteTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *fourByteTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
// Update list of precompiles based on current block
|
// Update list of precompiles based on current block
|
||||||
rules := env.ChainConfig.Rules(env.BlockNumber, env.Random != nil, env.Time)
|
rules := env.ChainConfig.Rules(env.BlockNumber, env.Random != nil, env.Time)
|
||||||
t.activePrecompiles = vm.ActivePrecompiles(rules)
|
t.activePrecompiles = vm.ActivePrecompiles(rules)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
// OnEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||||
func (t *fourByteTracer) CaptureEnter(depth int, opcode tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *fourByteTracer) OnEnter(depth int, opcode tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
// Skip if tracing was interrupted
|
// Skip if tracing was interrupted
|
||||||
if t.interrupt.Load() {
|
if t.interrupt.Load() {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -128,10 +128,10 @@ func newCallTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trac
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
|
|
@ -151,8 +151,8 @@ func newCallTracerObject(ctx *directory.Context, cfg json.RawMessage) (*callTrac
|
||||||
return &callTracer{callstack: make([]callFrame, 0, 1), config: config}, nil
|
return &callTracer{callstack: make([]callFrame, 0, 1), config: config}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
// OnEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||||
func (t *callTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *callTracer) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
t.depth = depth
|
t.depth = depth
|
||||||
if t.config.OnlyTopCall && depth > 0 {
|
if t.config.OnlyTopCall && depth > 0 {
|
||||||
return
|
return
|
||||||
|
|
@ -177,9 +177,9 @@ func (t *callTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Add
|
||||||
t.callstack = append(t.callstack, call)
|
t.callstack = append(t.callstack, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
// OnExit is called when EVM exits a scope, even if the scope didn't
|
||||||
// execute any code.
|
// execute any code.
|
||||||
func (t *callTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *callTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
t.captureEnd(output, gasUsed, err, reverted)
|
t.captureEnd(output, gasUsed, err, reverted)
|
||||||
return
|
return
|
||||||
|
|
@ -212,11 +212,11 @@ func (t *callTracer) captureEnd(output []byte, gasUsed uint64, err error, revert
|
||||||
t.callstack[0].processOutput(output, err, reverted)
|
t.callstack[0].processOutput(output, err, reverted)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *callTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *callTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
t.gasLimit = tx.Gas()
|
t.gasLimit = tx.Gas()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *callTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *callTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
// Error happened during tx validation.
|
// Error happened during tx validation.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ type flatCallTracer struct {
|
||||||
config flatCallTracerConfig
|
config flatCallTracerConfig
|
||||||
ctx *directory.Context // Holds tracer context data
|
ctx *directory.Context // Holds tracer context data
|
||||||
reason error // Textual reason for the interruption
|
reason error // Textual reason for the interruption
|
||||||
activePrecompiles []common.Address // Updated on CaptureStart based on given rules
|
activePrecompiles []common.Address // Updated on tx start based on given rules
|
||||||
}
|
}
|
||||||
|
|
||||||
type flatCallTracerConfig struct {
|
type flatCallTracerConfig struct {
|
||||||
|
|
@ -142,31 +142,19 @@ func newFlatCallTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.
|
||||||
ft := &flatCallTracer{tracer: t, ctx: ctx, config: config}
|
ft := &flatCallTracer{tracer: t, ctx: ctx, config: config}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: ft.CaptureTxStart,
|
OnTxStart: ft.OnTxStart,
|
||||||
OnTxEnd: ft.CaptureTxEnd,
|
OnTxEnd: ft.OnTxEnd,
|
||||||
OnEnter: ft.CaptureEnter,
|
OnEnter: ft.OnEnter,
|
||||||
OnExit: ft.CaptureExit,
|
OnExit: ft.OnExit,
|
||||||
OnOpcode: ft.CaptureState,
|
|
||||||
OnFault: ft.CaptureFault,
|
|
||||||
},
|
},
|
||||||
Stop: ft.Stop,
|
Stop: ft.Stop,
|
||||||
GetResult: ft.GetResult,
|
GetResult: ft.GetResult,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
// OnEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||||
func (t *flatCallTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (t *flatCallTracer) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
t.tracer.CaptureState(pc, op, gas, cost, scope, rData, depth, err)
|
t.tracer.OnEnter(depth, typ, from, to, input, gas, value)
|
||||||
}
|
|
||||||
|
|
||||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
|
||||||
func (t *flatCallTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
|
||||||
t.tracer.CaptureFault(pc, op, gas, cost, scope, depth, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
|
||||||
func (t *flatCallTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
|
||||||
t.tracer.CaptureEnter(depth, typ, from, to, input, gas, value)
|
|
||||||
|
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return
|
return
|
||||||
|
|
@ -178,10 +166,10 @@ func (t *flatCallTracer) CaptureEnter(depth int, typ tracing.OpCode, from common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
// OnExit is called when EVM exits a scope, even if the scope didn't
|
||||||
// execute any code.
|
// execute any code.
|
||||||
func (t *flatCallTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *flatCallTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
t.tracer.CaptureExit(depth, output, gasUsed, err, reverted)
|
t.tracer.OnExit(depth, output, gasUsed, err, reverted)
|
||||||
|
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return
|
return
|
||||||
|
|
@ -205,15 +193,15 @@ func (t *flatCallTracer) CaptureExit(depth int, output []byte, gasUsed uint64, e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *flatCallTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *flatCallTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
t.tracer.CaptureTxStart(env, tx, from)
|
t.tracer.OnTxStart(env, tx, from)
|
||||||
// Update list of precompiles based on current block
|
// Update list of precompiles based on current block
|
||||||
rules := env.ChainConfig.Rules(env.BlockNumber, env.Random != nil, env.Time)
|
rules := env.ChainConfig.Rules(env.BlockNumber, env.Random != nil, env.Time)
|
||||||
t.activePrecompiles = vm.ActivePrecompiles(rules)
|
t.activePrecompiles = vm.ActivePrecompiles(rules)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *flatCallTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *flatCallTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
t.tracer.CaptureTxEnd(receipt, err)
|
t.tracer.OnTxEnd(receipt, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetResult returns an empty json object.
|
// GetResult returns an empty json object.
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,13 @@ func newMuxTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trace
|
||||||
t := &muxTracer{names: names, tracers: objects}
|
t := &muxTracer{names: names, tracers: objects}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnEnter: t.CaptureEnter,
|
OnEnter: t.OnEnter,
|
||||||
OnExit: t.CaptureExit,
|
OnExit: t.OnExit,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
OnFault: t.CaptureFault,
|
OnFault: t.OnFault,
|
||||||
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.OnKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBalanceChange: t.OnBalanceChange,
|
OnBalanceChange: t.OnBalanceChange,
|
||||||
OnNonceChange: t.OnNonceChange,
|
OnNonceChange: t.OnNonceChange,
|
||||||
|
|
@ -78,8 +78,7 @@ func newMuxTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trace
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
func (t *muxTracer) OnOpcode(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
func (t *muxTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnOpcode != nil {
|
if t.OnOpcode != nil {
|
||||||
t.OnOpcode(pc, op, gas, cost, scope, rData, depth, err)
|
t.OnOpcode(pc, op, gas, cost, scope, rData, depth, err)
|
||||||
|
|
@ -87,8 +86,7 @@ func (t *muxTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
func (t *muxTracer) OnFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||||
func (t *muxTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnFault != nil {
|
if t.OnFault != nil {
|
||||||
t.OnFault(pc, op, gas, cost, scope, depth, err)
|
t.OnFault(pc, op, gas, cost, scope, depth, err)
|
||||||
|
|
@ -96,8 +94,7 @@ func (t *muxTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureKeccakPreimage is called during the KECCAK256 opcode.
|
func (t *muxTracer) OnKeccakPreimage(hash common.Hash, data []byte) {
|
||||||
func (t *muxTracer) CaptureKeccakPreimage(hash common.Hash, data []byte) {
|
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnKeccakPreimage != nil {
|
if t.OnKeccakPreimage != nil {
|
||||||
t.OnKeccakPreimage(hash, data)
|
t.OnKeccakPreimage(hash, data)
|
||||||
|
|
@ -105,7 +102,6 @@ func (t *muxTracer) CaptureKeccakPreimage(hash common.Hash, data []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureGasConsumed is called when gas is consumed.
|
|
||||||
func (t *muxTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {
|
func (t *muxTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnGasChange != nil {
|
if t.OnGasChange != nil {
|
||||||
|
|
@ -114,8 +110,7 @@ func (t *muxTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
func (t *muxTracer) OnEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
||||||
func (t *muxTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnEnter != nil {
|
if t.OnEnter != nil {
|
||||||
t.OnEnter(depth, typ, from, to, input, gas, value)
|
t.OnEnter(depth, typ, from, to, input, gas, value)
|
||||||
|
|
@ -123,9 +118,7 @@ func (t *muxTracer) CaptureEnter(depth int, typ tracing.OpCode, from common.Addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureExit is called when EVM exits a scope, even if the scope didn't
|
func (t *muxTracer) OnExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
// execute any code.
|
|
||||||
func (t *muxTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err error, reverted bool) {
|
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnExit != nil {
|
if t.OnExit != nil {
|
||||||
t.OnExit(depth, output, gasUsed, err, reverted)
|
t.OnExit(depth, output, gasUsed, err, reverted)
|
||||||
|
|
@ -133,7 +126,7 @@ func (t *muxTracer) CaptureExit(depth int, output []byte, gasUsed uint64, err er
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *muxTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *muxTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnTxStart != nil {
|
if t.OnTxStart != nil {
|
||||||
t.OnTxStart(env, tx, from)
|
t.OnTxStart(env, tx, from)
|
||||||
|
|
@ -141,7 +134,7 @@ func (t *muxTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *muxTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *muxTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.OnTxEnd != nil {
|
if t.OnTxEnd != nil {
|
||||||
t.OnTxEnd(receipt, err)
|
t.OnTxEnd(receipt, err)
|
||||||
|
|
|
||||||
|
|
@ -90,17 +90,17 @@ func newPrestateTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
Hooks: &tracing.Hooks{
|
Hooks: &tracing.Hooks{
|
||||||
OnTxStart: t.CaptureTxStart,
|
OnTxStart: t.OnTxStart,
|
||||||
OnTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.OnTxEnd,
|
||||||
OnOpcode: t.CaptureState,
|
OnOpcode: t.OnOpcode,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
// OnOpcode implements the EVMLogger interface to trace a single step of VM execution.
|
||||||
func (t *prestateTracer) CaptureState(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
func (t *prestateTracer) OnOpcode(pc uint64, opcode tracing.OpCode, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ func (t *prestateTracer) CaptureState(pc uint64, opcode tracing.OpCode, gas, cos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *prestateTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *prestateTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
t.env = env
|
t.env = env
|
||||||
if tx.To() == nil {
|
if tx.To() == nil {
|
||||||
t.to = crypto.CreateAddress(from, env.StateDB.GetNonce(from))
|
t.to = crypto.CreateAddress(from, env.StateDB.GetNonce(from))
|
||||||
|
|
@ -160,7 +160,7 @@ func (t *prestateTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transa
|
||||||
t.lookupAccount(env.Coinbase)
|
t.lookupAccount(env.Coinbase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *prestateTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *prestateTracer) OnTxEnd(receipt *types.Receipt, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue