core/vm: use uint64 instead of *big.Int in tracer (#3805)

This commit is contained in:
Yohann Leon
2017-03-22 15:32:51 +01:00
committed by Felix Lange
parent 9b84caf3a5
commit 6742fc526f
6 changed files with 17 additions and 21 deletions

View File

@ -695,8 +695,8 @@ type ExecutionResult struct {
type StructLogRes struct {
Pc uint64 `json:"pc"`
Op string `json:"op"`
Gas *big.Int `json:"gas"`
GasCost *big.Int `json:"gasCost"`
Gas uint64 `json:"gas"`
GasCost uint64 `json:"gasCost"`
Depth int `json:"depth"`
Error error `json:"error"`
Stack []string `json:"stack"`

View File

@ -278,7 +278,7 @@ func wrapError(context string, err error) error {
}
// CaptureState implements the Tracer interface to trace a single step of VM execution
func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost *big.Int, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error {
func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error {
if jst.err == nil {
jst.memory.memory = memory
jst.stack.stack = stack
@ -288,8 +288,8 @@ func (jst *JavascriptTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode,
jst.log["pc"] = pc
jst.log["op"] = ocw.toValue(jst.vm)
jst.log["gas"] = gas.Int64()
jst.log["gasPrice"] = cost.Int64()
jst.log["gas"] = gas
jst.log["gasPrice"] = cost
jst.log["memory"] = jst.memvalue
jst.log["stack"] = jst.stackvalue
jst.log["depth"] = depth

View File

@ -136,10 +136,10 @@ func TestHaltBetweenSteps(t *testing.T) {
env := vm.NewEVM(vm.Context{}, nil, params.TestChainConfig, vm.Config{Debug: true, Tracer: tracer})
contract := vm.NewContract(&account{}, &account{}, big.NewInt(0), 0)
tracer.CaptureState(env, 0, 0, big.NewInt(0), big.NewInt(0), nil, nil, contract, 0, nil)
tracer.CaptureState(env, 0, 0, 0, 0, nil, nil, contract, 0, nil)
timeout := errors.New("stahp")
tracer.Stop(timeout)
tracer.CaptureState(env, 0, 0, big.NewInt(0), big.NewInt(0), nil, nil, contract, 0, nil)
tracer.CaptureState(env, 0, 0, 0, 0, nil, nil, contract, 0, nil)
if _, err := tracer.GetResult(); err.Error() != "stahp in server-side tracer function 'step'" {
t.Errorf("Expected timeout error, got %v", err)