core/vm: resolve circular dependency to debug vm storage
This commit is contained in:
		@@ -27,6 +27,7 @@ type ContractRef interface {
 | 
				
			|||||||
	ReturnGas(*big.Int, *big.Int)
 | 
						ReturnGas(*big.Int, *big.Int)
 | 
				
			||||||
	Address() common.Address
 | 
						Address() common.Address
 | 
				
			||||||
	SetCode([]byte)
 | 
						SetCode([]byte)
 | 
				
			||||||
 | 
						EachStorage(cb func(key, value []byte))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Contract represents an ethereum contract in the state database. It contains
 | 
					// 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.Code = code
 | 
				
			||||||
	self.CodeAddr = addr
 | 
						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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,4 +121,5 @@ type Account interface {
 | 
				
			|||||||
	Address() common.Address
 | 
						Address() common.Address
 | 
				
			||||||
	ReturnGas(*big.Int, *big.Int)
 | 
						ReturnGas(*big.Int, *big.Int)
 | 
				
			||||||
	SetCode([]byte)
 | 
						SetCode([]byte)
 | 
				
			||||||
 | 
						EachStorage(cb func(key, value []byte))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,6 +133,7 @@ func (account) Balance() *big.Int            { return nil }
 | 
				
			|||||||
func (account) Address() common.Address                { return common.Address{} }
 | 
					func (account) Address() common.Address                { return common.Address{} }
 | 
				
			||||||
func (account) ReturnGas(*big.Int, *big.Int)           {}
 | 
					func (account) ReturnGas(*big.Int, *big.Int)           {}
 | 
				
			||||||
func (account) SetCode([]byte)                         {}
 | 
					func (account) SetCode([]byte)                         {}
 | 
				
			||||||
 | 
					func (account) EachStorage(cb func(key, value []byte)) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func runVmBench(test vmBench, b *testing.B) {
 | 
					func runVmBench(test vmBench, b *testing.B) {
 | 
				
			||||||
	var sender account
 | 
						var sender account
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
								stck[i] = new(big.Int).Set(item)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		storage := make(map[common.Hash][]byte)
 | 
							storage := make(map[common.Hash][]byte)
 | 
				
			||||||
		/*
 | 
							contract.self.EachStorage(func(k, v []byte) {
 | 
				
			||||||
			object := contract.self.(*state.StateObject)
 | 
					 | 
				
			||||||
			object.EachStorage(func(k, v []byte) {
 | 
					 | 
				
			||||||
			storage[common.BytesToHash(k)] = v
 | 
								storage[common.BytesToHash(k)] = v
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		self.env.AddStructLog(StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, err})
 | 
							self.env.AddStructLog(StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, err})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user