Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter events before reply block #589

Merged
merged 6 commits into from
Aug 12, 2021
Merged

Filter events before reply block #589

merged 6 commits into from
Aug 12, 2021

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Aug 12, 2021

Closes #587

  • Add failing testcase showing messages make it into reply block
  • Ensure reply doesn't get event(message)
  • Ensure submessage event(message) doesn't make it out with no reply block
  • Remove no-longer needed event(message) filtering in DefaultWasmVMContractResponseHandler.Handle
  • Update other tests as needed

@ethanfrey ethanfrey requested a review from alpe as a code owner August 12, 2021 11:17
@ethanfrey
Copy link
Member Author

Ready for review.

Added a few tests to assert the "message" events were not returned from DispatchSubmessages, nor ever returned to the Reply call.

Fixed/removed a few other tests that expected to find messages.

@codecov
Copy link

codecov bot commented Aug 12, 2021

Codecov Report

Merging #589 (7fbf513) into master (7b2e84c) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #589      +/-   ##
==========================================
+ Coverage   59.86%   59.92%   +0.06%     
==========================================
  Files          45       45              
  Lines        5197     5200       +3     
==========================================
+ Hits         3111     3116       +5     
+ Misses       1862     1861       -1     
+ Partials      224      223       -1     
Impacted Files Coverage Δ
x/wasm/keeper/keeper.go 86.97% <100.00%> (+0.24%) ⬆️
x/wasm/keeper/msg_dispatcher.go 87.23% <100.00%> (+1.02%) ⬆️

Copy link
Member

@alpe alpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good and works as expected 🌷

One note to reduce complexity in the filter

cap := 0
for _, evts := range events {
cap += len(evts)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 You can reduce complexity of this method a lot by just accepting []sdk.Event. On the caller side just do: filterEvents(append(em.Events(), events...)). I would not expect thousands of events that require some optimization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in Rust everytime you heap allocate to make vectors (slices), it is considered "expensive". I guess we do not micro-optimize so aggressively in Go.

I will simplify

@ethanfrey ethanfrey merged commit 1933578 into master Aug 12, 2021
@ethanfrey ethanfrey deleted the 577-reply-events-2 branch August 12, 2021 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure proper events sent in reply
2 participants