Fix invalid code hash algo
This commit is contained in:
parent
22eef2aa20
commit
e47d1a4dc8
@ -8,17 +8,16 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
auth "github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
|
||||||
|
|
||||||
"github.com/cosmos/ethermint/types"
|
"github.com/cosmos/ethermint/types"
|
||||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||||
ethstate "github.com/ethereum/go-ethereum/core/state"
|
ethstate "github.com/ethereum/go-ethereum/core/state"
|
||||||
|
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ ethstate.StateObject = (*stateObject)(nil)
|
_ ethstate.StateObject = (*stateObject)(nil)
|
||||||
|
|
||||||
emptyCodeHash = tmcrypto.Sha256(nil)
|
emptyCodeHash = ethcrypto.Keccak256(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -363,5 +362,5 @@ func (so stateObject) GetStorageByAddressKey(key []byte) ethcmn.Hash {
|
|||||||
copy(compositeKey, prefix)
|
copy(compositeKey, prefix)
|
||||||
copy(compositeKey[len(prefix):], key)
|
copy(compositeKey[len(prefix):], key)
|
||||||
|
|
||||||
return ethcmn.BytesToHash(tmcrypto.Sha256(compositeKey))
|
return ethcrypto.Keccak256Hash(compositeKey)
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,10 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||||
|
|
||||||
tmcrypto "github.com/tendermint/tendermint/crypto"
|
|
||||||
|
|
||||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||||
ethstate "github.com/ethereum/go-ethereum/core/state"
|
ethstate "github.com/ethereum/go-ethereum/core/state"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
|
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -140,8 +139,7 @@ func (csdb *CommitStateDB) SetState(addr ethcmn.Address, key, value ethcmn.Hash)
|
|||||||
func (csdb *CommitStateDB) SetCode(addr ethcmn.Address, code []byte) {
|
func (csdb *CommitStateDB) SetCode(addr ethcmn.Address, code []byte) {
|
||||||
so := csdb.GetOrNewStateObject(addr)
|
so := csdb.GetOrNewStateObject(addr)
|
||||||
if so != nil {
|
if so != nil {
|
||||||
key := ethcmn.BytesToHash(tmcrypto.Sha256(code))
|
so.SetCode(ethcrypto.Keccak256Hash(code), code)
|
||||||
so.SetCode(key, code)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user