Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions core/vm/cvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (cvm *CVM) Call(caller ContractRef, addr common.Address, input []byte, gas
// Calling a non existing account, don't do anything, but ping the tracer
if cvm.vmConfig.Debug && cvm.depth == 0 {
cvm.vmConfig.Tracer.CaptureStart(cvm, caller.Address(), addr, false, input, gas, value)
cvm.vmConfig.Tracer.CaptureEnd(ret, 0, 0, nil)
cvm.vmConfig.Tracer.CaptureEnd(ret, 0, nil)
}
return nil, gas, nil, nil
}
Expand All @@ -232,9 +232,9 @@ func (cvm *CVM) Call(caller ContractRef, addr common.Address, input []byte, gas
// Capture the tracer start/end events in debug mode
if cvm.vmConfig.Debug && cvm.depth == 0 {
cvm.vmConfig.Tracer.CaptureStart(cvm, caller.Address(), addr, false, input, gas, value)
defer func(startGas uint64, startTime time.Time) { // Lazy evaluation of the parameters
cvm.vmConfig.Tracer.CaptureEnd(ret, startGas-gas, time.Since(startTime), err)
}(gas, time.Now())
defer func(startGas uint64) { // Lazy evaluation of the parameters
cvm.vmConfig.Tracer.CaptureEnd(ret, startGas-gas, err)
}(gas)
}

if isPrecompile {
Expand Down Expand Up @@ -459,7 +459,6 @@ func (cvm *CVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
if cvm.vmConfig.Debug && cvm.depth == 0 {
cvm.vmConfig.Tracer.CaptureStart(cvm, caller.Address(), address, true, codeAndHash.code, gas, value)
}
start := time.Now()

ret, err := cvm.interpreter.Run(contract, nil, false)

Expand Down Expand Up @@ -494,7 +493,7 @@ func (cvm *CVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
}
}
if cvm.vmConfig.Debug && cvm.depth == 0 {
cvm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err)
cvm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, err)
}
return ret, address, contract.Gas, contract.ModelGas, err
}
Expand Down
3 changes: 1 addition & 2 deletions core/vm/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package vm

import (
"math/big"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
)
Expand All @@ -34,7 +33,7 @@ type CVMLogger interface {
CaptureTxEnd(restGas uint64)
// Top call frame
CaptureStart(env *CVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)
CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)
CaptureEnd(output []byte, gasUsed uint64, err error)
// Rest of call frames
CaptureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)
CaptureExit(output []byte, gasUsed uint64, err error)
Expand Down
4 changes: 1 addition & 3 deletions ctxc/tracers/js/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"math/big"
"time"

"github.com/dop251/goja"

