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

chore(evm): Deprecate x/params usage in x/evm #1472

Merged
merged 70 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9f3fee9
imp(evm): Migrate from old Cosmos SDK params module to new way of kee…
Vvaradinov Nov 17, 2022
7d8d228
Updated changelog
Vvaradinov Nov 17, 2022
63d4a62
Apply changes from code review
Vvaradinov Nov 18, 2022
9aaa035
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 18, 2022
bfb2633
(impv): Added Shanghai and Cancun blocks to current types and latest …
Vvaradinov Nov 18, 2022
fa68d16
(tests): Update unit tests to include Shanghai and Cancun blocks
Vvaradinov Nov 18, 2022
0566f9d
(fix) - ran golangci-lint on the entire project
Vvaradinov Nov 18, 2022
7d09bb8
(fix) - remove deprecated params method
Vvaradinov Nov 18, 2022
4d519d5
(impv): added marshaling of booleans per individual param key
Vvaradinov Nov 18, 2022
72a8d4b
(impv): added individual param getting and setting
Vvaradinov Nov 19, 2022
4c4be05
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 19, 2022
86cc0e4
(impv): replaced getters with individual param
Vvaradinov Nov 21, 2022
567043c
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 21, 2022
5eb724d
(impv): added amino codec for MsgEthereumTx
Vvaradinov Nov 21, 2022
422a247
Added changes suggested in code review
Vvaradinov Nov 22, 2022
f95e918
(fix): updated the migration files for v4
Vvaradinov Nov 22, 2022
52a45ec
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 22, 2022
53b4ab0
(fix): fixed unit tests panic for incorrect interface
Vvaradinov Nov 22, 2022
512ed48
Merge branch 'Vvaradinov/refactor-deprecated-evm-params-logic' of htt…
Vvaradinov Nov 22, 2022
669d8f6
(fix): updated module msg handler
Vvaradinov Nov 23, 2022
ca95892
(fix): rename to original params getter method
Vvaradinov Nov 23, 2022
85d5eff
(refactor): registered implementation for the new msg
Vvaradinov Nov 24, 2022
fe9dc4c
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 24, 2022
74b1878
(refactor): added correct amino codec for MsgUpdateParams and removed…
Vvaradinov Nov 25, 2022
42e1405
Applied changes from code review
Vvaradinov Nov 25, 2022
90f7877
(fix): removed unnecessary duplicate
Vvaradinov Nov 25, 2022
6788828
(fix): removed params_legacy from the types and moved logic to migration
Vvaradinov Nov 25, 2022
096f422
(fix): Added v4 mocks to the migrations_test
Vvaradinov Nov 25, 2022
5db39eb
(fix): undo all the non related work regarding the Cancun and Shangha…
Vvaradinov Nov 25, 2022
efd88b3
(fix): reverted linting the entire project - will make a separate PR …
Vvaradinov Nov 25, 2022
960b213
Applied changes from review
Vvaradinov Nov 25, 2022
d8dd162
Applied changes from code review
Vvaradinov Nov 25, 2022
7158f1c
(fix): removed comments
Vvaradinov Nov 25, 2022
7431a28
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 25, 2022
a5c3397
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 25, 2022
b82775f
(fix): Ran formatter and fixed linting issues on unsed functions
Vvaradinov Nov 25, 2022
19146e6
(fix): Linting issues resolved
Vvaradinov Nov 25, 2022
a5e1e9f
(fix): refactor migrations and added default EIPs
Vvaradinov Nov 28, 2022
f6a4290
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 28, 2022
28a315c
(fix): Combined into one call
Vvaradinov Nov 28, 2022
0c48520
(fix): Added more straightforward way to handle migration
Vvaradinov Nov 28, 2022
2995dab
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 29, 2022
03e5b52
(fix): corrected migration test
Vvaradinov Nov 29, 2022
42429e5
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 29, 2022
5b8f891
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 30, 2022
42aefa5
Applied changes from code review
Vvaradinov Nov 30, 2022
36e13cb
(fix): Linter fix
Vvaradinov Nov 30, 2022
4e3fb16
(fix): Linter
Vvaradinov Nov 30, 2022
584a751
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Nov 30, 2022
6c9a676
(fix): Lint proto files
Vvaradinov Dec 1, 2022
381df32
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
MalteHerrmann Dec 9, 2022
2153748
Apply suggestions from code review
Vvaradinov Dec 9, 2022
31b1031
(fix): Added new block to migration
Vvaradinov Dec 9, 2022
db4de42
Merge branch 'Vvaradinov/refactor-deprecated-evm-params-logic' of htt…
Vvaradinov Dec 9, 2022
973a7e1
(fix): Added additional comments and formatted proto files
Vvaradinov Dec 9, 2022
953a809
(fix): Added name to unit test cases
Vvaradinov Dec 9, 2022
f7d2ed4
(fix): removed unused import
Vvaradinov Dec 9, 2022
ba122d7
Apply changes from code review
Vvaradinov Dec 12, 2022
6f19bd8
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Dec 12, 2022
a91e4a4
(fix): typo
Vvaradinov Dec 12, 2022
83226dd
Merge branch 'Vvaradinov/refactor-deprecated-evm-params-logic' of htt…
Vvaradinov Dec 12, 2022
bfd8e89
(fix): remove HTTP endpoint exposure
Vvaradinov Dec 12, 2022
abceb75
Apply suggestions from code review
Vvaradinov Dec 16, 2022
9cb60cb
applied changes from code review
Vvaradinov Dec 19, 2022
c9a2418
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Dec 19, 2022
408d3aa
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Jan 3, 2023
0403e57
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
Vvaradinov Jan 3, 2023
3812eee
fix: extra line added in merge removed
Vvaradinov Jan 3, 2023
ddaf663
fix: applied changes from code review
Vvaradinov Jan 4, 2023
aae45b2
Merge branch 'main' into Vvaradinov/refactor-deprecated-evm-params-logic
danburck Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (evm) [#1472](https://github.com/evmos/ethermint/pull/1472) Deprecate x/params usage in x/evm
* (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).
Expand Down
4 changes: 2 additions & 2 deletions app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ type EVMKeeper interface {
ResetTransientGasUsed(ctx sdk.Context)
GetTxIndexTransient(ctx sdk.Context) uint64
GetChainConfig(ctx sdk.Context) evmtypes.ChainConfig
GetAllowUnprotectedTxs(ctx sdk.Context) bool
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
GetEVMDenom(ctx sdk.Context) string
GetEnableCreate(ctx sdk.Context) bool
GetEnableCall(ctx sdk.Context) bool
GetAllowUnprotectedTxs(ctx sdk.Context) bool
GetEnableCreate(ctx sdk.Context) bool
}

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

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

Expand Down
6 changes: 3 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ message Params {
// enable_call toggles state transitions that use the vm.Call function
bool enable_call = 3 [(gogoproto.moretags) = "yaml:\"enable_call\""];
// extra_eips defines the additional EIPs for the vm.Config
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
ExtraEIPs extra_eips = 4 [
(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\"", (gogoproto.nullable) = false
];
// chain_config defines the EVM chain configuration parameters
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 6;
}

// ExtraEIPs Represents extra EIPs for the vm.Config
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
message ExtraEIPs {
// extra_eips defines the additional EIPs for the vm.Config
repeated int64 extra_eips = 1 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
}
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved

// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
// instead of *big.Int.
message ChainConfig {
Expand Down
33 changes: 28 additions & 5 deletions proto/ethermint/evm/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";


option go_package = "github.com/evmos/ethermint/x/evm/types";

// Msg defines the evm Msg service.
Expand All @@ -15,6 +17,11 @@ 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) {
option (google.api.http).post = "/ethermint/evm/v1/update_params";
};
}

// MsgEthereumTx encapsulates an Ethereum transaction as an SDK message.
Expand Down Expand Up @@ -51,7 +58,7 @@ message LegacyTx {
string to = 4;
// value defines the unsigned integer value of the transaction amount.
string value = 5
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
// data is the data payload bytes of the transaction.
bytes data = 6;
// v defines the signature value
Expand Down Expand Up @@ -83,12 +90,12 @@ message AccessListTx {
string to = 5;
// value defines the unsigned integer value of the transaction amount.
string value = 6
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 7;
// accesses is an array of access tuples
repeated AccessTuple accesses = 8
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
// v defines the signature value
bytes v = 9;
// r defines the signature value
Expand Down Expand Up @@ -120,12 +127,12 @@ message DynamicFeeTx {
string to = 6;
// value defines the the transaction amount.
string value = 7
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 8;
// accesses is an array of access tuples
repeated AccessTuple accesses = 9
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
// v defines the signature value
bytes v = 10;
// r defines the signature value
Expand Down Expand Up @@ -158,3 +165,19 @@ message MsgEthereumTxResponse {
// gas_used specifies how much gas was consumed by the transaction
uint64 gas_used = 5;
}

Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
// MsgUpdateParams defines a Msg for updating the x/evm module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved

// 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 {}
10 changes: 5 additions & 5 deletions rpc/backend/backend_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package backend

import (
"bufio"
"fmt"
"math/big"
"os"
"path/filepath"
"testing"

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

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

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -21,6 +20,7 @@ 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 Expand Up @@ -49,7 +49,7 @@ func (suite *BackendTestSuite) SetupTest() {
ctx.Viper.Set("telemetry.global-labels", []interface{}{})

baseDir := suite.T().TempDir()
nodeDirName := "node"
nodeDirName := fmt.Sprintf("node")
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
clientDir := filepath.Join(baseDir, nodeDirName, "evmoscli")
keyRing, err := suite.generateTestKeyring(clientDir)
if err != nil {
Expand All @@ -70,7 +70,7 @@ func (suite *BackendTestSuite) SetupTest() {
suite.Require().NoError(err)

encodingConfig := encoding.MakeConfig(app.ModuleBasics)
clientCtx := client.Context{}.WithChainID(ChainID).
clientCtx := client.Context{}.WithChainID("ethermint_9000-1").
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
WithHeight(1).
WithTxConfig(encodingConfig.TxConfig).
WithKeyringDir(clientDir).
Expand All @@ -95,7 +95,7 @@ func (suite *BackendTestSuite) SetupTest() {
// buildEthereumTx returns an example legacy Ethereum transaction
func (suite *BackendTestSuite) buildEthereumTx() (*evmtypes.MsgEthereumTx, []byte) {
msgEthereumTx := evmtypes.NewTx(
suite.backend.chainID,
big.NewInt(1),
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
uint64(0),
&common.Address{},
big.NewInt(0),
Expand Down
3 changes: 1 addition & 2 deletions rpc/backend/call_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package backend
import (
"encoding/json"
"fmt"
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand All @@ -14,6 +12,7 @@ import (
"github.com/evmos/ethermint/tests"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"google.golang.org/grpc/metadata"
"math/big"
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
)

func (suite *BackendTestSuite) TestResend() {
Expand Down
5 changes: 4 additions & 1 deletion x/evm/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func InitGenesis(
) []abci.ValidatorUpdate {
k.WithChainID(ctx)

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

// ensure evm module account is set
if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil {
Expand Down
5 changes: 3 additions & 2 deletions x/evm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ 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)
Vvaradinov marked this conversation as resolved.
Show resolved Hide resolved
default:
err := errorsmod.Wrapf(errortypes.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion x/evm/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package evm_test

import (
"errors"
"github.com/evmos/ethermint/x/evm/keeper"
"math/big"
"testing"
"time"

"github.com/evmos/ethermint/x/evm/keeper"

sdkmath "cosmossdk.io/math"
"github.com/gogo/protobuf/proto"

Expand Down
11 changes: 6 additions & 5 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,11 @@ 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 @@ -1261,9 +1265,7 @@ 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 @@ -1334,7 +1336,6 @@ func (suite *KeeperTestSuite) TestEthCall() {
}
})
}

}

func (suite *KeeperTestSuite) TestEmptyRequest() {
Expand Down
22 changes: 10 additions & 12 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/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 @@ -36,8 +35,8 @@ type Keeper struct {
// key to access the transient store, which is reset on every block during Commit
transientKey storetypes.StoreKey

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

// 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,
paramSpace: paramSpace,
authority: authority,
accountKeeper: ak,
bankKeeper: bankKeeper,
stakingKeeper: sk,
Expand Down Expand Up @@ -141,6 +135,11 @@ func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
)
}

// GetAuthority returns the x/evm module authority address
func (k Keeper) GetAuthority() string {
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 @@ -297,8 +296,7 @@ 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())
evmDenom := ""
k.paramSpace.GetIfExists(ctx, types.ParamStoreKeyEVMDenom, &evmDenom)
evmDenom := k.GetEVMDenom(ctx)
// if node is pruned, params is empty. Return invalid value
if evmDenom == "" {
return big.NewInt(-1)
Expand Down
4 changes: 1 addition & 3 deletions x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (suite *KeeperTestSuite) SetupTest() {
// SetupApp setup test environment, it uses`require.TestingT` to support both `testing.T` and `testing.B`.
func (suite *KeeperTestSuite) SetupApp(checkTx bool) {
t := suite.T()

// account key, use a constant account to keep unit test deterministic.
ecdsaPriv, err := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
require.NoError(t, err)
Expand Down Expand Up @@ -480,10 +481,8 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() {
i++
return false
})

})
}

}

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

})
}
}
Loading