Skip to content
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

Immutably owned clones #19

Open
BlinkyStitt opened this issue Oct 14, 2020 · 3 comments
Open

Immutably owned clones #19

BlinkyStitt opened this issue Oct 14, 2020 · 3 comments

Comments

@BlinkyStitt
Copy link

BlinkyStitt commented Oct 14, 2020

My cloned proxy deploys costs less the 1/10th of what they did before I found EIP 1167, so thanks for the awesome contract!

Some projects with vote locking (such as https://dao.curve.fi) require smart wallets to have restrictions on transfer in order to be approved. I've been thinking of how to accomplish this and I have a working, but likely not optimal, solution (which also uses CREATE2 and so is one way to solve #18).

At first I was just going to remove the functions for changing the owner, but because the proxy contract has a delegatecall, it would be able to change the state anyway.

Then I was going to try using the new immutable keyword, but we are using an init function instead of a standard constructor to do the setup.

Here's my current solution:

  1. My factory contract appends the immutable owner's address to the end of the contract. This ensures that create2 gives a new address for every user.

https://github.com/SatoshiAndKin/argobytes-contracts-brownie/blob/slim/contracts/abstract/clonefactory/CloneFactory.sol#L56

  1. And then my proxy contract gets its owner from the contract's code:

https://github.com/SatoshiAndKin/argobytes-contracts-brownie/blob/slim/contracts/abstract/ArgobytesAuth.sol#L41

My testnet deploy script works and I'm working on adding more tests this week. I wanted to post this here in case this is helpful for someone else (or in case its a terrible idea and I should be stopped). I'm very new to assembly and so this is probably not perfect. Any suggestions are welcome.

@PaulRBerg
Copy link

PaulRBerg commented Sep 7, 2021

Hey @wysenynja, thanks for sharing your findings here. I need immutable ownership as well so this is helpful.

Any chance you could update the links you shared? They lead to "404 Not Found" pages now. Pro tip: if you hit Y while viewing a file in a repo, GitHub will add the current commit to the browser URL.

@PaulRBerg
Copy link

PaulRBerg commented Sep 7, 2021

Then I was going to try using the new immutable keyword, but we are using an init function instead of a standard constructor to do the setup.

Could you shed some light on this? Is it that only your set up requires an init function, or all clones deployed with EIP-1167 cannot use the usual Solidity constructor?

I'm still coming to grips with how this clone factory works.

Update: I figured it out on my own after reading the explanation shared by Nate Welch here. Having to use an init function is a limitation of EIP-1167's standard bytecodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants