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

fix: storage slot allocation bug #2391

Merged
merged 4 commits into from
Jul 23, 2021

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jul 22, 2021

This also refactors the nonreentrant key allocation so the functionality
happens in the same place as global variable allocation.

How to verify it

Apply a894a33 to master, see that tests don't pass but they do on this branch

Description for the changelog

Cute Animal Picture

image

@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2021

Codecov Report

Merging #2391 (5bcadcf) into master (db2606d) will decrease coverage by 0.09%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2391      +/-   ##
==========================================
- Coverage   85.84%   85.75%   -0.10%     
==========================================
  Files          91       91              
  Lines        9022     9028       +6     
  Branches     2152     2155       +3     
==========================================
- Hits         7745     7742       -3     
- Misses        785      790       +5     
- Partials      492      496       +4     
Impacted Files Coverage Δ
vyper/semantics/types/function.py 86.02% <33.33%> (-2.21%) ⬇️
...en/function_definitions/parse_external_function.py 100.00% <100.00%> (ø)
...en/function_definitions/parse_internal_function.py 97.89% <100.00%> (ø)
vyper/old_codegen/function_definitions/utils.py 100.00% <100.00%> (ø)
vyper/old_codegen/global_context.py 66.92% <100.00%> (-1.73%) ⬇️
vyper/old_codegen/return_.py 100.00% <100.00%> (ø)
vyper/semantics/validation/data_positions.py 90.00% <100.00%> (+3.33%) ⬆️
vyper/builtin_functions/functions.py 88.36% <0.00%> (-0.39%) ⬇️

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 db2606d...5bcadcf. Read the comment docs.

Reentrancy key was in the wrong location

This also refactors the nonreentrant key allocation so the functionality
happens in the same place as global variable allocation.
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.

Would be nice to see a test or two for this behavior failing

@@ -224,6 +224,7 @@ def add_globals_and_events(self, item):
def parse_type(self, ast_node, location):
return parse_type(ast_node, location, sigs=self._contracts, custom_structs=self._structs,)

# TODO this is dead code
def get_nonrentrant_counter(self, key):
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this dead code?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to now just in case it's a larger project

Copy link
Member

Choose a reason for hiding this comment

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

just remove it and push, if it causes CI failures then take it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

just remove it and push, if it causes CI failures then take it out.

done, see latest commit

The last storage variable was not being tested which is why this slipped
by.

The reason there was a collision in the last storage variable is because
there are holes in the storage allocator left by HashMaps (which is why
the slots in global_context and set_data_positions were not matching
up).
@charles-cooper charles-cooper marked this pull request as ready for review July 22, 2021 22:13
@charles-cooper
Copy link
Member Author

Would be nice to see a test or two for this behavior failing

Added, rather I fixed the existing test

@charles-cooper charles-cooper merged commit 0247629 into vyperlang:master Jul 23, 2021
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.

None yet

4 participants