-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
VIP: Factory contracts #2891
Comments
A few comments:
|
i kind of like re. the
mistake, fixed |
Rather not have another compiler mode. If it materially impacts the bytecode that gets generated, would rather have to have something in the source code that mirrors it. I think |
meeting notes: punt until new module system is done, and then the spec can be more concrete |
Is this solved by blueprints? |
Blueprints provide the implementation, this would essentially be a better UX around blueprints (so you don't need to call create_from_blueprint directly) |
Simple Summary
Create a first class factory contract, which stores initcode instead of runtime code.
Motivation
#2895 introduces the
create_with_code_of()
factory function. It is a good mechanism for calling arbitrary initcode (e.g., factory contracts that are created in solidity). However, it is untyped; it's cumbersome to assemble the constructor args to forward to the factory contract, the constructor arguments are not typechecked, and the type of the returned contract is unknown. Constructing the deploy code for the factory is also slightly tedious (although this can be solved at the tooling level). For Vyper-generated factories, we can do better. #2326 would be a way of implementing init code for proxies and also contracts created using the existingcreate*()
functions, but it uses a non-EVM-native mechanism and can't handle immutables.Specification
Add a
@factory
decorator which is only allowed on the__init__()
function. If the factory decorator is there, the regular deploy code for the factory deploys the initcode instead of the runtime code. Users of the factory will need to import the interface to the factory contract, and then callSomeFactory.create(*args)
(where*args
are the arguments specified inSomeFactory.__init__()
) which loads the initcode into memory along with*args
, and then executes the initcode with CREATE/CREATE2.Note that
SomeFactory.create(*args)
would be equivalent tocreate_with_code_of(some_factory.address, *args)
, with the added compile-time check that the arguments line up with the signature ofSomeFactory.__init__()
, and with the resulting address already casted to the target type ofSomeFactory
. Example usage:Backwards Compatibility
No breaking changes
Dependencies
Depends on syntactic changes to import system in #2431
References
#2326
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: