Skip to content

Commit

Permalink
OPSM: Begin implementing OP Stack Manager code and it's deployment (e…
Browse files Browse the repository at this point in the history
…thereum-optimism#11623)

* begin supporting specifying versions in OPSM

* add deploy logic

* deploy OPSM along with implementations

* scaffold opsm interface between scripts

* fixes

* mvp of DeployOPChain

* start working on an e2e opsm test, currently reverts

* fix tests

* test cleanup

* rename opsmSingleton to opsm

* chore: remove unused imports

* refactor: switch from 'new' to blueprints, 50% code size reduction

* fix semgrep

* feat: add OPSM interop tests

* test: add missing specs

* add DisputeGameFactory deployment

* chore: update snapshots

* fix opsm interop support

* chore: update snapshots

* Update packages/contracts-bedrock/test/DeployOPChain.t.sol

* fix: add L1StandardBridge setter and initialization

* chore: small clarification of deploy flow

* Update packages/contracts-bedrock/scripts/DeployImplementations.s.sol

Co-authored-by: Blaine Malone <[email protected]>

* chore: add todos

* fix: change bytes32 to string

* rename addrs to opChainAddrs for clarity

* test: fix assertion string numbering

* chore: update semver lock:

---------

Co-authored-by: Blaine Malone <[email protected]>
  • Loading branch information
mds1 and blmalone authored Sep 10, 2024
1 parent 53fa7b9 commit de31478
Show file tree
Hide file tree
Showing 14 changed files with 2,225 additions and 110 deletions.
325 changes: 307 additions & 18 deletions packages/contracts-bedrock/scripts/DeployImplementations.s.sol

Large diffs are not rendered by default.

69 changes: 67 additions & 2 deletions packages/contracts-bedrock/scripts/DeployOPChain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AnchorStateRegistry } from "src/dispute/AnchorStateRegistry.sol";
import { FaultDisputeGame } from "src/dispute/FaultDisputeGame.sol";
import { PermissionedDisputeGame } from "src/dispute/PermissionedDisputeGame.sol";

import { OPStackManager } from "src/L1/OPStackManager.sol";
import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol";
Expand All @@ -38,6 +39,7 @@ contract DeployOPChainInput {
uint32 basefeeScalar;
uint32 blobBaseFeeScalar;
uint256 l2ChainId;
OPStackManager opsm;
}

bool public inputSet = false;
Expand All @@ -59,6 +61,8 @@ contract DeployOPChainInput {
require(_input.roles.unsafeBlockSigner != address(0), "DeployOPChainInput: null unsafeBlockSigner");
require(_input.roles.proposer != address(0), "DeployOPChainInput: null proposer");
require(_input.roles.challenger != address(0), "DeployOPChainInput: null challenger");
require(_input.l2ChainId != 0 && _input.l2ChainId != block.chainid, "DeployOPChainInput: invalid l2ChainId");
require(address(_input.opsm) != address(0), "DeployOPChainInput: null opsm");

inputSet = true;
inputs = _input;
Expand Down Expand Up @@ -117,6 +121,11 @@ contract DeployOPChainInput {
assertInputSet();
return inputs.l2ChainId;
}

function opsm() public view returns (OPStackManager) {
assertInputSet();
return inputs.opsm;
}
}

