-
-
Notifications
You must be signed in to change notification settings - Fork 822
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[codegen]: panic on potential subscript eval order issue #4159
fix[codegen]: panic on potential subscript eval order issue #4159
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4159 +/- ##
===========================================
- Coverage 91.32% 46.22% -45.10%
===========================================
Files 109 109
Lines 15573 15606 +33
Branches 3420 3432 +12
===========================================
- Hits 14222 7214 -7008
- Misses 923 7838 +6915
- Partials 428 554 +126 ☔ View full report in Codecov by Sentry. |
passes def test_array_index_overlap_extcall(get_contract):
code = """
interface Bar:
def bar() -> uint256: payable
a: public(DynArray[DynArray[Bytes[96], 5], 5])
@external
def foo() -> Bytes[96]:
self.a.append([b'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'])
return self.a[0][extcall Bar(self).bar()]
@external
def bar() -> uint256:
self.a[0] = [b'yyy']
self.a.pop()
return 0
"""
c = get_contract(code)
assert c.foo() == b"yyy" |
--------- Co-authored-by: cyberthirst <cyberthirst.eth@gmail.com>
`potential_overlap()` doesn't actually work for our purposes here, we need a modification.
""" | ||
c = get_contract(code) | ||
# tricky to get this right, for now we just panic instead of generating code | ||
assert c.foo() == [b"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't be wrapped in [ ]
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm true, but if we ever modify codegen so it passes get_contract()
, the test needs to be fixed anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but anyway, updated -- a397c73
return 0 | ||
""" | ||
c = get_contract(code) | ||
assert c.foo() == [b"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
if len(left.referenced_variables & right.variable_writes) > 0: | ||
return True | ||
|
||
if len(left.referenced_variables) > 0 and right.contains_risky_call: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably overly conservative as contains_risky_call
checks against staticcall
What I did
panic on variant of #4157
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture