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
+1 -2
View File
@@ -478,7 +478,6 @@ func (suite *KeeperTestSuite) TestQueryValidatorAccount() {
}
func (suite *KeeperTestSuite) TestEstimateGas() {
ctx := sdk.WrapSDKContext(suite.ctx)
gasHelper := hexutil.Uint64(20000)
var (
@@ -545,7 +544,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
GasCap: gasCap,
}
rsp, err := suite.queryClient.EstimateGas(ctx, &req)
rsp, err := suite.queryClient.EstimateGas(sdk.WrapSDKContext(suite.ctx), &req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(tc.expGas, rsp.Gas)
-1
View File
@@ -307,7 +307,6 @@ func (k Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) (type
func (k Keeper) DeleteState(addr common.Address, key common.Hash) {
store := prefix.NewStore(k.Ctx().KVStore(k.storeKey), types.AddressStoragePrefix(addr))
key = types.KeyAddressStorage(addr, key)
store.Delete(key.Bytes())
}
+1 -3
View File
@@ -454,10 +454,9 @@ func (k *Keeper) GetRefund() uint64 {
// State
// ----------------------------------------------------------------------------
func doGetState(ctx sdk.Context, storeKey sdk.StoreKey, addr common.Address, hash common.Hash) common.Hash {
func doGetState(ctx sdk.Context, storeKey sdk.StoreKey, addr common.Address, key common.Hash) common.Hash {
store := prefix.NewStore(ctx.KVStore(storeKey), types.AddressStoragePrefix(addr))
key := types.KeyAddressStorage(addr, hash)
value := store.Get(key.Bytes())
if len(value) == 0 {
return common.Hash{}
@@ -496,7 +495,6 @@ func (k *Keeper) SetState(addr common.Address, key, value common.Hash) {
ctx := k.Ctx()
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.AddressStoragePrefix(addr))
key = types.KeyAddressStorage(addr, key)
action := "updated"
if ethermint.IsEmptyHash(value.Hex()) {