forked from cerc-io/laconicd-deprecated
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user