Skip to content

Commit

Permalink
fix[lang]: add raw_log() constancy check (#4201)
Browse files Browse the repository at this point in the history
disallow `raw_log()` from being called within staticcall context.
  • Loading branch information
cyberthirst authored Aug 5, 2024
1 parent 99304da commit 85269b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/functional/syntax/exceptions/test_constancy_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ def bar()->DynArray[uint16,3]:
@view
def topup(amount: uint256):
assert extcall self.token.transferFrom(msg.sender, self, amount)
""",
"""
@external
@view
def foo(_topic: bytes32):
raw_log([_topic], b"")
""",
"""
@external
@pure
def foo(_topic: bytes32):
raw_log([_topic], b"")
""",
],
)
Expand Down
2 changes: 2 additions & 0 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ def infer_arg_types(self, node, expected_return_typ=None):

@process_inputs
def build_IR(self, expr, args, kwargs, context):
context.check_is_not_constant(f"use {self._id}", expr)

topics_length = len(expr.args[0].elements)
topics = args[0].args
topics = [unwrap_location(topic) for topic in topics]
Expand Down

0 comments on commit 85269b0

Please sign in to comment.