Skip to content

Commit 3f4d94a

Browse files
authored
ctb: Implement addGameType method on OPCM (#13653)
1 parent 3d3deab commit 3f4d94a

File tree

12 files changed

+770
-64
lines changed

12 files changed

+770
-64
lines changed

packages/contracts-bedrock/scripts/deploy/DeployImplementations.s.sol

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
99
import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
1010
import { IProtocolVersions } from "interfaces/L1/IProtocolVersions.sol";
1111

12-
import { Bytes } from "src/libraries/Bytes.sol";
13-
1412
import { IDelayedWETH } from "interfaces/dispute/IDelayedWETH.sol";
1513
import { IPreimageOracle } from "interfaces/cannon/IPreimageOracle.sol";
1614
import { IMIPS } from "interfaces/cannon/IMIPS.sol";
@@ -493,14 +491,22 @@ contract DeployImplementations is Script {
493491
bytes32 salt = _dii.salt();
494492
OPContractsManager.Blueprints memory blueprints;
495493

494+
address checkAddress;
496495
vm.startBroadcast(msg.sender);
497-
blueprints.addressManager = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("AddressManager")), salt);
498-
blueprints.proxy = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("Proxy")), salt);
499-
blueprints.proxyAdmin = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("ProxyAdmin")), salt);
500-
blueprints.l1ChugSplashProxy = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("L1ChugSplashProxy")), salt);
501-
blueprints.resolvedDelegateProxy = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("ResolvedDelegateProxy")), salt);
502-
blueprints.anchorStateRegistry = deployBytecode(Blueprint.blueprintDeployerBytecode(vm.getCode("AnchorStateRegistry")), salt);
503-
(blueprints.permissionedDisputeGame1, blueprints.permissionedDisputeGame2) = deployBigBytecode(vm.getCode("PermissionedDisputeGame"), salt);
496+
(blueprints.addressManager, checkAddress) = Blueprint.create(vm.getCode("AddressManager"), salt);
497+
require(checkAddress == address(0), "OPCM-10");
498+
(blueprints.proxy, checkAddress) = Blueprint.create(vm.getCode("Proxy"), salt);
499+
require(checkAddress == address(0), "OPCM-20");
500+
(blueprints.proxyAdmin, checkAddress) = Blueprint.create(vm.getCode("ProxyAdmin"), salt);
501+
require(checkAddress == address(0), "OPCM-30");
502+
(blueprints.l1ChugSplashProxy, checkAddress) = Blueprint.create(vm.getCode("L1ChugSplashProxy"), salt);
503+
require(checkAddress == address(0), "OPCM-40");
504+
(blueprints.resolvedDelegateProxy, checkAddress) = Blueprint.create(vm.getCode("ResolvedDelegateProxy"), salt);
505+
require(checkAddress == address(0), "OPCM-50");
506+
(blueprints.anchorStateRegistry, checkAddress) = Blueprint.create(vm.getCode("AnchorStateRegistry"), salt);
507+
require(checkAddress == address(0), "OPCM-60");
508+
(blueprints.permissionedDisputeGame1, blueprints.permissionedDisputeGame2) = Blueprint.create(vm.getCode("PermissionedDisputeGame"), salt);
509+
(blueprints.permissionlessDisputeGame1, blueprints.permissionlessDisputeGame2) = Blueprint.create(vm.getCode("FaultDisputeGame"), salt);
504510
vm.stopBroadcast();
505511
// forgefmt: disable-end
506512

@@ -862,33 +868,6 @@ contract DeployImplementations is Script {
862868
dio_ = DeployImplementationsOutput(DeployUtils.toIOAddress(msg.sender, "optimism.DeployImplementationsOutput"));
863869
}
864870

