diff --git a/arbos/programs/api.go b/arbos/programs/api.go index ed43751a54..0519cd9f01 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -144,17 +144,19 @@ func newApiClosures( // Tracing: emit the call (value transfer is done later in evm.Call) if tracingInfo != nil { + var args []uint256.Int + args = append(args, *uint256.NewInt(gas)) // gas + args = append(args, *uint256.NewInt(0).SetBytes(contract.Bytes())) // to address + if opcode == vm.CALL { + args = append(args, *uint256.NewInt(0).SetBytes(value.Bytes())) // call value + } + args = append(args, *uint256.NewInt(0)) // memory offset + args = append(args, *uint256.NewInt(uint64(len(input)))) // memory length + args = append(args, *uint256.NewInt(0)) // return offset + args = append(args, *uint256.NewInt(0)) // return size s := &vm.ScopeContext{ - Memory: vm.NewMemory(), - Stack: util.TracingStackFromArgs( - *uint256.NewInt(gas), // gas - *uint256.NewInt(0).SetBytes(contract.Bytes()), // to address - *uint256.NewInt(0).SetBytes(value.Bytes()), // call value - *uint256.NewInt(0), // memory offset - *uint256.NewInt(uint64(len(input))), // memory length - *uint256.NewInt(0), // return offset - *uint256.NewInt(0), // return size - ), + Memory: util.TracingMemoryFromBytes(input), + Stack: util.TracingStackFromArgs(args...), Contract: scope.Contract, } tracingInfo.Tracer.CaptureState(0, opcode, startGas, baseCost+gas, s, []byte{}, depth, nil) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index f0f101bc20..f3564143c5 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -56,11 +56,8 @@ func (info *TracingInfo) RecordEmitLog(topics []common.Hash, data []byte) { for _, topic := range topics { args = append(args, HashToUint256(topic)) // topic: 32-byte value. Max topics count is 4 } - memory := vm.NewMemory() - memory.Resize(size) - memory.Set(0, size, data) scope := &vm.ScopeContext{ - Memory: memory, + Memory: TracingMemoryFromBytes(data), Stack: TracingStackFromArgs(args...), Contract: info.Contract, }