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
18 changes: 0 additions & 18 deletions packages/contracts-bedrock/interfaces/L1/ILiquidityMigrator.sol

This file was deleted.

2 changes: 0 additions & 2 deletions packages/contracts-bedrock/interfaces/L1/IOptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ISharedLockbox } from "interfaces/L1/ISharedLockbox.sol";

interface IOptimismPortal2 {
error CustomGasTokenNotSupported();
Expand Down Expand Up @@ -71,7 +70,6 @@ interface IOptimismPortal2 {
function disputeGameBlacklist(IDisputeGame) external view returns (bool);
function disputeGameFactory() external view returns (IDisputeGameFactory);
function disputeGameFinalityDelaySeconds() external view returns (uint256);
function sharedLockbox() external view returns (ISharedLockbox);
function donateETH() external payable;
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external;
function finalizeWithdrawalTransactionExternalProof(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface IOptimismPortalInterop {
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);
event ETHMigrated(uint256 amount);

receive() external payable;

Expand Down Expand Up @@ -118,6 +119,8 @@ interface IOptimismPortalInterop {
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
function version() external pure returns (string memory);
function migrateLiquidity() external;
function migrated() external view returns (bool);

function __constructor__(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) external;
}
20 changes: 7 additions & 13 deletions packages/contracts-bedrock/interfaces/L1/ISharedLockbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@
pragma solidity ^0.8.0;

import { ISemver } from "interfaces/universal/ISemver.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ISuperchainConfigInterop } from "interfaces/L1/ISuperchainConfigInterop.sol";

/// @title ISharedLockbox
/// @notice Interface for the SharedLockbox contract
interface ISharedLockbox is ISemver {
error Unauthorized();

error Paused();
error InvalidInitialization();
error NotInitializing();

event Initialized(uint64 version);
event ETHLocked(address indexed portal, uint256 amount);

event ETHUnlocked(address indexed portal, uint256 amount);

event PortalAuthorized(address indexed portal);

function SUPERCHAIN_CONFIG() external view returns (ISuperchainConfig);

function authorizedPortals(address) external view returns (bool);

function __constructor__(address _superchainConfig) external;

function superchainConfig() external view returns (ISuperchainConfigInterop superchainConfig_);
function initialize(address _superchainConfig) external;
function paused() external view returns (bool);

function unlockETH(uint256 _value) external;

function lockETH() external payable;

function authorizePortal(address _portal) external;
function __constructor__() external;
}
26 changes: 6 additions & 20 deletions packages/contracts-bedrock/interfaces/L1/ISuperchainConfig.sol
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IDependencySet } from "interfaces/L2/IDependencySet.sol";
import { ISharedLockbox } from "interfaces/L1/ISharedLockbox.sol";

interface ISuperchainConfig is IDependencySet {
interface ISuperchainConfig {
enum UpdateType {
GUARDIAN
GUARDIAN,
CLUSTER_MANAGER
}

event ConfigUpdate(UpdateType indexed updateType, bytes data);
event Initialized(uint8 version);
event Paused(string identifier);
event Unpaused();
event DependencyAdded(uint256 indexed chainId, address indexed systemConfig, address indexed portal);

error Unauthorized();
error DependencySetTooLarge();
error InvalidChainID();
error DependencyAlreadyAdded();

function GUARDIAN_SLOT() external view returns (bytes32);
function PAUSED_SLOT() external view returns (bytes32);
function DEPENDENCY_MANAGER_SLOT() external view returns (bytes32);
function SHARED_LOCKBOX() external view returns (ISharedLockbox);
function guardian() external view returns (address guardian_);
function dependencyManager() external view returns (address dependencyManager_);
function initialize(address _guardian, address _dependencyManager, bool _paused) external;
function initialize(address _guardian, bool _paused) external;
function pause(string memory _identifier) external;
function paused() external view returns (bool paused_);
function unpause() external;
function version() external view returns (string memory);
function addDependency(uint256 _chainId, address _systemConfig) external;
function dependencySet() external view returns (uint256[] memory);
function dependencySetSize() external view returns (uint8);
function version() external pure returns (string memory);

function __constructor__(address _sharedLockbox) external;
function __constructor__() external;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IDependencySet } from "interfaces/L2/IDependencySet.sol";
import { ISharedLockbox } from "interfaces/L1/ISharedLockbox.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";

interface ISuperchainConfigInterop is IDependencySet, ISuperchainConfig {
event DependencyAdded(uint256 indexed chainId, address indexed systemConfig, address indexed portal);

error Unauthorized();
error DependencySetTooLarge();
error DependencyAlreadyAdded();
error InvalidSuperchainConfig();
error PortalAlreadyAuthorized();

function CLUSTER_MANAGER_SLOT() external view returns (bytes32);
function sharedLockbox() external view returns (ISharedLockbox sharedLockbox_);
function clusterManager() external view returns (address clusterManager_);
function initialize(address _guardian, bool _paused, address _clusterManager, address _sharedLockbox) external;
function version() external pure returns (string memory);
function addDependency(uint256 _chainId, address _systemConfig) external;
function dependencySet() external view returns (uint256[] memory);
function dependencySetSize() external view returns (uint8);
function authorizedPortals(address _portal) external view returns (bool);

function __constructor__() external;
}
44 changes: 0 additions & 44 deletions packages/contracts-bedrock/interfaces/L2/ICrossL2Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,13 @@ struct Identifier {
/// @title ICrossL2Inbox
/// @notice Interface for the CrossL2Inbox contract.
interface ICrossL2Inbox {
error ReentrantCall();

/// @notice Thrown when the caller is not DEPOSITOR_ACCOUNT when calling `setInteropStart()`
error NotDepositor();

/// @notice Thrown when attempting to set interop start when it's already set.
error InteropStartAlreadySet();

/// @notice Thrown when a non-written transient storage slot is attempted to be read from.
error NotEntered();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier timestamp.
error InvalidTimestamp();

/// @notice Thrown when trying to execute a cross chain message and the target call fails.
error TargetCallFailed();

/// @notice Thrown when trying to execute a cross chain message on a deposit transaction.
error NoExecutingDeposits();

event ExecutingMessage(bytes32 indexed msgHash, Identifier id);

function version() external view returns (string memory);

/// @notice Returns the interop start timestamp.
/// @return interopStart_ interop start timestamp.
function interopStart() external view returns (uint256 interopStart_);

/// @notice Returns the origin address of the Identifier.
function origin() external view returns (address);

/// @notice Returns the block number of the Identifier.
function blockNumber() external view returns (uint256);

/// @notice Returns the log index of the Identifier.
function logIndex() external view returns (uint256);

/// @notice Returns the timestamp of the Identifier.
function timestamp() external view returns (uint256);

/// @notice Returns the chain ID of the Identifier.
function chainId() external view returns (uint256);

function setInteropStart() external;

/// @notice Executes a cross chain message on the destination chain.
/// @param _id An Identifier pointing to the initiating message.
/// @param _target Account that is called with _msg.
/// @param _message The message payload, matching the initiating message.
function executeMessage(Identifier calldata _id, address _target, bytes calldata _message) external payable;

/// @notice Validates a cross chain message on the destination chain
/// and emits an ExecutingMessage event. This function is useful
/// for applications that understand the schema of the _message payload and want to
Expand Down
21 changes: 21 additions & 0 deletions packages/contracts-bedrock/interfaces/L2/IDependencyManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ISemver } from "interfaces/universal/ISemver.sol";

/// @title IDependencyManager
/// @notice Interface for the DependencyManager contract.
interface IDependencyManager is ISemver {
error DependencySetSizeTooLarge();
error AlreadyDependency();
error Unauthorized();

event DependencyAdded(uint256 indexed chainId, address indexed systemConfig, address indexed superchainConfig);

function addDependency(address _superchainConfig, uint256 _chainId, address _systemConfig) external;
function isInDependencySet(uint256 _chainId) external view returns (bool);
function dependencySetSize() external view returns (uint8);
function dependencySet() external view returns (uint256[] memory);

function __constructor__() external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ interface IL2ToL2CrossDomainMessenger {
/// @notice Thrown when a call to the target contract during message relay fails.
error TargetCallFailed();

/// @notice Thrown when attempting to use a chain ID that is not in the dependency set.
error InvalidChainId();

/// @notice Emitted whenever a message is sent to a destination
/// @param destination Chain ID of the destination chain.
/// @param target Target contract or wallet address.
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts-bedrock/scripts/Artifacts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ abstract contract Artifacts {
return payable(Predeploys.OPTIMISM_SUPERCHAIN_ERC20_BEACON);
} else if (digest == keccak256(bytes("SuperchainTokenBridge"))) {
return payable(Predeploys.SUPERCHAIN_TOKEN_BRIDGE);
} else if (digest == keccak256(bytes("DependencyManager"))) {
return payable(Predeploys.DEPENDENCY_MANAGER);
}
return payable(address(0));
}
Expand Down
7 changes: 7 additions & 0 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ contract L2Genesis is Deployer {
setOptimismSuperchainERC20Factory(); // 26
setOptimismSuperchainERC20Beacon(); // 27
setSuperchainTokenBridge(); // 28
setDependencyManager(); // 29
}
}

Expand Down Expand Up @@ -595,6 +596,12 @@ contract L2Genesis is Deployer {
_setImplementationCode(Predeploys.SUPERCHAIN_TOKEN_BRIDGE);
}

/// @notice This predeploy is following the safety invariant #1.
/// This contract has no initializer.
function setDependencyManager() internal {
_setImplementationCode(Predeploys.DEPENDENCY_MANAGER);
}

/// @notice Sets all the preinstalls.
function setPreinstalls() public {
address tmpSetPreinstalls = address(uint160(uint256(keccak256("SetPreinstalls"))));
Expand Down
48 changes: 40 additions & 8 deletions packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { OPContractsManager } from "src/L1/OPContractsManager.sol";
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
import { ISuperchainConfigInterop } from "interfaces/L1/ISuperchainConfigInterop.sol";
import { ISharedLockbox } from "interfaces/L1/ISharedLockbox.sol";
import { ILiquidityMigrator } from "interfaces/L1/ILiquidityMigrator.sol";
import { IL1CrossDomainMessenger } from "interfaces/L1/IL1CrossDomainMessenger.sol";
import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { IL1ERC721Bridge } from "interfaces/L1/IL1ERC721Bridge.sol";
Expand Down Expand Up @@ -441,6 +441,7 @@ library ChainAssertions {
view
{
ISuperchainConfig superchainConfig = ISuperchainConfig(_contracts.SuperchainConfig);

console.log(
"Running chain assertions on the SuperchainConfig %s at %s",
_isProxy ? "proxy" : "implementation",
Expand All @@ -465,6 +466,36 @@ library ChainAssertions {
}
}

/// @notice Asserts that the SuperchainConfigInterop is setup correctly
function checkSuperchainConfigInterop(
Types.ContractSet memory _contracts,
DeployConfig _cfg,
bool _isPaused,
bool _isProxy
)
internal
view
{
ISuperchainConfigInterop superchainConfig = ISuperchainConfigInterop(_contracts.SuperchainConfig);
ISharedLockbox sharedLockbox = ISharedLockbox(_contracts.SharedLockbox);

console.log(
"Running chain assertions on the SuperchainConfigInterop %s at %s",
_isProxy ? "proxy" : "implementation",
address(superchainConfig)
);

if (_isProxy) {
require(superchainConfig.clusterManager() == _cfg.finalSystemOwner(), "CHECK-SCI-10");
require(address(superchainConfig.sharedLockbox()) == address(sharedLockbox), "CHECK-SCI-20");
} else {
require(superchainConfig.clusterManager() == address(0), "CHECK-SCI-30");
require(address(superchainConfig.sharedLockbox()) == address(0), "CHECK-SCI-40");
}

checkSuperchainConfig(_contracts, _cfg, _isPaused, _isProxy);
}

/// @notice Asserts that the OPContractsManager is setup correctly
function checkOPContractsManager(
Types.ContractSet memory _contracts,
Expand Down Expand Up @@ -545,7 +576,7 @@ library ChainAssertions {
/// @notice Asserts that the SharedLockbox is setup correctly
function checkSharedLockbox(Types.ContractSet memory _contracts, bool _isProxy) internal view {
ISharedLockbox sharedLockbox = ISharedLockbox(_contracts.SharedLockbox);
ISuperchainConfig superchainConfig = ISuperchainConfig(_contracts.SuperchainConfig);
ISuperchainConfigInterop superchainConfig = ISuperchainConfigInterop(_contracts.SuperchainConfig);

console.log(
"Running chain assertions on the SharedLockbox %s at %s",
Expand All @@ -554,13 +585,14 @@ library ChainAssertions {
);

require(address(sharedLockbox) != address(0), "CHECK-SLB-10");
require(sharedLockbox.SUPERCHAIN_CONFIG() == superchainConfig, "CHECK-SLB-20");
}

/// @notice Asserts that the LiquidityMigrator is setup correctly
function checkLiquidityMigrator(Types.ContractSet memory _contracts, address _liquidityMigrator) internal view {
ISharedLockbox sharedLockbox = ISharedLockbox(_contracts.SharedLockbox);
// Check that the contract is initialized
DeployUtils.assertInitializedOZv5({ _contractAddress: address(sharedLockbox), _isProxy: _isProxy });

require(ILiquidityMigrator(_liquidityMigrator).SHARED_LOCKBOX() == sharedLockbox, "LM-10");
if (_isProxy) {
require(sharedLockbox.superchainConfig() == superchainConfig, "CHECK-SLB-20");
} else {
require(address(sharedLockbox.superchainConfig()) == address(0), "CHECK-SLB-30");
}
}
}
Loading