865-
function deployBytecode(bytes memory _bytecode, bytes32 _salt) public returns (address newContract_) {
866-
assembly ("memory-safe") {
867-
newContract_ := create2(0, add(_bytecode, 0x20), mload(_bytecode), _salt)
868-
}
869-
require(newContract_ != address(0), "DeployImplementations: create2 failed");
870-
}
871-
872-
function deployBigBytecode(
873-
bytes memory _bytecode,
874-
bytes32 _salt
875-
)
876-
public
877-
returns (address newContract1_, address newContract2_)
878-
{
879-
// Preamble needs 3 bytes.
880-
uint256 maxInitCodeSize = 24576 - 3;
881-
require(_bytecode.length > maxInitCodeSize, "DeployImplementations: Use deployBytecode instead");
882-
883-
bytes memory part1Slice = Bytes.slice(_bytecode, 0, maxInitCodeSize);
884-
bytes memory part1 = Blueprint.blueprintDeployerBytecode(part1Slice);
885-
bytes memory part2Slice = Bytes.slice(_bytecode, maxInitCodeSize, _bytecode.length - maxInitCodeSize);
886-
bytes memory part2 = Blueprint.blueprintDeployerBytecode(part2Slice);
887-
888-
newContract1_ = deployBytecode(part1, _salt);
889-
newContract2_ = deployBytecode(part2, _salt);
890-
}
891-
892871
// Zero address is returned if the address is not found in '_standardVersionsToml'.
893872
function getReleaseAddress(
894873
string memory _version,

packages/contracts-bedrock/scripts/deploy/DeployOPCM.s.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ contract DeployOPCM is Script {
198198
resolvedDelegateProxy: _doi.resolvedDelegateProxyBlueprint(),
199199
anchorStateRegistry: _doi.anchorStateRegistryBlueprint(),
200200
permissionedDisputeGame1: _doi.permissionedDisputeGame1Blueprint(),
201-
permissionedDisputeGame2: _doi.permissionedDisputeGame2Blueprint()
201+
permissionedDisputeGame2: _doi.permissionedDisputeGame2Blueprint(),
202+
permissionlessDisputeGame1: address(0),
203+
permissionlessDisputeGame2: address(0)
202204
});
203205
OPContractsManager.Implementations memory implementations = OPContractsManager.Implementations({
204206
l1ERC721BridgeImpl: address(_doi.l1ERC721BridgeImpl()),

packages/contracts-bedrock/snapshots/abi/OPContractsManager.json

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@
5757
"internalType": "address",
5858
"name": "permissionedDisputeGame2",
5959
"type": "address"
60+
},
61+
{
62+
"internalType": "address",
63+
"name": "permissionlessDisputeGame1",
64+
"type": "address"
65+
},
66+
{
67+
"internalType": "address",
68+
"name": "permissionlessDisputeGame2",
69+
"type": "address"
6070
}
6171
],
6272
"internalType": "struct OPContractsManager.Blueprints",
@@ -132,6 +142,104 @@
132142
"stateMutability": "view",
133143
"type": "function"
134144
},
145+
{
146+
"inputs": [
147+
{
148+
"components": [
149+
{
150+
"internalType": "string",
151+
"name": "saltMixer",
152+
"type": "string"
153+
},
154+
{
155+
"internalType": "contract ISystemConfig",
156+
"name": "systemConfig",
157+
"type": "address"
158+
},
159+
{
160+
"internalType": "contract IProxyAdmin",
161+
"name": "proxyAdmin",
162+
"type": "address"
163+
},
164+
{
165+
"internalType": "contract IDelayedWETH",
166+
"name": "delayedWETH",
167+
"type": "address"
168+
},
169+
{
170+
"internalType": "GameType",
171+
"name": "disputeGameType",
172+
"type": "uint32"
173+
},
174+
{
175+
"internalType": "Claim",
176+
"name": "disputeAbsolutePrestate",
177+
"type": "bytes32"
178+
},
179+
{
180+
"internalType": "uint256",
181+
"name": "disputeMaxGameDepth",
182+
"type": "uint256"
183+
},
184+
{
185+
"internalType": "uint256",
186+
"name": "disputeSplitDepth",
187+
"type": "uint256"
188+
},
189+
{
190+
"internalType": "Duration",
191+
"name": "disputeClockExtension",
192+
"type": "uint64"
193+
},
194+
{
195+
"internalType": "Duration",
196+
"name": "disputeMaxClockDuration",
197+
"type": "uint64"
198+
},
199+
{
200+
"internalType": "uint256",
201+
"name": "initialBond",
202+
"type": "uint256"
203+
},
204+
{
205+
"internalType": "contract IBigStepper",
206+
"name": "vm",
207+
"type": "address"
208+
},
209+
{
210+
"internalType": "bool",
211+
"name": "permissioned",
212+
"type": "bool"
213+
}
214+
],
215+
"internalType": "struct OPContractsManager.AddGameInput[]",
216+
"name": "_gameConfigs",
217+
"type": "tuple[]"
218+
}
219+
],
220+
"name": "addGameType",
221+
"outputs": [
222+
{
223+
"components": [
224+
{
225+
"internalType": "contract IDelayedWETH",
226+
"name": "delayedWETH",
227+
"type": "address"
228+
},
229+
{
230+
"internalType": "contract IFaultDisputeGame",
231+
"name": "faultDisputeGame",
232+
"type": "address"
233+
}
234+
],
235+
"internalType": "struct OPContractsManager.AddGameOutput[]",
236+
"name": "",
237+
"type": "tuple[]"
238+
}
239+
],
240+
"stateMutability": "nonpayable",
241+
"type": "function"
242+
},
135243
{
136244
"inputs": [],
137245
"name": "blueprints",
@@ -177,6 +285,16 @@
177285
"internalType": "address",
178286
"name": "permissionedDisputeGame2",
179287
"type": "address"
288+
},
289+
{
290+
"internalType": "address",
291+
"name": "permissionlessDisputeGame1",
292+
"type": "address"
293+
},
294+
{
295+
"internalType": "address",
296+
"name": "permissionlessDisputeGame2",
297+
"type": "address"
180298
}
181299
],
182300
"internalType": "struct OPContractsManager.Blueprints",
@@ -596,6 +714,11 @@
596714
"name": "InvalidChainId",
597715
"type": "error"
598716
},
717+
{
718+
"inputs": [],
719+
"name": "InvalidGameConfigs",
720+
"type": "error"
721+
},
599722
{
600723
"inputs": [
601724
{
@@ -622,6 +745,11 @@
622745
"name": "NotABlueprint",
623746
"type": "error"
624747
},
748+
{
749+
"inputs": [],
750+
"name": "OnlyDelegatecall",
751+
"type": "error"
752+
},
625753
{
626754
"inputs": [],
627755
"name": "ReservedBitsSet",

0 commit comments

Comments
 (0)