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 15, 2022
1 parent 8f932dd commit 13c8467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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 @@ -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())
Expand Down

0 comments on commit 13c8467

Please sign in to comment.