aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-01-21 05:18:19 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-01-21 05:18:19 +0800
commit78f196409552466ff878a030e4069495a923c73e (patch)
tree0e1038f8bced35fdbdb44ac3dca2cf029d7824e5 /core
parent7b11e9444195cc728437d568bb61e1e86034ba39 (diff)
parent752c75fb21ad151204f2aadeee1fff597e013aa2 (diff)
downloaddexon-78f196409552466ff878a030e4069495a923c73e.tar
dexon-78f196409552466ff878a030e4069495a923c73e.tar.gz
dexon-78f196409552466ff878a030e4069495a923c73e.tar.bz2
dexon-78f196409552466ff878a030e4069495a923c73e.tar.lz
dexon-78f196409552466ff878a030e4069495a923c73e.tar.xz
dexon-78f196409552466ff878a030e4069495a923c73e.tar.zst
dexon-78f196409552466ff878a030e4069495a923c73e.zip
Merge pull request #2115 from karalabe/vm-debug-storage
core/vm: resolve circular dependency to debug vm storage
Diffstat (limited to 'core')
-rw-r--r--core/vm/contract.go7
-rw-r--r--core/vm/environment.go1
-rw-r--r--core/vm/jit_test.go17
-rw-r--r--core/vm/vm.go9
4 files changed, 20 insertions, 14 deletions
diff --git a/core/vm/contract.go b/core/vm/contract.go
index 95417e747..5981dcca0 100644
--- a/core/vm/contract.go
+++ b/core/vm/contract.go
@@ -27,6 +27,7 @@ type ContractRef interface {
ReturnGas(*big.Int, *big.Int)
Address() common.Address
SetCode([]byte)
+ EachStorage(cb func(key, value []byte))
}
// Contract represents an ethereum contract in the state database. It contains
@@ -124,3 +125,9 @@ func (self *Contract) SetCallCode(addr *common.Address, code []byte) {
self.Code = code
self.CodeAddr = addr
}
+
+// EachStorage iterates the contract's storage and calls a method for every key
+// value pair.
+func (self *Contract) EachStorage(cb func(key, value []byte)) {
+ self.caller.EachStorage(cb)
+}
diff --git a/core/vm/environment.go b/core/vm/environment.go
index 299d12674..4fee583bf 100644
--- a/core/vm/environment.go
+++ b/core/vm/environment.go
@@ -121,4 +121,5 @@ type Account interface {
Address() common.Address
ReturnGas(*big.Int, *big.Int)
SetCode([]byte)
+ EachStorage(cb func(key, value []byte))
}
diff --git a/core/vm/jit_test.go b/core/vm/jit_test.go
index aa97e5184..8c50ed0f5 100644
--- a/core/vm/jit_test.go
+++ b/core/vm/jit_test.go
@@ -125,14 +125,15 @@ type vmBench struct {
type account struct{}
-func (account) SubBalance(amount *big.Int) {}
-func (account) AddBalance(amount *big.Int) {}
-func (account) SetBalance(*big.Int) {}
-func (account) SetNonce(uint64) {}
-func (account) Balance() *big.Int { return nil }
-func (account) Address() common.Address { return common.Address{} }
-func (account) ReturnGas(*big.Int, *big.Int) {}
-func (account) SetCode([]byte) {}
+func (account) SubBalance(amount *big.Int) {}
+func (account) AddBalance(amount *big.Int) {}
+func (account) SetBalance(*big.Int) {}
+func (account) SetNonce(uint64) {}
+func (account) Balance() *big.Int { return nil }
+func (account) Address() common.Address { return common.Address{} }
+func (account) ReturnGas(*big.Int, *big.Int) {}
+func (account) SetCode([]byte) {}
+func (account) EachStorage(cb func(key, value []byte)) {}
func runVmBench(test vmBench, b *testing.B) {
var sender account
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 4b03e55f0..8e07aaa89 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -376,12 +376,9 @@ func (self *Vm) log(pc uint64, op OpCode, gas, cost *big.Int, memory *Memory, st
stck[i] = new(big.Int).Set(item)
}
storage := make(map[common.Hash][]byte)
- /*
- object := contract.self.(*state.StateObject)
- object.EachStorage(func(k, v []byte) {
- storage[common.BytesToHash(k)] = v
- })
- */
+ contract.self.EachStorage(func(k, v []byte) {
+ storage[common.BytesToHash(k)] = v
+ })
self.env.AddStructLog(StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, err})
}
}