Skip to content

fix[lang]: disable nonreentrant behavior of immutable and constant getters#4622

Merged
charles-cooper merged 9 commits intovyperlang:masterfrom
cyberthirst:feat/remove-lock-from-constant-immutable
May 1, 2025
Merged

fix[lang]: disable nonreentrant behavior of immutable and constant getters#4622
charles-cooper merged 9 commits intovyperlang:masterfrom
cyberthirst:feat/remove-lock-from-constant-immutable

Conversation

@cyberthirst
Copy link
Copy Markdown
Collaborator

@cyberthirst cyberthirst commented Apr 30, 2025

What I did

How I did it

Commit message

the nonreentrancy pragma enables reentrancy protection for all
public entrypoints, including immutable and constant getters. however
`immutable` and `constant` variables can't change after deployment, and
thus can't lead to issues due to read-only-reentrancy. thus, checking
the lock is undesirable (in other words, the getters should behave more
similarly to `pure` functions than `view` functions).

How to verify it

  • added relevant tests


With the pragma on, internal functions remain unlocked by default but can still use the ``@nonreentrant`` decorator. External ``view`` functions are protected by default (as before, checking the lock upon entry but only reading its state). External ``pure`` functions do not interact with the lock.

Internal functions, ``__init__`` function and getters for ``constants`` and ``immutables`` can be marked ``reentrant``. Reentrant behavior is the default for these structure anyway, and this feature can be used to explicitly highlight the fact.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Internal functions, ``__init__`` function and getters for ``constants`` and ``immutables`` can be marked ``reentrant``. Reentrant behavior is the default for these structure anyway, and this feature can be used to explicitly highlight the fact.
Internal functions, ``__init__`` function and getters for ``constants`` and ``immutables`` can be marked ``reentrant``. Reentrant behavior is the default for these structures anyway, and this feature can be used to explicitly highlight the fact.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (be84de7) to head (d9fce5b).
⚠️ Report is 53 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4622   +/-   ##
=======================================
  Coverage   92.49%   92.49%           
=======================================
  Files         128      128           
  Lines       18525    18526    +1     
  Branches     3211     3212    +1     
=======================================
+ Hits        17135    17136    +1     
  Misses        945      945           
  Partials      445      445           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cyberthirst
Copy link
Copy Markdown
Collaborator Author

the new changes look good

@charles-cooper charles-cooper enabled auto-merge (squash) April 30, 2025 14:28
@charles-cooper charles-cooper merged commit 11522b8 into vyperlang:master May 1, 2025
159 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.

2 participants