Commit bd35e43d authored by Diego's avatar Diego Committed by GitHub

add to L2Genesis Interop contracts (CrossL2Inbox, L2ToL2CrossDomainMessenger) (#10417)

* bedrock-devnet: add useInterop flag

* op-chain-ops: add useInterop flag

* op-node: add useInterop flag to config

* contracts-bedrock: add useInterop flag to Predeploy's getName

* contracts-bedrock: add useInterop flag to L2Genesis

* contracts-bedrock: add useInterop flag to Predeploy's test

* contracts-bedrock: add useInterop flag to Setup

* Revert "op-chain-ops: add useInterop flag"

This reverts commit 83c63cc63bcccf15c8f2e7d7c4f74d0316abcdae.

* Revert "op-node: add useInterop flag to config"

This reverts commit c3617f9fd8ae4777cf4f13dd399167f0718cd9d1.

* Revert "bedrock-devnet: add useInterop flag"

This reverts commit 858257c8666af70586e6f40a510b2a0ff3056bcb.

* contracts-bedrock: use L1Block in Predeploys for L1BlockInterop

* contracts-bedrock: remove useInterop argument in Predeploys

* op-chain-ops: fix TestConfigDataMarshalUnmarshal

* contracts-bedrock: add CrossL2Inbox, L2ToL2CrossDomainMessenger to L2Genesis script

* contracts-bedrock: add tests for interop branch of L2Genesis

* Revert "op-chain-ops: fix TestConfigDataMarshalUnmarshal"

This reverts commit fbc60c1fed796d03837dd674406b3aa63445deeb.
parent c41bb739
......@@ -192,7 +192,7 @@ contract L2Genesis is Deployer {
vm.etch(addr, code);
EIP1967Helper.setAdmin(addr, Predeploys.PROXY_ADMIN);
if (Predeploys.isSupportedPredeploy(addr)) {
if (Predeploys.isSupportedPredeploy(addr, cfg.useInterop())) {
address implementation = Predeploys.predeployToCodeNamespace(addr);
console.log("Setting proxy %s implementation: %s", addr, implementation);
EIP1967Helper.setImplementation(addr, implementation);
......@@ -231,6 +231,10 @@ contract L2Genesis is Deployer {
setSchemaRegistry(); // 20
setEAS(); // 21
setGovernanceToken(); // 42: OP (not behind a proxy)
if (cfg.useInterop()) {
setCrossL2Inbox(); // 22
setL2ToL2CrossDomainMessenger(); // 23
}
}
function setProxyAdmin() public {
......@@ -441,6 +445,18 @@ contract L2Genesis is Deployer {
vm.resetNonce(address(eas));
}
/// @notice This predeploy is following the saftey invariant #2.
/// This contract has no initializer.
function setCrossL2Inbox() internal {
_setImplementationCode(Predeploys.CROSS_L2_INBOX);
}
/// @notice This predeploy is following the saftey invariant #2.
/// This contract has no initializer.
function setL2ToL2CrossDomainMessenger() internal {
_setImplementationCode(Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER);
}
/// @notice Sets all the preinstalls.
/// Warning: the creator-accounts of the preinstall contracts have 0 nonce values.
/// When performing a regular user-initiated contract-creation of a preinstall,
......
......@@ -124,13 +124,14 @@ library Predeploys {
}
/// @notice Returns true if the address is a defined predeploy that is embedded into new OP-Stack chains.
function isSupportedPredeploy(address _addr) internal pure returns (bool) {
function isSupportedPredeploy(address _addr, bool _useInterop) internal pure returns (bool) {
return _addr == LEGACY_MESSAGE_PASSER || _addr == DEPLOYER_WHITELIST || _addr == WETH
|| _addr == L2_CROSS_DOMAIN_MESSENGER || _addr == GAS_PRICE_ORACLE || _addr == L2_STANDARD_BRIDGE
|| _addr == SEQUENCER_FEE_WALLET || _addr == OPTIMISM_MINTABLE_ERC20_FACTORY || _addr == L1_BLOCK_NUMBER
|| _addr == L2_ERC721_BRIDGE || _addr == L1_BLOCK_ATTRIBUTES || _addr == L2_TO_L1_MESSAGE_PASSER
|| _addr == OPTIMISM_MINTABLE_ERC721_FACTORY || _addr == PROXY_ADMIN || _addr == BASE_FEE_VAULT
|| _addr == L1_FEE_VAULT || _addr == SCHEMA_REGISTRY || _addr == EAS || _addr == GOVERNANCE_TOKEN;
|| _addr == L1_FEE_VAULT || _addr == SCHEMA_REGISTRY || _addr == EAS || _addr == GOVERNANCE_TOKEN
|| (_useInterop && _addr == CROSS_L2_INBOX) || (_useInterop && _addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER);
}
function isPredeployNamespace(address _addr) internal pure returns (bool) {
......
......@@ -121,13 +121,27 @@ contract L2GenesisTest is Test {
return abi.decode(vm.ffi(commands), (uint256));
}
/// @notice Tests the genesis predeploys setup using a temp file.
function test_genesis_predeploys() external {
withTempDump(_test_genesis_predeploys);
/// @notice Tests the genesis predeploys setup using a temp file for the case where useInterop is false.
function test_genesis_predeploys_notUsingInterop() external {
string memory path = tmpfile();
_test_genesis_predeploys(path, false);
deleteFile(path);
}
/// @notice Tests the genesis predeploys setup using a temp file for the case where useInterop is true.
function test_genesis_predeploys_usingInterop() external {
string memory path = tmpfile();
_test_genesis_predeploys(path, true);
deleteFile(path);
}
/// @notice Tests the genesis predeploys setup.
function _test_genesis_predeploys(string memory _path) internal {
function _test_genesis_predeploys(string memory _path, bool _useInterop) internal {
// Set the useInterop value
vm.mockCall(
address(genesis.cfg()), abi.encodeWithSelector(genesis.cfg().useInterop.selector), abi.encode(_useInterop)
);
// Set the predeploy proxies into state
genesis.setPredeployProxies();
genesis.writeGenesisAllocs(_path);
......@@ -135,8 +149,8 @@ contract L2GenesisTest is Test {
// 2 predeploys do not have proxies
assertEq(getCodeCount(_path, "Proxy.sol:Proxy"), Predeploys.PREDEPLOY_COUNT - 2);
// 17 proxies have the implementation set
assertEq(getPredeployCountWithSlotSet(_path, Constants.PROXY_IMPLEMENTATION_ADDRESS), 17);
// 19 proxies have the implementation set if useInterop is true and 17 if useInterop is false
assertEq(getPredeployCountWithSlotSet(_path, Constants.PROXY_IMPLEMENTATION_ADDRESS), _useInterop ? 19 : 17);
// All proxies except 2 have the proxy 1967 admin slot set to the proxy admin
assertEq(
......
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