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

feat[lang]: remove named reentrancy locks #3769

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Feb 10, 2024

What I did

implement #3760

How I did it

How to verify it

Commit message

this commit removes "fine-grained" nonreentrancy locks (i.e., reentrancy
locks with names) from vyper. they aren't really used (all known
production contracts just use a single global named lock) , and in any
case such a use case should better be implemented manually by the user.

this simplifies the language and allows moderate simplification to the
storage allocator, although some complexity is added because the global
restriction has to have special handling (it cannot be handled simply in
the recursion into child modules).

refactors:
- the routine for allocating nonreentrant keys has been refactored into
  a helper function.

Description for the changelog

Cute Animal Picture

image

@charles-cooper charles-cooper added this to the v0.4.0 milestone Feb 10, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (7bdebbf) 84.93% compared to head (c349742) 85.02%.
Report is 1 commits behind head on master.

Files Patch % Lines
vyper/semantics/types/function.py 83.33% 2 Missing and 2 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3769      +/-   ##
==========================================
+ Coverage   84.93%   85.02%   +0.08%     
==========================================
  Files          92       92              
  Lines       13685    13700      +15     
  Branches     3074     3074              
==========================================
+ Hits        11623    11648      +25     
+ Misses       1572     1565       -7     
+ Partials      490      487       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

Question: I can declare variables as public in Vyper and the compiler will generate a view getter function on these functions. Example:

totalSupply: public(uint256)

Should it be possible via a kwarg to set the global nonreentrant key there as well?

totalSupply: public(uint256, nonreentrant=True)

@fubuloubu
Copy link
Member

Question: I can declare variables as public in Vyper and the compiler will generate a view getter function on these functions. Example:

totalSupply: public(uint256)

Should it be possible via a kwarg to set the global nonreentrant key there as well?

totalSupply: public(uint256, nonreentrant=True)

This brings up a great point around flipping reentrancy locks to being the default: how would a developer be able to allow the public getter generated to be accessible to a downstream caller contract, who may need to read some properties of the calling contract (maybe in a flash loan setting)

@charles-cooper
Copy link
Member Author

charles-cooper commented Feb 12, 2024

Question: I can declare variables as public in Vyper and the compiler will generate a view getter function on these functions. Example:

totalSupply: public(uint256)

no, you need to write your own getter (EDIT: misread the statement)

Should it be possible via a kwarg to set the global nonreentrant key there as well?

totalSupply: public(uint256, nonreentrant=True)

hmm yea, why not. i was thinking about how to handle this for other decorators like @bundle and other potential decorators in the future, so maybe this works for those as well.

@charles-cooper charles-cooper changed the title feat: remove named reentrancy locks feat[lang]: remove named reentrancy locks Feb 13, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) February 13, 2024 14:37
@charles-cooper charles-cooper merged commit 199f2b6 into vyperlang:master Feb 13, 2024
84 checks passed
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.

6 participants