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

bump Cosmos SDK version to v0.38.2 #183

Merged
merged 91 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
832759e
evm: move Keeper and Querier to /keeper package
fedekunze Mar 6, 2020
e5945f8
keeper: update keeper_test.go
fedekunze Mar 6, 2020
2d1a7b4
fix format
fedekunze Mar 6, 2020
23a7822
evm: use aliased types
fedekunze Mar 6, 2020
2e3081c
bump SDK version to v0.38.1
fedekunze Mar 6, 2020
f01326c
app: updates from new version
fedekunze Mar 6, 2020
213e278
errors: switch sdk.Error -> error
fedekunze Mar 6, 2020
af010c6
errors: switch sdk.Error -> error. Continuation
fedekunze Mar 6, 2020
28e94fb
more fixes
fedekunze Mar 6, 2020
865d962
update app/
fedekunze Mar 9, 2020
ad347a0
update keys and client pkgs
fedekunze Mar 9, 2020
1add197
merge master
fedekunze Mar 9, 2020
359de7a
build
fedekunze Mar 10, 2020
e41a25e
fix tests
fedekunze Mar 10, 2020
230ddf8
lint
fedekunze Mar 10, 2020
569a511
minor changes
fedekunze Mar 11, 2020
2c0dc2a
changelog
fedekunze Mar 11, 2020
6122b3c
address @austinbell comments
fedekunze Mar 11, 2020
fae679b
Fix keyring usage in rpc API and CLI
austinabell Mar 11, 2020
3988040
fix keyring
fedekunze Mar 12, 2020
ff91e3c
break line
fedekunze Mar 12, 2020
729ebf2
Misc cleanup (#188)
fedekunze Mar 12, 2020
b70f6cb
evm: update statedb to create ethermint Account instead of BaseAccount
fedekunze Mar 12, 2020
9eaf77f
fix importer test
fedekunze Mar 12, 2020
9db72db
address @austinabell comments
fedekunze Mar 13, 2020
2abf58b
update README
fedekunze Mar 13, 2020
ace3028
changelog
fedekunze Mar 13, 2020
6036b76
evm: update codec
fedekunze Mar 13, 2020
b37053e
Merge branch 'development' into fedekunze/177-bump-sdk-version
fedekunze Mar 13, 2020
84935a4
merge development
fedekunze Mar 16, 2020
89bfa6f
merge development
fedekunze Mar 17, 2020
cc59134
fix event sender
fedekunze Mar 17, 2020
d0aa494
store logs in keeper after transition (#210)
noot Mar 18, 2020
f92b815
fix encoding bug
fedekunze Mar 18, 2020
c955ed2
minor fix
fedekunze Mar 19, 2020
c05a72c
rpc: error handling
fedekunze Mar 19, 2020
aca648b
rpc: simulate only returns gasConsumed
fedekunze Mar 19, 2020
98c92f7
rpc: error ineffassign
fedekunze Mar 19, 2020
ffe98db
go: bump version to 1.14 and SDK version to latest master
fedekunze Mar 20, 2020
8d08f1c
rpc: fix simulation return value
fedekunze Mar 20, 2020
936e76a
breaking changes from SDK
fedekunze Mar 20, 2020
73b0e9f
sdk: breaking changes; build
fedekunze Mar 20, 2020
4ef5329
tests: fixes
fedekunze Mar 20, 2020
1cfee62
minor fix
fedekunze Mar 20, 2020
5cd63d9
proto: ethermint types attempt
fedekunze Mar 23, 2020
f6100a3
proto: define EthAccount proto type and extend sdk std.Codec
fedekunze Mar 23, 2020
37ac604
evm: fix panic on handler test
fedekunze Mar 24, 2020
b8e39dc
evm: minor state object changes
fedekunze Mar 24, 2020
df412db
cleanup
fedekunze Mar 24, 2020
abb321c
tests: update test-importer
fedekunze Mar 24, 2020
4ce2507
fix pubkey registration
fedekunze Mar 31, 2020
88d2aea
fix conflicts
fedekunze Mar 31, 2020
2acedcb
lint
fedekunze Mar 31, 2020
260946c
cleanup
fedekunze Mar 31, 2020
105b43e
more test checks for importer
fedekunze Mar 31, 2020
f966fbf
minor change
fedekunze Mar 31, 2020
a8286f1
codec fixes
fedekunze Mar 31, 2020
0c4c4b2
rm init func
fedekunze Mar 31, 2020
c9e968d
cleanup changes
fedekunze Apr 1, 2020
23c5422
fix importer test build
fedekunze Apr 1, 2020
4e640ec
fix marshaling for TxDecoder
fedekunze Apr 2, 2020
0c1d0ab
use amino codec for evm
fedekunze Apr 3, 2020
11d0722
fix marshaling for SimulationResponse
fedekunze Apr 3, 2020
0a080ee
use jsonpb for unmarshaling
fedekunze Apr 6, 2020
2859a1b
changes from development
fedekunze Apr 6, 2020
a34faad
fix method handler crashed
fedekunze Apr 6, 2020
1b4d0f0
return err on VerifySig
fedekunze Apr 6, 2020
1c15fca
switch stateObject balance to sdk.Int
fedekunze Apr 7, 2020
333d849
changes from development
fedekunze Apr 13, 2020
1e3359e
fixes to codec and encoding
fedekunze Apr 13, 2020
3887dc7
cleanup
fedekunze Apr 13, 2020
b46bd56
merge development
fedekunze Apr 13, 2020
36a9d7b
set tmhash -> ethhash in state transition
noot Apr 13, 2020
3c4314d
add tmhash->ethereumhash to csdb.GetLogs
noot Apr 13, 2020
aae0cf9
attempt to fix tests
noot Apr 13, 2020
c411a2c
Merge branch 'noot/hashes' of github.com:ChainSafe/ethermint into fed…
fedekunze Apr 13, 2020
c57db86
update GetLogs to switch with Has
noot Apr 13, 2020
594bbc1
Merge branch 'noot/hashes' of github.com:ChainSafe/ethermint into fed…
fedekunze Apr 13, 2020
fa4e8dc
ante panic
fedekunze Apr 13, 2020
07f1b66
changes from development
fedekunze Apr 13, 2020
363d969
diff changes
fedekunze Apr 13, 2020
5a9b68d
update SetLogs
noot Apr 15, 2020
d1bbf34
merge development
fedekunze Apr 16, 2020
23703c6
evm/cli: use ethermint codec
fedekunze Apr 16, 2020
a997dce
use LengthPrefixed for encoding
fedekunze Apr 16, 2020
aa594a9
add check for nil *big.Int
fedekunze Apr 16, 2020
a6eba63
add balance to UpdateAccounts
fedekunze Apr 16, 2020
9199ed2
fix previous balance
fedekunze Apr 16, 2020
6f70742
fix conflicts from development
fedekunze Apr 22, 2020
e016309
fix balance bug
fedekunze Apr 22, 2020
c7227af
prevent panic on make test-import
fedekunze Apr 22, 2020
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
19 changes: 11 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,30 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (x/evm) [\#181](https://github.com/ChainSafe/ethermint/issues/181) Updated EVM module to the recommended module structure. [@fedekunze](https://github.com/fedekunze)
* (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) [@fedekunze](https://github.com/fedekunze):
* Add `x/evidence` module to ethermint app
* Bump Go requirement to 1.14+
* (`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
* [\#236](https://github.com/ChainSafe/ethermint/pull/236) Changes from upgrade [@fedekunze](https://github.com/fedekunze)
* (app/ante) Moved `AnteHandler` implementation to `app/ante`
* (`app/ante`) Moved `AnteHandler` implementation to `app/ante`
* (keys) Marked `ExportEthKeyCommand` as **UNSAFE**
* (x/evm) Moved `BeginBlock` and `EndBlock` to `x/evm/abci.go`
* (`x/evm`) Moved `BeginBlock` and `EndBlock` to `x/evm/abci.go`

### Features

* (rpc) [\#231](https://github.com/ChainSafe/ethermint/issues/231) Implement NewBlockFilter in rpc/filters.go which instantiates a polling block filter
* Polls for new blocks via BlockNumber rpc call; if block number changes, it requests the new block via GetBlockByNumber rpc call and adds it to its internal list of blocks
* Update uninstallFilter and getFilterChanges accordingly
* uninstallFilter stops the polling goroutine
* getFilterChanges returns the filter's internal list of block hashes and resets it
* Polls for new blocks via BlockNumber rpc call; if block number changes, it requests the new block via GetBlockByNumber rpc call and adds it to its internal list of blocks
* Update uninstallFilter and getFilterChanges accordingly
* uninstallFilter stops the polling goroutine
* getFilterChanges returns the filter's internal list of block hashes and resets it

* (rpc) [\#54](https://github.com/ChainSafe/ethermint/issues/54) [\#55](https://github.com/ChainSafe/ethermint/issues/55)
* (rpc) [\#54](https://github.com/ChainSafe/ethermint/issues/54) [\#55](https://github.com/ChainSafe/ethermint/issues/55)
Implement eth_getFilterLogs and eth_getLogs
* for a given filter, look through each block for transactions. If there are transactions in the block, get the logs from it, and filter using the filterLogs method
* eth_getLogs and eth_getFilterChanges for log filters use the same underlying method as eth_getFilterLogs
Expand Down
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,73 @@ format:

.PHONY: build install update-tools tools godocs clean format lint \
test-cli test-race test-unit test test-import

###############################################################################
### Protobuf ###
###############################################################################

proto-all: proto-gen proto-lint proto-check-breaking

proto-gen:
@./scripts/protocgen.sh

proto-lint:
@buf check lint --error-format=json

# NOTE: should match the default repo branch
proto-check-breaking:
@buf check breaking --against-input '.git#branch=development'


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.33.3
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
SDK_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/master

TM_KV_TYPES = third_party/proto/tendermint/libs/kv
TM_MERKLE_TYPES = third_party/proto/tendermint/crypto/merkle
TM_ABCI_TYPES = third_party/proto/tendermint/abci/types
GOGO_PROTO_TYPES = third_party/proto/gogoproto
COSMOS_PROTO_TYPES = third_party/proto/cosmos-proto
SDK_PROTO_TYPES = third_party/proto/cosmos-sdk/types
AUTH_PROTO_TYPES = third_party/proto/cosmos-sdk/x/auth/types
VESTING_PROTO_TYPES = third_party/proto/cosmos-sdk/x/auth/vesting/types
SUPPLY_PROTO_TYPES = third_party/proto/cosmos-sdk/x/supply/types

proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(COSMOS_PROTO_TYPES)
@curl -sSL $(COSMOS_PROTO_URL)/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto

@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types/types.proto > $(TM_ABCI_TYPES)/types.proto
@sed -i '' '8 s|crypto/merkle/merkle.proto|third_party/proto/tendermint/crypto/merkle/merkle.proto|g' $(TM_ABCI_TYPES)/types.proto
@sed -i '' '9 s|libs/kv/types.proto|third_party/proto/tendermint/libs/kv/types.proto|g' $(TM_ABCI_TYPES)/types.proto

@mkdir -p $(TM_KV_TYPES)
@curl -sSL $(TM_URL)/libs/kv/types.proto > $(TM_KV_TYPES)/types.proto

@mkdir -p $(TM_MERKLE_TYPES)
@curl -sSL $(TM_URL)/crypto/merkle/merkle.proto > $(TM_MERKLE_TYPES)/merkle.proto

@mkdir -p $(SDK_PROTO_TYPES)
@curl -sSL $(SDK_PROTO_URL)/types/types.proto > $(SDK_PROTO_TYPES)/types.proto

@mkdir -p $(AUTH_PROTO_TYPES)
@curl -sSL $(SDK_PROTO_URL)/x/auth/types/types.proto > $(AUTH_PROTO_TYPES)/types.proto
@sed -i '' '5 s|types/types.proto|third_party/proto/cosmos-sdk/types/types.proto|g' $(AUTH_PROTO_TYPES)/types.proto

@mkdir -p $(VESTING_PROTO_TYPES)
curl -sSL $(SDK_PROTO_URL)/x/auth/vesting/types/types.proto > $(VESTING_PROTO_TYPES)/types.proto
@sed -i '' '5 s|types/types.proto|third_party/proto/cosmos-sdk/types/types.proto|g' $(VESTING_PROTO_TYPES)/types.proto
@sed -i '' '6 s|x/auth/types/types.proto|third_party/proto/cosmos-sdk/x/auth/types/types.proto|g' $(VESTING_PROTO_TYPES)/types.proto

@mkdir -p $(SUPPLY_PROTO_TYPES)
curl -sSL $(SDK_PROTO_URL)/x/supply/types/types.proto > $(SUPPLY_PROTO_TYPES)/types.proto
@sed -i '' '5 s|types/types.proto|third_party/proto/cosmos-sdk/types/types.proto|g' $(SUPPLY_PROTO_TYPES)/types.proto
@sed -i '' '6 s|x/auth/types/types.proto|third_party/proto/cosmos-sdk/x/auth/types/types.proto|g' $(SUPPLY_PROTO_TYPES)/types.proto


.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

__**WARNING:**__ Ethermint is under VERY ACTIVE DEVELOPMENT and should be treated as pre-alpha software. This means it is not meant to be run in production, its APIs are subject to change without warning and should not be relied upon, and it should not be used to hold any value. We will remove this warning when we have a release that is stable, secure, and properly tested.

**Note**: Requires [Go 1.13+](https://golang.org/dl/)

## What is it?

`ethermint` will be an implementation of the EVM that runs on top of [`tendermint`](https://github.com/tendermint/tendermint) consensus, a Proof of Stake system. This project has as its primary goals:
Expand Down Expand Up @@ -37,10 +39,10 @@ To build, execute the following commands:

```bash
# To build the project and install it in $GOBIN
$ make install
make install

# To build the binary and put the resulting binary in ./build
$ make build
make build
```

### Starting a Ethermint daemon (node)
Expand All @@ -56,9 +58,11 @@ To initalize your chain manually, first create a key to use in signing the genes
```bash
emintcli keys add mykey --keyring-backend test
```

> replace mykey with whatever you want to name the key

Then, run these commands to start up a node

```bash
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
emintd init mymoniker --chain-id 8
Expand All @@ -85,6 +89,7 @@ emintd validate-genesis
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
emintd start --pruning=nothing
```

> Note: If you used `make build` instead of make install, and replace all `emintcli` and `emintd` references to `./build/emintcli` and `./build/emintd` respectively

### Starting Ethermint Web3 RPC API
Expand All @@ -97,7 +102,7 @@ emintcli rest-server --laddr "tcp://localhost:8545" --unlock-key mykey

and to make sure the server has started correctly, try querying the current block number:

```
```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
```

Expand Down Expand Up @@ -126,7 +131,7 @@ emintcli config keyring-backend file
To export the private key from Ethermint to something like Metamask, run:

```bash
emintcli keys export-eth-key mykey
emintcli keys unsafe-export-eth-key mykey
```

Import account through private key, and to verify that the Ethereum address is correct with:
Expand All @@ -140,13 +145,13 @@ emintcli keys parse $(emintcli keys show mykey -a)
Integration tests are invoked via:

```bash
$ make test
make test
```

To run CLI tests, execute:

```bash
$ make test-cli
make test-cli
```

#### Ethereum Mainnet Import
Expand All @@ -156,7 +161,7 @@ that includes blocks up to height `97638`. To execute and test a full import of
these blocks using the EVM module, execute:

```bash
$ make test-import
make test-import
```

You may also provide a custom blockchain export file to test importing more blocks
Expand Down
5 changes: 3 additions & 2 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"

"github.com/cosmos/ethermint/crypto"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
Expand All @@ -24,7 +25,7 @@ const (
// Ethereum or SDK transaction to an internal ante handler for performing
// transaction-level processing (e.g. fee payment, signature verification) before
// being passed onto it's respective handler.
func NewAnteHandler(ak auth.AccountKeeper, sk types.SupplyKeeper) sdk.AnteHandler {
func NewAnteHandler(ak auth.AccountKeeper, bk bank.Keeper, sk types.SupplyKeeper) sdk.AnteHandler {
return func(
ctx sdk.Context, tx sdk.Tx, sim bool,
) (newCtx sdk.Context, err error) {
Expand All @@ -50,7 +51,7 @@ func NewAnteHandler(ak auth.AccountKeeper, sk types.SupplyKeeper) sdk.AnteHandle
NewEthSetupContextDecorator(), // outermost AnteDecorator. EthSetUpContext must be called first
NewEthMempoolFeeDecorator(),
NewEthSigVerificationDecorator(),
NewAccountVerificationDecorator(ak),
NewAccountVerificationDecorator(ak, bk),
NewNonceVerificationDecorator(ak),
NewEthGasConsumeDecorator(ak, sk),
NewIncrementSenderSequenceDecorator(ak), // innermost AnteDecorator.
Expand Down
40 changes: 20 additions & 20 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func (suite *AnteTestSuite) TestValidEthTx() {
addr2, _ := newTestAddrKey()

acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc1.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
suite.Require().NoError(err)

acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
err = acc2.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
suite.Require().NoError(err)

// require a valid Ethereum tx to pass
to := ethcmn.BytesToAddress(addr2.Bytes())
Expand All @@ -68,14 +68,14 @@ func (suite *AnteTestSuite) TestValidTx() {
addr2, priv2 := newTestAddrKey()

acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc1.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
suite.Require().NoError(err)

acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
err = acc2.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
suite.Require().NoError(err)

// require a valid SDK tx to pass
fee := newTestStdFee()
Expand All @@ -99,14 +99,14 @@ func (suite *AnteTestSuite) TestSDKInvalidSigs() {
addr3, priv3 := newTestAddrKey()

acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc1.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
suite.Require().NoError(err)

acc2 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr2)
err = acc2.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc2)
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc2.GetAddress(), newTestCoins())
suite.Require().NoError(err)

fee := newTestStdFee()
msg1 := newTestMsg(addr1, addr2)
Expand Down Expand Up @@ -149,9 +149,9 @@ func (suite *AnteTestSuite) TestSDKInvalidAcc() {
addr1, priv1 := newTestAddrKey()

acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc1.SetCoins(newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc1)
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc1.GetAddress(), newTestCoins())
suite.Require().NoError(err)

fee := newTestStdFee()
msg1 := newTestMsg(addr1)
Expand Down Expand Up @@ -198,7 +198,7 @@ func (suite *AnteTestSuite) TestEthInvalidNonce() {
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc.SetSequence(10)
suite.Require().NoError(err)
err = acc.SetCoins(newTestCoins())
err = suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

Expand Down Expand Up @@ -238,7 +238,7 @@ func (suite *AnteTestSuite) TestEthInvalidIntrinsicGas() {
addr2, _ := newTestAddrKey()

acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc.SetCoins(newTestCoins())
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

Expand All @@ -257,14 +257,14 @@ func (suite *AnteTestSuite) TestEthInvalidMempoolFees() {
// setup app with checkTx = true
suite.app = app.Setup(true)
suite.ctx = suite.app.BaseApp.NewContext(true, abci.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()})
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.SupplyKeeper)
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.SupplyKeeper)

suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewCoins(sdk.NewCoin(types.DenomDefault, sdk.NewInt(500000)))))
suite.ctx = suite.ctx.WithMinGasPrices(sdk.NewDecCoins(sdk.NewDecCoin(types.DenomDefault, sdk.NewInt(500000))))
addr1, priv1 := newTestAddrKey()
addr2, _ := newTestAddrKey()

acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc.SetCoins(newTestCoins())
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

Expand All @@ -285,7 +285,7 @@ func (suite *AnteTestSuite) TestEthInvalidChainID() {
addr2, _ := newTestAddrKey()

acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
err := acc.SetCoins(newTestCoins())
err := suite.app.BankKeeper.SetBalances(suite.ctx, acc.GetAddress(), newTestCoins())
suite.Require().NoError(err)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

Expand Down
9 changes: 6 additions & 3 deletions app/ante/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank"

emint "github.com/cosmos/ethermint/types"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
Expand Down Expand Up @@ -146,12 +147,14 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
// AccountVerificationDecorator validates an account balance checks
type AccountVerificationDecorator struct {
ak auth.AccountKeeper
bk bank.Keeper
}

// NewAccountVerificationDecorator creates a new AccountVerificationDecorator
func NewAccountVerificationDecorator(ak auth.AccountKeeper) AccountVerificationDecorator {
func NewAccountVerificationDecorator(ak auth.AccountKeeper, bk bank.Keeper) AccountVerificationDecorator {
return AccountVerificationDecorator{
ak: ak,
bk: bk,
}
}

Expand Down Expand Up @@ -186,8 +189,8 @@ func (avd AccountVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s
}

// validate sender has enough funds
balance := acc.GetCoins().AmountOf(emint.DenomDefault)
if balance.BigInt().Cmp(msgEthTx.Cost()) < 0 {
balance := avd.bk.GetBalance(ctx, acc.GetAddress(), emint.DenomDefault)
if balance.Amount.BigInt().Cmp(msgEthTx.Cost()) < 0 {
return ctx, sdkerrors.Wrapf(
sdkerrors.ErrInsufficientFunds,
"%s < %s%s", balance.String(), msgEthTx.Cost().String(), emint.DenomDefault,
Expand Down
4 changes: 2 additions & 2 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (suite *AnteTestSuite) SetupTest() {
suite.app.Codec().RegisterConcrete(&sdk.TestMsg{}, "test/TestMsg", nil)

suite.ctx = suite.app.BaseApp.NewContext(checkTx, abci.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()})
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.SupplyKeeper)
suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.SupplyKeeper)
}

func TestAnteTestSuite(t *testing.T) {
Expand Down Expand Up @@ -80,7 +80,7 @@ func newTestSDKTx(
}

sigs[i] = auth.StdSignature{
PubKey: priv.PubKey(),
PubKey: priv.PubKey().Bytes(),
Signature: sig,
}
}
Expand Down
Loading