Expand Down Expand Up @@ -284,9 +283,8 @@ func (t *jsTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *jsTracer) CaptureEnd(output []byte, gasUsed uint64, duration time.Duration, err error) {
func (t *jsTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
t.ctx["output"] = t.vm.ToValue(output)
t.ctx["time"] = t.vm.ToValue(duration.String())
t.ctx["gasUsed"] = t.vm.ToValue(gasUsed)
if err != nil {
t.ctx["error"] = t.vm.ToValue(err.Error())
Expand Down
1 change: 0 additions & 1 deletion ctxc/tracers/js/internal/tracers/call_tracer_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@
input: call.input,
output: call.output,
error: call.error,
time: call.time,
calls: call.calls,
}
for (var key in sorted) {
Expand Down
5 changes: 2 additions & 3 deletions ctxc/tracers/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"math/big"
"strings"
"sync/atomic"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/common/hexutil"
Expand Down Expand Up @@ -219,7 +218,7 @@ func (l *StructLogger) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, s
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) {
func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, err error) {
l.output = output
l.err = err
if l.cfg.Debug {
Expand Down Expand Up @@ -385,7 +384,7 @@ func (t *mdLogger) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope
fmt.Fprintf(t.out, "\nError: at pc=%d, op=%v: %v\n", pc, op, err)
}

func (t *mdLogger) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error) {
func (t *mdLogger) CaptureEnd(output []byte, gasUsed uint64, err error) {
fmt.Fprintf(t.out, "\nOutput: `%#x`\nConsumed gas: `%d`\nError: `%v`\n",
output, gasUsed, err)
}
Expand Down
6 changes: 2 additions & 4 deletions ctxc/tracers/logger/logger_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"io"
"math/big"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/common/math"
Expand Down Expand Up @@ -80,18 +79,17 @@ func (l *JSONLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco
}

// CaptureEnd is triggered at end of execution.
func (l *JSONLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) {
func (l *JSONLogger) CaptureEnd(output []byte, gasUsed uint64, err error) {
type endLog struct {
Output string `json:"output"`
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
Time time.Duration `json:"time"`
Err string `json:"error,omitempty"`
}
var errMsg string
if err != nil {
errMsg = err.Error()
}
l.encoder.Encode(endLog{common.Bytes2Hex(output), math.HexOrDecimal64(gasUsed), t, errMsg})
l.encoder.Encode(endLog{common.Bytes2Hex(output), math.HexOrDecimal64(gasUsed), errMsg})
}

func (l *JSONLogger) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) {
Expand Down
3 changes: 1 addition & 2 deletions ctxc/tracers/native/4byte.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"math/big"
"strconv"
"sync/atomic"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/vm"
Expand Down Expand Up @@ -125,7 +124,7 @@ func (t *fourByteTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64,
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *fourByteTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *fourByteTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
}

func (*fourByteTracer) CaptureTxStart(gasLimit uint64) {}
Expand Down
3 changes: 1 addition & 2 deletions ctxc/tracers/native/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"math/big"
"sync/atomic"
"time"

"github.com/CortexFoundation/CortexTheseus/accounts/abi"
"github.com/CortexFoundation/CortexTheseus/common"
Expand Down Expand Up @@ -141,7 +140,7 @@ func (t *callTracer) CaptureStart(env *vm.CVM, from common.Address, to common.Ad
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *callTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *callTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
t.callstack[0].processOutput(output, err)
}

Expand Down
5 changes: 2 additions & 3 deletions ctxc/tracers/native/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package native
import (
"encoding/json"
"math/big"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/vm"
Expand Down Expand Up @@ -67,9 +66,9 @@ func (t *muxTracer) CaptureStart(env *vm.CVM, from common.Address, to common.Add
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *muxTracer) CaptureEnd(output []byte, gasUsed uint64, elapsed time.Duration, err error) {
func (t *muxTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
for _, t := range t.tracers {
t.CaptureEnd(output, gasUsed, elapsed, err)
t.CaptureEnd(output, gasUsed, err)
}
}

Expand Down
3 changes: 1 addition & 2 deletions ctxc/tracers/native/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package native
import (
"encoding/json"
"math/big"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/core/vm"
Expand All @@ -44,7 +43,7 @@ func (t *noopTracer) CaptureStart(env *vm.CVM, from common.Address, to common.Ad
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *noopTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
}

// CaptureState implements the CVMLogger interface to trace a single step of VM execution.
Expand Down
3 changes: 1 addition & 2 deletions ctxc/tracers/native/prestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"math/big"
"sync/atomic"
"time"

"github.com/CortexFoundation/CortexTheseus/common"
"github.com/CortexFoundation/CortexTheseus/common/hexutil"
Expand Down Expand Up @@ -117,7 +116,7 @@ func (t *prestateTracer) CaptureStart(env *vm.CVM, from common.Address, to commo
}

// CaptureEnd is called after the call finishes to finalize the tracing.
func (t *prestateTracer) CaptureEnd(output []byte, gasUsed uint64, _ time.Duration, err error) {
func (t *prestateTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {
if t.config.DiffMode {
return
}
Expand Down