mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
rename Capture hooks to On
# Conflicts: # cmd/evm/internal/t8ntool/execution.go # core/vm/instructions.go # eth/tracers/directory/noop.go # eth/tracers/internal/tracetest/calltrace_test.go # eth/tracers/internal/tracetest/flat_calltrace_test.go # eth/tracers/internal/tracetest/prestate_test.go # eth/tracers/js/goja.go # eth/tracers/js/tracer_test.go # eth/tracers/live/noop.go # eth/tracers/native/4byte.go # eth/tracers/native/call.go # eth/tracers/native/call_flat.go # eth/tracers/native/mux.go # eth/tracers/native/prestate.go
This commit is contained in:
parent
a2ad953d21
commit
25a3a744c3
24 changed files with 207 additions and 195 deletions
|
|
@ -241,7 +241,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig)
|
evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig)
|
||||||
|
|
||||||
if tracer != nil {
|
if tracer != nil {
|
||||||
tracer.CaptureTxStart(evm.GetVMContext(), tx, msg.From)
|
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
}
|
}
|
||||||
// (ret []byte, usedGas uint64, failed bool, err error)
|
// (ret []byte, usedGas uint64, failed bool, err error)
|
||||||
msgResult, err := core.ApplyMessage(evm, msg, gaspool)
|
msgResult, err := core.ApplyMessage(evm, msg, gaspool)
|
||||||
|
|
@ -251,7 +251,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
|
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
|
||||||
gaspool.SetGas(prevGas)
|
gaspool.SetGas(prevGas)
|
||||||
if tracer != nil {
|
if tracer != nil {
|
||||||
tracer.CaptureTxEnd(nil, err)
|
tracer.OnTxEnd(nil, err)
|
||||||
if err := writeTraceResult(tracer, traceOutput); err != nil {
|
if err := writeTraceResult(tracer, traceOutput); err != nil {
|
||||||
log.Warn("Error writing tracer output", "err", err)
|
log.Warn("Error writing tracer output", "err", err)
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +298,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
receipt.TransactionIndex = uint(txIndex)
|
receipt.TransactionIndex = uint(txIndex)
|
||||||
receipts = append(receipts, receipt)
|
receipts = append(receipts, receipt)
|
||||||
if tracer != nil {
|
if tracer != nil {
|
||||||
tracer.LiveLogger.CaptureTxEnd(receipt, nil)
|
tracer.Hooks.OnTxEnd(receipt, nil)
|
||||||
writeTraceResult(tracer, traceOutput)
|
writeTraceResult(tracer, traceOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,8 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
// and uses the input parameters for its environment similar to ApplyTransaction. However,
|
// and uses the input parameters for its environment similar to ApplyTransaction. However,
|
||||||
// this method takes an already created EVM instance as input.
|
// this method takes an already created EVM instance as input.
|
||||||
func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (receipt *types.Receipt, err error) {
|
func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (receipt *types.Receipt, err error) {
|
||||||
if evm.Config.Tracer != nil && evm.Config.Tracer.CaptureTxStart != nil {
|
if evm.Config.Tracer != nil && evm.Config.Tracer.OnTxStart != nil {
|
||||||
evm.Config.Tracer.CaptureTxStart(&tracing.VMContext{
|
evm.Config.Tracer.OnTxStart(&tracing.VMContext{
|
||||||
ChainConfig: evm.ChainConfig(),
|
ChainConfig: evm.ChainConfig(),
|
||||||
StateDB: statedb,
|
StateDB: statedb,
|
||||||
BlockNumber: evm.Context.BlockNumber,
|
BlockNumber: evm.Context.BlockNumber,
|
||||||
|
|
@ -120,9 +120,9 @@ func ApplyTransactionWithEVM(msg *Message, config *params.ChainConfig, gp *GasPo
|
||||||
Coinbase: evm.Context.Coinbase,
|
Coinbase: evm.Context.Coinbase,
|
||||||
Random: evm.Context.Random,
|
Random: evm.Context.Random,
|
||||||
}, tx, msg.From)
|
}, tx, msg.From)
|
||||||
if evm.Config.Tracer.CaptureTxEnd != nil {
|
if evm.Config.Tracer.OnTxEnd != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
evm.Config.Tracer.CaptureTxEnd(receipt, err)
|
evm.Config.Tracer.OnTxEnd(receipt, err)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,8 @@ type (
|
||||||
// be indicated by `reverted == false` and `err == ErrCodeStoreOutOfGas`.
|
// be indicated by `reverted == false` and `err == ErrCodeStoreOutOfGas`.
|
||||||
ExitHook = func(output []byte, gasUsed uint64, err error, reverted bool)
|
ExitHook = func(output []byte, gasUsed uint64, err error, reverted bool)
|
||||||
|
|
||||||
// StateHook is invoked just prior to the execution of an opcode.
|
// OpcodeHook is invoked just prior to the execution of an opcode.
|
||||||
StateHook = func(pc uint64, op OpCode, gas, cost uint64, scope OpContext, rData []byte, depth int, err error)
|
OpcodeHook = func(pc uint64, op OpCode, gas, cost uint64, scope OpContext, rData []byte, depth int, err error)
|
||||||
|
|
||||||
// FaultHook is invoked when an error occurs during the execution of an opcode.
|
// FaultHook is invoked when an error occurs during the execution of an opcode.
|
||||||
FaultHook = func(pc uint64, op OpCode, gas, cost uint64, scope OpContext, depth int, err error)
|
FaultHook = func(pc uint64, op OpCode, gas, cost uint64, scope OpContext, depth int, err error)
|
||||||
|
|
@ -165,16 +165,16 @@ type (
|
||||||
|
|
||||||
type Hooks struct {
|
type Hooks struct {
|
||||||
// VM events
|
// VM events
|
||||||
CaptureTxStart TxStartHook
|
OnTxStart TxStartHook
|
||||||
CaptureTxEnd TxEndHook
|
OnTxEnd TxEndHook
|
||||||
CaptureStart StartHook
|
OnStart StartHook
|
||||||
CaptureEnd EndHook
|
OnEnd EndHook
|
||||||
CaptureEnter EnterHook
|
OnEnter EnterHook
|
||||||
CaptureExit ExitHook
|
OnExit ExitHook
|
||||||
CaptureState StateHook
|
OnOpcode OpcodeHook
|
||||||
CaptureFault FaultHook
|
OnFault FaultHook
|
||||||
CaptureKeccakPreimage KeccakPreimageHook
|
OnKeccakPreimage KeccakPreimageHook
|
||||||
OnGasChange GasChangeHook
|
OnGasChange GasChangeHook
|
||||||
// Chain events
|
// Chain events
|
||||||
OnBlockchainInit BlockchainInitHook
|
OnBlockchainInit BlockchainInitHook
|
||||||
OnBlockStart BlockStartHook
|
OnBlockStart BlockStartHook
|
||||||
|
|
@ -284,7 +284,7 @@ const (
|
||||||
// GasChangeCallCodeStorage is the amount of gas that will be charged for code storage.
|
// GasChangeCallCodeStorage is the amount of gas that will be charged for code storage.
|
||||||
GasChangeCallCodeStorage GasChangeReason = 10
|
GasChangeCallCodeStorage GasChangeReason = 10
|
||||||
// GasChangeCallOpCode is the amount of gas that will be charged for an opcode executed by the EVM, exact opcode that was
|
// GasChangeCallOpCode is the amount of gas that will be charged for an opcode executed by the EVM, exact opcode that was
|
||||||
// performed can be check by `CaptureState` handling.
|
// performed can be check by `OnOpcode` handling.
|
||||||
GasChangeCallOpCode GasChangeReason = 11
|
GasChangeCallOpCode GasChangeReason = 11
|
||||||
// GasChangeCallPrecompiledContract is the amount of gas that will be charged for a precompiled contract execution.
|
// GasChangeCallPrecompiledContract is the amount of gas that will be charged for a precompiled contract execution.
|
||||||
GasChangeCallPrecompiledContract GasChangeReason = 12
|
GasChangeCallPrecompiledContract GasChangeReason = 12
|
||||||
|
|
|
||||||
|
|
@ -522,11 +522,11 @@ func (evm *EVM) captureBegin(isRoot bool, typ OpCode, from common.Address, to co
|
||||||
tracer := evm.Config.Tracer
|
tracer := evm.Config.Tracer
|
||||||
|
|
||||||
if isRoot {
|
if isRoot {
|
||||||
if tracer.CaptureStart != nil {
|
if tracer.OnStart != nil {
|
||||||
tracer.CaptureStart(from, to, typ == CREATE || typ == CREATE2, input, startGas, value)
|
tracer.OnStart(from, to, typ == CREATE || typ == CREATE2, input, startGas, value)
|
||||||
}
|
}
|
||||||
} else if tracer.CaptureEnter != nil {
|
} else if tracer.OnEnter != nil {
|
||||||
tracer.CaptureEnter(tracing.OpCode(typ), from, to, input, startGas, value)
|
tracer.OnEnter(tracing.OpCode(typ), from, to, input, startGas, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tracer.OnGasChange != nil {
|
if tracer.OnGasChange != nil {
|
||||||
|
|
@ -548,11 +548,11 @@ func (evm *EVM) captureEnd(isRoot bool, typ OpCode, startGas uint64, leftOverGas
|
||||||
reverted = false
|
reverted = false
|
||||||
}
|
}
|
||||||
if isRoot {
|
if isRoot {
|
||||||
if tracer.CaptureEnd != nil {
|
if tracer.OnEnd != nil {
|
||||||
tracer.CaptureEnd(ret, startGas-leftOverGas, VMErrorFromErr(err), reverted)
|
tracer.OnEnd(ret, startGas-leftOverGas, VMErrorFromErr(err), reverted)
|
||||||
}
|
}
|
||||||
} else if tracer.CaptureExit != nil {
|
} else if tracer.OnExit != nil {
|
||||||
tracer.CaptureExit(ret, startGas-leftOverGas, VMErrorFromErr(err), reverted)
|
tracer.OnExit(ret, startGas-leftOverGas, VMErrorFromErr(err), reverted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,8 @@ func opKeccak256(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) (
|
||||||
if evm.Config.EnablePreimageRecording {
|
if evm.Config.EnablePreimageRecording {
|
||||||
evm.StateDB.AddPreimage(interpreter.hasherBuf, data)
|
evm.StateDB.AddPreimage(interpreter.hasherBuf, data)
|
||||||
}
|
}
|
||||||
if interpreter.evm.Config.Tracer != nil && interpreter.evm.Config.Tracer.CaptureKeccakPreimage != nil {
|
if interpreter.evm.Config.Tracer != nil && interpreter.evm.Config.Tracer.OnKeccakPreimage != nil {
|
||||||
interpreter.evm.Config.Tracer.CaptureKeccakPreimage(common.BytesToHash(interpreter.hasherBuf[:]), data)
|
interpreter.evm.Config.Tracer.OnKeccakPreimage(common.BytesToHash(interpreter.hasherBuf[:]), data)
|
||||||
}
|
}
|
||||||
size.SetBytes(interpreter.hasherBuf[:])
|
size.SetBytes(interpreter.hasherBuf[:])
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -858,11 +858,11 @@ func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
interpreter.evm.StateDB.SelfDestruct(scope.Contract.Address())
|
interpreter.evm.StateDB.SelfDestruct(scope.Contract.Address())
|
||||||
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.CaptureEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
tracer.CaptureEnter(tracing.OpCode(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
tracer.OnEnter(tracing.OpCode(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
||||||
}
|
}
|
||||||
if tracer.CaptureExit != nil {
|
if tracer.OnExit != nil {
|
||||||
tracer.CaptureExit([]byte{}, 0, nil, false)
|
tracer.OnExit([]byte{}, 0, nil, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
|
|
@ -878,11 +878,11 @@ func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeCon
|
||||||
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
|
||||||
interpreter.evm.StateDB.Selfdestruct6780(scope.Contract.Address())
|
interpreter.evm.StateDB.Selfdestruct6780(scope.Contract.Address())
|
||||||
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
||||||
if tracer.CaptureEnter != nil {
|
if tracer.OnEnter != nil {
|
||||||
tracer.CaptureEnter(tracing.OpCode(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
tracer.OnEnter(tracing.OpCode(SELFDESTRUCT), scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
||||||
}
|
}
|
||||||
if tracer.CaptureExit != nil {
|
if tracer.OnExit != nil {
|
||||||
tracer.CaptureExit([]byte{}, 0, nil, false)
|
tracer.OnExit([]byte{}, 0, nil, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
|
|
|
||||||
|
|
@ -190,11 +190,11 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !logged {
|
if !logged {
|
||||||
if in.evm.Config.Tracer.CaptureState != nil {
|
if in.evm.Config.Tracer.OnOpcode != nil {
|
||||||
in.evm.Config.Tracer.CaptureState(pcCopy, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
in.evm.Config.Tracer.OnOpcode(pcCopy, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
||||||
}
|
}
|
||||||
} else if in.evm.Config.Tracer.CaptureFault != nil {
|
} else if in.evm.Config.Tracer.OnFault != nil {
|
||||||
in.evm.Config.Tracer.CaptureFault(pcCopy, tracing.OpCode(op), gasCopy, cost, callContext, in.evm.depth, VMErrorFromErr(err))
|
in.evm.Config.Tracer.OnFault(pcCopy, tracing.OpCode(op), gasCopy, cost, callContext, in.evm.depth, VMErrorFromErr(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
@ -255,8 +255,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
if in.evm.Config.Tracer.OnGasChange != nil {
|
if in.evm.Config.Tracer.OnGasChange != nil {
|
||||||
in.evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
in.evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
||||||
}
|
}
|
||||||
if in.evm.Config.Tracer.CaptureState != nil {
|
if in.evm.Config.Tracer.OnOpcode != nil {
|
||||||
in.evm.Config.Tracer.CaptureState(pc, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
in.evm.Config.Tracer.OnOpcode(pc, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
||||||
logged = true
|
logged = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -267,8 +267,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
if in.evm.Config.Tracer.OnGasChange != nil {
|
if in.evm.Config.Tracer.OnGasChange != nil {
|
||||||
in.evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
in.evm.Config.Tracer.OnGasChange(gasCopy, gasCopy-cost, tracing.GasChangeCallOpCode)
|
||||||
}
|
}
|
||||||
if in.evm.Config.Tracer.CaptureState != nil {
|
if in.evm.Config.Tracer.OnOpcode != nil {
|
||||||
in.evm.Config.Tracer.CaptureState(pc, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
in.evm.Config.Tracer.OnOpcode(pc, tracing.OpCode(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
||||||
logged = true
|
logged = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
|
||||||
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil {
|
if cfg.EVMConfig.Tracer != nil {
|
||||||
cfg.EVMConfig.Tracer.CaptureTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{To: &address, Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
cfg.EVMConfig.Tracer.OnTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{To: &address, Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
||||||
}
|
}
|
||||||
// Execute the preparatory steps for state transition which includes:
|
// Execute the preparatory steps for state transition which includes:
|
||||||
// - prepare accessList(post-berlin)
|
// - prepare accessList(post-berlin)
|
||||||
|
|
@ -159,7 +159,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
|
||||||
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil {
|
if cfg.EVMConfig.Tracer != nil {
|
||||||
cfg.EVMConfig.Tracer.CaptureTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
cfg.EVMConfig.Tracer.OnTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
||||||
}
|
}
|
||||||
// Execute the preparatory steps for state transition which includes:
|
// Execute the preparatory steps for state transition which includes:
|
||||||
// - prepare accessList(post-berlin)
|
// - prepare accessList(post-berlin)
|
||||||
|
|
@ -190,7 +190,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er
|
||||||
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time)
|
||||||
)
|
)
|
||||||
if cfg.EVMConfig.Tracer != nil {
|
if cfg.EVMConfig.Tracer != nil {
|
||||||
cfg.EVMConfig.Tracer.CaptureTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{To: &address, Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
cfg.EVMConfig.Tracer.OnTxStart(vmenv.GetVMContext(), types.NewTx(&types.LegacyTx{To: &address, Data: input, Value: cfg.Value, Gas: cfg.GasLimit}), cfg.Origin)
|
||||||
}
|
}
|
||||||
// Execute the preparatory steps for state transition which includes:
|
// Execute the preparatory steps for state transition which includes:
|
||||||
// - prepare accessList(post-berlin)
|
// - prepare accessList(post-berlin)
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ func benchmarkNonModifyingCode(gas uint64, code []byte, name string, tracerCode
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
cfg.EVMConfig = vm.Config{
|
cfg.EVMConfig = vm.Config{
|
||||||
Tracer: tracer.LiveLogger,
|
Tracer: tracer.Hooks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
|
@ -510,7 +510,7 @@ func TestEip2929Cases(t *testing.T) {
|
||||||
code, ops)
|
code, ops)
|
||||||
Execute(code, nil, &Config{
|
Execute(code, nil, &Config{
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: logger.NewMarkdownLogger(nil, os.Stdout).Logger(),
|
Tracer: logger.NewMarkdownLogger(nil, os.Stdout).Hooks(),
|
||||||
ExtraEips: []int{2929},
|
ExtraEips: []int{2929},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
@ -663,7 +663,7 @@ func TestColdAccountAccessCost(t *testing.T) {
|
||||||
tracer := logger.NewStructLogger(nil)
|
tracer := logger.NewStructLogger(nil)
|
||||||
Execute(tc.code, nil, &Config{
|
Execute(tc.code, nil, &Config{
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: tracer.GetTracer().LiveLogger,
|
Tracer: tracer.Hooks(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
have := tracer.StructLogs()[tc.step].GasCost
|
have := tracer.StructLogs()[tc.step].GasCost
|
||||||
|
|
@ -834,7 +834,7 @@ func TestRuntimeJSTracer(t *testing.T) {
|
||||||
GasLimit: 1000000,
|
GasLimit: 1000000,
|
||||||
State: statedb,
|
State: statedb,
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: tracer.LiveLogger,
|
Tracer: tracer.Hooks,
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("didn't expect error", err)
|
t.Fatal("didn't expect error", err)
|
||||||
|
|
@ -868,7 +868,7 @@ func TestJSTracerCreateTx(t *testing.T) {
|
||||||
_, _, _, err = Create(code, &Config{
|
_, _, _, err = Create(code, &Config{
|
||||||
State: statedb,
|
State: statedb,
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: tracer.LiveLogger,
|
Tracer: tracer.Hooks,
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -784,9 +784,9 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||||
// Execute the transaction and flush any traces to disk
|
// Execute the transaction and flush any traces to disk
|
||||||
vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf)
|
vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf)
|
||||||
statedb.SetTxContext(tx.Hash(), i)
|
statedb.SetTxContext(tx.Hash(), i)
|
||||||
vmConf.Tracer.CaptureTxStart(vmenv.GetVMContext(), tx, msg.From)
|
vmConf.Tracer.OnTxStart(vmenv.GetVMContext(), tx, msg.From)
|
||||||
vmRet, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
vmRet, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))
|
||||||
vmConf.Tracer.CaptureTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, err)
|
vmConf.Tracer.OnTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, err)
|
||||||
if writer != nil {
|
if writer != nil {
|
||||||
writer.Flush()
|
writer.Flush()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,22 @@ type NoopTracer struct{}
|
||||||
func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
|
func newNoopTracer(ctx *Context, _ json.RawMessage) (*Tracer, error) {
|
||||||
t := &NoopTracer{}
|
t := &NoopTracer{}
|
||||||
return &Tracer{
|
return &Tracer{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureEnd: t.CaptureEnd,
|
OnEnd: t.CaptureEnd,
|
||||||
CaptureEnter: t.CaptureEnter,
|
OnEnter: t.CaptureEnter,
|
||||||
CaptureExit: t.CaptureExit,
|
OnExit: t.CaptureExit,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
CaptureFault: t.CaptureFault,
|
OnFault: t.CaptureFault,
|
||||||
CaptureKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBalanceChange: t.OnBalanceChange,
|
OnBalanceChange: t.OnBalanceChange,
|
||||||
OnNonceChange: t.OnNonceChange,
|
OnNonceChange: t.OnNonceChange,
|
||||||
OnCodeChange: t.OnCodeChange,
|
OnCodeChange: t.OnCodeChange,
|
||||||
OnStorageChange: t.OnStorageChange,
|
OnStorageChange: t.OnStorageChange,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
|
||||||
|
|
@ -149,13 +149,13 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.LiveLogger})
|
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.Hooks})
|
||||||
tracer.CaptureTxStart(evm.GetVMContext(), tx, msg.From)
|
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to execute transaction: %v", err)
|
t.Fatalf("failed to execute transaction: %v", err)
|
||||||
}
|
}
|
||||||
tracer.CaptureTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
tracer.OnTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
||||||
// Retrieve the trace result and compare against the expected.
|
// Retrieve the trace result and compare against the expected.
|
||||||
res, err := tracer.GetResult()
|
res, err := tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -398,12 +398,12 @@ func TestInternals(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("test %v: failed to create message: %v", tc.name, err)
|
t.Fatalf("test %v: failed to create message: %v", tc.name, err)
|
||||||
}
|
}
|
||||||
tc.tracer.CaptureTxStart(evm.GetVMContext(), tx, msg.From)
|
tc.tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("test %v: failed to execute transaction: %v", tc.name, err)
|
t.Fatalf("test %v: failed to execute transaction: %v", tc.name, err)
|
||||||
}
|
}
|
||||||
tc.tracer.CaptureTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
tc.tracer.OnTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
||||||
// Retrieve the trace result and compare against the expected
|
// Retrieve the trace result and compare against the expected
|
||||||
res, err := tc.tracer.GetResult()
|
res, err := tc.tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,13 @@ func flatCallTracerTestRunner(tracerName string, filename string, dirPath string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to prepare transaction for tracing: %v", err)
|
return fmt.Errorf("failed to prepare transaction for tracing: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.LiveLogger})
|
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.Hooks})
|
||||||
tracer.CaptureTxStart(evm.GetVMContext(), tx, msg.From)
|
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to execute transaction: %v", err)
|
return fmt.Errorf("failed to execute transaction: %v", err)
|
||||||
}
|
}
|
||||||
tracer.CaptureTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
tracer.OnTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
||||||
|
|
||||||
// Retrieve the trace result and compare against the etalon
|
// Retrieve the trace result and compare against the etalon
|
||||||
res, err := tracer.GetResult()
|
res, err := tracer.GetResult()
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,13 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.LiveLogger})
|
evm := vm.NewEVM(context, core.NewEVMTxContext(msg), statedb, test.Genesis.Config, vm.Config{Tracer: tracer.Hooks})
|
||||||
tracer.CaptureTxStart(evm.GetVMContext(), tx, msg.From)
|
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to execute transaction: %v", err)
|
t.Fatalf("failed to execute transaction: %v", err)
|
||||||
}
|
}
|
||||||
tracer.CaptureTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
tracer.OnTxEnd(&types.Receipt{GasUsed: vmRet.UsedGas}, nil)
|
||||||
// Retrieve the trace result and compare against the expected
|
// Retrieve the trace result and compare against the expected
|
||||||
res, err := tracer.GetResult()
|
res, err := tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -213,15 +213,15 @@ func newJsTracer(code string, ctx *directory.Context, cfg json.RawMessage) (*dir
|
||||||
t.logValue = t.log.setupObject()
|
t.logValue = t.log.setupObject()
|
||||||
|
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureEnd: t.CaptureEnd,
|
OnEnd: t.CaptureEnd,
|
||||||
CaptureEnter: t.CaptureEnter,
|
OnEnter: t.CaptureEnter,
|
||||||
CaptureExit: t.CaptureExit,
|
OnExit: t.CaptureExit,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
CaptureFault: t.CaptureFault,
|
OnFault: t.CaptureFault,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
@ -329,7 +329,7 @@ func (t *jsTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
if t.err != nil {
|
if t.err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Other log fields have been already set as part of the last CaptureState.
|
// Other log fields have been already set as part of the last OnOpcode.
|
||||||
t.log.err = err
|
t.log.err = err
|
||||||
if _, err := t.fault(t.obj, t.logValue, t.dbValue); err != nil {
|
if _, err := t.fault(t.obj, t.logValue, t.dbValue); err != nil {
|
||||||
t.onError("fault", err)
|
t.onError("fault", err)
|
||||||
|
|
@ -407,7 +407,7 @@ func (t *jsTracer) Stop(err error) {
|
||||||
// execution.
|
// execution.
|
||||||
func (t *jsTracer) onError(context string, err error) {
|
func (t *jsTracer) onError(context string, err error) {
|
||||||
t.err = wrapError(context, err)
|
t.err = wrapError(context, err)
|
||||||
// `env` is set on CaptureStart which comes before any JS execution.
|
// `env` is set on OnStart which comes before any JS execution.
|
||||||
// So it should be non-nil.
|
// So it should be non-nil.
|
||||||
t.env.VM.Cancel()
|
t.env.VM.Cancel()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ func runTrace(tracer *directory.Tracer, vmctx *vmContext, chaincfg *params.Chain
|
||||||
contract.Code = contractCode
|
contract.Code = contractCode
|
||||||
}
|
}
|
||||||
|
|
||||||
tracer.CaptureTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{Gas: gasLimit}), contract.Caller())
|
tracer.OnTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{Gas: gasLimit}), contract.Caller())
|
||||||
tracer.CaptureStart(contract.Caller(), contract.Address(), false, []byte{}, startGas, value)
|
tracer.OnStart(contract.Caller(), contract.Address(), false, []byte{}, startGas, value)
|
||||||
ret, err := env.Interpreter().Run(contract, []byte{}, false)
|
ret, err := env.Interpreter().Run(contract, []byte{}, false)
|
||||||
tracer.CaptureEnd(ret, startGas-contract.Gas, err, true)
|
tracer.OnEnd(ret, startGas-contract.Gas, err, true)
|
||||||
// Rest gas assumes no refund
|
// Rest gas assumes no refund
|
||||||
tracer.CaptureTxEnd(&types.Receipt{GasUsed: gasLimit - contract.Gas}, nil)
|
tracer.OnTxEnd(&types.Receipt{GasUsed: gasLimit - contract.Gas}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -185,13 +185,13 @@ func TestHaltBetweenSteps(t *testing.T) {
|
||||||
scope := &vm.ScopeContext{
|
scope := &vm.ScopeContext{
|
||||||
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
||||||
}
|
}
|
||||||
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(1)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer.LiveLogger})
|
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(1)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer.Hooks})
|
||||||
tracer.CaptureTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{}), common.Address{})
|
tracer.OnTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{}), common.Address{})
|
||||||
tracer.CaptureStart(common.Address{}, common.Address{}, false, []byte{}, 0, big.NewInt(0))
|
tracer.OnStart(common.Address{}, common.Address{}, false, []byte{}, 0, big.NewInt(0))
|
||||||
tracer.CaptureState(0, 0, 0, 0, scope, nil, 0, nil)
|
tracer.OnOpcode(0, 0, 0, 0, scope, nil, 0, nil)
|
||||||
timeout := errors.New("stahp")
|
timeout := errors.New("stahp")
|
||||||
tracer.Stop(timeout)
|
tracer.Stop(timeout)
|
||||||
tracer.CaptureState(0, 0, 0, 0, scope, nil, 0, nil)
|
tracer.OnOpcode(0, 0, 0, 0, scope, nil, 0, nil)
|
||||||
|
|
||||||
if _, err := tracer.GetResult(); !strings.Contains(err.Error(), timeout.Error()) {
|
if _, err := tracer.GetResult(); !strings.Contains(err.Error(), timeout.Error()) {
|
||||||
t.Errorf("Expected timeout error, got %v", err)
|
t.Errorf("Expected timeout error, got %v", err)
|
||||||
|
|
@ -207,10 +207,10 @@ func TestNoStepExec(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(100)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer.LiveLogger})
|
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{GasPrice: big.NewInt(100)}, &dummyStatedb{}, params.TestChainConfig, vm.Config{Tracer: tracer.Hooks})
|
||||||
tracer.CaptureTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{}), common.Address{})
|
tracer.OnTxStart(env.GetVMContext(), types.NewTx(&types.LegacyTx{}), common.Address{})
|
||||||
tracer.CaptureStart(common.Address{}, common.Address{}, false, []byte{}, 1000, big.NewInt(0))
|
tracer.OnStart(common.Address{}, common.Address{}, false, []byte{}, 1000, big.NewInt(0))
|
||||||
tracer.CaptureEnd(nil, 0, nil, false)
|
tracer.OnEnd(nil, 0, nil, false)
|
||||||
ret, err := tracer.GetResult()
|
ret, err := tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
@ -279,8 +279,8 @@ func TestEnterExit(t *testing.T) {
|
||||||
scope := &vm.ScopeContext{
|
scope := &vm.ScopeContext{
|
||||||
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
||||||
}
|
}
|
||||||
tracer.CaptureEnter(tracing.OpCode(vm.CALL), scope.Contract.Caller(), scope.Contract.Address(), []byte{}, 1000, new(big.Int))
|
tracer.OnEnter(tracing.OpCode(vm.CALL), scope.Contract.Caller(), scope.Contract.Address(), []byte{}, 1000, new(big.Int))
|
||||||
tracer.CaptureExit([]byte{}, 400, nil, false)
|
tracer.OnExit([]byte{}, 400, nil, false)
|
||||||
|
|
||||||
have, err := tracer.GetResult()
|
have, err := tracer.GetResult()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -23,27 +23,27 @@ type noop struct{}
|
||||||
|
|
||||||
func newNoopTracer(_ json.RawMessage) (*tracing.LiveLogger, error) {
|
func newNoopTracer(_ json.RawMessage) (*tracing.LiveLogger, error) {
|
||||||
t := &noop{}
|
t := &noop{}
|
||||||
return &tracing.LiveLogger{
|
return &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureEnd: t.CaptureEnd,
|
OnEnd: t.CaptureEnd,
|
||||||
CaptureEnter: t.CaptureEnter,
|
OnEnter: t.CaptureEnter,
|
||||||
CaptureExit: t.CaptureExit,
|
OnExit: t.CaptureExit,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
CaptureFault: t.CaptureFault,
|
OnFault: t.CaptureFault,
|
||||||
CaptureKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBlockchainInit: t.OnBlockchainInit,
|
OnBlockchainInit: t.OnBlockchainInit,
|
||||||
OnBlockStart: t.OnBlockStart,
|
OnBlockStart: t.OnBlockStart,
|
||||||
OnBlockEnd: t.OnBlockEnd,
|
OnBlockEnd: t.OnBlockEnd,
|
||||||
OnSkippedBlock: t.OnSkippedBlock,
|
OnSkippedBlock: t.OnSkippedBlock,
|
||||||
OnGenesisBlock: t.OnGenesisBlock,
|
OnGenesisBlock: t.OnGenesisBlock,
|
||||||
OnBalanceChange: t.OnBalanceChange,
|
OnBalanceChange: t.OnBalanceChange,
|
||||||
OnNonceChange: t.OnNonceChange,
|
OnNonceChange: t.OnNonceChange,
|
||||||
OnCodeChange: t.OnCodeChange,
|
OnCodeChange: t.OnCodeChange,
|
||||||
OnStorageChange: t.OnStorageChange,
|
OnStorageChange: t.OnStorageChange,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ 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{
|
||||||
CaptureState: a.CaptureState,
|
OnOpcode: a.CaptureState,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,10 @@ func NewStructLogger(cfg *Config) *StructLogger {
|
||||||
|
|
||||||
func (l *StructLogger) Hooks() *tracing.Hooks {
|
func (l *StructLogger) Hooks() *tracing.Hooks {
|
||||||
return &tracing.Hooks{
|
return &tracing.Hooks{
|
||||||
CaptureTxStart: l.CaptureTxStart,
|
OnTxStart: l.CaptureTxStart,
|
||||||
CaptureTxEnd: l.CaptureTxEnd,
|
OnTxEnd: l.CaptureTxEnd,
|
||||||
CaptureEnd: l.CaptureEnd,
|
OnEnd: l.CaptureEnd,
|
||||||
CaptureState: l.CaptureState,
|
OnOpcode: l.CaptureState,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -354,11 +354,11 @@ 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{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
CaptureFault: t.CaptureFault,
|
OnFault: t.CaptureFault,
|
||||||
CaptureEnd: t.CaptureEnd,
|
OnEnd: t.CaptureEnd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ 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{
|
||||||
CaptureTxStart: l.CaptureTxStart,
|
OnTxStart: l.CaptureTxStart,
|
||||||
CaptureEnd: l.CaptureEnd,
|
OnEnd: l.CaptureEnd,
|
||||||
CaptureState: l.CaptureState,
|
OnOpcode: l.CaptureState,
|
||||||
CaptureFault: l.CaptureFault,
|
OnFault: l.CaptureFault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,10 @@ func newFourByteTracer(ctx *directory.Context, _ json.RawMessage) (*directory.Tr
|
||||||
ids: make(map[string]int),
|
ids: make(map[string]int),
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureEnter: t.CaptureEnter,
|
OnEnter: t.CaptureEnter,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ func newCallTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trac
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
|
<<<<<<< HEAD
|
||||||
LiveLogger: &tracing.LiveLogger{
|
LiveLogger: &tracing.LiveLogger{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
CaptureTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
CaptureTxEnd: t.CaptureTxEnd,
|
||||||
|
|
@ -136,6 +137,17 @@ func newCallTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trac
|
||||||
CaptureExit: t.CaptureExit,
|
CaptureExit: t.CaptureExit,
|
||||||
CaptureState: t.CaptureState,
|
CaptureState: t.CaptureState,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
|
=======
|
||||||
|
Hooks: &tracing.Hooks{
|
||||||
|
OnTxStart: t.CaptureTxStart,
|
||||||
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
|
OnStart: t.CaptureStart,
|
||||||
|
OnEnd: t.CaptureEnd,
|
||||||
|
OnEnter: t.CaptureEnter,
|
||||||
|
OnExit: t.CaptureExit,
|
||||||
|
OnOpcode: t.CaptureState,
|
||||||
|
OnLog: t.OnLog,
|
||||||
|
>>>>>>> 923c180058 (rename Capture hooks to On)
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
|
||||||
|
|
@ -141,15 +141,15 @@ 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{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: ft.CaptureTxStart,
|
OnTxStart: ft.CaptureTxStart,
|
||||||
CaptureTxEnd: ft.CaptureTxEnd,
|
OnTxEnd: ft.CaptureTxEnd,
|
||||||
CaptureStart: ft.CaptureStart,
|
OnStart: ft.CaptureStart,
|
||||||
CaptureEnd: ft.CaptureEnd,
|
OnEnd: ft.CaptureEnd,
|
||||||
CaptureEnter: ft.CaptureEnter,
|
OnEnter: ft.CaptureEnter,
|
||||||
CaptureExit: ft.CaptureExit,
|
OnExit: ft.CaptureExit,
|
||||||
CaptureState: ft.CaptureState,
|
OnOpcode: ft.CaptureState,
|
||||||
CaptureFault: ft.CaptureFault,
|
OnFault: ft.CaptureFault,
|
||||||
},
|
},
|
||||||
Stop: ft.Stop,
|
Stop: ft.Stop,
|
||||||
GetResult: ft.GetResult,
|
GetResult: ft.GetResult,
|
||||||
|
|
|
||||||
|
|
@ -58,22 +58,22 @@ 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{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
CaptureStart: t.CaptureStart,
|
OnStart: t.CaptureStart,
|
||||||
CaptureEnd: t.CaptureEnd,
|
OnEnd: t.CaptureEnd,
|
||||||
CaptureEnter: t.CaptureEnter,
|
OnEnter: t.CaptureEnter,
|
||||||
CaptureExit: t.CaptureExit,
|
OnExit: t.CaptureExit,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
CaptureFault: t.CaptureFault,
|
OnFault: t.CaptureFault,
|
||||||
CaptureKeccakPreimage: t.CaptureKeccakPreimage,
|
OnKeccakPreimage: t.CaptureKeccakPreimage,
|
||||||
OnGasChange: t.OnGasChange,
|
OnGasChange: t.OnGasChange,
|
||||||
OnBalanceChange: t.OnBalanceChange,
|
OnBalanceChange: t.OnBalanceChange,
|
||||||
OnNonceChange: t.OnNonceChange,
|
OnNonceChange: t.OnNonceChange,
|
||||||
OnCodeChange: t.OnCodeChange,
|
OnCodeChange: t.OnCodeChange,
|
||||||
OnStorageChange: t.OnStorageChange,
|
OnStorageChange: t.OnStorageChange,
|
||||||
OnLog: t.OnLog,
|
OnLog: t.OnLog,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
@ -83,8 +83,8 @@ func newMuxTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.Trace
|
||||||
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
// CaptureStart implements the EVMLogger interface to initialize the tracing operation.
|
||||||
func (t *muxTracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
func (t *muxTracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.CaptureStart != nil {
|
if t.OnStart != nil {
|
||||||
t.CaptureStart(from, to, create, input, gas, value)
|
t.OnStart(from, to, create, input, gas, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,8 +92,8 @@ func (t *muxTracer) CaptureStart(from common.Address, to common.Address, create
|
||||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
// CaptureEnd is called after the call finishes to finalize the tracing.
|
||||||
func (t *muxTracer) CaptureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *muxTracer) CaptureEnd(output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.CaptureEnd != nil {
|
if t.OnEnd != nil {
|
||||||
t.CaptureEnd(output, gasUsed, err, reverted)
|
t.OnEnd(output, gasUsed, err, reverted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +101,8 @@ func (t *muxTracer) CaptureEnd(output []byte, gasUsed uint64, err error, reverte
|
||||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
||||||
func (t *muxTracer) CaptureState(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.CaptureState != nil {
|
if t.OnOpcode != nil {
|
||||||
t.CaptureState(pc, op, gas, cost, scope, rData, depth, err)
|
t.OnOpcode(pc, op, gas, cost, scope, rData, depth, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -110,8 +110,8 @@ func (t *muxTracer) CaptureState(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
||||||
func (t *muxTracer) CaptureFault(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.CaptureFault != nil {
|
if t.OnFault != nil {
|
||||||
t.CaptureFault(pc, op, gas, cost, scope, depth, err)
|
t.OnFault(pc, op, gas, cost, scope, depth, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,8 +119,8 @@ func (t *muxTracer) CaptureFault(pc uint64, op tracing.OpCode, gas, cost uint64,
|
||||||
// CaptureKeccakPreimage is called during the KECCAK256 opcode.
|
// CaptureKeccakPreimage is called during the KECCAK256 opcode.
|
||||||
func (t *muxTracer) CaptureKeccakPreimage(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.CaptureKeccakPreimage != nil {
|
if t.OnKeccakPreimage != nil {
|
||||||
t.CaptureKeccakPreimage(hash, data)
|
t.OnKeccakPreimage(hash, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -137,8 +137,8 @@ func (t *muxTracer) OnGasChange(old, new uint64, reason tracing.GasChangeReason)
|
||||||
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
// CaptureEnter is called when EVM enters a new scope (via call, create or selfdestruct).
|
||||||
func (t *muxTracer) CaptureEnter(typ tracing.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
|
func (t *muxTracer) CaptureEnter(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.CaptureEnter != nil {
|
if t.OnEnter != nil {
|
||||||
t.CaptureEnter(typ, from, to, input, gas, value)
|
t.OnEnter(typ, from, to, input, gas, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,24 +147,24 @@ func (t *muxTracer) CaptureEnter(typ tracing.OpCode, from common.Address, to com
|
||||||
// execute any code.
|
// execute any code.
|
||||||
func (t *muxTracer) CaptureExit(output []byte, gasUsed uint64, err error, reverted bool) {
|
func (t *muxTracer) CaptureExit(output []byte, gasUsed uint64, err error, reverted bool) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.CaptureExit != nil {
|
if t.OnExit != nil {
|
||||||
t.CaptureExit(output, gasUsed, err, reverted)
|
t.OnExit(output, gasUsed, err, reverted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *muxTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
func (t *muxTracer) CaptureTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.CaptureTxStart != nil {
|
if t.OnTxStart != nil {
|
||||||
t.CaptureTxStart(env, tx, from)
|
t.OnTxStart(env, tx, from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *muxTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
func (t *muxTracer) CaptureTxEnd(receipt *types.Receipt, err error) {
|
||||||
for _, t := range t.tracers {
|
for _, t := range t.tracers {
|
||||||
if t.CaptureTxEnd != nil {
|
if t.OnTxEnd != nil {
|
||||||
t.CaptureTxEnd(receipt, err)
|
t.OnTxEnd(receipt, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,10 @@ func newPrestateTracer(ctx *directory.Context, cfg json.RawMessage) (*directory.
|
||||||
deleted: make(map[common.Address]bool),
|
deleted: make(map[common.Address]bool),
|
||||||
}
|
}
|
||||||
return &directory.Tracer{
|
return &directory.Tracer{
|
||||||
LiveLogger: &tracing.LiveLogger{
|
Hooks: &tracing.Hooks{
|
||||||
CaptureTxStart: t.CaptureTxStart,
|
OnTxStart: t.CaptureTxStart,
|
||||||
CaptureTxEnd: t.CaptureTxEnd,
|
OnTxEnd: t.CaptureTxEnd,
|
||||||
CaptureState: t.CaptureState,
|
OnOpcode: t.CaptureState,
|
||||||
},
|
},
|
||||||
GetResult: t.GetResult,
|
GetResult: t.GetResult,
|
||||||
Stop: t.Stop,
|
Stop: t.Stop,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue