Skip to content

Commit 85269b0

Browse files
authored
fix[lang]: add raw_log() constancy check (#4201)
disallow `raw_log()` from being called within staticcall context.
1 parent 99304da commit 85269b0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/functional/syntax/exceptions/test_constancy_exception.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ def bar()->DynArray[uint16,3]:
130130
@view
131131
def topup(amount: uint256):
132132
assert extcall self.token.transferFrom(msg.sender, self, amount)
133+
""",
134+
"""
135+
@external
136+
@view
137+
def foo(_topic: bytes32):
138+
raw_log([_topic], b"")
139+
""",
140+
"""
141+
@external
142+
@pure
143+
def foo(_topic: bytes32):
144+
raw_log([_topic], b"")
133145
""",
134146
],
135147
)

vyper/builtins/functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ def infer_arg_types(self, node, expected_return_typ=None):
12671267

12681268
@process_inputs
12691269
def build_IR(self, expr, args, kwargs, context):
1270+
context.check_is_not_constant(f"use {self._id}", expr)
1271+
12701272
topics_length = len(expr.args[0].elements)
12711273
topics = args[0].args
12721274
topics = [unwrap_location(topic) for topic in topics]

0 commit comments

Comments
 (0)