Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/l1 migrate #131

Merged
merged 11 commits into from
Apr 5, 2024
45 changes: 23 additions & 22 deletions packages/contracts-bedrock/scripts/oasys/L1/build/Build.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ contract Build is Script {
address l2OutputOracleProposer;
// L2OutputOracleChallenger is the address of the account that challenges L2 outputs.
address l2OutputOracleChallenger;
// MessageRelayer is the address of message-relayer finalizer.
address messageRelayer;
// FinalizationPeriodSeconds represents the number of seconds before an output is considered
// finalized. This impacts the amount of time that withdrawals take to finalize and is
// generally set to 1 week.
Expand Down Expand Up @@ -219,15 +221,11 @@ contract Build is Script {
address l2ooChallenger = vm.envAddress("L2OO_CHALLENGER");
address l2ooProposer = vm.envAddress("L2OO_PROPOSER");
address batchSender = vm.envAddress("BATCH_SENDER");
address messageRelayer = vm.envAddress("MESSAGE_RELAYER");
uint256 l2ChainId = vm.envUint("L2_CHAIN_ID");
uint256 l1BlockTime = vm.envUint("L1_BLOCK_TIME");
uint256 l2BlockTime = vm.envUint("L2_BLOCK_TIME");
uint256 l2GasLimit = vm.envUint("L2_GAS_LIMIT");
uint256 finalizationPeriodSeconds = vm.envUint("FINALIZATION_PERIOD_SECONDS");
uint256 outputOracleSubmissionInterval = vm.envUint("OUTPUT_ORACLE_SUBMISSION_INTERVAL");
uint256 outputOracleStartingBlockNumber = vm.envUint("OUTPUT_ORACLE_STARTING_BLOCK_NUMBER");
uint256 outputOracleStartingTimestamp = vm.envUint("OUTPUT_ORACLE_STARTING_TIMESTAMP");
uint256 l2ZeroFeeTime = vm.envOr("ENABLE_L2_ZERO_FEE", false) ? block.timestamp : 0;

// construct a deployment configuration.
deployCfg = DeployConfig({
Expand All @@ -248,14 +246,16 @@ contract Build is Script {
p2pSequencerAddress: p2pSequencer,
batchSenderAddress: batchSender,
// ----
l2OutputOracleSubmissionInterval: outputOracleSubmissionInterval,
l2OutputOracleStartingBlockNumber: outputOracleStartingBlockNumber,
l2OutputOracleStartingTimestamp: outputOracleStartingTimestamp,
l2OutputOracleSubmissionInterval: vm.envUint("OUTPUT_ORACLE_SUBMISSION_INTERVAL"),
l2OutputOracleStartingBlockNumber: vm.envUint("OUTPUT_ORACLE_STARTING_BLOCK_NUMBER"),
l2OutputOracleStartingTimestamp: vm.envUint("OUTPUT_ORACLE_STARTING_TIMESTAMP"),
// ----
l2OutputOracleProposer: l2ooProposer,
l2OutputOracleChallenger: l2ooChallenger,
// ----
finalizationPeriodSeconds: finalizationPeriodSeconds,
messageRelayer: messageRelayer,
// ----
finalizationPeriodSeconds: vm.envUint("FINALIZATION_PERIOD_SECONDS"),
// ----
proxyAdminOwner: finalSystemOwner,
baseFeeVaultRecipient: finalSystemOwner,
Expand Down Expand Up @@ -290,7 +290,7 @@ contract Build is Script {
requiredProtocolVersion: bytes32(0),
recommendedProtocolVersion: bytes32(0),
// ----
l2ZeroFeeTime: l2ZeroFeeTime,
l2ZeroFeeTime: vm.envOr("ENABLE_L2_ZERO_FEE", false) ? block.timestamp : 0,
// set later.
batchInboxAddress: address(0),
l1StandardBridgeProxy: address(0),
Expand All @@ -307,6 +307,7 @@ contract Build is Script {
l2OutputOracleChallenger: deployCfg.l2OutputOracleChallenger,
batchSenderAddress: deployCfg.batchSenderAddress,
p2pSequencerAddress: deployCfg.p2pSequencerAddress,
messageRelayer: deployCfg.messageRelayer,
l2BlockTime: deployCfg.l2BlockTime,
l2GasLimit: uint64(deployCfg.l2GenesisBlockGasLimit),
l2OutputOracleSubmissionInterval: deployCfg.l2OutputOracleSubmissionInterval,
Expand Down Expand Up @@ -334,24 +335,22 @@ contract Build is Script {
deposit.deposit{ value: 1 ether }(msg.sender);

// build L2.
(address proxyAdmin, address[7] memory proxys,, address batchInbox, address addressManager) =
agent.build(deployCfg.l2ChainID, buildCfg);
(IL1BuildAgent.BuiltAddressList memory results,) = agent.build(deployCfg.l2ChainID, buildCfg);
vm.stopBroadcast();

// set deployed addresses
deployCfg.optimismPortalProxy = proxys[0];
deployCfg.systemConfigProxy = proxys[2];
deployCfg.l1CrossDomainMessengerProxy = proxys[3];
deployCfg.l1StandardBridgeProxy = proxys[4];
deployCfg.l1ERC721BridgeProxy = proxys[5];
deployCfg.batchInboxAddress = batchInbox;
address protocolVersions = proxys[6];
address l2OutputOracleProxy = proxys[1];
deployCfg.optimismPortalProxy = results.oasysPortal;
deployCfg.systemConfigProxy = results.systemConfig;
deployCfg.l1CrossDomainMessengerProxy = results.l1CrossDomainMessenger;
deployCfg.l1StandardBridgeProxy = results.l1StandardBridge;
deployCfg.l1ERC721BridgeProxy = results.l1ERC721Bridge;
deployCfg.batchInboxAddress = results.batchInbox;

// output opstack configuration files.
string memory deployCfgJson = _deployConfigJson("DeployConfig");
string memory addressesJson =
_addressesJson("deployed", proxyAdmin, l2OutputOracleProxy, addressManager, protocolVersions);
string memory addressesJson = _addressesJson(
"deployed", results.proxyAdmin, results.oasysL2OutputOracle, address(0), results.protocolVersions
);

// output to the `./tmp/L1BuildAgent/Build/latest` directory
_writeJson(deployCfgJson, Path.buildLatestOutDir(), "/deploy-config.json");
Expand Down Expand Up @@ -424,6 +423,8 @@ contract Build is Script {
json.serialize("l2OutputOracleProposer", deployCfg.l2OutputOracleProposer);
json.serialize("l2OutputOracleChallenger", deployCfg.l2OutputOracleChallenger);

json.serialize("messageRelayer", deployCfg.messageRelayer);

json.serialize("finalizationPeriodSeconds", deployCfg.finalizationPeriodSeconds);

json.serialize("proxyAdminOwner", deployCfg.proxyAdminOwner);
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-bedrock/src/L1/L1ERC721Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ import { Constants } from "src/libraries/Constants.sol";
/// @notice The L1 ERC721 bridge is a contract which works together with the L2 ERC721 bridge to
/// make it possible to transfer ERC721 tokens from Ethereum to Optimism. This contract
/// acts as an escrow for ERC721 tokens deposited into L2.
/// ------------------------------
/// Oasys made a change to this contract
// The change is comment out in the mapping of deposits
contract L1ERC721Bridge is ERC721Bridge, ISemver {
/// @notice Mapping of L1 token to L2 token to ID to boolean, indicating if the given L1 token
/// by ID was deposited for a given L2 token.
/// -------------------------
// Move this mapping to the `L1ERC721BridgeLegacySpacer` contract
// To follow the storage layout of Oasys Legacy L1ERC721Bridge
// mapping(address => mapping(address => mapping(uint256 => bool))) public deposits;

/// @notice Semantic version.
/// @custom:semver 1.5.0
string public constant version = "1.5.0";
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/src/L2/L2ERC721Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract L2ERC721Bridge is ERC721Bridge, ISemver {
uint256 _tokenId,
bytes calldata _extraData
)
external
public
virtual
onlyOtherBridge
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract BuildOasysPortal is IBuildOasysPortal, ISemver {
}

/// @inheritdoc IBuildOasysPortal
function initializeData(bool _paused) external pure returns (bytes memory) {
return abi.encodeCall(OasysPortal.initialize, (_paused));
function initializeData(bool _paused, address relayer) external pure returns (bytes memory) {
return abi.encodeCall(OasysPortal.initializeWithRelayer, (_paused, relayer));
ironbeer marked this conversation as resolved.
Show resolved Hide resolved
}
}
28 changes: 0 additions & 28 deletions packages/contracts-bedrock/src/oasys/L1/build/BuildProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { IBuildProxy } from "src/oasys/L1/build/interfaces/IBuildProxy.sol";
import { Proxy } from "src/universal/Proxy.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { ResolvedDelegateProxy } from "src/legacy/ResolvedDelegateProxy.sol";
import { AddressManager } from "src/legacy/AddressManager.sol";

/// @notice Hold the deployment bytecode
/// Separate from build contract to avoid bytecode size limitations
Expand All @@ -16,12 +13,6 @@ contract BuildProxy is IBuildProxy, ISemver {
/// @custom:semver 1.0.0
string public constant version = "1.0.0";

/// @inheritdoc IBuildProxy
function deployAddressManager(address owner) external returns (AddressManager addressManager) {
addressManager = new AddressManager();
addressManager.transferOwnership(owner);
}

/// @inheritdoc IBuildProxy
function deployProxyAdmin(address owner) external returns (ProxyAdmin proxyAdmin) {
proxyAdmin = new ProxyAdmin({ _owner: owner });
Expand All @@ -31,23 +22,4 @@ contract BuildProxy is IBuildProxy, ISemver {
function deployERC1967Proxy(address admin) external returns (Proxy proxy) {
proxy = new Proxy({ _admin: admin });
}

/// @inheritdoc IBuildProxy
function deployChugProxy(address owner) external returns (L1ChugSplashProxy proxy) {
proxy = new L1ChugSplashProxy({ _owner: owner });
}

/// @inheritdoc IBuildProxy
function deployResolvedProxy(
address addressManager,
string memory implementationName
)
external
returns (ResolvedDelegateProxy proxy)
{
proxy = new ResolvedDelegateProxy({
_addressManager: AddressManager(addressManager),
_implementationName: implementationName
});
}
}
Loading