Only emit cosmos events if no error in precompiles #1744
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes and provide context
Although we recently made a change to mark EVM txs that encountered as failed on cosmos level, so that events emit by any cosmwasm contract as part of the EVM tx won't be persisted, this does not prevent similar issue from happening if the cosmwasm call error is caught and handled by the invoking solidity contract. In such cases, events from the failed CW call would still emit, which is not desired. The impact of this depends on whether there is any application depending on CW events for mission-critical flows, which is unclear right now.
UPDATE: in order to have this treatment for all modules, not just wasm, this PR included a rather large refactor to precompiles so that common logic (like the event logic introduced by this PR) can go into a base class. No behavioral change is expected from this refactor, so existing tests should still hold (aside from necessary field/struct name changes)
Testing performed to validate your change
unit tests