-
-
Notifications
You must be signed in to change notification settings - Fork 793
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: Cloning #2326
Labels
VIP: Approved
VIP Approved
Comments
fubuloubu
added
the
VIP: Discussion
Used to denote VIPs and more complex issues that are waiting discussion in a meeting
label
Feb 27, 2021
fubuloubu
added
VIP: Approved
VIP Approved
and removed
VIP: Discussion
Used to denote VIPs and more complex issues that are waiting discussion in a meeting
labels
Mar 1, 2021
NOTE: Any use of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Summary
Enable a popular "cloning" pattern using simple forwarder proxies (e.g.
create_forwarder_to
)Motivation
A popular pattern with smart contracts is to create a "cloning factory" using 1 implementation contract that implements a construction sequence (usually deployment without initializing anything and an
initialize()
method that serves as the constructor). This can sometimes cause issues if not handled appropriately (seedevops199
) by enforcing that theinitialize
method is called when deploying a clone of that contract. To avoid the potential pitfalls of failing to appropiately handle these scenarios, a methodology that "clone-enabled" contracts to be simply used is preferred.The pattern in general looks like this:
(requires enabling internal methods to be callable in constructors e.g. #2251)
Specification
Introduce the
@cloneable
decorator, only applicable to constructors, which wraps the above common implementation into the following macro:Note that
clone
andinitialize
should be reserved keywords so that functions with those names cannot exist in the contract if@cloneable
is used.Backwards Compatibility
No backwards incompatibilities except the
clone()
function name becomes a protected keywordDependencies
No dependencies to other VIPs
References
#2251 can make this easier to implement
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: