Commit 4ea33e13 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat(ctb): standardize initialization logic for L1 (#2885)

* feat(ctb): standardize initialization logic for L1

Standardizes the initialization for L1 contracts. Ensures that all
contracts use the same pattern of:
1. VERSION variable that represents the contract version.
2. constructor that sets immutables and calls initialize.
3. initialize function that sets any remaining mutables.

* op-bindings: update
Co-authored-by: default avatarMark Tyneway <mark.tyneway@gmail.com>
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 9a693575
---
'@eth-optimism/contracts-bedrock': patch
---
Standardizes initialization logic for L1 contracts
This diff is collapsed.
This diff is collapsed.
......@@ -27,26 +27,26 @@ L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10844)
L1CrossDomainMessenger_Test:testCannot_L1MessengerUnpause() (gas: 10858)
L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8388)
L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31860)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61217)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44837)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61261)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44903)
L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41587)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172199)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254211)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172133)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254167)
L1CrossDomainMessenger_Test:test_L1MessengerUnpause() (gas: 23804)
L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10599)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 59022)
L1StandardBridge_Test:test_depositERC20() (gas: 452889)
L1StandardBridge_Test:test_depositERC20To() (gas: 454644)
L1StandardBridge_Test:test_depositETH() (gas: 247083)
L1StandardBridge_Test:test_depositETHTo() (gas: 204967)
L1StandardBridge_Test:test_finalizeERC20Withdrawal() (gas: 438779)
L1StandardBridge_Test:test_finalizeETHWithdrawal() (gas: 48005)
L1StandardBridge_Test:test_initialize() (gas: 14885)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 59088)
L1StandardBridge_Test:test_depositERC20() (gas: 452890)
L1StandardBridge_Test:test_depositERC20To() (gas: 454645)
L1StandardBridge_Test:test_depositETH() (gas: 247039)
L1StandardBridge_Test:test_depositETHTo() (gas: 204923)
L1StandardBridge_Test:test_finalizeERC20Withdrawal() (gas: 438816)
L1StandardBridge_Test:test_finalizeETHWithdrawal() (gas: 47983)
L1StandardBridge_Test:test_initialize() (gas: 14863)
L1StandardBridge_Test:test_onlyEOADepositERC20() (gas: 12085)
L1StandardBridge_Test:test_onlyEOADepositETH() (gas: 30637)
L1StandardBridge_Test:test_onlyL2BridgeFinalizeERC20Withdrawal() (gas: 23565)
L1StandardBridge_Test:test_onlyPortalFinalizeERC20Withdrawal() (gas: 22919)
L1StandardBridge_Test:test_receive() (gas: 391823)
L1StandardBridge_Test:test_onlyEOADepositETH() (gas: 30615)
L1StandardBridge_Test:test_onlyL2BridgeFinalizeERC20Withdrawal() (gas: 23543)
L1StandardBridge_Test:test_onlyPortalFinalizeERC20Withdrawal() (gas: 22875)
L1StandardBridge_Test:test_receive() (gas: 391801)
L2CrossDomainMessenger_Test:testCannot_L2MessengerPause() (gas: 10843)
L2CrossDomainMessenger_Test:test_L2MessengerMessageVersion() (gas: 8410)
L2CrossDomainMessenger_Test:test_L2MessengerPause() (gas: 31837)
......@@ -57,26 +57,26 @@ L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 119682)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133142)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 10599)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 54881)
L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 24163)
L2OutputOracleTest:testCannot_appendFutureTimetamp() (gas: 26130)
L2OutputOracleTest:testCannot_appendOnWrongFork() (gas: 26415)
L2OutputOracleTest:testCannot_appendOutputIfNotSequencer() (gas: 23554)
L2OutputOracleTest:testCannot_appendUnexpectedBlockNumber() (gas: 26039)
L2OutputOracleTest:testCannot_deleteL2Output_ifNotOwner() (gas: 24799)
L2OutputOracleTest:testCannot_deleteL2Output_withWrongRoot() (gas: 91157)
L2OutputOracleTest:testCannot_deleteL2Output_withWrongTime() (gas: 87150)
L2OutputOracleTest:test_appendWithBlockhashAndHeight() (gas: 75061)
L2OutputOracleTest:test_appendingAnotherOutput() (gas: 76861)
L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 24119)
L2OutputOracleTest:testCannot_appendFutureTimetamp() (gas: 26086)
L2OutputOracleTest:testCannot_appendOnWrongFork() (gas: 26371)
L2OutputOracleTest:testCannot_appendOutputIfNotSequencer() (gas: 23510)
L2OutputOracleTest:testCannot_appendUnexpectedBlockNumber() (gas: 25995)
L2OutputOracleTest:testCannot_deleteL2Output_ifNotOwner() (gas: 24777)
L2OutputOracleTest:testCannot_deleteL2Output_withWrongRoot() (gas: 91091)
L2OutputOracleTest:testCannot_deleteL2Output_withWrongTime() (gas: 87084)
L2OutputOracleTest:test_appendWithBlockhashAndHeight() (gas: 75017)
L2OutputOracleTest:test_appendingAnotherOutput() (gas: 76817)
L2OutputOracleTest:test_changeSequencer() (gas: 55776)
L2OutputOracleTest:test_computeL2Timestamp() (gas: 30288)
L2OutputOracleTest:test_constructor() (gas: 48845)
L2OutputOracleTest:test_deleteL2Output() (gas: 76604)
L2OutputOracleTest:test_getL2Output() (gas: 83012)
L2OutputOracleTest:test_latestBlockNumber() (gas: 76264)
L2OutputOracleTest:test_nextBlockNumber() (gas: 15166)
L2OutputOracleTest:test_updateOwner() (gas: 34646)
L2OutputOracleUpgradeable_Test:test_cannotInitImpl() (gas: 8453)
L2OutputOracleUpgradeable_Test:test_cannotInitProxy() (gas: 13430)
L2OutputOracleTest:test_computeL2Timestamp() (gas: 30200)
L2OutputOracleTest:test_constructor() (gas: 48823)
L2OutputOracleTest:test_deleteL2Output() (gas: 76516)
L2OutputOracleTest:test_getL2Output() (gas: 82924)
L2OutputOracleTest:test_latestBlockNumber() (gas: 76220)
L2OutputOracleTest:test_nextBlockNumber() (gas: 15144)
L2OutputOracleTest:test_updateOwner() (gas: 34580)
L2OutputOracleUpgradeable_Test:test_cannotInitImpl() (gas: 8476)
L2OutputOracleUpgradeable_Test:test_cannotInitProxy() (gas: 13453)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy() (gas: 38906)
L2OutputOracleUpgradeable_Test:test_upgrading() (gas: 230843)
L2StandardBridge_Test:test_ERC20BridgeFailed_whenLocalTokenIsBridge() (gas: 133097)
......@@ -114,25 +114,25 @@ OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1100125)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2181161)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9374)
OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12696)
OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10958)
OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15956)
OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 15967)
OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10936)
OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15934)
OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 16034)
OptimismPortalUpgradeable_Test:test_upgrading() (gas: 230843)
OptimismPortal_Test:test_OptimismPortalConstructor() (gas: 17286)
OptimismPortal_Test:test_OptimismPortalContractCreationReverts() (gas: 14214)
OptimismPortal_Test:test_OptimismPortalConstructor() (gas: 17330)
OptimismPortal_Test:test_OptimismPortalContractCreationReverts() (gas: 14192)
OptimismPortal_Test:test_OptimismPortalReceiveEth() (gas: 126643)
OptimismPortal_Test:test_cannotVerifyRecentWithdrawal() (gas: 31945)
OptimismPortal_Test:test_depositTransaction_NoValueContract() (gas: 75774)
OptimismPortal_Test:test_depositTransaction_NoValueEOA() (gas: 76120)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract() (gas: 75779)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForEOA() (gas: 76123)
OptimismPortal_Test:test_depositTransaction_withEthValueAndContractContractCreation() (gas: 82823)
OptimismPortal_Test:test_depositTransaction_withEthValueAndEOAContractCreation() (gas: 74941)
OptimismPortal_Test:test_depositTransaction_withEthValueFromContract() (gas: 82484)
OptimismPortal_Test:test_depositTransaction_withEthValueFromEOA() (gas: 83100)
OptimismPortal_Test:test_invalidWithdrawalProof() (gas: 45251)
OptimismPortal_Test:test_isOutputFinalized() (gas: 132162)
OptimismPortal_Test:test_simple_isOutputFinalized() (gas: 23965)
OptimismPortal_Test:test_cannotVerifyRecentWithdrawal() (gas: 31901)
OptimismPortal_Test:test_depositTransaction_NoValueContract() (gas: 75752)
OptimismPortal_Test:test_depositTransaction_NoValueEOA() (gas: 76098)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract() (gas: 75757)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForEOA() (gas: 76101)
OptimismPortal_Test:test_depositTransaction_withEthValueAndContractContractCreation() (gas: 82801)
OptimismPortal_Test:test_depositTransaction_withEthValueAndEOAContractCreation() (gas: 74919)
OptimismPortal_Test:test_depositTransaction_withEthValueFromContract() (gas: 82462)
OptimismPortal_Test:test_depositTransaction_withEthValueFromEOA() (gas: 83078)
OptimismPortal_Test:test_invalidWithdrawalProof() (gas: 45163)
OptimismPortal_Test:test_isOutputFinalized() (gas: 131744)
OptimismPortal_Test:test_simple_isOutputFinalized() (gas: 23877)
Proxy_Test:test_clashingFunctionSignatures() (gas: 101427)
Proxy_Test:test_implementationKey() (gas: 20942)
Proxy_Test:test_implementationProxyCallIfNotAdmin() (gas: 30021)
......
......@@ -50,15 +50,19 @@
➡ L1StandardBridge
=======================
+-------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------+
| Name | Type | Slot | Offset | Bytes | Contract |
+============================================================================================================================================+
| messenger | contract CrossDomainMessenger | 0 | 0 | 20 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|-------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| otherBridge | contract StandardBridge | 1 | 0 | 20 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|-------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| deposits | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
+-------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------+
+---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------+
| Name | Type | Slot | Offset | Bytes | Contract |
+==============================================================================================================================================+
| messenger | contract CrossDomainMessenger | 0 | 0 | 20 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| otherBridge | contract StandardBridge | 1 | 0 | 20 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| deposits | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| _initialized | uint8 | 3 | 0 | 1 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
|---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------|
| _initializing | bool | 3 | 1 | 1 | contracts/L1/L1StandardBridge.sol:L1StandardBridge |
+---------------+-------------------------------------------------+------+--------+-------+----------------------------------------------------+
=======================
➡ L2OutputOracle
......
......@@ -58,3 +58,46 @@ npx hardhat deploy --network <network-name>
In the `hardhat.config.ts`, there is a `deployConfigSpec` field that validates that the types
are correct, be sure to export an object in the `deploy-config/<network-name>.ts` file that
has a key for each property in the `deployConfigSpec`.
## Standards and Conventions
### Style
#### Comments
We use [Seaport](https://github.com/ProjectOpenSea/seaport/blob/main/contracts/Seaport.sol)-style comments with some minor modifications.
Some basic rules:
* Always use `@notice` since it has the same general effect as `@dev` but avoids confusion about when to use one over the other.
* Include a newline between `@notice` and the first `@param`.
* Include a newline between `@param` and the first `@return`.
* Use a line-length of 100 characters.
We also have the following custom tags:
* `@custom:proxied`: Add to a contract whenever it's meant to live behind a proxy.
* `@custom:legacy`: Add to an event or function when it only exists for legacy support.
#### Errors
* Use `require` statements when making simple assertions.
* Use `revert` if throwing an error where an assertion is not being made (no custom errors). See [here](https://github.com/ethereum-optimism/optimism/blob/861ae315a6db698a8c0adb1f8eab8311fd96be4c/packages/contracts-bedrock/contracts/L2/OVM_ETH.sol#L31) for an example of this in practice.
* Error strings MUST have the format `"{ContractName}: {message}"` where `message` is a lower case string.
#### Function Parameters
* Function parameters should be prefixed with an underscore.
#### Event Parameters
* Event parameters should NOT be prefixed with an underscore.
### Proxy by Default
All contracts should be assumed to live behind proxies (except in certain special circumstances).
This means that new contracts MUST be built under the assumption of upgradeability.
We use a minimal [`Proxy`](./contracts/universal/Proxy.sol) contract designed to be owned by a corresponding [`ProxyAdmin`](./contracts/universal/ProxyAdmin.sol) which follow the interfaces of OpenZeppelin's `Proxy` and `ProxyAdmin` contracts, respectively.
Unless explicitly discussed otherwise, you MUST include the following basic upgradeability pattern for each new implementation contract:
1. Extend OpenZeppelin's `Initializable` base contract.
2. Include a `uint8 public constant VERSION = X` at the TOP of your contract.
3. Include a function `initialize` with the modifier `reinitializer(VERSION)`.
3. In the `constructor`, set any `immutable` variables and call the `initialize` function for setting mutables.
......@@ -13,22 +13,33 @@ import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol";
* interface instead of interacting with lower-level contracts directly.
*/
contract L1CrossDomainMessenger is CrossDomainMessenger {
/**
* @notice Contract version number.
*/
uint8 public constant VERSION = 1;
/**
* @notice Address of the OptimismPortal.
*/
OptimismPortal public portal;
/**
* @notice Initializes the L1CrossDomainMessenger.
* @param _portal Address of the OptimismPortal to send and receive messages through.
*/
constructor(OptimismPortal _portal) public {
// Mutables
initialize(_portal);
}
/**
* @notice Intializes mutable variables.
*
* @param _portal Address of the OptimismPortal to send and receive messages through.
*/
function initialize(OptimismPortal _portal) external {
function initialize(OptimismPortal _portal) public reinitializer(VERSION) {
portal = _portal;
address[] memory blockedSystemAddresses = new address[](1);
blockedSystemAddresses[0] = address(this);
_initialize(Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER, blockedSystemAddresses);
}
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import { Lib_PredeployAddresses } from "../libraries/Lib_PredeployAddresses.sol";
import { StandardBridge } from "../universal/StandardBridge.sol";
......@@ -11,7 +12,12 @@ import { StandardBridge } from "../universal/StandardBridge.sol";
* L2. ERC20 tokens deposited into L2 are escrowed within this contract until withdrawal.
* ETH is transferred to and escrowed within the OptimismPortal contract.
*/
contract L1StandardBridge is StandardBridge {
contract L1StandardBridge is StandardBridge, Initializable {
/**
* @notice Contract version number.
*/
uint8 public constant VERSION = 1;
/**
* @custom:legacy
* @notice Emitted whenever a deposit of ETH from L1 into L2 is initiated.
......@@ -85,11 +91,19 @@ contract L1StandardBridge is StandardBridge {
);
/**
* @notice Initializes the L1StandardBridge.
* @param _messenger Address of the L1CrossDomainMessenger.
*/
constructor(address payable _messenger) public {
// Mutables
initialize(_messenger);
}
/**
* @notice Intializes mutable variables.
*
* @param _messenger Address of the L1CrossDomainMessenger.
*/
function initialize(address payable _messenger) public {
function initialize(address payable _messenger) public reinitializer(VERSION) {
_initialize(_messenger, payable(Lib_PredeployAddresses.L2_STANDARD_BRIDGE));
}
......
......@@ -6,6 +6,7 @@ import {
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
/**
* @custom:proxied
* @title L2OutputOracle
* @notice The L2 state is committed to in this contract
* The payable keyword is used on appendL2Output to save gas on the msg.value check.
......@@ -16,7 +17,7 @@ contract L2OutputOracle is OwnableUpgradeable {
/**
* @notice Contract version number.
*/
uint8 public constant L2_OUTPUT_ORACLE_VERSION = 1;
uint8 public constant VERSION = 1;
/**
* @notice OutputProposal represents a commitment to the L2 state.
......@@ -29,6 +30,7 @@ contract L2OutputOracle is OwnableUpgradeable {
uint256 timestamp;
}
// TODO: Events should NOT be underscore prefixed.
/**
* @notice Emitted when an output is appended.
*
......@@ -101,7 +103,7 @@ contract L2OutputOracle is OwnableUpgradeable {
/**
* @notice A mapping from L2 block numbers to the respective output root. Note that these
* outputs should not be considered finalized until the finalization period (as defined
* in the Optimism Portal) has passed.
* in the Optimism Portal) has passed.
*/
mapping(uint256 => OutputProposal) internal l2Outputs;
......@@ -114,13 +116,9 @@ contract L2OutputOracle is OwnableUpgradeable {
}
/**
* @notice Initialize the L2OutputOracle contract.
*
* @param _submissionInterval The desired interval in seconds at which
* checkpoints must be submitted.
* @param _submissionInterval Interval in blocks at which checkpoints must be submitted.
* @param _genesisL2Output The initial L2 output of the L2 chain.
* @param _historicalTotalBlocks The number of blocks that preceding the
* initialization of the L2 chain.
* @param _historicalTotalBlocks Number of blocks preceding this L2 chain.
* @param _startingBlockNumber The number of the first L2 block.
* @param _startingTimestamp The timestamp of the first L2 block.
* @param _l2BlockTime The timestamp of the first L2 block.
......@@ -141,33 +139,35 @@ contract L2OutputOracle is OwnableUpgradeable {
_l2BlockTime < block.timestamp,
"Output Oracle: Initial L2 block time must be less than current time"
);
// Immutables
SUBMISSION_INTERVAL = _submissionInterval;
HISTORICAL_TOTAL_BLOCKS = _historicalTotalBlocks;
STARTING_BLOCK_NUMBER = _startingBlockNumber;
STARTING_TIMESTAMP = _startingTimestamp;
L2_BLOCK_TIME = _l2BlockTime;
// Mutables
initialize(_genesisL2Output, _startingBlockNumber, _sequencer, _owner);
}
/**
* @notice Initialize the L2OutputOracle contract.
* @notice Intializes mutable variables.
*
* @param _genesisL2Output The initial L2 output of the L2 chain.
* @param _genesisL2Output The initial L2 output of the L2 chain.
* @param _startingBlockNumber The timestamp to start L2 block at.
* @param _sequencer The address of the sequencer.
* @param _owner The address of the owner.
* @param _sequencer The address of the sequencer.
* @param _owner The address of the owner.
*/
function initialize(
bytes32 _genesisL2Output,
uint256 _startingBlockNumber,
address _sequencer,
address _owner
) public reinitializer(L2_OUTPUT_ORACLE_VERSION) {
) public reinitializer(VERSION) {
l2Outputs[_startingBlockNumber] = OutputProposal(_genesisL2Output, block.timestamp);
latestBlockNumber = _startingBlockNumber;
__Ownable_init();
changeSequencer(_sequencer);
_transferOwnership(_owner);
}
......@@ -175,8 +175,7 @@ contract L2OutputOracle is OwnableUpgradeable {
/**
* @notice Accepts an L2 outputRoot and the timestamp of the corresponding L2 block. The
* timestamp must be equal to the current value returned by `nextTimestamp()` in order
* to be accepted.
* This function may only be called by the Sequencer.
* to be accepted. This function may only be called by the Sequencer.
*
* @param _l2Output The L2 output of the checkpoint block.
* @param _l2BlockNumber The L2 block number that resulted in _l2Output.
......@@ -226,6 +225,7 @@ contract L2OutputOracle is OwnableUpgradeable {
* owner, not the sequencer. Longer term, this should be replaced with a more robust
* mechanism which will allow deletion of proposals shown to be invalid by a fault
* proof.
*
* @param _proposal Represents the output proposal to delete
*/
function deleteL2Output(OutputProposal memory _proposal) external onlyOwner {
......
......@@ -19,7 +19,7 @@ contract OptimismPortal is Initializable, ResourceMetering {
/**
* @notice Contract version number.
*/
uint8 public constant OPTIMISM_PORTAL_VERSION = 1;
uint8 public constant VERSION = 1;
/**
* @notice Emitted when a transaction is deposited from L1 to L2. The parameters of this event
......@@ -94,22 +94,22 @@ contract OptimismPortal is Initializable, ResourceMetering {
uint256[48] private __gap;
/**
* @notice The constructor sets immutable values in the implementation.
* This means that these values can only changed by an upgrade. But the efficiency gains
* are worthwhile.
* Also ensures that the implementation is initialized upon deployment.
* @param _l2Oracle Address of the L2OutputOracle contract.
* @param _finalizationPeriodSeconds Output finalization time in seconds.
*/
constructor(L2OutputOracle _l2Oracle, uint256 _finalizationPeriodSeconds) {
// Set these immutable values into the bytcode of the implementation.
// Immutables
L2_ORACLE = _l2Oracle;
FINALIZATION_PERIOD_SECONDS = _finalizationPeriodSeconds;
// Mutables
initialize();
}
/**
* @notice Initializes the contract and parent contract(s).
* @notice Intializes mutable variables.
*/
function initialize() public reinitializer(OPTIMISM_PORTAL_VERSION) {
function initialize() public reinitializer(VERSION) {
l2Sender = DEFAULT_L2_SENDER;
__ResourceMetering_init();
}
......
......@@ -164,8 +164,7 @@ contract Messenger_Initializer is L2OutputOracle_Initializer {
op = new OptimismPortal(oracle, 7 days);
vm.label(address(op), "OptimismPortal");
L1Messenger = new L1CrossDomainMessenger();
L1Messenger.initialize(op);
L1Messenger = new L1CrossDomainMessenger(op);
vm.etch(
Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER,
......@@ -311,8 +310,7 @@ contract Bridge_Initializer is Messenger_Initializer {
// Deploy the L1 bridge and initialize it with the address of the
// L1CrossDomainMessenger
L1Bridge = new L1StandardBridge();
L1Bridge.initialize(payable(address(L1Messenger)));
L1Bridge = new L1StandardBridge(payable(address(L1Messenger)));
vm.label(address(L1Bridge), "L1StandardBridge");
// Deploy the L2StandardBridge, move it to the correct predeploy
......
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