From 9a2d39bf182c1bb8d9923900d9eebaf649c2d235 Mon Sep 17 00:00:00 2001 From: noot <36753753+noot@users.noreply.github.com> Date: Tue, 15 Sep 2020 13:17:22 -0400 Subject: [PATCH] update minimum gas price to be 1 (#515) * update minimum gas price to be 1 * update changelog --- CHANGELOG.md | 2 ++ x/evm/types/msg.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0ae1725..cdc18433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,12 +51,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (`x/evm`) [\#458](https://github.com/ChainSafe/ethermint/pull/458) Define parameter for token denomination used for the EVM module. * (`x/evm`) [\#443](https://github.com/ChainSafe/ethermint/issues/443) Support custom Ethereum `ChainConfig` params. * (types) [\#434](https://github.com/ChainSafe/ethermint/issues/434) Update default denomination to Atto Photon (`aphoton`). +* (types) [\#515](https://github.com/ChainSafe/ethermint/pull/515) Update minimum gas price to be 1. ### Bug Fixes * (types) [\#507](https://github.com/ChainSafe/ethermint/pull/507) Fix hardcoded `aphoton` on `EthAccount` balance getter and setter. * (`x/evm`) [\#496](https://github.com/ChainSafe/ethermint/pull/496) Fix bugs on `journal.revert` and `CommitStateDB.Copy`. * (types) [\#480](https://github.com/ChainSafe/ethermint/pull/480) Update [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) coin type to `60` to satisfy [EIP84](https://github.com/ethereum/EIPs/issues/84). +* (types) [\#513](https://github.com/ChainSafe/ethermint/pull/513) Fix simulated transaction bug that was causing a consensus error by unintentionally affecting the state. ## [v0.1.0] - 2020-08-23 diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index a5b88199..a35d63d0 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -82,8 +82,12 @@ func (msg MsgEthermint) GetSignBytes() []byte { // ValidateBasic runs stateless checks on the message func (msg MsgEthermint) ValidateBasic() error { + if msg.Price.IsZero() { + return sdkerrors.Wrapf(types.ErrInvalidValue, "gas price cannot be 0") + } + if msg.Price.Sign() == -1 { - return sdkerrors.Wrapf(types.ErrInvalidValue, "price cannot be negative %s", msg.Price) + return sdkerrors.Wrapf(types.ErrInvalidValue, "gas price cannot be negative %s", msg.Price) } // Amount can be 0 @@ -185,8 +189,12 @@ func (msg MsgEthereumTx) Type() string { return TypeMsgEthereumTx } // ValidateBasic implements the sdk.Msg interface. It performs basic validation // checks of a Transaction. If returns an error if validation fails. func (msg MsgEthereumTx) ValidateBasic() error { + if msg.Data.Price.Cmp(big.NewInt(0)) == 0 { + return sdkerrors.Wrapf(types.ErrInvalidValue, "gas price cannot be 0") + } + if msg.Data.Price.Sign() == -1 { - return sdkerrors.Wrapf(types.ErrInvalidValue, "price cannot be negative %s", msg.Data.Price) + return sdkerrors.Wrapf(types.ErrInvalidValue, "gas price cannot be negative %s", msg.Data.Price) } // Amount can be 0