diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-10 18:57:37 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-10 18:57:37 +0800 |
commit | 6fb6e6679eb7c329ac9013d0c879a7c4b17daca5 (patch) | |
tree | 42157e1347034cbbfb58b70baa756c5114bc8f0f /core/vm | |
parent | 38c61f6f2567e7943c9a16e2be0a2bfedb3a1fb3 (diff) | |
download | go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar.gz go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar.bz2 go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar.lz go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar.xz go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.tar.zst go-tangerine-6fb6e6679eb7c329ac9013d0c879a7c4b17daca5.zip |
core/vm, core/state: added storage to structured vm logging
Diffstat (limited to 'core/vm')
-rw-r--r-- | core/vm/environment.go | 11 | ||||
-rw-r--r-- | core/vm/vm.go | 13 |
2 files changed, 16 insertions, 8 deletions
diff --git a/core/vm/environment.go b/core/vm/environment.go index 31d5d5ea6..25bd2515e 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -34,11 +34,12 @@ type Environment interface { } type StructLog struct { - Pc uint64 - Op OpCode - Gas *big.Int - Memory []byte - Stack []*big.Int + Pc uint64 + Op OpCode + Gas *big.Int + Memory []byte + Stack []*big.Int + Storage map[common.Hash][]byte } type Account interface { diff --git a/core/vm/vm.go b/core/vm/vm.go index 7c4a7ce6d..e4f6e9268 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -95,7 +95,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) { // Get the memory location of pc op = context.GetOp(pc) - self.log(pc, op, context.Gas, mem, stack) + self.log(pc, op, context.Gas, mem, stack, context) newMemSize, gas, err := self.calculateGasAndSize(context, caller, op, statedb, mem, stack) if err != nil { @@ -778,13 +778,20 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context * } } -func (self *Vm) log(pc uint64, op OpCode, gas *big.Int, memory *Memory, stack *Stack) { +func (self *Vm) log(pc uint64, op OpCode, gas *big.Int, memory *Memory, stack *Stack, context *Context) { if Debug { mem := make([]byte, len(memory.Data())) copy(mem, memory.Data()) stck := make([]*big.Int, len(stack.Data())) copy(stck, stack.Data()) - self.env.AddStructLog(StructLog{pc, op, new(big.Int).Set(gas), mem, stck}) + + object := context.self.(*state.StateObject) + storage := make(map[common.Hash][]byte) + object.EachStorage(func(k, v []byte) { + storage[common.BytesToHash(k)] = v + }) + + self.env.AddStructLog(StructLog{pc, op, new(big.Int).Set(gas), mem, stck, storage}) } } |