Commit 63d877a0 authored by Kelvin Fichter's avatar Kelvin Fichter Committed by Maurelian

fix(ctb): better XDM pause in MSD

Improves the pausing mechanism for the CrossDomainMessenger in the
MigrationSystemDictator.
parent dbb8721b
......@@ -49,15 +49,24 @@ contract MigrationSystemDictator is BaseSystemDictator {
}
/**
* @notice Pauses the system by shutting down the L1CrossDomainMessenger and clearing many
* addresses inside the AddressManager.
* @notice Pauses the system by shutting down the L1CrossDomainMessenger and setting the
* deposit halt flag to tell the Sequencer's DTL to stop accepting deposits.
*/
function step2() external onlyOwner step(2) {
// Pause the L1CrossDomainMessenger
L1CrossDomainMessenger(config.proxyAddressConfig.l1CrossDomainMessengerProxy).pause();
// Temporarily brick the L1CrossDomainMessenger by setting its implementation address to
// address(0) which will cause the ResolvedDelegateProxy to revert. Better than pausing
// the L1CrossDomainMessenger via pause() because it can be easily reverted.
config.globalConfig.addressManager.setAddress("OVM_L1CrossDomainMessenger", address(0));
// TODO: Set the deposit halt flag.
}
// Remove all dead addresses from the AddressManager
string[18] memory deads = [
/**
* @notice Removes deprecated addresses from the AddressManager.
*/
function step3() external onlyOwner step(3) {
// Remove all deprecated addresses from the AddressManager
string[18] memory deprecated = [
"Proxy__OVM_L1CrossDomainMessenger",
"Proxy__OVM_L1StandardBridge",
"OVM_CanonicalTransactionChain",
......@@ -78,15 +87,15 @@ contract MigrationSystemDictator is BaseSystemDictator {
"OVM_L1MultiMessageRelayer"
];
for (uint256 i = 0; i < deads.length; i++) {
config.globalConfig.addressManager.setAddress(deads[i], address(0));
for (uint256 i = 0; i < deprecated.length; i++) {
config.globalConfig.addressManager.setAddress(deprecated[i], address(0));
}
}
/**
* @notice Transfers system ownership to the ProxyAdmin.
*/
function step3() external onlyOwner step(3) {
function step4() external onlyOwner step(4) {
// Transfer ownership of the AddressManager to the ProxyAdmin.
config.globalConfig.addressManager.transferOwnership(
address(config.globalConfig.proxyAdmin)
......@@ -101,7 +110,11 @@ contract MigrationSystemDictator is BaseSystemDictator {
/**
* @notice Upgrades and initializes proxy contracts.
*/
function step4() external onlyOwner step(4) {
function step5() external onlyOwner step(5) {
// Pause the L1CrossDomainMessenger. Now we use the real pause() function because by the
// time we're done here we'll have access to the unpause() function.
L1CrossDomainMessenger(config.proxyAddressConfig.l1CrossDomainMessengerProxy).pause();
// Upgrade and initialize the L2OutputOracle.
config.globalConfig.proxyAdmin.upgradeAndCall(
payable(config.proxyAddressConfig.l2OutputOracleProxy),
......@@ -175,7 +188,7 @@ contract MigrationSystemDictator is BaseSystemDictator {
/**
* @notice Unpauses the system at which point the system should be fully operational.
*/
function step5() external onlyOwner step(5) {
function step6() external onlyOwner step(6) {
// Unpause the L1CrossDomainMessenger.
L1CrossDomainMessenger(config.proxyAddressConfig.l1CrossDomainMessengerProxy).unpause();
}
......@@ -183,7 +196,7 @@ contract MigrationSystemDictator is BaseSystemDictator {
/**
* @notice Tranfers admin ownership to the final owner.
*/
function step6() external onlyOwner step(6) {
function step7() external onlyOwner step(7) {
// Transfer ownership of the L1CrossDomainMessenger to the final owner.
L1CrossDomainMessenger(config.proxyAddressConfig.l1CrossDomainMessengerProxy)
.transferOwnership(config.globalConfig.finalOwner);
......
......@@ -188,7 +188,12 @@ const deployFn: DeployFunction = async (hre) => {
)
},
2: async () => {
await assertContractVariable(L1CrossDomainMessenger, 'paused', true)
assert(
(await AddressManager.getAddress('OVM_L1CrossDomainMessenger')) ===
ethers.constants.AddressZero
)
},
3: async () => {
const deads = [
'Proxy__OVM_L1CrossDomainMessenger',
'Proxy__OVM_L1StandardBridge',
......@@ -216,7 +221,7 @@ const deployFn: DeployFunction = async (hre) => {
)
}
},
3: async () => {
4: async () => {
await assertContractVariable(AddressManager, 'owner', ProxyAdmin.address)
assert(
(await L1StandardBridgeProxy.callStatic.getOwner({
......@@ -224,7 +229,7 @@ const deployFn: DeployFunction = async (hre) => {
})) === ProxyAdmin.address
)
},
4: async () => {
5: async () => {
// Check L2OutputOracle was initialized properly.
await assertContractVariable(
L2OutputOracle,
......@@ -279,6 +284,7 @@ const deployFn: DeployFunction = async (hre) => {
)
// Check L1CrossDomainMessenger was initialized properly.
await assertContractVariable(L1CrossDomainMessenger, 'paused', true)
try {
await L1CrossDomainMessenger.xDomainMessageSender()
assert(false, `L1CrossDomainMessenger was not initialized properly`)
......@@ -318,10 +324,10 @@ const deployFn: DeployFunction = async (hre) => {
L1CrossDomainMessenger.address
)
},
5: async () => {
6: async () => {
await assertContractVariable(L1CrossDomainMessenger, 'paused', false)
},
6: async () => {
7: async () => {
await assertContractVariable(
L1CrossDomainMessenger,
'owner',
......@@ -335,7 +341,7 @@ const deployFn: DeployFunction = async (hre) => {
},
}
for (let i = 1; i <= 6; i++) {
for (let i = 1; i <= 7; i++) {
if ((await MigrationSystemDictator.currentStep()) === i) {
if (isLiveDeployer) {
console.log(`Executing step ${i}...`)
......
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