Skip to content

Conversation

@cyberthirst
Copy link
Collaborator

@cyberthirst cyberthirst commented Apr 30, 2025

What I did

Commit Message

per title, disallow staticcall via `raw_call` in pure context.

this commit adds a special case for checking `raw_call`'s
mutability. `raw_call` is an outlier because its mutability depends on
the call's arguments, we could make the mechanism more general but for
now that seems unnecessary

How to verify it

  • added tests that show the compilation now fails

@codecov
Copy link

codecov bot commented Apr 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (427e033) to head (0a37a73).
⚠️ Report is 55 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4619      +/-   ##
==========================================
- Coverage   92.50%   92.49%   -0.01%     
==========================================
  Files         128      128              
  Lines       18510    18521      +11     
  Branches     3208     3210       +2     
==========================================
+ Hits        17122    17131       +9     
- Misses        944      945       +1     
- Partials      444      445       +1     

☔ 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.

"""
@pure
def foo(a: address):
x: Bytes[32] = raw_call(a, b'', max_outsize=32, is_static_call=True or False)
Copy link
Member

Choose a reason for hiding this comment

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

nice -- please add comment saying this is to test constant folding

self._check_call_mutability(func_type.mutability) # type: ignore
from vyper.builtins.functions import RawCall

# opposed to other funs, raw_call's mutability depends on its arguments
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# opposed to other funs, raw_call's mutability depends on its arguments
# as opposed to other functions, raw_call's mutability depends on its arguments


self.visit(node.func, func_type)

def get_raw_call_mutability(self, node: vy_ast.Call):
Copy link
Member

Choose a reason for hiding this comment

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

this method should rather be on RawCall

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

looks good, just some small changes

@cyberthirst
Copy link
Collaborator Author

the recent changes seem good

@charles-cooper charles-cooper enabled auto-merge (squash) April 30, 2025 14:10
@charles-cooper charles-cooper merged commit 8852a40 into vyperlang:master Apr 30, 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