Skip to content

Commit

Permalink
Add deployImplementations to ForkLive flow
Browse files Browse the repository at this point in the history
  • Loading branch information
maurelian committed Jan 4, 2025
1 parent 8e643a4 commit c0742df
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 19 deletions.
61 changes: 42 additions & 19 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ contract Deploy is Deployer {
L2OutputOracle: getAddress("L2OutputOracleImpl"),
DisputeGameFactory: getAddress("DisputeGameFactoryImpl"),
DelayedWETH: getAddress("DelayedWETHImpl"),
PermissionedDelayedWETH: getAddress("PermissionedDelayedWETHImpl"),
PermissionedDelayedWETH: getAddress("DelayedWETHImpl"),
AnchorStateRegistry: getAddress("AnchorStateRegistryImpl"),
OptimismMintableERC20Factory: getAddress("OptimismMintableERC20FactoryImpl"),
OptimismPortal: getAddress("OptimismPortalImpl"),
Expand Down Expand Up @@ -202,7 +202,7 @@ contract Deploy is Deployer {
deploySuperchain();
}

deployImplementations({ _isInterop: cfg.useInterop() });
deployImplementations({ _isInterop: cfg.useInterop(), _suffix: "" });

// Deploy Current OPChain Contracts
deployOpChain();
Expand Down Expand Up @@ -277,7 +277,11 @@ contract Deploy is Deployer {
}

/// @notice Deploy all of the implementations
function deployImplementations(bool _isInterop) public {
/// @param _isInterop Whether to use interop
/// @param _suffix An optional suffix to append to the implementation names. Used in the ForkLives script to
/// distinguish between implementations already in production and new implementations deployed by
/// this script.
function deployImplementations(bool _isInterop, string memory _suffix) public {
require(_isInterop == cfg.useInterop(), "Deploy: Interop setting mismatch.");

console.log("Deploying implementations");
Expand All @@ -304,22 +308,41 @@ contract Deploy is Deployer {
}
di.run(dii, dio);

save("L1CrossDomainMessengerImpl", address(dio.l1CrossDomainMessengerImpl()));
save("OptimismMintableERC20FactoryImpl", address(dio.optimismMintableERC20FactoryImpl()));
save("SystemConfigImpl", address(dio.systemConfigImpl()));
save("L1StandardBridgeImpl", address(dio.l1StandardBridgeImpl()));
save("L1ERC721BridgeImpl", address(dio.l1ERC721BridgeImpl()));
save(string.concat("L1CrossDomainMessengerImpl", _suffix), address(dio.l1CrossDomainMessengerImpl()));
save(
string.concat("OptimismMintableERC20FactoryImpl", _suffix), address(dio.optimismMintableERC20FactoryImpl())
);
save(string.concat("SystemConfigImpl", _suffix), address(dio.systemConfigImpl()));
save(string.concat("L1StandardBridgeImpl", _suffix), address(dio.l1StandardBridgeImpl()));
save(string.concat("L1ERC721BridgeImpl", _suffix), address(dio.l1ERC721BridgeImpl()));

// Fault proofs
save("OptimismPortalImpl", address(dio.optimismPortalImpl()));
save("OptimismPortal2Impl", address(dio.optimismPortalImpl()));
save("DisputeGameFactoryImpl", address(dio.disputeGameFactoryImpl()));
save("DelayedWETHImpl", address(dio.delayedWETHImpl()));
save("PreimageOracleSingleton", address(dio.preimageOracleSingleton()));
save("MipsSingleton", address(dio.mipsSingleton()));
save("OPContractsManager", address(dio.opcm()));

Types.ContractSet memory contracts = _impls();
save(string.concat("OptimismPortalImpl", _suffix), address(dio.optimismPortalImpl()));
save(string.concat("OptimismPortal2Impl", _suffix), address(dio.optimismPortalImpl()));
save(string.concat("DisputeGameFactoryImpl", _suffix), address(dio.disputeGameFactoryImpl()));
save(string.concat("DelayedWETHImpl", _suffix), address(dio.delayedWETHImpl()));
save(string.concat("PreimageOracleSingleton", _suffix), address(dio.preimageOracleSingleton()));
save(string.concat("MipsSingleton", _suffix), address(dio.mipsSingleton()));
save(string.concat("OPContractsManager", _suffix), address(dio.opcm()));

// Get a contract set from the implementation addresses with the suffix.
Types.ContractSet memory contracts = Types.ContractSet({
L1CrossDomainMessenger: mustGetAddress(string.concat("L1CrossDomainMessengerImpl", _suffix)),
L1StandardBridge: mustGetAddress(string.concat("L1StandardBridgeImpl", _suffix)),
L2OutputOracle: address(0),
DisputeGameFactory: mustGetAddress(string.concat("DisputeGameFactoryImpl", _suffix)),
DelayedWETH: mustGetAddress(string.concat("DelayedWETHImpl", _suffix)),
PermissionedDelayedWETH: mustGetAddress(string.concat("DelayedWETHImpl", _suffix)),
AnchorStateRegistry: address(0),
OptimismMintableERC20Factory: mustGetAddress(string.concat("OptimismMintableERC20FactoryImpl", _suffix)),
OptimismPortal: mustGetAddress(string.concat("OptimismPortalImpl", _suffix)),
SystemConfig: mustGetAddress(string.concat("SystemConfigImpl", _suffix)),
L1ERC721Bridge: mustGetAddress(string.concat("L1ERC721BridgeImpl", _suffix)),
// We didn't deploy a new version of these so we don't append a suffix
ProtocolVersions: mustGetAddress("ProtocolVersionsImpl"),
SuperchainConfig: mustGetAddress("SuperchainConfigImpl")
});

ChainAssertions.checkL1CrossDomainMessenger({ _contracts: contracts, _vm: vm, _isProxy: false });
ChainAssertions.checkL1StandardBridge({ _contracts: contracts, _isProxy: false });
ChainAssertions.checkL1ERC721Bridge({ _contracts: contracts, _isProxy: false });
Expand All @@ -342,8 +365,8 @@ contract Deploy is Deployer {
});
ChainAssertions.checkOPContractsManager({
_contracts: contracts,
_opcm: OPContractsManager(mustGetAddress("OPContractsManager")),
_mips: IMIPS(mustGetAddress("MipsSingleton"))
_opcm: OPContractsManager(mustGetAddress(string.concat("OPContractsManager", _suffix))),
_mips: IMIPS(mustGetAddress(string.concat("MipsSingleton", _suffix)))
});
if (_isInterop) {
ChainAssertions.checkSystemConfigInterop({ _contracts: contracts, _cfg: cfg, _isProxy: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,14 @@ contract DeployImplementations is Script {

function etchIOContracts() public returns (DeployImplementationsInput dii_, DeployImplementationsOutput dio_) {
(dii_, dio_) = getIOContracts();

vm.etch(address(dii_), type(DeployImplementationsInput).runtimeCode);
vm.label(address(dii_), "DeployImplementationsInput");
vm.allowCheatcodes(address(dii_));

vm.etch(address(dio_), type(DeployImplementationsOutput).runtimeCode);
vm.label(address(dio_), "DeployImplementationsOutput");
vm.allowCheatcodes(address(dio_));
}

function getIOContracts() public view returns (DeployImplementationsInput dii_, DeployImplementationsOutput dio_) {
Expand Down
17 changes: 17 additions & 0 deletions packages/contracts-bedrock/test/setup/ForkLive.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { stdJson } from "forge-std/StdJson.sol";

// Scripts
import { Deployer } from "scripts/deploy/Deployer.sol";
import { Deploy } from "scripts/deploy/Deploy.s.sol";

// Libraries
import { GameTypes } from "src/dispute/lib/Types.sol";
Expand Down Expand Up @@ -93,6 +94,21 @@ contract ForkLive is Deployer {
IFaultDisputeGame(address(disputeGameFactory.gameImpls(GameTypes.PERMISSIONED_CANNON)));
save("PermissionedDisputeGame", address(permissionedDisputeGame));
save("PermissionedDelayedWETHProxy", address(permissionedDisputeGame.weth()));

// Now deploy the updated OPCM and implementations of the contracts
_deployNewImplementations();
}

function _deployNewImplementations() internal {
Deploy deployNew = Deploy(address(uint160(uint256(keccak256(abi.encode("optimism.deploy.new"))))));
vm.etch(address(deployNew), vm.getDeployedCode("Deploy.s.sol:Deploy"));
vm.label(address(deployNew), "DeployNew");
vm.allowCheatcodes(address(deployNew));
vm.setEnv("CONTRACT_ADDRESSES_PATH", string.concat(vm.projectRoot(), "/deployments/1-deploy.json"));

deployNew.setUp();
deployNew.cfg().setUseFaultProofs(true);
deployNew.deployImplementations({ _isInterop: false, _suffix: "_NextVersion" });
}

/// @notice Saves the proxy and implementation addresses for a contract name
Expand All @@ -102,6 +118,7 @@ contract ForkLive is Deployer {
function saveProxyAndImpl(string memory _contractName, string memory _tomlPath, string memory _tomlKey) internal {
address proxy = vm.parseTomlAddress(_tomlPath, _tomlKey);
save(string.concat(_contractName, "Proxy"), proxy);

address impl = EIP1967Helper.getImplementation(proxy);
require(impl != address(0), "Upgrade: Implementation address is zero");
save(string.concat(_contractName, "Impl"), impl);
Expand Down

0 comments on commit c0742df

Please sign in to comment.