Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ contract L2Genesis is Script {

for (uint256 i = 0; i < Predeploys.PREDEPLOY_COUNT; i++) {
address addr = address(prefix | uint160(i));
if (Predeploys.notProxied(addr)) {
continue;
}

// Non-proxied predeploys are excluded from proxy setup.
if (Predeploys.notProxied(addr)) continue;

vm.etch(addr, code);
EIP1967Helper.setAdmin(addr, Predeploys.PROXY_ADMIN);
Expand All @@ -257,9 +257,9 @@ contract L2Genesis is Script {
// Must be first: other contracts' initialize() calls assert _assertOnlyProxyAdminOrProxyAdminOwner(),
// which reads L2ProxyAdmin.owner(). The owner slot must be set before any initializer runs.
setL2ProxyAdmin(_input); // 18
setLegacyMessagePasser(); // 0
setLegacyMessagePasser(); // 0: LEGACY_MESSAGE_PASSER is deprecated and not used in OP-Stack
// 01: legacy, not used in OP-Stack
setDeployerWhitelist(); // 2
setDeployerWhitelist(); // 2: DEPLOYER_WHITELIST is deprecated and not used in OP-Stack
// 3,4,5: legacy, not used in OP-Stack.
setWETH(); // 6: WETH (not behind a proxy)
setL2CrossDomainMessenger(_input.l1CrossDomainMessengerProxy); // 7
Expand All @@ -268,7 +268,7 @@ contract L2Genesis is Script {
setL2StandardBridge(_input.l1StandardBridgeProxy); // 10
setSequencerFeeVault(_input); // 11
setOptimismMintableERC20Factory(); // 12
setL1BlockNumber(); // 13
setL1BlockNumber(); // 13: L1_BLOCK_NUMBER is deprecated and not used in OP-Stack
setL2ERC721Bridge(_input.l1ERC721BridgeProxy); // 14
setL1Block(_input); // 15
setL2ToL1MessagePasser(_input.useCustomGasToken); // 16
Expand Down Expand Up @@ -533,25 +533,31 @@ contract L2Genesis is Script {
/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setCrossL2Inbox() internal {
Predeploys.assertGates(Predeploys.CROSS_L2_INBOX, DevFeatures.OPTIMISM_PORTAL_INTEROP, Features.INTEROP);
_setImplementationCode(Predeploys.CROSS_L2_INBOX);
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setL2ToL2CrossDomainMessenger() internal {
Predeploys.assertGates(
Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, DevFeatures.OPTIMISM_PORTAL_INTEROP, Features.INTEROP
);
_setImplementationCode(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER);
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setETHLiquidity() internal {
Predeploys.assertGates(Predeploys.ETH_LIQUIDITY, DevFeatures.OPTIMISM_PORTAL_INTEROP, Features.INTEROP);
_setImplementationCode(Predeploys.ETH_LIQUIDITY);
vm.deal(Predeploys.ETH_LIQUIDITY, type(uint128).max);
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setSuperchainETHBridge() internal {
Predeploys.assertGates(Predeploys.SUPERCHAIN_ETH_BRIDGE, DevFeatures.OPTIMISM_PORTAL_INTEROP, Features.INTEROP);
_setImplementationCode(Predeploys.SUPERCHAIN_ETH_BRIDGE);
}

Expand All @@ -578,6 +584,7 @@ contract L2Genesis is Script {

/// @notice This predeploy is following the safety invariant #1.
function setLiquidityController(Input memory _input) internal {
Predeploys.assertGates(Predeploys.LIQUIDITY_CONTROLLER, bytes32(0), Features.CUSTOM_GAS_TOKEN);
address impl = _setImplementationCode(Predeploys.LIQUIDITY_CONTROLLER);

ILiquidityController(impl).initialize({
Expand All @@ -596,6 +603,7 @@ contract L2Genesis is Script {
/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setNativeAssetLiquidity(Input memory _input) internal {
Predeploys.assertGates(Predeploys.NATIVE_ASSET_LIQUIDITY, bytes32(0), Features.CUSTOM_GAS_TOKEN);
_setImplementationCode(Predeploys.NATIVE_ASSET_LIQUIDITY);

require(
Expand All @@ -609,11 +617,13 @@ contract L2Genesis is Script {

/// @notice This predeploy is following the safety invariant #1.
function setConditionalDeployer() internal {
Predeploys.assertGates(Predeploys.CONDITIONAL_DEPLOYER, DevFeatures.L2CM, bytes32(0));
_setImplementationCode(Predeploys.CONDITIONAL_DEPLOYER);
}

/// @notice Sets up the L2DevFeatureFlags predeploy with the development feature bitmap.
function setL2DevFeatureFlags(Input memory _input) internal {
Predeploys.assertGates(Predeploys.L2_DEV_FEATURE_FLAGS, DevFeatures.L2CM, bytes32(0));
_setImplementationCode(Predeploys.L2_DEV_FEATURE_FLAGS);
vm.prank(Constants.DEPOSITOR_ACCOUNT);
IL2DevFeatureFlags(Predeploys.L2_DEV_FEATURE_FLAGS).setDevFeatureBitmap(_input.devFeatureBitmap);
Expand Down
67 changes: 0 additions & 67 deletions packages/contracts-bedrock/scripts/libraries/UpgradeUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ import { ConditionalDeployer } from "src/L2/ConditionalDeployer.sol";
library UpgradeUtils {
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

/// @notice The number of implementations deployed in every upgrade.
/// Includes:
/// - 1 StorageSetter
/// - 18 base predeploys
/// - 4 INTEROP predeploys
/// - 2 CGT predeploys (NativeAssetLiquidity, LiquidityController)
/// - 2 CGT variants (L1BlockCGT, L2ToL1MessagePasserCGT)
uint256 internal constant IMPLEMENTATION_COUNT = 27;

/// @notice Gas limits for different types of upgrade transactions.
/// @param l2cmDeployment Gas for deploying L2ContractsManager
/// @param upgradeExecution Gas for L2ProxyAdmin.upgradePredeploys() call
Expand All @@ -46,22 +37,6 @@ library UpgradeUtils {
uint64 proxyAdminUpgrade;
}

/// @notice Returns the total number of transactions for the current upgrade.
/// @dev Total count:
/// - IMPLEMENTATION_COUNT implementation deployments
/// - [KARST] 2 ConditionalDeployer (deployment + upgrade)
/// - [KARST] 1 ProxyAdmin upgrade
/// - 1 L2CM deployment
/// - 1 Upgrade Predeploys call
function getTransactionCount() internal pure returns (uint256 txnCount_) {
if (IMPLEMENTATION_COUNT != 27) {
revert(
"UpgradeUtils: implementation count changed, ensure that the txnCount_ calculation is still correct."
);
}
txnCount_ = IMPLEMENTATION_COUNT + 5;
}

/// @notice Returns the gas limits for all upgrade transaction types.
/// @dev Gas limits are chosen to provide sufficient headroom while being
/// conservative enough to fit within the upgrade block gas allocation.
Expand Down Expand Up @@ -90,48 +65,6 @@ library UpgradeUtils {
});
}

/// @notice Returns the array of predeploy names to upgrade.
/// @dev Exception: StorageSetter is not a predeploy, but is upgraded in L2CM too.
/// @return implementations_ Array of implementation names to upgrade.
function getImplementationsNamesToUpgrade() internal pure returns (string[] memory implementations_) {
implementations_ = new string[](IMPLEMENTATION_COUNT);

// StorageSetter
implementations_[0] = "StorageSetter";

// Base predeploys
implementations_[1] = "L2CrossDomainMessenger";
implementations_[2] = "GasPriceOracle";
implementations_[3] = "L2StandardBridge";
implementations_[4] = "SequencerFeeVault";
implementations_[5] = "OptimismMintableERC20Factory";
implementations_[6] = "L2ERC721Bridge";
implementations_[7] = "L1Block";
implementations_[8] = "L2ToL1MessagePasser";
implementations_[9] = "OptimismMintableERC721Factory";
implementations_[10] = "L2ProxyAdmin";
implementations_[11] = "BaseFeeVault";
implementations_[12] = "L1FeeVault";
implementations_[13] = "OperatorFeeVault";
implementations_[14] = "SchemaRegistry";
implementations_[15] = "EAS";
implementations_[16] = "FeeSplitter";
implementations_[17] = "ConditionalDeployer";
implementations_[18] = "L2DevFeatureFlags";

// INTEROP predeploys
implementations_[19] = "CrossL2Inbox";
implementations_[20] = "L2ToL2CrossDomainMessenger";
implementations_[21] = "SuperchainETHBridge";
implementations_[22] = "ETHLiquidity";

// CGT predeploys
implementations_[23] = "L1BlockCGT";
implementations_[24] = "L2ToL1MessagePasserCGT";
implementations_[25] = "LiquidityController";
implementations_[26] = "NativeAssetLiquidity";
}

/// @notice Uses vm.computeCreate2Address to compute the CREATE2 address for given initcode and salt.
/// @dev Uses the DeterministicDeploymentProxy address as the deployer.
/// @param _code The contract initcode (creation bytecode).
Expand Down
Loading
Loading