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

attribute error due to missing reentrancy_key_position #3922

Closed
cyberthirst opened this issue Apr 8, 2024 · 1 comment · Fixed by #3927
Closed

attribute error due to missing reentrancy_key_position #3922

cyberthirst opened this issue Apr 8, 2024 · 1 comment · Fixed by #3927
Labels
bug - UX a bug related to UX
Milestone

Comments

@cyberthirst
Copy link
Collaborator

Version Information

  • vyper Version (output of vyper --version): 0.4.0b6+commit.e29a584c

What's your issue about?

# main.vy
import lib1

exports: lib1.bar

@external
def foo():
    pass
    
# lib1.vy
@external
@nonreentrant
def bar():
    pass

raises:

AttributeError: 'ContractFunctionT' object has no attribute 'reentrancy_key_position'. Did you mean: 'set_reentrancy_key_position'?

another variant:

#main.vy
import lib1

@external
def foo():
    lib1.bar()

#lib1.vy
@internal
@nonreentrant
def bar():
    pass

How can it be fixed?

Didn't check thoroughly but the recursion to imported modules in the allocation phase is guided by:

if isinstance(node, vy_ast.InitializesDecl):

which is missing in this instance

@charles-cooper charles-cooper added the bug - UX a bug related to UX label Apr 8, 2024
@charles-cooper charles-cooper added this to the v0.4.0 milestone Apr 8, 2024
@cyberthirst
Copy link
Collaborator Author

note from @trocher:
When a module is never initialized, it should only be allowed to call
functions that are stateless in the sense that they do not access
storage or immutables. However, the analysis does not account for
non-reentrant decorators. If a non-initialized module's non-reentrant
function is called, the compiler will crash during code generation after
successfully passing semantic analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - UX a bug related to UX
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants