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

reject tx if address in blacklist #754

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 @@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (api) [\#687](https://github.com/cosmos/ethermint/issues/687) Returns error for a transaction with an incorrect nonce.
* (evm) [\#674](https://github.com/cosmos/ethermint/issues/674) Reset all cache after account data has been committed in `EndBlock` to make sure every node state consistent.
* (evm) [\#672](https://github.com/cosmos/ethermint/issues/672) Fix panic of `wrong Block.Header.AppHash` when restart a node with snapshot.
* (evm) [\#753](https://github.com/cosmos/ethermint/issues/753) Using evm tx to transfer token to the module account causes the module account balance to be tainted.

## [v0.4.0] - 2020-12-15

Expand Down
2 changes: 1 addition & 1 deletion app/ethermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func NewEthermintApp(
)
app.UpgradeKeeper = upgrade.NewKeeper(skipUpgradeHeights, keys[upgrade.StoreKey], app.cdc)
app.EvmKeeper = evm.NewKeeper(
app.cdc, keys[evm.StoreKey], app.subspaces[evm.ModuleName], app.AccountKeeper,
app.cdc, keys[evm.StoreKey], app.subspaces[evm.ModuleName], app.AccountKeeper, app.BankKeeper
)

// create evidence keeper with router
Expand Down
10 changes: 9 additions & 1 deletion x/evm/types/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"github.com/cosmos/cosmos-sdk/x/bank"
"math/big"
"sort"
"sync"
Expand Down Expand Up @@ -45,6 +46,7 @@ type CommitStateDB struct {
storeKey sdk.StoreKey
paramSpace params.Subspace
accountKeeper AccountKeeper
bankKeeper bank.Keeper

// array that hold 'live' objects, which will get modified while processing a
// state transition
Expand Down Expand Up @@ -90,13 +92,14 @@ type CommitStateDB struct {
// CONTRACT: Stores used for state must be cache-wrapped as the ordering of the
// key/value space matters in determining the merkle root.
func NewCommitStateDB(
ctx sdk.Context, storeKey sdk.StoreKey, paramSpace params.Subspace, ak AccountKeeper,
ctx sdk.Context, storeKey sdk.StoreKey, paramSpace params.Subspace, ak AccountKeeper, bk bank.Keeper,
) *CommitStateDB {
return &CommitStateDB{
ctx: ctx,
storeKey: storeKey,
paramSpace: paramSpace,
accountKeeper: ak,
bankKeeper: bk,
stateObjects: []stateEntry{},
addressToObjectIndex: make(map[ethcmn.Address]int),
stateObjectsDirty: make(map[ethcmn.Address]struct{}),
Expand Down Expand Up @@ -568,6 +571,11 @@ func (csdb *CommitStateDB) updateStateObject(so *stateObject) error {
return fmt.Errorf("invalid balance %s", newBalance)
}

//checking and reject tx if address in blacklist
if csdb.bankKeeper.BlacklistedAddr(so.account.GetAddress()) {
return fmt.Errorf("invalid address %s", so.account.GetAddress().String())
}

coins := so.account.GetCoins()
balance := coins.AmountOf(newBalance.Denom)
if balance.IsZero() || !balance.Equal(newBalance.Amount) {
Expand Down