-
-
Notifications
You must be signed in to change notification settings - Fork 788
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
feat[lang]: singleton modules with ownership hierarchy #3729
feat[lang]: singleton modules with ownership hierarchy #3729
Conversation
refactor: - refactor generate_ir_for_function into generate_ir_for_external_function and generate_ir_for_internal_function - move get_nonreentrant_lock to function-definitions/common.py
9e60d60
to
1089ee0
Compare
can remove context.globals now!
fd4135f
to
9d94161
Compare
hint += "a top-level statement to your contract" | ||
raise ImmutableViolation(msg, hint=hint) | ||
|
||
# the leftmost- referenced module |
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.
# the leftmost- referenced module | |
# the leftmost referenced module |
nit
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.
Alright, I tested the new design on a couple of contracts. Some further feedback, but overall lgtm:
- Maybe I missed them, but there are no tests on
event
imports? I did some local tests and it should work (at least it compiled for me 😄). - It will be important to test the full design in combination with export bundles to ensure the correct behaviour of
implements
. - The
implements
keyword doesn't work properly with module imports yet:
# mod3.vy
# Assume a folder `interfaces` at root directory with a file `IAccessControl.vy`
import interfaces.IAccessControl as IAccessControl
# mod2.vy
import mod3
# mod1.vy
import mod2 as acl
implements: acl.mod3.IAccessControl
@deploy
def __init__():
pass
This will throw with:
vyper.exceptions.InvalidType: 'acl.mod3.IAccessControl' is not a type!
Which is not the correct error first (it should state that the interface is not implemented), and second shows that the implements
feature doesn't work yet with modules.
- Nit: the error
vyper.exceptions.CallViolation: Cannot call external functions via 'self' or via library
can be split into theself
and library case since it's easy to analyse this
this seems like an outstanding issue, it should already work on master (but doesn't) |
Created an issue here #3766 |
it's a planned feature to auto-export (in the ABI) events that are used from imported modules. right now they won't show up in the ABI, so they can't be tested via web3. |
the interfaces issue happens only when accessing an interface defined via |
|
note: there is a fuzz failure in https://github.com/vyperlang/vyper/actions/runs/7845945261/job/21411529442?pr=3729 which doesn't appear to be related to this PR (that is, it is reproducible on master). tests/functional/builtins/folding/test_bitwise.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/functional/builtins/folding/test_bitwise.py:84: in test_bitwise_shift_signed
validate_expected_type(new_node, INT256_T) # force bounds check
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
node = vyper.ast.nodes.Int:
---> 1 128 << 248
-------^
expected_type = (int256,)
...
...
...
E vyper.exceptions.TypeMismatch: Expected int256 but literal can only be cast as uint256.
E
E line 1:0
E ---> 1 128 << 248
E -------^
vyper/semantics/analysis/utils.py:615: TypeMismatch
---------------------------------- Hypothesis ----------------------------------
Falsifying example: test_bitwise_shift_signed(
get_contract=<function tests.conftest.get_contract.<locals>.fn>,
a=128,
b=248,
op='<<',
) |
fixed here: #3768 |
What I did
implement #3722 (comment)
also partially implements #3740
incidentally fixes #3161, #3554
fixes #3766
this PR seems to add 5% to the compile time for some large-ish contracts. with #3761 applied (cherry-picked), the compile time overhead (that is, comparing this branch directly to #3761) comes down to ~1.3%.
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture