Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Misc cleanup (#188)
Browse files Browse the repository at this point in the history
* evm: move Begin and EndBlock to abci.go

* evm: use expected keeper interfaces

* app: use EthermintApp for integration and unit test setup

* evm: remove count type; update codec

* go mod verify

* evm: rename msgs for consistency

* evm: events

* minor cleanup

* lint

* ante: update tests

* changelog

* nolint
  • Loading branch information
fedekunze authored Mar 12, 2020
1 parent ff91e3c commit 729ebf2
Show file tree
Hide file tree
Showing 29 changed files with 482 additions and 506 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (sdk) [\#171](https://github.com/ChainSafe/ethermint/issues/177) Bump Cosmos SDK version to [v0.38.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.1)
* Add `x/evidence` module to ethermint app
* (x/evm) [\#181](https://github.com/ChainSafe/ethermint/issues/181) Updated EVM module to the recommended module structure. [@fedekunze](https://github.com/fedekunze)
* (`x/evm`) [\#181](https://github.com/ChainSafe/ethermint/issues/181) Updated EVM module to the recommended module structure. [@fedekunze](https://github.com/fedekunze)
* (app) [\#188](https://github.com/ChainSafe/ethermint/issues/186) Misc cleanup [@fedekunze](https://github.com/fedekunze):
* (`x/evm`) Rename `EthereumTxMsg` --> `MsgEthereumTx` and `EmintMsg` --> `MsgEthermint` for consistency with SDK standards
* Updated integration and unit tests to use `EthermintApp` as testing suite
* Use expected keeper interface for `AccountKeeper`
* Replaced `count` type in keeper with `int`
* Add SDK events for transactions
16 changes: 8 additions & 8 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewAnteHandler(ak auth.AccountKeeper, sk types.SupplyKeeper) sdk.AnteHandle

return stdAnte(ctx, tx, sim)

case *evmtypes.EthereumTxMsg:
case *evmtypes.MsgEthereumTx:
return ethAnteHandler(ctx, ak, sk, castTx, sim)

default:
Expand Down Expand Up @@ -92,7 +92,7 @@ func sigGasConsumer(
// prevent spam and DoS attacks.
func ethAnteHandler(
ctx sdk.Context, ak auth.AccountKeeper, sk types.SupplyKeeper,
ethTxMsg *evmtypes.EthereumTxMsg, sim bool,
ethTxMsg *evmtypes.MsgEthereumTx, sim bool,
) (newCtx sdk.Context, err error) {

var senderAddr sdk.AccAddress
Expand Down Expand Up @@ -175,7 +175,7 @@ func ethAnteHandler(
}

func validateEthTxCheckTx(
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.EthereumTxMsg,
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.MsgEthereumTx,
) (sdk.AccAddress, error) {
// Validate sufficient fees have been provided that meet a minimum threshold
// defined by the proposer (for mempool purposes during CheckTx).
Expand All @@ -202,7 +202,7 @@ func validateEthTxCheckTx(
}

// Validates signature and returns sender address
func validateSignature(ctx sdk.Context, ethTxMsg *evmtypes.EthereumTxMsg) (sdk.AccAddress, error) {
func validateSignature(ctx sdk.Context, ethTxMsg *evmtypes.MsgEthereumTx) (sdk.AccAddress, error) {
// parse the chainID from a string to a base-10 integer
chainID, ok := new(big.Int).SetString(ctx.ChainID(), 10)
if !ok {
Expand All @@ -223,7 +223,7 @@ func validateSignature(ctx sdk.Context, ethTxMsg *evmtypes.EthereumTxMsg) (sdk.A
// that the transaction uses before the transaction is executed. The gas is a
// constant value of 21000 plus any cost inccured by additional bytes of data
// supplied with the transaction.
func validateIntrinsicGas(ethTxMsg *evmtypes.EthereumTxMsg) error {
func validateIntrinsicGas(ethTxMsg *evmtypes.MsgEthereumTx) error {
gas, err := ethcore.IntrinsicGas(ethTxMsg.Data.Payload, ethTxMsg.To() == nil, true)
if err != nil {
return sdkerrors.Wrap(err, "failed to compute intrinsic gas cost")
Expand All @@ -241,7 +241,7 @@ func validateIntrinsicGas(ethTxMsg *evmtypes.EthereumTxMsg) error {
// validateAccount validates the account nonce and that the account has enough
// funds to cover the tx cost.
func validateAccount(
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.EthereumTxMsg, signer sdk.AccAddress,
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.MsgEthereumTx, signer sdk.AccAddress,
) error {

acc := ak.GetAccount(ctx, signer)
Expand Down Expand Up @@ -272,7 +272,7 @@ func validateAccount(
}

func checkNonce(
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.EthereumTxMsg, signer sdk.AccAddress,
ctx sdk.Context, ak auth.AccountKeeper, ethTxMsg *evmtypes.MsgEthereumTx, signer sdk.AccAddress,
) error {
acc := ak.GetAccount(ctx, signer)
// Validate the transaction nonce is valid (equivalent to the sender account’s
Expand All @@ -293,7 +293,7 @@ func checkNonce(
// proposer.
//
// NOTE: This should only be ran during a CheckTx mode.
func ensureSufficientMempoolFees(ctx sdk.Context, ethTxMsg *evmtypes.EthereumTxMsg) error {
func ensureSufficientMempoolFees(ctx sdk.Context, ethTxMsg *evmtypes.MsgEthereumTx) error {
// fee = GP * GL
fee := sdk.NewDecCoinFromCoin(sdk.NewInt64Coin(emint.DenomDefault, ethTxMsg.Fee().Int64()))

Expand Down
Loading

0 comments on commit 729ebf2

Please sign in to comment.