-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Change default owner/admin accounts to tx.origin
rather than msg.sender
#3044
Comments
yes using tx.origin for constructor only seems ok |
Hello @pcaversaccio The wizard's role is to produce templates / first draft, that users can modify depending on their needs. In this case, it would be easy to do any of the following:
@frangio: In the wizard when access control is enabled, maybe we want to add an optional field "admin" that would replace msg.sender ? |
@Amxx yes agreed - but a template / first draft should be generic as much as possible (same goes for the default For /**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(tx.origin);
} As far as I've seen, there is no need to change function _txOrigin() internal view virtual returns (address) {
return tx.origin;
} This would change the first snippet in the following way: /**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_txOrigin());
} I've thought through all |
We disagree that it's okay to use This is always going to be a problem with factories and the factory created contract needs to be aware of that and/or offer a way to initialize it to the right values. For example, with an This is a proposal for a more general solution for the Wizard: |
We already had some request to change the
IMO this would be much better then using tx.origin, yet we rejected this proposition because it would be a breaking change. We are VERY careful about any breaking change, which you proposal would be. Also we are, like most of the community, against using tx.origin. This has been the source of a lot of bugs. If you really want to set tx.origin has the original owner (I would advice against it) you always have the possibility to do.
|
Think OP has a good proposal. Think it would be worth the change. +1 Setting owner should be simpler. Setting tx.origin as owner for factories is a must. |
🧐 Motivation
Some background: I'm the author of the Hardhat plugin
xdeployer
that helps to deploy smart contracts across multiple EVM chains with the same deterministic address (keywordCREATE2
opcode). Since opcodes can only be called via smart contracts, the default owner of a deployed contract withCREATE2
(and my plugin) will be a contract address (using your defaultnpm
package as dependency) which is obviously not good. How about setting the default owner totx.origin
and make everything more agnostic? Like that it can be ensured that the original EOA user will always be the owner. The same applies to the default roles in your OpenZeppelin Wizard forDEFAULT_ADMIN_ROLE
,PAUSER_ROLE
,MINTER_ROLE
:I'm fully aware of the security considerations re
tx.origin
(https://docs.soliditylang.org/en/v0.8.11/security-considerations.html?highlight=tx.origin#tx-origin), however, in this case, we would not touch the authorization but rather "only" the constructor argument.The text was updated successfully, but these errors were encountered: