Commit f19d11c5 authored by Kelvin Fichter's avatar Kelvin Fichter

feat(ctb): allow owner to finalize MSD at any time

Allows the owner of the MigrationSystemDictator to finalize the
deployment at any time. Finalizing the deployment will transfer
ownership of relevant contracts to the final owner.
parent 66d56a47
......@@ -17,6 +17,16 @@ import { BaseSystemDictator } from "./BaseSystemDictator.sol";
* proxies and implementations already be deployed before this contract is used.
*/
contract MigrationSystemDictator is BaseSystemDictator {
/**
* @notice Step where proxy ownership is transferred.
*/
uint8 constant PROXY_TRANSFER_STEP = 3;
/**
* @notice Whether or not the deployment is finalized.
*/
bool public finalized;
/**
* @param _config System configuration.
*/
......@@ -195,12 +205,28 @@ contract MigrationSystemDictator is BaseSystemDictator {
/**
* @notice Tranfers admin ownership to the final owner.
*/
function step7() external onlyOwner step(7) {
function finalize() external onlyOwner {
// Transfer ownership of the L1CrossDomainMessenger to the final owner.
L1CrossDomainMessenger(config.proxyAddressConfig.l1CrossDomainMessengerProxy)
.transferOwnership(config.globalConfig.finalOwner);
// Transfer ownership of the ProxyAdmin to the final owner.
config.globalConfig.proxyAdmin.transferOwnership(config.globalConfig.finalOwner);
// Optionally also transfer AddressManager and L1StandardBridge if we still own it. Might
// happen if we're exiting early.
if (currentStep <= PROXY_TRANSFER_STEP) {
// Transfer ownership of the AddressManager to the final owner.
config.globalConfig.addressManager.transferOwnership(
address(config.globalConfig.finalOwner)
);
// Transfer ownership of the L1StandardBridge to the final owner.
L1ChugSplashProxy(payable(config.proxyAddressConfig.l1StandardBridgeProxy)).setOwner(
address(config.globalConfig.finalOwner)
);
}
finalized = true;
}
}
......@@ -326,21 +326,9 @@ const deployFn: DeployFunction = async (hre) => {
6: async () => {
await assertContractVariable(L1CrossDomainMessenger, 'paused', false)
},
7: async () => {
await assertContractVariable(
L1CrossDomainMessenger,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable(
ProxyAdmin,
'owner',
hre.deployConfig.finalSystemOwner
)
},
}
for (let i = 1; i <= 7; i++) {
for (let i = 1; i <= 6; i++) {
if ((await MigrationSystemDictator.currentStep()) === i) {
if (isLiveDeployer) {
console.log(`Executing step ${i}...`)
......@@ -360,6 +348,31 @@ const deployFn: DeployFunction = async (hre) => {
console.log(`Step ${i} executed`)
}
}
if ((await MigrationSystemDictator.currentStep()) === 7) {
if (isLiveDeployer) {
console.log(`Finalizing deployment...`)
await MigrationSystemDictator.finalize()
} else {
console.log(`Please finalize deployment...`)
}
await awaitCondition(async () => {
return MigrationSystemDictator.finalized()
})
await assertContractVariable(
L1CrossDomainMessenger,
'owner',
hre.deployConfig.finalSystemOwner
)
await assertContractVariable(
ProxyAdmin,
'owner',
hre.deployConfig.finalSystemOwner
)
}
}
deployFn.tags = ['MigrationSystemDictatorSteps', 'migration']
......
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