aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorcdetrio <cdetrio@gmail.com>2017-09-22 16:22:56 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-09-22 16:22:56 +0800
commit673007d7aed1d2678ea3277eceb7b55dc29cf092 (patch)
tree8c65442124a473963113208bf109321c85d9c777 /core
parentd558a595adf4e89bab5b28ffde1448dc1e5768b0 (diff)
downloadgo-tangerine-673007d7aed1d2678ea3277eceb7b55dc29cf092.tar.gz
go-tangerine-673007d7aed1d2678ea3277eceb7b55dc29cf092.tar.zst
go-tangerine-673007d7aed1d2678ea3277eceb7b55dc29cf092.zip
core/vm: standard vm traces (#15035)
Diffstat (limited to 'core')
-rw-r--r--core/vm/interpreter.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index b0d796a44..94b922c79 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -137,12 +137,17 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
// to be uint256. Practically much less so feasible.
pc = uint64(0) // program counter
cost uint64
+ // copies used by tracer
+ stackCopy = newstack() // stackCopy needed for Tracer since stack is mutated by 63/64 gas rule
+ pcCopy uint64 // needed for the deferred Tracer
+ gasCopy uint64 // for Tracer to log gas remaining before execution
+ logged bool // deferred Tracer should ignore already logged steps
)
contract.Input = input
defer func() {
- if err != nil && in.cfg.Debug {
- in.cfg.Tracer.CaptureState(in.evm, pc, op, contract.Gas, cost, mem, stack, contract, in.evm.depth, err)
+ if err != nil && !logged && in.cfg.Debug {
+ in.cfg.Tracer.CaptureState(in.evm, pcCopy, op, gasCopy, cost, mem, stackCopy, contract, in.evm.depth, err)
}
}()
@@ -154,6 +159,16 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
// Get the memory location of pc
op = contract.GetOp(pc)
+ if in.cfg.Debug {
+ logged = false
+ pcCopy = uint64(pc)
+ gasCopy = uint64(contract.Gas)
+ stackCopy = newstack()
+ for _, val := range stack.data {
+ stackCopy.push(val)
+ }
+ }
+
// get the operation from the jump table matching the opcode
operation := in.cfg.JumpTable[op]
if err := in.enforceRestrictions(op, operation, stack); err != nil {
@@ -199,7 +214,8 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
}
if in.cfg.Debug {
- in.cfg.Tracer.CaptureState(in.evm, pc, op, contract.Gas, cost, mem, stack, contract, in.evm.depth, err)
+ in.cfg.Tracer.CaptureState(in.evm, pc, op, gasCopy, cost, mem, stackCopy, contract, in.evm.depth, err)
+ logged = true
}
// execute the operation