diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d17fed12..1549c98a83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking * (evm) [tharsis#1124](https://github.com/tharsis/ethermint/pull/1124) Reject non-replay-protected tx in ante handler to prevent replay attack +* (evm) [tharsis#1128](https://github.com/tharsis/ethermint/pull/1128) Clear tx logs if tx failed in post processing hooks ### Bug Fixes diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index cb381e13b3..45f347e796 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -599,6 +599,7 @@ func (suite *EvmTestSuite) TestERC20TransferReverted() { suite.Require().True(res.Failed()) suite.Require().Equal(tc.expErr, res.VmError) + suite.Require().Empty(res.Logs) after := k.GetBalance(suite.ctx, suite.from) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index fbc56538fa..fe2beac398 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -277,6 +277,11 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t } } + // If the tx failed in post processing hooks, we should clear the logs + if res.Failed() { + res.Logs = nil + } + // refund gas in order to match the Ethereum gas consumption instead of the default SDK one. if err = k.RefundGas(ctx, msg, msg.Gas()-res.GasUsed, cfg.Params.EvmDenom); err != nil { return nil, sdkerrors.Wrapf(err, "failed to refund gas leftover gas to sender %s", msg.From())