diff --git a/CHANGELOG.md b/CHANGELOG.md index 895c2ef0..d924ba13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [tharsis#68](https://github.com/tharsis/ethermint/issues/68) Replace block hash storage map to use staking `HistoricalInfo`. * (evm) [tharsis#276](https://github.com/tharsis/ethermint/pull/276) Vm errors don't result in cosmos tx failure, just different tx state and events. +* (evm) [tharsis#342](https://github.com/tharsis/ethermint/issues/342) Don't clear balance when resetting the account. ### API Breaking diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 19852ffa..60702dc1 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -316,17 +316,9 @@ func (k Keeper) ClearBalance(addr sdk.AccAddress) (prevBalance sdk.Coin, err err return prevBalance, nil } -// ResetAccount removes the code, storage state and evm denom balance coins stored +// ResetAccount removes the code, storage state, but keep all the native tokens stored // with the given address. func (k Keeper) ResetAccount(addr common.Address) { k.DeleteCode(addr) k.DeleteAccountStorage(addr) - _, err := k.ClearBalance(addr.Bytes()) - if err != nil { - k.Logger(k.ctx).Error( - "failed to clear balance during account reset", - "ethereum-address", addr.Hex(), - "error", err, - ) - } } diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 35f4667b..859172a9 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -27,14 +27,14 @@ func (suite *KeeperTestSuite) TestCreateAccount() { callback func(common.Address) }{ { - "reset account", + "reset account (keep balance)", suite.address, func(addr common.Address) { suite.app.EvmKeeper.AddBalance(addr, big.NewInt(100)) suite.Require().NotZero(suite.app.EvmKeeper.GetBalance(addr).Int64()) }, func(addr common.Address) { - suite.Require().Zero(suite.app.EvmKeeper.GetBalance(addr).Int64()) + suite.Require().Equal(suite.app.EvmKeeper.GetBalance(addr).Int64(), int64(100)) }, }, {