Commit 388bd0ba authored by Diego's avatar Diego Committed by GitHub

feat/interop: create `OptimismPortalInterop` (#10585)

* contracts-bedrock: create OptimismPortalInterop

* contracts-bedrock: update to use ConfigType.GAS_PAYING_TOKEN

* contracts-bedrock: update snapshots

* contracts-bedrock: update semver-lock
parent b3bb812c
...@@ -21,6 +21,7 @@ import { L1StandardBridge } from "src/L1/L1StandardBridge.sol"; ...@@ -21,6 +21,7 @@ import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
import { StandardBridge } from "src/universal/StandardBridge.sol"; import { StandardBridge } from "src/universal/StandardBridge.sol";
import { OptimismPortal } from "src/L1/OptimismPortal.sol"; import { OptimismPortal } from "src/L1/OptimismPortal.sol";
import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol"; import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol";
import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol"; import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol"; import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol";
import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol"; import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol";
...@@ -636,20 +637,20 @@ contract Deploy is Deployer { ...@@ -636,20 +637,20 @@ contract Deploy is Deployer {
/// @notice Deploy the OptimismPortal /// @notice Deploy the OptimismPortal
function deployOptimismPortal() public broadcast returns (address addr_) { function deployOptimismPortal() public broadcast returns (address addr_) {
console.log("Deploying OptimismPortal implementation"); console.log("Deploying OptimismPortal implementation");
if (cfg.useInterop()) {
OptimismPortal portal = new OptimismPortal{ salt: _implSalt() }(); addr_ = address(new OptimismPortalInterop{ salt: _implSalt() }());
} else {
save("OptimismPortal", address(portal)); addr_ = address(new OptimismPortal{ salt: _implSalt() }());
console.log("OptimismPortal deployed at %s", address(portal)); }
save("OptimismPortal", addr_);
console.log("OptimismPortal deployed at %s", addr_);
// Override the `OptimismPortal` contract to the deployed implementation. This is necessary // Override the `OptimismPortal` contract to the deployed implementation. This is necessary
// to check the `OptimismPortal` implementation alongside dependent contracts, which // to check the `OptimismPortal` implementation alongside dependent contracts, which
// are always proxies. // are always proxies.
Types.ContractSet memory contracts = _proxiesUnstrict(); Types.ContractSet memory contracts = _proxiesUnstrict();
contracts.OptimismPortal = address(portal); contracts.OptimismPortal = addr_;
ChainAssertions.checkOptimismPortal({ _contracts: contracts, _cfg: cfg, _isProxy: false }); ChainAssertions.checkOptimismPortal({ _contracts: contracts, _cfg: cfg, _isProxy: false });
addr_ = address(portal);
} }
/// @notice Deploy the OptimismPortal2 /// @notice Deploy the OptimismPortal2
......
...@@ -32,13 +32,17 @@ ...@@ -32,13 +32,17 @@
"sourceCodeHash": "0xf5fcf570721e25459fadbb37e02f9efe349e1c8afcbf1e3b5fdb09c9f612cdc0" "sourceCodeHash": "0xf5fcf570721e25459fadbb37e02f9efe349e1c8afcbf1e3b5fdb09c9f612cdc0"
}, },
"src/L1/OptimismPortal.sol": { "src/L1/OptimismPortal.sol": {
"initCodeHash": "0xbb8e7b110d3aa0f4807cd790174d6fb6d98c44348c977007ad7a11aa7053f1c5", "initCodeHash": "0xfdc8cf0b0b26961f6ac493ee564761716447d263291bea4d366a7b94afe33392",
"sourceCodeHash": "0x3d0e9dc8ed75b6f2e59444e9204341b18d343af02d6e37ecd9f759da2c8c118b" "sourceCodeHash": "0x9fe0a9001edecd2a04daada4ca9e17d66141b1c982f73653493b4703d2c675c4"
}, },
"src/L1/OptimismPortal2.sol": { "src/L1/OptimismPortal2.sol": {
"initCodeHash": "0x45cae622788a795c2fc4f4bc8e6b85d8edf284a1dc20e1b5fa01e88d737deb23", "initCodeHash": "0x45cae622788a795c2fc4f4bc8e6b85d8edf284a1dc20e1b5fa01e88d737deb23",
"sourceCodeHash": "0xea564dbff9831ad1bf0c1b345fbc3da4675cf112d2605ba94e1ef5c7b745b7ae" "sourceCodeHash": "0xea564dbff9831ad1bf0c1b345fbc3da4675cf112d2605ba94e1ef5c7b745b7ae"
}, },
"src/L1/OptimismPortalInterop.sol": {
"initCodeHash": "0x4ab4c99bd776d1817f7475161db0ce47e735a91bb9fb486338238aa762fe0909",
"sourceCodeHash": "0x49ae32c402536774928116b833e2256741dbbdf99900ea5df159efab684d1008"
},
"src/L1/ProtocolVersions.sol": { "src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8", "initCodeHash": "0x72cd467e8bcf019c02675d72ab762e088bcc9cc0f1a4e9f587fa4589f7fdd1b8",
"sourceCodeHash": "0xbd56a23cd3221cb9d25029e80cd9f2afe2c615ae9c0b3956bf6ed373b8b805b6" "sourceCodeHash": "0xbd56a23cd3221cb9d25029e80cd9f2afe2c615ae9c0b3956bf6ed373b8b805b6"
......
...@@ -474,7 +474,7 @@ ...@@ -474,7 +474,7 @@
"type": "string" "type": "string"
} }
], ],
"stateMutability": "view", "stateMutability": "pure",
"type": "function" "type": "function"
}, },
{ {
......
[
{
"bytes": "1",
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "uint8"
},
{
"bytes": "1",
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "bool"
},
{
"bytes": "32",
"label": "params",
"offset": 0,
"slot": "1",
"type": "struct ResourceMetering.ResourceParams"
},
{
"bytes": "1536",
"label": "__gap",
"offset": 0,
"slot": "2",
"type": "uint256[48]"
},
{
"bytes": "20",
"label": "l2Sender",
"offset": 0,
"slot": "50",
"type": "address"
},
{
"bytes": "32",
"label": "finalizedWithdrawals",
"offset": 0,
"slot": "51",
"type": "mapping(bytes32 => bool)"
},
{
"bytes": "32",
"label": "provenWithdrawals",
"offset": 0,
"slot": "52",
"type": "mapping(bytes32 => struct OptimismPortal.ProvenWithdrawal)"
},
{
"bytes": "1",
"label": "spacer_53_0_1",
"offset": 0,
"slot": "53",
"type": "bool"
},
{
"bytes": "20",
"label": "superchainConfig",
"offset": 1,
"slot": "53",
"type": "contract SuperchainConfig"
},
{
"bytes": "20",
"label": "l2Oracle",
"offset": 0,
"slot": "54",
"type": "contract L2OutputOracle"
},
{
"bytes": "20",
"label": "systemConfig",
"offset": 0,
"slot": "55",
"type": "contract SystemConfig"
},
{
"bytes": "20",
"label": "spacer_56_0_20",
"offset": 0,
"slot": "56",
"type": "address"
},
{
"bytes": "32",
"label": "spacer_57_0_32",
"offset": 0,
"slot": "57",
"type": "bytes32"
},
{
"bytes": "32",
"label": "spacer_58_0_32",
"offset": 0,
"slot": "58",
"type": "bytes32"
},
{
"bytes": "32",
"label": "spacer_59_0_32",
"offset": 0,
"slot": "59",
"type": "bytes32"
},
{
"bytes": "32",
"label": "spacer_60_0_32",
"offset": 0,
"slot": "60",
"type": "bytes32"
},
{
"bytes": "32",
"label": "_balance",
"offset": 0,
"slot": "61",
"type": "uint256"
}
]
\ No newline at end of file
...@@ -128,8 +128,10 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver { ...@@ -128,8 +128,10 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
} }
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 2.8.0 /// @custom:semver 2.8.1-beta.1
string public constant version = "2.8.0"; function version() public pure virtual returns (string memory) {
return "2.8.1-beta.1";
}
/// @notice Constructs the OptimismPortal contract. /// @notice Constructs the OptimismPortal contract.
constructor() { constructor() {
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { OptimismPortal } from "src/L1/OptimismPortal.sol";
import { L1BlockInterop, ConfigType } from "src/L2/L1BlockInterop.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Constants } from "src/libraries/Constants.sol";
/// @custom:proxied
/// @title OptimismPortalInterop
/// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1
/// and L2. Messages sent directly to the OptimismPortal have no form of replayability.
/// Users are encouraged to use the L1CrossDomainMessenger for a higher-level interface.
contract OptimismPortalInterop is OptimismPortal {
/// @notice Thrown when a non-depositor account attempts update static configuration.
error Unauthorized();
/// @custom:semver +interop
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop");
}
/// @notice Sets static configuration options for the L2 system.
/// @param _type Type of configuration to set.
/// @param _value Encoded value of the configuration.
function setConfig(ConfigType _type, bytes memory _value) external {
if (msg.sender != address(systemConfig)) revert Unauthorized();
// Set L2 deposit gas as used without paying burning gas. Ensures that deposits cannot use too much L2 gas.
// This value must be large enough to cover the cost of calling `L1Block.setConfig`.
useGas(SYSTEM_DEPOSIT_GAS_LIMIT);
// Emit the special deposit transaction directly that sets the config in the L1Block predeploy contract.
emit TransactionDeposited(
Constants.DEPOSITOR_ACCOUNT,
Predeploys.L1_BLOCK_ATTRIBUTES,
DEPOSIT_VERSION,
abi.encodePacked(
uint256(0), // mint
uint256(0), // value
uint64(SYSTEM_DEPOSIT_GAS_LIMIT), // gasLimit
false, // isCreation,
abi.encodeCall(L1BlockInterop.setConfig, (_type, _value))
)
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
// Testing utilities
import { CommonTest } from "test/setup/CommonTest.sol";
// Libraries
import { Constants } from "src/libraries/Constants.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
// Target contract dependencies
import "src/libraries/PortalErrors.sol";
import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol";
import { L1BlockInterop, ConfigType } from "src/L2/L1BlockInterop.sol";
contract OptimismPortalInterop_Test is CommonTest {
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
function setUp() public virtual override {
super.enableInterop();
super.setUp();
}
/// @dev Tests that the config for the gas paying token can be set.
function testFuzz_setConfig_gasPayingToken_succeeds(bytes calldata _value) public {
vm.expectEmit(address(optimismPortal));
emitTransactionDeposited({
_from: Constants.DEPOSITOR_ACCOUNT,
_to: Predeploys.L1_BLOCK_ATTRIBUTES,
_value: 0,
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.SET_GAS_PAYING_TOKEN, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
_optimismPortalInterop().setConfig(ConfigType.SET_GAS_PAYING_TOKEN, _value);
}
/// @dev Tests that setting the gas paying token config as not the system config reverts.
function testFuzz_setConfig_gasPayingToken_notSystemConfig_reverts(bytes calldata _value) public {
vm.expectRevert(Unauthorized.selector);
_optimismPortalInterop().setConfig(ConfigType.SET_GAS_PAYING_TOKEN, _value);
}
/// @dev Tests that the config for adding a dependency can be set.
function testFuzz_setConfig_addDependency_succeeds(bytes calldata _value) public {
vm.expectEmit(address(optimismPortal));
emitTransactionDeposited({
_from: Constants.DEPOSITOR_ACCOUNT,
_to: Predeploys.L1_BLOCK_ATTRIBUTES,
_value: 0,
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.ADD_DEPENDENCY, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
_optimismPortalInterop().setConfig(ConfigType.ADD_DEPENDENCY, _value);
}
/// @dev Tests that setting the add dependency config as not the system config reverts.
function testFuzz_setConfig_addDependency_notSystemConfig_reverts(bytes calldata _value) public {
vm.expectRevert(Unauthorized.selector);
_optimismPortalInterop().setConfig(ConfigType.ADD_DEPENDENCY, _value);
}
/// @dev Tests that the config for removing a dependency can be set.
function testFuzz_setConfig_removeDependency_succeeds(bytes calldata _value) public {
vm.expectEmit(address(optimismPortal));
emitTransactionDeposited({
_from: Constants.DEPOSITOR_ACCOUNT,
_to: Predeploys.L1_BLOCK_ATTRIBUTES,
_value: 0,
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.REMOVE_DEPENDENCY, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
_optimismPortalInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, _value);
}
/// @dev Tests that setting the remove dependency config as not the system config reverts.
function testFuzz_setConfig_removeDependency_notSystemConfig_reverts(bytes calldata _value) public {
vm.expectRevert(Unauthorized.selector);
_optimismPortalInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, _value);
}
/// @dev Returns the OptimismPortalInterop instance.
function _optimismPortalInterop() internal view returns (OptimismPortalInterop) {
return OptimismPortalInterop(payable(address(optimismPortal)));
}
}
...@@ -21,7 +21,7 @@ contract DeploymentSummary is DeploymentSummaryCode { ...@@ -21,7 +21,7 @@ contract DeploymentSummary is DeploymentSummaryCode {
address internal constant l1StandardBridgeProxyAddress = 0x0c8b5822b6e02CDa722174F19A1439A7495a3fA6; address internal constant l1StandardBridgeProxyAddress = 0x0c8b5822b6e02CDa722174F19A1439A7495a3fA6;
address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60; address internal constant l2OutputOracleAddress = 0x19652082F846171168Daf378C4fD3ee85a0D4A60;
address internal constant l2OutputOracleProxyAddress = 0x8B71b41D4dBEb2b6821d44692d3fACAAf77480Bb; address internal constant l2OutputOracleProxyAddress = 0x8B71b41D4dBEb2b6821d44692d3fACAAf77480Bb;
address internal constant optimismPortalAddress = 0xFc9AD479AC641888D36EE5Dc265bcD3ecceBDc58; address internal constant optimismPortalAddress = 0xbdD90485FCbcac869D5b5752179815a3103d8131;
address internal constant optimismPortalProxyAddress = 0x978e3286EB805934215a88694d80b09aDed68D90; address internal constant optimismPortalProxyAddress = 0x978e3286EB805934215a88694d80b09aDed68D90;
address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F; address internal constant protocolVersionsAddress = 0xfbfD64a6C0257F613feFCe050Aa30ecC3E3d7C3F;
address internal constant protocolVersionsProxyAddress = 0x416C42991d05b31E9A6dC209e91AD22b79D87Ae6; address internal constant protocolVersionsProxyAddress = 0x416C42991d05b31E9A6dC209e91AD22b79D87Ae6;
...@@ -440,7 +440,7 @@ contract DeploymentSummary is DeploymentSummaryCode { ...@@ -440,7 +440,7 @@ contract DeploymentSummary is DeploymentSummaryCode {
value = hex"000000000000000000000000000000000000000000000000000000000000000a"; value = hex"000000000000000000000000000000000000000000000000000000000000000a";
vm.store(systemOwnerSafeAddress, slot, value); vm.store(systemOwnerSafeAddress, slot, value);
slot = hex"360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"; slot = hex"360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
value = hex"000000000000000000000000fc9ad479ac641888d36ee5dc265bcd3eccebdc58"; value = hex"000000000000000000000000bdd90485fcbcac869d5b5752179815a3103d8131";
vm.store(optimismPortalProxyAddress, slot, value); vm.store(optimismPortalProxyAddress, slot, value);
slot = hex"0000000000000000000000000000000000000000000000000000000000000000"; slot = hex"0000000000000000000000000000000000000000000000000000000000000000";
value = hex"0000000000000000000000000000000000000000000000000000000000000001"; value = hex"0000000000000000000000000000000000000000000000000000000000000001";
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -351,7 +351,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -351,7 +351,7 @@ contract Initializer_Test is Bridge_Initializer {
// Ensure that all L1, L2 `Initializable` contracts are accounted for, in addition to // Ensure that all L1, L2 `Initializable` contracts are accounted for, in addition to
// OptimismMintableERC20FactoryImpl, OptimismMintableERC20FactoryProxy, OptimismPortal2, // OptimismMintableERC20FactoryImpl, OptimismMintableERC20FactoryProxy, OptimismPortal2,
// DisputeGameFactoryImpl, DisputeGameFactoryProxy, DelayedWETHImpl, DelayedWETHProxy. // DisputeGameFactoryImpl, DisputeGameFactoryProxy, DelayedWETHImpl, DelayedWETHProxy.
assertEq(_getNumInitializable() + 5, contracts.length); assertEq(_getNumInitializable() + 3, contracts.length);
// Attempt to re-initialize all contracts within the `contracts` array. // Attempt to re-initialize all contracts within the `contracts` array.
for (uint256 i; i < contracts.length; i++) { for (uint256 i; i < contracts.length; i++) {
......
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