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

Agency contract optimization #5042

Closed
Smilestate opened this issue May 14, 2024 · 3 comments
Closed

Agency contract optimization #5042

Smilestate opened this issue May 14, 2024 · 3 comments

Comments

@Smilestate
Copy link

version:5.0.0

🧐 Motivation
When I used the above version of the proxy contract, I was surprised to find that deploying the proxy contract would trigger the deployment of the proxyAdmin contract and give the proxy upgrade permission to proxyAdmin. I think it is unreasonable. If there are many proxy contracts in my project, I There are many admin contract addresses to remember.

📝 Details
I saw the constructors logic, admin, and data of the transparent proxy in the previous version. Among them, admin is the proxyAdmin contract address. It is possible to manage multiple agency contracts with one admin contract. But in the latest version, I found that the constructor is logic, owner, data, where owner is the manager who automatically deploys admin. That is to say, each agent contract will deploy an admin contract internally for management and upgrade. However, there is no external method to obtain the admin contract address, and it can only be viewed through the released changeAdmin event.

`/**
* @dev Returns the admin of this proxy.
*/
function _proxyAdmin() internal virtual returns (address) {
return _admin;
}
Added method to obtain proxyAdmin!

constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
_admin = address(new ProxyAdmin(initialOwner));
// Set the storage value and emit an event for ERC-1967 compatibility
ERC1967Utils.changeAdmin(_proxyAdmin());
}

constructor(address logic, address admin, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
changeAdmin(admin);
}
Or adjust the constructor to the specified proxyAdmin contract address that has been deployed.
`
I hope it can be updated as soon as possible, because it is a headache for users to deploy multiple agents and have multiple management contracts! Hope to adopt!

@Smilestate
Copy link
Author

@openzeppelin/contracts
The above 5.0.2 version does not provide view, but the source code provides the view method. Please update and sync.
code
npmjs

@Smilestate
Copy link
Author

Please allow my submission.
Solve the problem of upgrade and transition from 4.0.0 to 5.0.0 agent contract.

The following is my expectation, and I very much look forward to contributors pointing out my shortcomings.

#5043

@cairoeth
Copy link
Contributor

Closing as this is a deliberate design decision.

@cairoeth cairoeth closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2024
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