Skip to content
Merged
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
1 change: 1 addition & 0 deletions .semgrep/rules/sol-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ rules:
- packages/contracts-bedrock/src/L2/OptimismMintableERC721.sol
- packages/contracts-bedrock/src/L2/OptimismMintableERC721Factory.sol
- packages/contracts-bedrock/src/L2/XForkL2ContractsManager.sol
- packages/contracts-bedrock/src/L2/L2ContractsManager.sol
- packages/contracts-bedrock/src/cannon/MIPS64.sol
- packages/contracts-bedrock/src/cannon/PreimageOracle.sol
- packages/contracts-bedrock/src/dispute/AnchorStateRegistry.sol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"type": "address"
}
],
"internalType": "struct XForkL2CMTypes.Implementations",
"internalType": "struct L2ContractsManagerTypes.Implementations",
"name": "_implementations",
"type": "tuple"
}
Expand Down Expand Up @@ -172,9 +172,25 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_target",
"type": "address"
}
],
"name": "L2ContractsManager_DowngradeNotAllowed",
"type": "error"
},
{
"inputs": [],
"name": "L2ContractsManager_OnlyDelegatecall",
"type": "error"
},
{
"inputs": [],
"name": "XForkL2ContractsManager_OnlyDelegatecall",
"name": "SemverComp_InvalidSemverParts",
"type": "error"
}
]
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
"initCodeHash": "0x6efb9055142e90b408c6312074243769df0d365f6f984e226e0320bec55a45b8",
"sourceCodeHash": "0x6a12e541b47b79f19d1061ff7b64ffdcffa1e8d06225cca6798daca53fd96890"
},
"src/L2/L2ContractsManager.sol:L2ContractsManager": {
"initCodeHash": "0x5770f8b4f605f5b13b8f499a7d21f90df2aad86b09268dcb517c14fef33e2f76",
"sourceCodeHash": "0x1b45f8de05722ce89d5ae075a5c94fad57e24a433de5761923946abb57dd50ca"
},
"src/L2/L2CrossDomainMessenger.sol:L2CrossDomainMessenger": {
"initCodeHash": "0xe160be403df12709c371c33195d1b9c3b5e9499e902e86bdabc8eed749c3fd61",
"sourceCodeHash": "0x12ea125038b87e259a0d203e119faa6e9726ab2bdbc30430f820ccd48fe87e14"
Expand Down Expand Up @@ -175,10 +179,6 @@
"initCodeHash": "0xbc2cd025153720943e51b79822c2dc374d270a78b92cf47d49548c468e218e46",
"sourceCodeHash": "0x734a6b2aa6406bc145d848ad6071d3af1d40852aeb8f4b2f6f51beaad476e2d3"
},
"src/L2/XForkL2ContractsManager.sol:XForkL2ContractsManager": {
"initCodeHash": "0x35c9fa7868ac67f1f6465613f9a8c49d8cec3c4841206d031138a729d33298dc",
"sourceCodeHash": "0xacd5a2b5ec2f0527aa471dcb2db9ba92a1bd71285f144f14b3def39d499598c0"
},
"src/cannon/MIPS64.sol:MIPS64": {
"initCodeHash": "0x13196c1652a1f51cf0c16191f0092898f127eff036c773923c72b02a2823c7f4",
"sourceCodeHash": "0xd745aaf4ed265be7be7bff9bca1dd040e15dfe41e3a453906d72ca09a47f2c8b"
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-bedrock/src/L2/L2ContractsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ contract L2ContractsManager is ISemver {
OPERATOR_FEE_VAULT_IMPL = _implementations.operatorFeeVaultImpl;
SCHEMA_REGISTRY_IMPL = _implementations.schemaRegistryImpl;
EAS_IMPL = _implementations.easImpl;
// TODO(#18838): Add dev flagging for CrossL2Inbox and L2ToL2CrossDomainMessenger once DevFeatures is
// implemented for L2.
CROSS_L2_INBOX_IMPL = _implementations.crossL2InboxImpl;
L2_TO_L2_CROSS_DOMAIN_MESSENGER_IMPL = _implementations.l2ToL2CrossDomainMessengerImpl;
SUPERCHAIN_ETH_BRIDGE_IMPL = _implementations.superchainETHBridgeImpl;
Expand Down Expand Up @@ -371,6 +373,8 @@ contract L2ContractsManager is ISemver {
Predeploys.OPTIMISM_MINTABLE_ERC721_FACTORY, OPTIMISM_MINTABLE_ERC721_FACTORY_IMPL
);
L2ContractsManagerUtils.upgradeTo(Predeploys.PROXY_ADMIN, PROXY_ADMIN_IMPL);
// TODO(#18838): Add dev flagging for CrossL2Inbox and L2ToL2CrossDomainMessenger once DevFeatures is
// implemented for L2.
L2ContractsManagerUtils.upgradeTo(Predeploys.CROSS_L2_INBOX, CROSS_L2_INBOX_IMPL);
L2ContractsManagerUtils.upgradeTo(
Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER, L2_TO_L2_CROSS_DOMAIN_MESSENGER_IMPL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library L2ContractsManagerUtils {

// We avoid downgrading Predeploys
if (
// Predeploys.PROXY_ADMIN is not checked for downgrades because it has no version number.
// TODO(#19195): Remove this code skipping the ProxyAdmin once version is implemented.
_proxy != Predeploys.PROXY_ADMIN
&& ProxyAdmin(Predeploys.PROXY_ADMIN).getProxyImplementation(_proxy) != address(0)
&& SemverComp.gt(ISemver(_proxy).version(), ISemver(_implementation).version())
Expand Down Expand Up @@ -87,7 +87,7 @@ library L2ContractsManagerUtils {
if (!Predeploys.isUpgradeable(_proxy)) return;

if (
// Predeploys.PROXY_ADMIN is not checked for downgrades because it has no version number.
// TODO(#19195): Remove this code skipping the ProxyAdmin once version is implemented.
// This should never be the case, if you're trying to initialize the ProxyAdmin, it's probably a mistake.
_proxy != Predeploys.PROXY_ADMIN
&& ProxyAdmin(Predeploys.PROXY_ADMIN).getProxyImplementation(_proxy) != address(0)
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts-bedrock/src/libraries/Predeploys.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ library Predeploys {
|| (_isCustomGasToken && _addr == NATIVE_ASSET_LIQUIDITY);
}

/// @notice Returns true if the address is in the predeploy namespace.
/// @param _addr The address to check.
/// @return True if the address is in range 0x4200...0000 to 0x4200...07FF.
function isPredeployNamespace(address _addr) internal pure returns (bool) {
return uint160(_addr) >> 11 == uint160(0x4200000000000000000000000000000000000000) >> 11;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ contract L2ContractsManager_Upgrade_Test is CommonTest {
// The L2CM must be called via DELEGATECALL from the ProxyAdmin.
// We simulate this by pranking as the ProxyAdmin and using delegatecall.
address proxyAdmin = Predeploys.PROXY_ADMIN;
prankDelegateCall(proxyAdmin);
vm.prank(proxyAdmin, true);
(bool success,) = address(l2cm).delegatecall(abi.encodeCall(L2ContractsManager.upgrade, ()));
require(success, "L2ContractsManager: Upgrade failed");
}
Expand Down