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: disallow value= passing for delegate and static raw_calls #3755

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/functional/builtins/codegen/test_raw_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,22 @@ def foo(_addr: address):
(
"""
@external
def foo(_addr: address):
raw_call(_addr, method_id("foo()"), is_delegate_call=True, value=1)
""",
ArgumentException,
),
(
"""
@external
def foo(_addr: address):
raw_call(_addr, method_id("foo()"), is_static_call=True, value=1)
""",
ArgumentException,
),
(
"""
@external
@view
def foo(_addr: address):
raw_call(_addr, 256)
Expand Down
9 changes: 6 additions & 3 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,16 @@ def build_IR(self, expr, args, kwargs, context):

if delegate_call and static_call:
raise ArgumentException(
"Call may use one of `is_delegate_call` or `is_static_call`, not both", expr
"Call may use one of `is_delegate_call` or `is_static_call`, not both"
)

if (delegate_call or static_call) and value.value != 0:
raise ArgumentException("value= may not be passed for static or delegate calls!")

if not static_call and context.is_constant():
raise StateAccessViolation(
f"Cannot make modifying calls from {context.pp_constancy()},"
" use `is_static_call=True` to perform this action",
expr,
" use `is_static_call=True` to perform this action"
)

if data.value == "~calldata":
Expand Down
Loading