Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Revert "chore(evm): Deprecate x/params usage in x/evm (#1472)"
Browse files Browse the repository at this point in the history
This reverts commit 0f7bdce.
  • Loading branch information
GAtom22 committed Jan 23, 2023
1 parent d9bfd3d commit e593a86
Show file tree
Hide file tree
Showing 30 changed files with 195 additions and 5,053 deletions.
26 changes: 4 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (feemarket) [#1509](https://github.com/evmos/ethermint/pull/1509) Deprecate usage of x/params in x/feemarket
* (evm) [#1472](https://github.com/evmos/ethermint/pull/1472) Deprecate x/params usage in x/evm
* (deps) [#1575](https://github.com/evmos/ethermint/pull/1575) bump ibc-go to [`v6.1.0`]
* (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade Cosmos SDK to [`v0.46.6`]

### Improvements

* (evm) [#1582](https://github.com/evmos/ethermint/pull/1582) cleanup `evm` files
* (evm) [#1544](https://github.com/evmos/ethermint/pull/1544) Migrate deprecated event emitting to new TypedEvent
* (deps) [#1532](https://github.com/evmos/ethermint/pull/1532) Upgrade Go-Ethereum version to [`v1.10.26`](https://github.com/ethereum/go-ethereum/releases/tag/v1.10.26).

### Bug Fixes
* (rpc) [#1600](https://github.com/evmos/ethermint/pull/1600) Revert changes from `TypedEvents`
* (proto) [#1586](https://github.com/evmos/ethermint/pull/1586) Avoid duplicate register proto type in `evm` & `feemarket`

## [v0.20.0] - 2022-12-28

### State Machine Breaking

* (deps) [#1564](https://github.com/evmos/ethermint/pull/1564) Bump ibc-go to [`v5.2.0`](https://github.com/cosmos/ibc-go/releases/tag/v5.2.0)
* (evm) [#1272](https://github.com/evmos/ethermint/pull/1272) Implement modular interface for the EVM.
* (deps) [#1551](https://github.com/evmos/ethermint/pull/1551) Upgrade Cosmos SDK to [`v0.46.7`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.7).
* (deps) #[1575](https://github.com/evmos/ethermint/pull/1575) bump ibc-go to [`v6.1.0`]
* (deps) [#1361](https://github.com/evmos/ethermint/pull/1361) Bump ibc-go to [`v5.1.0`](https://github.com/cosmos/ibc-go/releases/tag/v5.1.0)
* (evm) [\#1272](https://github.com/evmos/ethermint/pull/1272) Implement modular interface for the EVM.
* (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade Cosmos SDK to [`v0.46.6`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6).
* (feemarket) [#1194](https://github.com/evmos/ethermint/pull/1194) Apply feemarket to native cosmos tx.
* (eth) [#1346](https://github.com/evmos/ethermint/pull/1346) Added support for `sdk.Dec` and `ed25519` type on eip712.
* (evm) [#1452](https://github.com/evmos/ethermint/pull/1452) Simplify Gas Math in `ApplyTransaction`.
Expand Down
6 changes: 5 additions & 1 deletion app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ type EVMKeeper interface {
GetBalance(ctx sdk.Context, addr common.Address) *big.Int
ResetTransientGasUsed(ctx sdk.Context)
GetTxIndexTransient(ctx sdk.Context) uint64
GetParams(ctx sdk.Context) evmtypes.Params
GetChainConfig(ctx sdk.Context) evmtypes.ChainConfig
GetEVMDenom(ctx sdk.Context) string
GetEnableCreate(ctx sdk.Context) bool
GetEnableCall(ctx sdk.Context) bool
GetAllowUnprotectedTxs(ctx sdk.Context) bool
}

type protoTxProvider interface {
Expand Down
8 changes: 3 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,8 @@ func NewEthermintApp(
keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketSs,
)

// Set authority to x/gov module account to only expect the module account to update params
evmSs := app.GetSubspace(evmtypes.ModuleName)
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName),
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
nil, geth.NewEVM, tracer, evmSs,
)
Expand Down Expand Up @@ -509,8 +507,8 @@ func NewEthermintApp(
ibc.NewAppModule(app.IBCKeeper),
transferModule,
// Ethermint app modules
feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketSs),
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs),
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down
6 changes: 3 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ message ChainConfig {
];
// dao_fork_support defines whether the nodes supports or opposes the DAO hard-fork
bool dao_fork_support = 3
[(gogoproto.customname) = "DAOForkSupport", (gogoproto.moretags) = "yaml:\"dao_fork_support\""];
[(gogoproto.customname) = "DAOForkSupport", (gogoproto.moretags) = "yaml:\"dao_fork_support\""];
// eip150_block: EIP150 implements the Gas price changes
// (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil no fork)
string eip150_block = 4 [
Expand Down Expand Up @@ -127,6 +127,7 @@ message ChainConfig {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"cancun_block\""
];

}

// State represents a single Storage key value pair item.
Expand Down
20 changes: 0 additions & 20 deletions proto/ethermint/evm/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
syntax = "proto3";
package ethermint.evm.v1;

import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "ethermint/evm/v1/evm.proto";
import "gogoproto/gogo.proto";
Expand All @@ -16,9 +15,6 @@ service Msg {
rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) {
option (google.api.http).post = "/ethermint/evm/v1/ethereum_tx";
};
// UpdateParams defined a governance operation for updating the x/evm module parameters.
// The authority is hard-coded to the Cosmos SDK x/gov module account
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
Expand Down Expand Up @@ -162,19 +158,3 @@ message MsgEthereumTxResponse {
// gas_used specifies how much gas was consumed by the transaction
uint64 gas_used = 5;
}

// MsgUpdateParams defines a Msg for updating the x/evm module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params defines the x/evm parameters to update.
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}
3 changes: 2 additions & 1 deletion rpc/backend/backend_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"path/filepath"
"testing"

"github.com/evmos/ethermint/crypto/ethsecp256k1"

dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -19,7 +21,6 @@ import (
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"

"github.com/evmos/ethermint/app"
"github.com/evmos/ethermint/crypto/ethsecp256k1"
"github.com/evmos/ethermint/crypto/hd"
"github.com/evmos/ethermint/encoding"
"github.com/evmos/ethermint/indexer"
Expand Down
5 changes: 1 addition & 4 deletions x/evm/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ func InitGenesis(
) []abci.ValidatorUpdate {
k.WithChainID(ctx)

err := k.SetParams(ctx, data.Params)
if err != nil {
panic(fmt.Errorf("error setting params %s", err))
}
k.SetParams(ctx, data.Params)

// ensure evm module account is set
if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil {
Expand Down
5 changes: 2 additions & 3 deletions x/evm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ func NewHandler(server types.MsgServer) sdk.Handler {

switch msg := msg.(type) {
case *types.MsgEthereumTx:
// execute state transition
res, err := server.EthereumTx(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgUpdateParams:
res, err := server.UpdateParams(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)

default:
err := errorsmod.Wrapf(errortypes.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
return nil, err
Expand Down
8 changes: 5 additions & 3 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
"enough balance",
func() {
args = types.TransactionArgs{To: &common.Address{}, From: &suite.address, Value: (*hexutil.Big)(big.NewInt(100))}
}, false, 0, false,
},
}, false, 0, false},
// should success, because gas limit lower than 21000 is ignored
{
"gas exceed allowance",
Expand Down Expand Up @@ -1262,7 +1261,9 @@ func (suite *KeeperTestSuite) TestQueryBaseFee() {
}

func (suite *KeeperTestSuite) TestEthCall() {
var req *types.EthCallRequest
var (
req *types.EthCallRequest
)

address := tests.GenerateAddress()
suite.Require().Equal(uint64(0), suite.app.EvmKeeper.GetNonce(suite.ctx, address))
Expand Down Expand Up @@ -1333,6 +1334,7 @@ func (suite *KeeperTestSuite) TestEthCall() {
}
})
}

}

func (suite *KeeperTestSuite) TestEmptyRequest() {
Expand Down
25 changes: 10 additions & 15 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -51,8 +51,8 @@ type Keeper struct {
// key to access the transient store, which is reset on every block during Commit
transientKey storetypes.StoreKey

// the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
authority sdk.AccAddress
// module specific parameter space that can be configured through governance
paramSpace paramtypes.Subspace
// access to account state
accountKeeper types.AccountKeeper
// update balance and accounting operations with coins
Expand Down Expand Up @@ -84,7 +84,7 @@ type Keeper struct {
func NewKeeper(
cdc codec.BinaryCodec,
storeKey, transientKey storetypes.StoreKey,
authority sdk.AccAddress,
paramSpace paramtypes.Subspace,
ak types.AccountKeeper,
bankKeeper types.BankKeeper,
sk types.StakingKeeper,
Expand All @@ -99,15 +99,15 @@ func NewKeeper(
panic("the EVM module account has not been set")
}

// ensure the authority account is correct
if err := sdk.VerifyAddressFormat(authority); err != nil {
panic(err)
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
}

// NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations
return &Keeper{
cdc: cdc,
authority: authority,
paramSpace: paramSpace,
accountKeeper: ak,
bankKeeper: bankKeeper,
stakingKeeper: sk,
Expand Down Expand Up @@ -160,11 +160,6 @@ func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
)
}

// GetAuthority returns the x/evm module authority address
func (k Keeper) GetAuthority() sdk.AccAddress {
return k.authority
}

// GetBlockBloomTransient returns bloom bytes for the current block height
func (k Keeper) GetBlockBloomTransient(ctx sdk.Context) *big.Int {
store := prefix.NewStore(ctx.TransientStore(k.transientKey), types.KeyPrefixTransientBloom)
Expand Down Expand Up @@ -321,8 +316,8 @@ func (k *Keeper) GetNonce(ctx sdk.Context, addr common.Address) uint64 {
// GetBalance load account's balance of gas token
func (k *Keeper) GetBalance(ctx sdk.Context, addr common.Address) *big.Int {
cosmosAddr := sdk.AccAddress(addr.Bytes())
evmParams := k.GetParams(ctx)
evmDenom := evmParams.GetEvmDenom()
evmDenom := ""
k.paramSpace.GetIfExists(ctx, types.ParamStoreKeyEVMDenom, &evmDenom)
// if node is pruned, params is empty. Return invalid value
if evmDenom == "" {
return big.NewInt(-1)
Expand Down
3 changes: 3 additions & 0 deletions x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,10 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() {
i++
return false
})

})
}

}

func (suite *KeeperTestSuite) TestGetAccountOrEmpty() {
Expand Down Expand Up @@ -531,6 +533,7 @@ func (suite *KeeperTestSuite) TestGetAccountOrEmpty() {
} else {
suite.Require().NotEqual(empty, res)
}

})
}
}
25 changes: 3 additions & 22 deletions x/evm/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,14 @@
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v4 "github.com/evmos/ethermint/x/evm/migrations/v4"
v5 "github.com/evmos/ethermint/x/evm/migrations/v5"
"github.com/evmos/ethermint/x/evm/types"
)

// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper Keeper
legacySubspace types.Subspace
keeper Keeper
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper Keeper, legacySubspace types.Subspace) Migrator {
func NewMigrator(keeper Keeper) Migrator {
return Migrator{
keeper: keeper,
legacySubspace: legacySubspace,
keeper: keeper,
}
}

// Migrate3to4 migrates the store from consensus version 3 to 4
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.legacySubspace, m.keeper.cdc)
}

// Migrate4to5 migrates the store from consensus version 4 to 5
func (m Migrator) Migrate4to5(ctx sdk.Context) error {
return v5.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
41 changes: 0 additions & 41 deletions x/evm/keeper/migrations_test.go

This file was deleted.

19 changes: 0 additions & 19 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"fmt"
"strconv"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmtypes "github.com/tendermint/tendermint/types"

Expand Down Expand Up @@ -142,20 +140,3 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t

return response, nil
}

// UpdateParams implements the gRPC MsgServer interface. When an UpdateParams
// proposal passes, it updates the module parameters. The update can only be
// performed if the requested authority is the Cosmos SDK governance module
// account.
func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if k.authority.String() != req.Authority {
return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority, expected %s, got %s", k.authority.String(), req.Authority)
}

ctx := sdk.UnwrapSDKContext(goCtx)
if err := k.SetParams(ctx, req.Params); err != nil {
return nil, err
}

return &types.MsgUpdateParamsResponse{}, nil
}
Loading

0 comments on commit e593a86

Please sign in to comment.