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

refactor events #2403

Merged
merged 3 commits into from
Aug 6, 2021
Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Aug 1, 2021

What I did

refactor events to use abi_encode. Fixes #1170, #1476

  • use abi_encode for the data
  • use keccak256_helper for non-basetype topics
  • block non-value types in event indexes

note: a test for blocked functionality has been removed because the functionality now works

How I did it

How to verify it

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2021

Codecov Report

Merging #2403 (cea5dd8) into master (cff69d6) will decrease coverage by 0.24%.
The diff coverage is 87.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2403      +/-   ##
==========================================
- Coverage   85.73%   85.48%   -0.25%     
==========================================
  Files          91       91              
  Lines        9101     9035      -66     
  Branches     2176     2151      -25     
==========================================
- Hits         7803     7724      -79     
- Misses        796      805       +9     
- Partials      502      506       +4     
Impacted Files Coverage Δ
vyper/ast/folding.py 93.61% <ø> (ø)
vyper/old_codegen/parser_utils.py 77.89% <61.53%> (-0.84%) ⬇️
vyper/old_codegen/keccak256_helper.py 78.57% <73.33%> (-0.38%) ⬇️
vyper/old_codegen/events.py 95.12% <94.73%> (-4.10%) ⬇️
vyper/builtin_functions/functions.py 88.32% <100.00%> (-0.38%) ⬇️
vyper/old_codegen/abi.py 74.82% <100.00%> (+0.94%) ⬆️
vyper/old_codegen/stmt.py 84.15% <100.00%> (-0.36%) ⬇️
vyper/old_codegen/types/types.py 81.86% <100.00%> (+0.76%) ⬆️
vyper/semantics/types/__init__.py 100.00% <100.00%> (ø)
vyper/semantics/types/user/event.py 78.33% <100.00%> (+0.74%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cff69d6...cea5dd8. Read the comment docs.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Aug 1, 2021

This pull request introduces 3 alerts when merging 492587d into 0a389e3 - view on LGTM.com

new alerts:

  • 3 for Unused import

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Aug 2, 2021

This pull request introduces 8 alerts when merging e9e568c into 0a389e3 - view on LGTM.com

new alerts:

  • 8 for Unused import

- use abi_encode for the data
- use keccak256_helper for non-basetype topics
- block non-value types in indexes

note: a test for blocked functionality has been removed because the functionality now works
@charles-cooper charles-cooper marked this pull request as ready for review August 2, 2021 21:53
@charles-cooper charles-cooper marked this pull request as draft August 4, 2021 13:59
@charles-cooper charles-cooper changed the title Events refactor refactor events Aug 4, 2021
@charles-cooper charles-cooper marked this pull request as ready for review August 4, 2021 14:35
The key is to make sure the memory is allocated and registered with the
context variable BEFORE evaluating the expressions inside the event (in
case any of them make internal calls)

fixes vyperlang#1476
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Not sure I understand the test changes (from static array to integer), but otherwise looks fine

@charles-cooper
Copy link
Member Author

Not sure I understand the test changes (from static array to integer), but otherwise looks fine

I removed those because arrays are now blocked from being event indexes.

@charles-cooper charles-cooper merged commit 4ebf54d into vyperlang:master Aug 6, 2021
if typ.is_dynamic_size:
maxlen += typ.size_in_bytes
# sanity check, abi size_bound is the same calculated both ways
print(data.typ, type(data.typ))
Copy link
Member Author

Choose a reason for hiding this comment

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

oh haha i left this in

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.

VIP Structs in Events
4 participants