Commit b6e27b65 authored by Maurelian's avatar Maurelian Committed by GitHub

test(deploy): Deploy a distinct ProxyAdmin for Superchain contracts (#12130)

* test(deploy): Deploy a distinct ProxyAdmin for Superchain contracts

* fix: only set address manager for OP Chain's ProxyAdmin

* fix: typo

* test: fix create2 collision between ProxyAdmins

* fix: lint

* fix: move setupOpChainAdmin() before setupOpAltDA

The DA challenge contract needs a proxy admin too

* feat: use create2AndSave for ProxyAdmin

* fix: Do not double save the superchain ProxyAdmin

* Fix whitespace
Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>

---------
Co-authored-by: default avatarMatt Solomon <matt@mattsolomon.dev>
parent b127499e
...@@ -191,8 +191,9 @@ contract Deploy is Deployer { ...@@ -191,8 +191,9 @@ 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() public broadcast { function transferProxyAdminOwnership(bool _isSuperchain) public broadcast {
IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress("ProxyAdmin")); string memory proxyAdminName = _isSuperchain ? "SuperchainProxyAdmin" : "ProxyAdmin";
IProxyAdmin proxyAdmin = IProxyAdmin(mustGetAddress(proxyAdminName));
address owner = proxyAdmin.owner(); address owner = proxyAdmin.owner();
address finalSystemOwner = cfg.finalSystemOwner(); address finalSystemOwner = cfg.finalSystemOwner();
...@@ -202,17 +203,6 @@ contract Deploy is Deployer { ...@@ -202,17 +203,6 @@ contract Deploy is Deployer {
} }
} }
/// @notice Transfer ownership of a Proxy to the ProxyAdmin contract
/// This is expected to be used in conjusting with deployERC1967ProxyWithOwner after setup actions
/// have been performed on the proxy.
/// @param _name The name of the proxy to transfer ownership of.
function transferProxyToProxyAdmin(string memory _name) public broadcast {
IProxy proxy = IProxy(mustGetAddress(_name));
address proxyAdmin = mustGetAddress("ProxyAdmin");
proxy.changeAdmin(proxyAdmin);
console.log("Proxy %s ownership transferred to ProxyAdmin at: %s", _name, proxyAdmin);
}
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// SetUp and Run // // SetUp and Run //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -276,16 +266,13 @@ contract Deploy is Deployer { ...@@ -276,16 +266,13 @@ 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!");
// Deploy a new ProxyAdmin and AddressManager
// This proxy will be used on the SuperchainConfig and ProtocolVersions contracts, as well as the contracts
// in the OP Chain system.
setupAdmin();
if (_needsSuperchain) { if (_needsSuperchain) {
deployProxyAdmin({ _isSuperchain: true });
setupSuperchain(); setupSuperchain();
console.log("set up superchain!"); console.log("set up superchain!");
} }
setupOpChainAdmin();
if (cfg.useAltDA()) { if (cfg.useAltDA()) {
bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType())); bytes32 typeHash = keccak256(bytes(cfg.daCommitmentType()));
bytes32 keccakHash = keccak256(bytes("KeccakCommitment")); bytes32 keccakHash = keccak256(bytes("KeccakCommitment"));
...@@ -293,6 +280,7 @@ contract Deploy is Deployer { ...@@ -293,6 +280,7 @@ contract Deploy is Deployer {
setupOpAltDA(); setupOpAltDA();
} }
} }
setupOpChain(); setupOpChain();
console.log("set up op chain!"); console.log("set up op chain!");
} }
...@@ -302,9 +290,9 @@ contract Deploy is Deployer { ...@@ -302,9 +290,9 @@ contract Deploy is Deployer {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
/// @notice Deploy the address manager and proxy admin contracts. /// @notice Deploy the address manager and proxy admin contracts.
function setupAdmin() public { function setupOpChainAdmin() public {
deployAddressManager(); deployAddressManager();
deployProxyAdmin(); deployProxyAdmin({ _isSuperchain: false });
} }
/// @notice Deploy a full system with a new SuperchainConfig /// @notice Deploy a full system with a new SuperchainConfig
...@@ -315,12 +303,12 @@ contract Deploy is Deployer { ...@@ -315,12 +303,12 @@ contract Deploy is Deployer {
console.log("Setting up Superchain"); console.log("Setting up Superchain");
// Deploy the SuperchainConfigProxy // Deploy the SuperchainConfigProxy
deployERC1967Proxy("SuperchainConfigProxy"); deployERC1967ProxyWithOwner("SuperchainConfigProxy", mustGetAddress("SuperchainProxyAdmin"));
deploySuperchainConfig(); deploySuperchainConfig();
initializeSuperchainConfig(); initializeSuperchainConfig();
// Deploy the ProtocolVersionsProxy // Deploy the ProtocolVersionsProxy
deployERC1967Proxy("ProtocolVersionsProxy"); deployERC1967ProxyWithOwner("ProtocolVersionsProxy", mustGetAddress("SuperchainProxyAdmin"));
deployProtocolVersions(); deployProtocolVersions();
initializeProtocolVersions(); initializeProtocolVersions();
} }
...@@ -346,7 +334,7 @@ contract Deploy is Deployer { ...@@ -346,7 +334,7 @@ contract Deploy is Deployer {
transferDisputeGameFactoryOwnership(); transferDisputeGameFactoryOwnership();
transferDelayedWETHOwnership(); transferDelayedWETHOwnership();
transferProxyAdminOwnership(); transferProxyAdminOwnership({ _isSuperchain: false });
} }
/// @notice Deploy all of the OP Chain specific contracts /// @notice Deploy all of the OP Chain specific contracts
...@@ -441,23 +429,33 @@ contract Deploy is Deployer { ...@@ -441,23 +429,33 @@ contract Deploy is Deployer {
} }
/// @notice Deploy the ProxyAdmin /// @notice Deploy the ProxyAdmin
function deployProxyAdmin() public broadcast returns (address addr_) { function deployProxyAdmin(bool _isSuperchain) public broadcast returns (address addr_) {
string memory proxyAdminName = _isSuperchain ? "SuperchainProxyAdmin" : "ProxyAdmin";
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: _implSalt(), _salt: keccak256(abi.encode(_implSalt(), proxyAdminName)),
_name: "ProxyAdmin", _name: "ProxyAdmin",
_nick: proxyAdminName,
_args: DeployUtils.encodeConstructor(abi.encodeCall(IProxyAdmin.__constructor__, (msg.sender))) _args: DeployUtils.encodeConstructor(abi.encodeCall(IProxyAdmin.__constructor__, (msg.sender)))
}) })
); );
require(admin.owner() == msg.sender); require(admin.owner() == msg.sender);
IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager")); // The AddressManager is only required for OP Chains
if (admin.addressManager() != addressManager) { if (!_isSuperchain) {
admin.setAddressManager(addressManager); IAddressManager addressManager = IAddressManager(mustGetAddress("AddressManager"));
if (admin.addressManager() != addressManager) {
admin.setAddressManager(addressManager);
}
require(admin.addressManager() == addressManager);
} }
console.log("%s deployed at %s", proxyAdminName, address(admin));
require(admin.addressManager() == addressManager);
addr_ = address(admin); addr_ = address(admin);
} }
...@@ -933,7 +931,7 @@ contract Deploy is Deployer { ...@@ -933,7 +931,7 @@ contract Deploy is Deployer {
address payable superchainConfigProxy = mustGetAddress("SuperchainConfigProxy"); address payable superchainConfigProxy = mustGetAddress("SuperchainConfigProxy");
address payable superchainConfig = mustGetAddress("SuperchainConfig"); address payable superchainConfig = mustGetAddress("SuperchainConfig");
IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("ProxyAdmin"))); IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin")));
proxyAdmin.upgradeAndCall({ proxyAdmin.upgradeAndCall({
_proxy: superchainConfigProxy, _proxy: superchainConfigProxy,
_implementation: superchainConfig, _implementation: superchainConfig,
...@@ -1345,7 +1343,7 @@ contract Deploy is Deployer { ...@@ -1345,7 +1343,7 @@ contract Deploy is Deployer {
uint256 requiredProtocolVersion = cfg.requiredProtocolVersion(); uint256 requiredProtocolVersion = cfg.requiredProtocolVersion();
uint256 recommendedProtocolVersion = cfg.recommendedProtocolVersion(); uint256 recommendedProtocolVersion = cfg.recommendedProtocolVersion();
IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("ProxyAdmin"))); IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("SuperchainProxyAdmin")));
proxyAdmin.upgradeAndCall({ proxyAdmin.upgradeAndCall({
_proxy: payable(protocolVersionsProxy), _proxy: payable(protocolVersionsProxy),
_implementation: protocolVersions, _implementation: protocolVersions,
......
...@@ -19,8 +19,8 @@ import { DeputyGuardianModule } from "src/safe/DeputyGuardianModule.sol"; ...@@ -19,8 +19,8 @@ import { DeputyGuardianModule } from "src/safe/DeputyGuardianModule.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { Deploy } from "./Deploy.s.sol"; import { Deploy } from "./Deploy.s.sol";
/// @notice Configuration for a Safe
/// @notice Configuration for a Safe
struct SafeConfig { struct SafeConfig {
uint256 threshold; uint256 threshold;
address[] owners; address[] owners;
......
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