core, tests: get_hash fix
Make sure that we're fetching the hash from the current chain and not the canonical chain.
This commit is contained in:
parent
796952a49a
commit
80f26086ee
@ -39,7 +39,7 @@ type Environment interface {
|
|||||||
// The block number this VM is invoken on
|
// The block number this VM is invoken on
|
||||||
BlockNumber() *big.Int
|
BlockNumber() *big.Int
|
||||||
// The n'th hash ago from this block number
|
// The n'th hash ago from this block number
|
||||||
GetHash(n uint64) common.Hash
|
GetHash(uint64) common.Hash
|
||||||
// The handler's address
|
// The handler's address
|
||||||
Coinbase() common.Address
|
Coinbase() common.Address
|
||||||
// The current time (block time)
|
// The current time (block time)
|
||||||
|
@ -59,9 +59,11 @@ func (self *VMEnv) SetDepth(i int) { self.depth = i }
|
|||||||
func (self *VMEnv) VmType() vm.Type { return self.typ }
|
func (self *VMEnv) VmType() vm.Type { return self.typ }
|
||||||
func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
|
func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
|
||||||
func (self *VMEnv) GetHash(n uint64) common.Hash {
|
func (self *VMEnv) GetHash(n uint64) common.Hash {
|
||||||
if block := self.chain.GetBlockByNumber(n); block != nil {
|
for block := self.chain.GetBlock(self.header.ParentHash); block != nil; block = self.chain.GetBlock(block.ParentHash()) {
|
||||||
|
if block.NumberU64() == n {
|
||||||
return block.Hash()
|
return block.Hash()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ type Env struct {
|
|||||||
Gas *big.Int
|
Gas *big.Int
|
||||||
|
|
||||||
origin common.Address
|
origin common.Address
|
||||||
//parent common.Hash
|
parent common.Hash
|
||||||
coinbase common.Address
|
coinbase common.Address
|
||||||
|
|
||||||
number *big.Int
|
number *big.Int
|
||||||
@ -163,7 +163,7 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
|
|||||||
env := NewEnv(state)
|
env := NewEnv(state)
|
||||||
|
|
||||||
env.origin = common.HexToAddress(exeValues["caller"])
|
env.origin = common.HexToAddress(exeValues["caller"])
|
||||||
//env.parent = common.Hex2Bytes(envValues["previousHash"])
|
env.parent = common.HexToHash(envValues["previousHash"])
|
||||||
env.coinbase = common.HexToAddress(envValues["currentCoinbase"])
|
env.coinbase = common.HexToAddress(envValues["currentCoinbase"])
|
||||||
env.number = common.Big(envValues["currentNumber"])
|
env.number = common.Big(envValues["currentNumber"])
|
||||||
env.time = common.Big(envValues["currentTimestamp"])
|
env.time = common.Big(envValues["currentTimestamp"])
|
||||||
@ -176,8 +176,6 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
|
|||||||
|
|
||||||
func (self *Env) Origin() common.Address { return self.origin }
|
func (self *Env) Origin() common.Address { return self.origin }
|
||||||
func (self *Env) BlockNumber() *big.Int { return self.number }
|
func (self *Env) BlockNumber() *big.Int { return self.number }
|
||||||
|
|
||||||
//func (self *Env) PrevHash() []byte { return self.parent }
|
|
||||||
func (self *Env) Coinbase() common.Address { return self.coinbase }
|
func (self *Env) Coinbase() common.Address { return self.coinbase }
|
||||||
func (self *Env) Time() *big.Int { return self.time }
|
func (self *Env) Time() *big.Int { return self.time }
|
||||||
func (self *Env) Difficulty() *big.Int { return self.difficulty }
|
func (self *Env) Difficulty() *big.Int { return self.difficulty }
|
||||||
|
Loading…
Reference in New Issue
Block a user