contract DeployOPChainOutput {
Expand Down Expand Up @@ -298,10 +307,66 @@ contract DeployOPChain is Script {
return dso.output();
}

function run(DeployOPChainInput _dsi, DeployOPChainOutput _dso) public view {
function run(DeployOPChainInput _dsi, DeployOPChainOutput _dso) public {
require(_dsi.inputSet(), "DeployOPChain: input not set");

// TODO call OP Stack Manager deploy method
OPStackManager opsm = _dsi.opsm();

OPStackManager.Roles memory roles = OPStackManager.Roles({
opChainProxyAdminOwner: _dsi.opChainProxyAdminOwner(),
systemConfigOwner: _dsi.systemConfigOwner(),
batcher: _dsi.batcher(),
unsafeBlockSigner: _dsi.unsafeBlockSigner(),
proposer: _dsi.proposer(),
challenger: _dsi.challenger()
});
OPStackManager.DeployInput memory deployInput = OPStackManager.DeployInput({
roles: roles,
basefeeScalar: _dsi.basefeeScalar(),
blobBasefeeScalar: _dsi.blobBaseFeeScalar(),
l2ChainId: _dsi.l2ChainId()
});

vm.broadcast(msg.sender);
OPStackManager.DeployOutput memory deployOutput = opsm.deploy(deployInput);

vm.label(address(deployOutput.opChainProxyAdmin), "opChainProxyAdmin");
vm.label(address(deployOutput.addressManager), "addressManager");
vm.label(address(deployOutput.l1ERC721BridgeProxy), "l1ERC721BridgeProxy");
vm.label(address(deployOutput.systemConfigProxy), "systemConfigProxy");
vm.label(address(deployOutput.optimismMintableERC20FactoryProxy), "optimismMintableERC20FactoryProxy");
vm.label(address(deployOutput.l1StandardBridgeProxy), "l1StandardBridgeProxy");
vm.label(address(deployOutput.l1CrossDomainMessengerProxy), "l1CrossDomainMessengerProxy");
vm.label(address(deployOutput.optimismPortalProxy), "optimismPortalProxy");
vm.label(address(deployOutput.disputeGameFactoryProxy), "disputeGameFactoryProxy");
vm.label(address(deployOutput.disputeGameFactoryImpl), "disputeGameFactoryImpl");
vm.label(address(deployOutput.anchorStateRegistryProxy), "anchorStateRegistryProxy");
vm.label(address(deployOutput.anchorStateRegistryImpl), "anchorStateRegistryImpl");
vm.label(address(deployOutput.faultDisputeGame), "faultDisputeGame");
vm.label(address(deployOutput.permissionedDisputeGame), "permissionedDisputeGame");
vm.label(address(deployOutput.delayedWETHPermissionedGameProxy), "delayedWETHPermissionedGameProxy");
vm.label(address(deployOutput.delayedWETHPermissionlessGameProxy), "delayedWETHPermissionlessGameProxy");

_dso.set(_dso.opChainProxyAdmin.selector, address(deployOutput.opChainProxyAdmin));
_dso.set(_dso.addressManager.selector, address(deployOutput.addressManager));
_dso.set(_dso.l1ERC721BridgeProxy.selector, address(deployOutput.l1ERC721BridgeProxy));
_dso.set(_dso.systemConfigProxy.selector, address(deployOutput.systemConfigProxy));
_dso.set(
_dso.optimismMintableERC20FactoryProxy.selector, address(deployOutput.optimismMintableERC20FactoryProxy)
);
_dso.set(_dso.l1StandardBridgeProxy.selector, address(deployOutput.l1StandardBridgeProxy));
_dso.set(_dso.l1CrossDomainMessengerProxy.selector, address(deployOutput.l1CrossDomainMessengerProxy));
_dso.set(_dso.optimismPortalProxy.selector, address(deployOutput.optimismPortalProxy));
_dso.set(_dso.disputeGameFactoryProxy.selector, address(deployOutput.disputeGameFactoryProxy));
_dso.set(_dso.disputeGameFactoryImpl.selector, address(deployOutput.disputeGameFactoryImpl));
_dso.set(_dso.anchorStateRegistryProxy.selector, address(deployOutput.anchorStateRegistryProxy));
_dso.set(_dso.anchorStateRegistryImpl.selector, address(deployOutput.anchorStateRegistryImpl));
_dso.set(_dso.faultDisputeGame.selector, address(deployOutput.faultDisputeGame));
_dso.set(_dso.permissionedDisputeGame.selector, address(deployOutput.permissionedDisputeGame));
_dso.set(_dso.delayedWETHPermissionedGameProxy.selector, address(deployOutput.delayedWETHPermissionedGameProxy));
_dso.set(
_dso.delayedWETHPermissionlessGameProxy.selector, address(deployOutput.delayedWETHPermissionlessGameProxy)
);

_dso.checkOutput();
}
Expand Down
34 changes: 33 additions & 1 deletion packages/contracts-bedrock/scripts/libraries/Solarray.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pragma solidity ^0.8.13;
// since Solidity does not have great array UX.
//
// This library was generated using the `generator.py` script from the linked repo with the length
// set to 10, and then everything except the `addresses` functions was removed.
// set accordingly, and then everything except the `addresses` functions was removed.
library Solarray {
function addresses(address a) internal pure returns (address[] memory) {
address[] memory arr = new address[](1);
Expand Down Expand Up @@ -189,6 +189,38 @@ library Solarray {
return arr;
}

function addresses(
address a,
address b,
address c,
address d,
address e,
address f,
address g,
address h,
address i,
address j,
address k
)
internal
pure
returns (address[] memory)
{
address[] memory arr = new address[](11);
arr[0] = a;
arr[1] = b;
arr[2] = c;
arr[3] = d;
arr[4] = e;
arr[5] = f;
arr[6] = g;
arr[7] = h;
arr[8] = i;
arr[9] = j;
arr[10] = k;
return arr;
}

function extend(address[] memory arr1, address[] memory arr2) internal pure returns (address[] memory newArr) {
uint256 length1 = arr1.length;
uint256 length2 = arr2.length;
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649"
},
"src/L1/OPStackManager.sol": {
"initCodeHash": "0x67bf02405bf1ca7d78c4215c350ad9c5c7b4cece35d9fab837f279d65f995c5d",
"sourceCodeHash": "0x8e272e707e383d516b8f1cce0ea29ff46a0eb448c8386fa146e6a43f3100042a"
"initCodeHash": "0xe1eab75651e3d81ad20ca01b1e7d373b25d716ee5f8841a56e56b4531a6e0e70",
"sourceCodeHash": "0x5182a2678dadb200dd255ecdfa395e5f7b1e1e27288e78ddf8802ab51ed2dd81"
},
"src/L1/OptimismPortal.sol": {
"initCodeHash": "0x6bf59539298b20221de6c51db21016be8d3278bdbe0be1cdd49638dc828e003e",
Expand Down
Loading

0 comments on commit de31478

Please sign in to comment.