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

Setting an owner on upgradeable contracts without being able to call constructor #120

Open
treeder opened this issue Aug 22, 2019 · 10 comments
Labels
question Further information is requested

Comments

@treeder
Copy link
Contributor

treeder commented Aug 22, 2019

If the contract requires an owner, how can you securely set it to the deployers address when using upgradeable contracts? cc @benbjohnson

@treeder treeder added the question Further information is requested label Aug 22, 2019
@benbjohnson
Copy link
Contributor

IIRC, it sets the owner to the msg.sender when it gets created.

@jmank88
Copy link
Contributor

jmank88 commented Aug 22, 2019

@treeder
Copy link
Contributor Author

treeder commented Aug 22, 2019

I mean the constructor of the underlying contract, that doesn't run right? (or if it does, the docs are wrong).

@jmank88
Copy link
Contributor

jmank88 commented Aug 22, 2019

AFAIK that is correct. Perhaps the contract would need to reference the proxy owner via keccak256("gochain.proxy.owner") to bootstrap its own owner, or to just use directly instead.

@treeder
Copy link
Contributor Author

treeder commented Aug 22, 2019

Maybe we should have the proxy call an init() function (if it exists), that can be used as a constructor. Otherwise, it seems to me that you'd have to deploy, then call functions a constructor would do, such as call setOwner. And that setOwner to be secure would have to have a defense in like if owner == address(0x0) then allow it so it can only be called once.

@treeder
Copy link
Contributor Author

treeder commented Aug 22, 2019

cc @brockmcblockchain

@jmank88
Copy link
Contributor

jmank88 commented Aug 22, 2019

An generalized init() solution might be possible, but if the only concern is managing an owner, then the target contract can reference the owner from the proxy contract with keccak256("gochain.proxy.owner") because they share the same state.

@treeder
Copy link
Contributor Author

treeder commented Aug 22, 2019

It's not just owner, it's anything you'd put in a constructor. That's just a common one.

@treeder
Copy link
Contributor Author

treeder commented Aug 22, 2019

Alternatively, can we figure out a way to call the constructor?

@jmank88
Copy link
Contributor

jmank88 commented Aug 22, 2019

AFAIK running the constructor of the target contract against the state of the proxy contract is not possible. It does run when the target is deployed, but against its own state, not the proxy state.

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

No branches or pull requests

3 participants