Commit c54044f4 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ct): error in deploy script (#12264)

Fixes an error in the deploy script that was recently introduced.
SuperchainProxyAdmin was being set twice and ownership was being
set incorrectly.
parent 00f965dd
...@@ -169,16 +169,21 @@ contract Deploy is Deployer { ...@@ -169,16 +169,21 @@ contract Deploy is Deployer {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/// @notice Transfer ownership of the ProxyAdmin contract to the final system owner /// @notice Transfer ownership of the ProxyAdmin contract to the final system owner
function transferProxyAdminOwnership(bool _isSuperchain) public broadcast { function transferProxyAdminOwnership() public broadcast {
string memory proxyAdminName = _isSuperchain ? "SuperchainProxyAdmin" : "ProxyAdmin"; // Get the ProxyAdmin contract.
IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress(proxyAdminName)); IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress("ProxyAdmin"));
address owner = proxyAdmin.owner();
// Transfer ownership to the final system owner if necessary.
address owner = proxyAdmin.owner();
address finalSystemOwner = cfg.finalSystemOwner(); address finalSystemOwner = cfg.finalSystemOwner();
if (owner != finalSystemOwner) { if (owner != finalSystemOwner) {
proxyAdmin.transferOwnership(finalSystemOwner); proxyAdmin.transferOwnership(finalSystemOwner);
console.log("ProxyAdmin ownership transferred to final system owner at: %s", finalSystemOwner); console.log("ProxyAdmin ownership transferred to final system owner at: %s", finalSystemOwner);
} }
// Make sure the ProxyAdmin owner is set to the final system owner.
owner = proxyAdmin.owner();
require(owner == finalSystemOwner, "Deploy: ProxyAdmin ownership not transferred to final system owner");
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -244,11 +249,11 @@ contract Deploy is Deployer { ...@@ -244,11 +249,11 @@ contract Deploy is Deployer {
function _run(bool _needsSuperchain) internal { function _run(bool _needsSuperchain) internal {
console.log("start of L1 Deploy!"); console.log("start of L1 Deploy!");
// Set up the Superchain if needed.
if (_needsSuperchain) { if (_needsSuperchain) {
deployProxyAdmin({ _isSuperchain: true });
setupSuperchain(); setupSuperchain();
console.log("set up superchain!");
} }
if (cfg.useInterop()) { if (cfg.useInterop()) {
deployImplementationsInterop(); deployImplementationsInterop();
} else { } else {
...@@ -278,7 +283,8 @@ contract Deploy is Deployer { ...@@ -278,7 +283,8 @@ contract Deploy is Deployer {
setupOpAltDA(); setupOpAltDA();
} }
} }
transferProxyAdminOwnership({ _isSuperchain: false });
transferProxyAdminOwnership();
console.log("set up op chain!"); console.log("set up op chain!");
} }
...@@ -296,29 +302,35 @@ contract Deploy is Deployer { ...@@ -296,29 +302,35 @@ contract Deploy is Deployer {
(DeploySuperchainInput dsi, DeploySuperchainOutput dso) = deploySuperchain.etchIOContracts(); (DeploySuperchainInput dsi, DeploySuperchainOutput dso) = deploySuperchain.etchIOContracts();
// Set the input values on the input contract. // Set the input values on the input contract.
dsi.set(dsi.superchainProxyAdminOwner.selector, mustGetAddress("SuperchainProxyAdmin"));
// TODO: when DeployAuthSystem is done, finalSystemOwner should be replaced with the Foundation Upgrades Safe // TODO: when DeployAuthSystem is done, finalSystemOwner should be replaced with the Foundation Upgrades Safe
dsi.set(dsi.protocolVersionsOwner.selector, cfg.finalSystemOwner()); dsi.set(dsi.protocolVersionsOwner.selector, cfg.finalSystemOwner());
dsi.set(dsi.superchainProxyAdminOwner.selector, cfg.finalSystemOwner());
dsi.set(dsi.guardian.selector, cfg.superchainConfigGuardian()); dsi.set(dsi.guardian.selector, cfg.superchainConfigGuardian());
dsi.set(dsi.paused.selector, false); dsi.set(dsi.paused.selector, false);
dsi.set(dsi.requiredProtocolVersion.selector, ProtocolVersion.wrap(cfg.requiredProtocolVersion())); dsi.set(dsi.requiredProtocolVersion.selector, ProtocolVersion.wrap(cfg.requiredProtocolVersion()));
dsi.set(dsi.recommendedProtocolVersion.selector, ProtocolVersion.wrap(cfg.recommendedProtocolVersion())); dsi.set(dsi.recommendedProtocolVersion.selector, ProtocolVersion.wrap(cfg.recommendedProtocolVersion()));
// Run the deployment script. // Run the deployment script.
deploySuperchain.run(dsi, dso); deploySuperchain.run(dsi, dso);
save("superchainProxyAdmin", address(dso.superchainProxyAdmin())); save("SuperchainProxyAdmin", address(dso.superchainProxyAdmin()));
save("SuperchainConfigProxy", address(dso.superchainConfigProxy())); save("SuperchainConfigProxy", address(dso.superchainConfigProxy()));
save("SuperchainConfig", address(dso.superchainConfigImpl())); save("SuperchainConfig", address(dso.superchainConfigImpl()));
save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy())); save("ProtocolVersionsProxy", address(dso.protocolVersionsProxy()));
save("ProtocolVersions", address(dso.protocolVersionsImpl())); save("ProtocolVersions", address(dso.protocolVersionsImpl()));
// Run chain assertions.
// Run assertions for ProtocolVersions and SuperchainConfig proxy contracts.
ChainAssertions.checkProtocolVersions({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isProxy: true });
ChainAssertions.checkSuperchainConfig({ _contracts: _proxiesUnstrict(), _cfg: cfg, _isPaused: false });
// TODO: Add assertions for SuperchainConfig and ProtocolVersions impl contracts.
// TODO: Add assertions for SuperchainProxyAdmin.
} }
/// @notice Deploy all of the OP Chain specific contracts /// @notice Deploy all of the OP Chain specific contracts
function deployOpChain() public { function deployOpChain() public {
console.log("Deploying OP Chain"); console.log("Deploying OP Chain");
deployAddressManager(); deployAddressManager();
deployProxyAdmin({ _isSuperchain: false }); deployProxyAdmin();
transferAddressManagerOwnership(); // to the ProxyAdmin transferAddressManagerOwnership(); // to the ProxyAdmin
// Ensure that the requisite contracts are deployed // Ensure that the requisite contracts are deployed
...@@ -435,34 +447,31 @@ contract Deploy is Deployer { ...@@ -435,34 +447,31 @@ contract Deploy is Deployer {
addr_ = address(manager); addr_ = address(manager);
} }
/// @notice Deploy the ProxyAdmin /// @notice Deploys the ProxyAdmin contract. Should NOT be used for the Superchain.
function deployProxyAdmin(bool _isSuperchain) public broadcast returns (address addr_) { function deployProxyAdmin() public broadcast returns (address addr_) {
string memory proxyAdminName = _isSuperchain ? "SuperchainProxyAdmin" : "ProxyAdmin"; // Deploy the ProxyAdmin contract.
console.log("Deploying %s", proxyAdminName);
// Include the proxyAdminName in the salt to prevent a create2 collision when both the Superchain and an OP
// Chain are being setup.
IProxyAdmin admin = IProxyAdmin( IProxyAdmin admin = IProxyAdmin(
DeployUtils.create2AndSave({ DeployUtils.create2AndSave({
_save: this, _save: this,
_salt: keccak256(abi.encode(_implSalt(), proxyAdminName)), _salt: _implSalt(),
_name: "ProxyAdmin", _name: "ProxyAdmin",
_nick: proxyAdminName,
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProxyAdmin.__constructor__, (msg.sender))) _args: DeployUtils.encodeConstructor(abi.encodeCall(IProxyAdmin.__constructor__, (msg.sender)))
}) })
); );
// Make sure the owner was set to the deployer.
require(admin.owner() == msg.sender); require(admin.owner() == msg.sender);
// The AddressManager is only required for OP Chains // Set the address manager if it is not already set.
if (!_isSuperchain) { IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager"));
IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager")); if (admin.addressManager() != addressManager) {
if (admin.addressManager() != addressManager) { admin.setAddressManager(addressManager);
admin.setAddressManager(addressManager);
}
require(admin.addressManager() == addressManager);
} }
console.log("%s deployed at %s", proxyAdminName, address(admin));
// Make sure the address manager is set properly.
require(admin.addressManager() == addressManager);
// Return the address of the deployed contract.
addr_ = address(admin); addr_ = address(admin);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment