Commit 4e5b3d73 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: delete sherlock upgrade scripts

Deletes these old upgrade scripts that were used to
upgrade the contracts on goerli with the sherlock audit
fixes. These scripts are not general enough to be used
again, so there is no need to keep them around.

Removing them will help to speed up compile time.
`solc` takes awhile at this point to compile the
contracts repo so we should prune out code that is
not being used or will not be used in the future.

We should iterate on the design so that we can have generic
upgrade scripts in the future.
parent 44c40a85
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { console } from "forge-std/console.sol";
import { SafeBuilder } from "../universal/SafeBuilder.sol";
import { IMulticall3 } from "forge-std/interfaces/IMulticall3.sol";
import { IGnosisSafe, Enum } from "../interfaces/IGnosisSafe.sol";
import { LibSort } from "../libraries/LibSort.sol";
import { ProxyAdmin } from "../../src/universal/ProxyAdmin.sol";
import { Constants } from "../../src/libraries/Constants.sol";
import { SystemConfig } from "../../src/L1/SystemConfig.sol";
import { ResourceMetering } from "../../src/L1/ResourceMetering.sol";
import { Semver } from "../../src/universal/Semver.sol";
/// @title PostSherlockL1
/// @notice Upgrade script for upgrading the L1 contracts after the sherlock audit.
contract PostSherlockL1 is SafeBuilder {
/// @notice Address of the ProxyAdmin, passed in via constructor of `run`.
ProxyAdmin internal PROXY_ADMIN;
/// @notice Represents a set of L1 contracts. Used to represent a set of
/// implementations and also a set of proxies.
struct ContractSet {
address L1CrossDomainMessenger;
address L1StandardBridge;
address L2OutputOracle;
address OptimismMintableERC20Factory;
address OptimismPortal;
address SystemConfig;
address L1ERC721Bridge;
}
/// @notice A mapping of chainid to a ContractSet of implementations.
mapping(uint256 => ContractSet) internal implementations;
/// @notice A mapping of chainid to ContractSet of proxy addresses.
mapping(uint256 => ContractSet) internal proxies;
/// @notice The expected versions for the contracts to be upgraded to.
string internal constant L1CrossDomainMessenger_Version = "1.4.0";
string internal constant L1StandardBridge_Version = "1.1.0";
string internal constant L2OutputOracle_Version = "1.3.0";
string internal constant OptimismMintableERC20Factory_Version = "1.1.0";
string internal constant OptimismPortal_Version = "1.6.0";
string internal constant SystemConfig_Version = "1.3.0";
string internal constant L1ERC721Bridge_Version = "1.1.1";
/// @notice Place the contract addresses in storage so they can be used when building calldata.
function setUp() external {
implementations[GOERLI] = ContractSet({
L1CrossDomainMessenger: 0x9D1dACf9d9299D17EFFE1aAd559c06bb3Fbf9BC4,
L1StandardBridge: 0x022Fc3EBAA3d53F8f9b270CC4ABe1B0e4A406253,
L2OutputOracle: 0x0C2b6590De9D61b37094617b5e6f794Ae118176E,
OptimismMintableERC20Factory: 0x0EebA1A5da867EB3bc0956f6389d490d0F4b8086,
OptimismPortal: 0x9e760aBd847E48A56b4a348Cba56Ae7267FeCE80,
SystemConfig: 0x821EE96B88dAA1569F41cD46b0EA87fA89714b45,
L1ERC721Bridge: 0x015609dC8cBF8f9947ba571432Bc0d9837c583a4
});
proxies[GOERLI] = ContractSet({
L1CrossDomainMessenger: 0x5086d1eEF304eb5284A0f6720f79403b4e9bE294,
L1StandardBridge: 0x636Af16bf2f682dD3109e60102b8E1A089FedAa8,
L2OutputOracle: 0xE6Dfba0953616Bacab0c9A8ecb3a9BBa77FC15c0,
OptimismMintableERC20Factory: 0x883dcF8B05364083D849D8bD226bC8Cb4c42F9C5,
OptimismPortal: 0x5b47E1A08Ea6d985D6649300584e6722Ec4B1383,
SystemConfig: 0xAe851f927Ee40dE99aaBb7461C00f9622ab91d60,
L1ERC721Bridge: 0x8DD330DdE8D9898d43b4dc840Da27A07dF91b3c9
});
}
/// @notice Follow up assertions to ensure that the script ran to completion.
function _postCheck() internal view override {
ContractSet memory prox = getProxies();
require(
_versionHash(prox.L1CrossDomainMessenger) == keccak256(bytes(L1CrossDomainMessenger_Version)),
"L1CrossDomainMessenger"
);
require(_versionHash(prox.L1StandardBridge) == keccak256(bytes(L1StandardBridge_Version)), "L1StandardBridge");
require(_versionHash(prox.L2OutputOracle) == keccak256(bytes(L2OutputOracle_Version)), "L2OutputOracle");
require(
_versionHash(prox.OptimismMintableERC20Factory) == keccak256(bytes(OptimismMintableERC20Factory_Version)),
"OptimismMintableERC20Factory"
);
require(_versionHash(prox.OptimismPortal) == keccak256(bytes(OptimismPortal_Version)), "OptimismPortal");
require(_versionHash(prox.SystemConfig) == keccak256(bytes(SystemConfig_Version)), "SystemConfig");
require(_versionHash(prox.L1ERC721Bridge) == keccak256(bytes(L1ERC721Bridge_Version)), "L1ERC721Bridge");
ResourceMetering.ResourceConfig memory rcfg = SystemConfig(prox.SystemConfig).resourceConfig();
ResourceMetering.ResourceConfig memory dflt = Constants.DEFAULT_RESOURCE_CONFIG();
require(keccak256(abi.encode(rcfg)) == keccak256(abi.encode(dflt)));
// Check that the codehashes of all implementations match the proxies set implementations.
ContractSet memory impl = getImplementations();
require(
PROXY_ADMIN.getProxyImplementation(prox.L1CrossDomainMessenger).codehash
== impl.L1CrossDomainMessenger.codehash,
"L1CrossDomainMessenger codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.L1StandardBridge).codehash == impl.L1StandardBridge.codehash,
"L1StandardBridge codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.L2OutputOracle).codehash == impl.L2OutputOracle.codehash,
"L2OutputOracle codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.OptimismMintableERC20Factory).codehash
== impl.OptimismMintableERC20Factory.codehash,
"OptimismMintableERC20Factory codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.OptimismPortal).codehash == impl.OptimismPortal.codehash,
"OptimismPortal codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.SystemConfig).codehash == impl.SystemConfig.codehash,
"SystemConfig codehash"
);
require(
PROXY_ADMIN.getProxyImplementation(prox.L1ERC721Bridge).codehash == impl.L1ERC721Bridge.codehash,
"L1ERC721Bridge codehash"
);
}
/// @notice Test coverage of the logic. Should only run on goerli but other chains
/// could be added.
function test_script_succeeds() external skipWhenNotForking {
address _safe;
address _proxyAdmin;
if (block.chainid == GOERLI) {
_safe = 0xBc1233d0C3e6B5d53Ab455cF65A6623F6dCd7e4f;
_proxyAdmin = 0x01d3670863c3F4b24D7b107900f0b75d4BbC6e0d;
// Set the proxy admin for the `_postCheck` function
PROXY_ADMIN = ProxyAdmin(_proxyAdmin);
}
require(_safe != address(0) && _proxyAdmin != address(0));
address[] memory owners = IGnosisSafe(payable(_safe)).getOwners();
for (uint256 i; i < owners.length; i++) {
address owner = owners[i];
vm.startBroadcast(owner);
bool success = _run(_safe, _proxyAdmin);
vm.stopBroadcast();
if (success) {
console.log("tx success");
break;
}
}
_postCheck();
}
/// @notice Builds the calldata that the multisig needs to make for the upgrade to happen.
/// A total of 8 calls are made, 7 upgrade implementations and 1 sets the resource
/// config to the default value in the SystemConfig contract.
function buildCalldata(address _proxyAdmin) internal view override returns (bytes memory) {
IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](8);
ContractSet memory impl = getImplementations();
ContractSet memory prox = getProxies();
// Upgrade the L1CrossDomainMessenger
calls[0] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(
ProxyAdmin.upgrade, (payable(prox.L1CrossDomainMessenger), impl.L1CrossDomainMessenger)
)
});
// Upgrade the L1StandardBridge
calls[1] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L1StandardBridge), impl.L1StandardBridge))
});
// Upgrade the L2OutputOracle
calls[2] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L2OutputOracle), impl.L2OutputOracle))
});
// Upgrade the OptimismMintableERC20Factory
calls[3] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(
ProxyAdmin.upgrade, (payable(prox.OptimismMintableERC20Factory), impl.OptimismMintableERC20Factory)
)
});
// Upgrade the OptimismPortal
calls[4] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.OptimismPortal), impl.OptimismPortal))
});
// Upgrade the SystemConfig
calls[5] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.SystemConfig), impl.SystemConfig))
});
// Upgrade the L1ERC721Bridge
calls[6] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L1ERC721Bridge), impl.L1ERC721Bridge))
});
// Set the default resource config
ResourceMetering.ResourceConfig memory rcfg = Constants.DEFAULT_RESOURCE_CONFIG();
calls[7] = IMulticall3.Call3({
target: prox.SystemConfig,
allowFailure: false,
callData: abi.encodeCall(SystemConfig.setResourceConfig, (rcfg))
});
return abi.encodeCall(IMulticall3.aggregate3, (calls));
}
/// @notice Returns the ContractSet that represents the implementations for a given network.
function getImplementations() internal view returns (ContractSet memory) {
ContractSet memory set = implementations[block.chainid];
require(set.L1CrossDomainMessenger != address(0), "no implementations for this network");
return set;
}
/// @notice Returns the ContractSet that represents the proxies for a given network.
function getProxies() internal view returns (ContractSet memory) {
ContractSet memory set = proxies[block.chainid];
require(set.L1CrossDomainMessenger != address(0), "no proxies for this network");
return set;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { console } from "forge-std/console.sol";
import { SafeBuilder } from "../universal/SafeBuilder.sol";
import { IGnosisSafe, Enum } from "../interfaces/IGnosisSafe.sol";
import { IMulticall3 } from "forge-std/interfaces/IMulticall3.sol";
import { Predeploys } from "../../src/libraries/Predeploys.sol";
import { ProxyAdmin } from "../../src/universal/ProxyAdmin.sol";
/// @title PostSherlockL2
/// @notice Upgrades the L2 contracts.
contract PostSherlockL2 is SafeBuilder {
/// @notice The proxy admin predeploy on L2.
ProxyAdmin constant PROXY_ADMIN = ProxyAdmin(0x4200000000000000000000000000000000000018);
/// @notice Represents a set of L2 predepploy contracts. Used to represent a set of
/// implementations and also a set of proxies.
struct ContractSet {
address BaseFeeVault;
address GasPriceOracle;
address L1Block;
address L1FeeVault;
address L2CrossDomainMessenger;
address L2ERC721Bridge;
address L2StandardBridge;
address L2ToL1MessagePasser;
address SequencerFeeVault;
address OptimismMintableERC20Factory;
address OptimismMintableERC721Factory;
}
/// @notice A mapping of chainid to a ContractSet of implementations.
mapping(uint256 => ContractSet) internal implementations;
/// @notice A mapping of chainid to ContractSet of proxy addresses.
mapping(uint256 => ContractSet) internal proxies;
/// @notice The expected versions for the contracts to be upgraded to.
string internal constant BaseFeeVault_Version = "1.1.0";
string internal constant GasPriceOracle_Version = "1.0.0";
string internal constant L1Block_Version = "1.0.0";
string internal constant L1FeeVault_Version = "1.1.0";
string internal constant L2CrossDomainMessenger_Version = "1.4.0";
string internal constant L2ERC721Bridge_Version = "1.1.0";
string internal constant L2StandardBridge_Version = "1.1.0";
string internal constant L2ToL1MessagePasser_Version = "1.0.0";
string internal constant SequencerFeeVault_Version = "1.1.0";
string internal constant OptimismMintableERC20Factory_Version = "1.1.0";
string internal constant OptimismMintableERC721Factory_Version = "1.2.0";
/// @notice Place the contract addresses in storage so they can be used when building calldata.
function setUp() external {
implementations[OP_GOERLI] = ContractSet({
BaseFeeVault: 0x984eBeFb32A5c2862e92ce90EA0C81Ab69F026B5,
GasPriceOracle: 0xb43C412454f5D1e58Fe895B1a832B6700ADB5FA7,
L1Block: 0x6dF83A19647A398d48e77a6835F4A28EB7e2f7c0,
L1FeeVault: 0xC7d3389726374B8BFF53116585e20A483415f6f6,
L2CrossDomainMessenger: 0x3305a8110469eB7168870126b26BDAD56067C679,
L2ERC721Bridge: 0x5Eb0EE8d7f29856F50b5c97F9CF1225491404bF1,
L2StandardBridge: 0x26A77636eD9A97BBDE9740bed362bFCE5CaB8e10,
L2ToL1MessagePasser: 0x50CcA47c1e06084459dc83c9E964F4a158cB28Ae,
SequencerFeeVault: 0x9eE472aB07Aa92bAe20a9d3E2d29beD3248b9075,
OptimismMintableERC20Factory: 0x3F94732CFd48eE3597d7cEDfb853cfB2De31219c,
OptimismMintableERC721Factory: 0x13DcfC403eCEF3E8Eab66C00dC64e793dc40Be1d
});
proxies[OP_GOERLI] = ContractSet({
BaseFeeVault: Predeploys.BASE_FEE_VAULT,
GasPriceOracle: Predeploys.GAS_PRICE_ORACLE,
L1Block: Predeploys.L1_BLOCK_ATTRIBUTES,
L1FeeVault: Predeploys.L1_FEE_VAULT,
L2CrossDomainMessenger: Predeploys.L2_CROSS_DOMAIN_MESSENGER,
L2ERC721Bridge: Predeploys.L2_ERC721_BRIDGE,
L2StandardBridge: Predeploys.L2_STANDARD_BRIDGE,
L2ToL1MessagePasser: Predeploys.L2_TO_L1_MESSAGE_PASSER,
SequencerFeeVault: Predeploys.SEQUENCER_FEE_WALLET,
OptimismMintableERC20Factory: Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY,
OptimismMintableERC721Factory: Predeploys.OPTIMISM_MINTABLE_ERC721_FACTORY
});
}
/// @notice Follow up assertions to ensure that the script ran to completion.
function _postCheck() internal view override {
ContractSet memory prox = getProxies();
require(_versionHash(prox.BaseFeeVault) == keccak256(bytes(BaseFeeVault_Version)), "BaseFeeVault");
require(_versionHash(prox.GasPriceOracle) == keccak256(bytes(GasPriceOracle_Version)), "GasPriceOracle");
require(_versionHash(prox.L1Block) == keccak256(bytes(L1Block_Version)), "L1Block");
require(_versionHash(prox.L1FeeVault) == keccak256(bytes(L1FeeVault_Version)), "L1FeeVault");
require(
_versionHash(prox.L2CrossDomainMessenger) == keccak256(bytes(L2CrossDomainMessenger_Version)),
"L2CrossDomainMessenger"
);
require(_versionHash(prox.L2ERC721Bridge) == keccak256(bytes(L2ERC721Bridge_Version)), "L2ERC721Bridge");
require(_versionHash(prox.L2StandardBridge) == keccak256(bytes(L2StandardBridge_Version)), "L2StandardBridge");
require(
_versionHash(prox.L2ToL1MessagePasser) == keccak256(bytes(L2ToL1MessagePasser_Version)),
"L2ToL1MessagePasser"
);
require(
_versionHash(prox.SequencerFeeVault) == keccak256(bytes(SequencerFeeVault_Version)), "SequencerFeeVault"
);
require(
_versionHash(prox.OptimismMintableERC20Factory) == keccak256(bytes(OptimismMintableERC20Factory_Version)),
"OptimismMintableERC20Factory"
);
require(
_versionHash(prox.OptimismMintableERC721Factory) == keccak256(bytes(OptimismMintableERC721Factory_Version)),
"OptimismMintableERC721Factory"
);
// Check that the codehashes of all implementations match the proxies set implementations.
ContractSet memory impl = getImplementations();
require(PROXY_ADMIN.getProxyImplementation(prox.BaseFeeVault).codehash == impl.BaseFeeVault.codehash);
require(PROXY_ADMIN.getProxyImplementation(prox.GasPriceOracle).codehash == impl.GasPriceOracle.codehash);
require(PROXY_ADMIN.getProxyImplementation(prox.L1Block).codehash == impl.L1Block.codehash);
require(PROXY_ADMIN.getProxyImplementation(prox.L1FeeVault).codehash == impl.L1FeeVault.codehash);
require(
PROXY_ADMIN.getProxyImplementation(prox.L2CrossDomainMessenger).codehash
== impl.L2CrossDomainMessenger.codehash
);
require(PROXY_ADMIN.getProxyImplementation(prox.L2ERC721Bridge).codehash == impl.L2ERC721Bridge.codehash);
require(PROXY_ADMIN.getProxyImplementation(prox.L2StandardBridge).codehash == impl.L2StandardBridge.codehash);
require(
PROXY_ADMIN.getProxyImplementation(prox.L2ToL1MessagePasser).codehash == impl.L2ToL1MessagePasser.codehash
);
require(PROXY_ADMIN.getProxyImplementation(prox.SequencerFeeVault).codehash == impl.SequencerFeeVault.codehash);
require(
PROXY_ADMIN.getProxyImplementation(prox.OptimismMintableERC20Factory).codehash
== impl.OptimismMintableERC20Factory.codehash
);
require(
PROXY_ADMIN.getProxyImplementation(prox.OptimismMintableERC721Factory).codehash
== impl.OptimismMintableERC721Factory.codehash
);
}
/// @notice Test coverage of the logic. Should only run on goerli but other chains
/// could be added.
function test_script_succeeds() external skipWhenNotForking {
address _safe;
address _proxyAdmin;
if (block.chainid == OP_GOERLI) {
_safe = 0xE534ccA2753aCFbcDBCeB2291F596fc60495257e;
_proxyAdmin = 0x4200000000000000000000000000000000000018;
}
require(_safe != address(0) && _proxyAdmin != address(0));
address[] memory owners = IGnosisSafe(payable(_safe)).getOwners();
for (uint256 i; i < owners.length; i++) {
address owner = owners[i];
vm.startBroadcast(owner);
bool success = _run(_safe, _proxyAdmin);
vm.stopBroadcast();
if (success) {
console.log("tx success");
break;
}
}
_postCheck();
}
/// @notice Builds the calldata that the multisig needs to make for the upgrade to happen.
/// A total of 9 calls are made to the proxy admin to upgrade the implementations
/// of the predeploys.
function buildCalldata(address _proxyAdmin) internal view override returns (bytes memory) {
IMulticall3.Call3[] memory calls = new IMulticall3.Call3[](11);
ContractSet memory impl = getImplementations();
ContractSet memory prox = getProxies();
// Upgrade the BaseFeeVault
calls[0] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.BaseFeeVault), impl.BaseFeeVault))
});
// Upgrade the GasPriceOracle
calls[1] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.GasPriceOracle), impl.GasPriceOracle))
});
// Upgrade the L1Block predeploy
calls[2] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L1Block), impl.L1Block))
});
// Upgrade the L1FeeVault
calls[3] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L1FeeVault), impl.L1FeeVault))
});
// Upgrade the L2CrossDomainMessenger
calls[4] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(
ProxyAdmin.upgrade, (payable(prox.L2CrossDomainMessenger), impl.L2CrossDomainMessenger)
)
});
// Upgrade the L2ERC721Bridge
calls[5] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L2ERC721Bridge), impl.L2ERC721Bridge))
});
// Upgrade the L2StandardBridge
calls[6] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L2StandardBridge), impl.L2StandardBridge))
});
// Upgrade the L2ToL1MessagePasser
calls[7] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.L2ToL1MessagePasser), impl.L2ToL1MessagePasser))
});
// Upgrade the SequencerFeeVault
calls[8] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(ProxyAdmin.upgrade, (payable(prox.SequencerFeeVault), impl.SequencerFeeVault))
});
// Upgrade the OptimismMintableERC20Factory
calls[9] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(
ProxyAdmin.upgrade, (payable(prox.OptimismMintableERC20Factory), impl.OptimismMintableERC20Factory)
)
});
// Upgrade the OptimismMintableERC721Factory
calls[10] = IMulticall3.Call3({
target: _proxyAdmin,
allowFailure: false,
callData: abi.encodeCall(
ProxyAdmin.upgrade, (payable(prox.OptimismMintableERC721Factory), impl.OptimismMintableERC721Factory)
)
});
return abi.encodeCall(IMulticall3.aggregate3, (calls));
}
/// @notice Returns the ContractSet that represents the implementations for a given network.
function getImplementations() internal view returns (ContractSet memory) {
ContractSet memory set = implementations[block.chainid];
require(set.BaseFeeVault != address(0), "no implementations for this network");
return set;
}
/// @notice Returns the ContractSet that represents the proxies for a given network.
function getProxies() internal view returns (ContractSet memory) {
ContractSet memory set = proxies[block.chainid];
require(set.BaseFeeVault != address(0), "no proxies for this network");
return set;
}
}
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