evm: fix import/export genesis for contract storage (#590)

* Problem: import/export roundtrip test fail contract storage

Closes: #589

- don't hash the key again in InitGenesis

* changelog

* try to fix estimate-gas undeterministics Closes #536
This commit is contained in:
yihuang
2021-09-27 12:26:45 +02:00
committed by GitHub
parent 2088297e3d
commit d6a64a275a
5 changed files with 3 additions and 21 deletions
-15
View File
@@ -2,7 +2,6 @@ package types
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
const (
@@ -69,17 +68,3 @@ func AddressStoragePrefix(address common.Address) []byte {
func StateKey(address common.Address, key []byte) []byte {
return append(AddressStoragePrefix(address), key...)
}
// KeyAddressStorage returns the key hash to access a given account state. The composite key
// (address + hash) is hashed using Keccak256.
func KeyAddressStorage(address common.Address, hash common.Hash) common.Hash {
prefix := address.Bytes()
key := hash.Bytes()
compositeKey := make([]byte, len(prefix)+len(key))
copy(compositeKey, prefix)
copy(compositeKey[len(prefix):], key)
return crypto.Keccak256Hash(compositeKey)
}