Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Problem: clear logs if tx failed in post processing hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jun 16, 2022
1 parent 8f932dd commit 6899a7b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions x/evm/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
// If hooks return error, revert the whole tx.
res.VmError = types.ErrPostTxProcessing.Error()
k.Logger(ctx).Error("tx post processing failed", "error", err)

// If the tx failed in post processing hooks, we should clear the logs
if res.Failed() {
res.Logs = nil
}
} else if commit != nil {
// PostTxProcessing is successful, commit the tmpCtx
commit()
Expand Down

0 comments on commit 6899a7b

Please sign in to comment.