core/state: return empty hash root instead of zero

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-10-31 19:25:39 +08:00
parent 10fe6415f4
commit bf7d3a35c1

View file

@ -305,7 +305,7 @@ func (s *StateDB) GetStorageRoot(addr common.Address) common.Hash {
if stateObject != nil { if stateObject != nil {
return stateObject.Root() return stateObject.Root()
} }
return common.Hash{} return types.EmptyRootHash
} }
// TxIndex returns the current transaction index set by Prepare. // TxIndex returns the current transaction index set by Prepare.
@ -331,11 +331,11 @@ func (s *StateDB) GetCodeSize(addr common.Address) int {
func (s *StateDB) GetCodeHash(addr common.Address) common.Hash { func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
stateObject := s.getStateObject(addr) stateObject := s.getStateObject(addr)
if stateObject == nil { if stateObject != nil {
return common.Hash{}
}
return common.BytesToHash(stateObject.CodeHash()) return common.BytesToHash(stateObject.CodeHash())
} }
return types.EmptyCodeHash
}
// GetState retrieves a value from the given account's storage trie. // GetState retrieves a value from the given account's storage trie.
func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash { func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {