Skip to content

Commit 71c612a

Browse files
wip
1 parent 5e3fc2e commit 71c612a

38 files changed

+2864
-179
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@ workflows:
24412441
- main
24422442
- OPTIMISM_PORTAL_INTEROP
24432443
- CANNON_KONA,DEPLOY_V2_DISPUTE_GAMES
2444+
- OPCM_V2
24442445
context:
24452446
- circleci-repo-readonly-authenticated-github-token
24462447
requires:

.semgrep/rules/sol-rules.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,14 @@ rules:
383383
# LegacyMintableERC20 and the corresponding interface use legacy naming conventions.
384384
- packages/contracts-bedrock/src/legacy/LegacyMintableERC20.sol
385385
- packages/contracts-bedrock/interfaces/legacy/ILegacyMintableERC20Full.sol
386+
387+
- id: sol-safety-loadorbuildproxy-false-requires-todo
388+
languages: [generic]
389+
severity: ERROR
390+
message: _loadOrBuildProxy calls with false as _mustLoad parameter must include inline TODO on the same line
391+
patterns:
392+
- pattern: _loadOrBuildProxy(..., false)
393+
- pattern-not: _loadOrBuildProxy(..., false // TODO(...))
394+
paths:
395+
include:
396+
- packages/contracts-bedrock/src

op-chain-ops/addresses/contracts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type ImplementationsContracts struct {
4949
AnchorStateRegistryImpl common.Address
5050
FaultDisputeGameV2Impl common.Address
5151
PermissionedDisputeGameV2Impl common.Address
52+
StorageSetterImpl common.Address
5253
}
5354

5455
// OpChainContracts struct contains all the contracts for a specific L2 OpChain

op-chain-ops/interopgen/deployments.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Implementations struct {
1717
OpcmUpgrader common.Address `json:"OPCMUpgrader"`
1818
OpcmInteropMigrator common.Address `json:"OPCMInteropMigrator"`
1919
OpcmStandardValidator common.Address `json:"OPCMStandardValidator"`
20+
OpcmV2 common.Address `json:"OPCMV2"`
2021
DelayedWETHImpl common.Address `json:"DelayedWETHImpl"`
2122
OptimismPortalImpl common.Address `json:"OptimismPortalImpl"`
2223
OptimismPortalInteropImpl common.Address `json:"OptimismPortalInteropImpl"`
@@ -36,6 +37,7 @@ type Implementations struct {
3637
PermissionedDisputeGameV2Impl common.Address `json:"PermissionedDisputeGameV2Impl"`
3738
SuperFaultDisputeGameImpl common.Address `json:"SuperFaultDisputeGameImpl"`
3839
SuperPermissionedDisputeGameImpl common.Address `json:"SuperPermissionedDisputeGameImpl"`
40+
StorageSetterImpl common.Address `json:"StorageSetterImpl"`
3941
}
4042

4143
type SuperchainDeployment struct {

op-deployer/pkg/deployer/opcm/implementations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type DeployImplementationsOutput struct {
3535
OpcmUpgrader common.Address `json:"opcmUpgraderAddress"`
3636
OpcmInteropMigrator common.Address `json:"opcmInteropMigratorAddress"`
3737
OpcmStandardValidator common.Address `json:"opcmStandardValidatorAddress"`
38+
OpcmV2 common.Address `json:"opcmV2Address" abi:"opcmV2"`
3839
DelayedWETHImpl common.Address `json:"delayedWETHImplAddress"`
3940
OptimismPortalImpl common.Address `json:"optimismPortalImplAddress"`
4041
OptimismPortalInteropImpl common.Address `json:"optimismPortalInteropImplAddress"`
@@ -54,6 +55,7 @@ type DeployImplementationsOutput struct {
5455
PermissionedDisputeGameV2Impl common.Address `json:"permissionedDisputeGameV2ImplAddress"`
5556
SuperFaultDisputeGameImpl common.Address `json:"superFaultDisputeGameImplAddress"`
5657
SuperPermissionedDisputeGameImpl common.Address `json:"superPermissionedDisputeGameImplAddress"`
58+
StorageSetterImpl common.Address `json:"storageSetterImplAddress"`
5759
}
5860

5961
type DeployImplementationsScript script.DeployScriptWithOutput[DeployImplementationsInput, DeployImplementationsOutput]

op-deployer/pkg/deployer/pipeline/implementations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func DeployImplementations(env *Env, intent *state.Intent, st *state.State) erro
8989
AnchorStateRegistryImpl: dio.AnchorStateRegistryImpl,
9090
FaultDisputeGameV2Impl: dio.FaultDisputeGameV2Impl,
9191
PermissionedDisputeGameV2Impl: dio.PermissionedDisputeGameV2Impl,
92+
StorageSetterImpl: dio.StorageSetterImpl,
9293
}
9394

9495
return nil

packages/contracts-bedrock/foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ compilation_restrictions = [
2929
{ paths = "src/L1/OPContractsManager.sol", optimizer_runs = 5000 },
3030
{ paths = "src/L1/OPContractsManagerStandardValidator.sol", optimizer_runs = 5000 },
3131
{ paths = "src/L1/OptimismPortal2.sol", optimizer_runs = 5000 },
32-
{ paths = "src/L1/ProtocolVersions.sol", optimizer_runs = 5000 }
32+
{ paths = "src/L1/ProtocolVersions.sol", optimizer_runs = 5000 },
33+
{ paths = "src/universal/StorageSetter.sol", optimizer_runs = 5000 }
3334
]
3435

3536
extra_output = ['devdoc', 'userdoc', 'metadata', 'storageLayout']

packages/contracts-bedrock/interfaces/L1/IOPContractsManager.sol

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IL1ERC721Bridge } from "interfaces/L1/IL1ERC721Bridge.sol";
2323
import { IL1StandardBridge } from "interfaces/L1/IL1StandardBridge.sol";
2424
import { IOptimismMintableERC20Factory } from "interfaces/universal/IOptimismMintableERC20Factory.sol";
2525
import { IETHLockbox } from "interfaces/L1/IETHLockbox.sol";
26+
import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
2627
import { IOPContractsManagerStandardValidator } from "interfaces/L1/IOPContractsManagerStandardValidator.sol";
2728

2829
interface IOPContractsManagerContractsContainer {
@@ -126,6 +127,117 @@ interface IOPContractsManagerInteropMigrator {
126127
function migrate(MigrateInput calldata _input) external;
127128
}
128129

130+
interface IOPContractsManagerV2 {
131+
/// @notice Dispute game configuration for a specific game type.
132+
struct DisputeGameConfig {
133+
bool enabled;
134+
uint256 initBond;
135+
GameType gameType;
136+
bytes gameArgs;
137+
}
138+
139+
/// @notice Addresses of the deployed and wired contracts for an OP Chain.
140+
struct ChainContracts {
141+
ISystemConfig systemConfig;
142+
IProxyAdmin proxyAdmin;
143+
IAddressManager addressManager;
144+
IL1CrossDomainMessenger l1CrossDomainMessenger;
145+
IL1ERC721Bridge l1ERC721Bridge;
146+
IL1StandardBridge l1StandardBridge;
147+
IOptimismPortal2 optimismPortal;
148+
IETHLockbox ethLockbox;
149+
IOptimismMintableERC20Factory optimismMintableERC20Factory;
150+
IDisputeGameFactory disputeGameFactory;
151+
IAnchorStateRegistry anchorStateRegistry;
152+
IDelayedWETH delayedWETH;
153+
}
154+
155+
/// @notice Full configuration for deploying a new OP Chain.
156+
struct FullConfig {
157+
string saltMixer;
158+
ISuperchainConfig superchainConfig;
159+
address proxyAdminOwner;
160+
address systemConfigOwner;
161+
address unsafeBlockSigner;
162+
address batcher;
163+
Proposal startingAnchorRoot;
164+
GameType startingRespectedGameType;
165+
uint32 basefeeScalar;
166+
uint32 blobBasefeeScalar;
167+
uint64 gasLimit;
168+
uint256 l2ChainId;
169+
IResourceMetering.ResourceConfig resourceConfig;
170+
uint256 disputeMaxGameDepth;
171+
uint256 disputeSplitDepth;
172+
Duration disputeClockExtension;
173+
Duration disputeMaxClockDuration;
174+
DisputeGameConfig[] disputeGameConfigs;
175+
}
176+
177+
/// @notice Input for upgrading an existing OP Chain.
178+
struct UpgradeInput {
179+
ISystemConfig systemConfig;
180+
DisputeGameConfig[] disputeGameConfigs;
181+
}
182+
183+
/// @notice Emitted when a proxy is created.
184+
event ProxyCreation(string name, address proxy);
185+
186+
/// @notice Errors surfaced by OPContractsManagerV2.
187+
error AddressHasNoCode(address who);
188+
error BytesArrayTooLong();
189+
error DeploymentFailed();
190+
error EmptyInitcode();
191+
error IdentityPrecompileCallFailed();
192+
error NotABlueprint();
193+
error OPContractsManagerV2_InvalidGameConfigs();
194+
error OPContractsManagerV2_ProxyLoadBadError();
195+
error OPContractsManagerV2_ProxyLoadBadReturn();
196+
error OPContractsManagerV2_ProxyLoadNeedsGas();
197+
error OPContractsManagerV2_ProxyLogOnlySelf();
198+
error OPContractsManagerV2_ProxyMustLoad();
199+
error OPContractsManagerV2_SuperchainConfigNeedsUpgrade();
200+
error OPContractsManagerV2_UnsupportedGameType();
201+
error OPContractsManager_InvalidGameType();
202+
error ReservedBitsSet();
203+
error SemverComp_InvalidSemverParts();
204+
error UnexpectedPreambleData(bytes data);
205+
error UnsupportedERCVersion(uint8 version);
206+
207+
/// @notice Pseudo-constructor for CREATE2 deployment via an external deployer.
208+
function __constructor__(IOPContractsManagerContractsContainer _container) external;
209+
210+
/// @notice Deploys and wires a complete OP Chain per the provided configuration.
211+
function deploy(FullConfig memory _cfg) external returns (ChainContracts memory);
212+
213+
/// @notice Upgrades contracts on an existing OP Chain per the provided input.
214+
function upgrade(UpgradeInput memory _inp) external returns (ChainContracts memory);
215+
216+
/// @notice Returns the contracts container used by this manager.
217+
function contractsContainer() external view returns (IOPContractsManagerContractsContainer);
218+
219+
/// @notice Returns the blueprint contract addresses used for deployment.
220+
function blueprints() external view returns (IOPContractsManager.Blueprints memory);
221+
222+
/// @notice Returns the implementation contract addresses used for wiring proxies.
223+
function implementations() external view returns (IOPContractsManager.Implementations memory);
224+
225+
/// @notice Retrieves the development feature bitmap stored in this contract.
226+
function devFeatureBitmap() external view returns (bytes32);
227+
228+
/// @notice Returns whether a development feature is enabled.
229+
function isDevFeatureEnabled(bytes32 _feature) external view returns (bool);
230+
231+
/// @notice Computes the L1 batch inbox address for an L2 chain ID.
232+
function chainIdToBatchInboxAddress(uint256 _l2ChainId) external pure returns (address);
233+
234+
/// @notice Asserts an address is a deployed contract address.
235+
function assertValidContractAddress(address _who) external view;
236+
237+
/// @notice Emits a ProxyCreation event for a new proxy (internal tooling hook).
238+
function logProxyCreation(string calldata _name, address _proxy) external;
239+
}
240+
129241
interface IOPContractsManager {
130242
// -------- Structs --------
131243

@@ -216,6 +328,7 @@ interface IOPContractsManager {
216328
address permissionedDisputeGameV2Impl;
217329
address superFaultDisputeGameImpl;
218330
address superPermissionedDisputeGameImpl;
331+
address storageSetterImpl;
219332
}
220333

221334
/// @notice The input required to identify a chain for upgrading.
@@ -302,6 +415,10 @@ interface IOPContractsManager {
302415

303416
error InvalidDevFeatureAccess(bytes32 devFeature);
304417

418+
error MissingPermissionedDisputeGame();
419+
420+
event Deployed(uint256 indexed l2ChainId, address indexed deployer, bytes deployOutput);
421+
305422
// -------- Methods --------
306423

307424
function __constructor__(
@@ -310,6 +427,7 @@ interface IOPContractsManager {
310427
IOPContractsManagerUpgrader _opcmUpgrader,
311428
IOPContractsManagerInteropMigrator _opcmInteropMigrator,
312429
IOPContractsManagerStandardValidator _opcmStandardValidator,
430+
IOPContractsManagerV2 _opcmV2,
313431
ISuperchainConfig _superchainConfig,
314432
IProtocolVersions _protocolVersions
315433
)
@@ -391,6 +509,8 @@ interface IOPContractsManager {
391509

392510
function opcmStandardValidator() external view returns (IOPContractsManagerStandardValidator);
393511

512+
function opcmV2() external view returns (IOPContractsManagerV2);
513+
394514
/// @notice Retrieves the development feature bitmap stored in this OPCM contract
395515
/// @return The development feature bitmap.
396516
function devFeatureBitmap() external view returns (bytes32);

packages/contracts-bedrock/interfaces/L1/ISystemConfig.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface ISystemConfig is IProxyAdminOwnedBase {
2323
address l1StandardBridge;
2424
address optimismPortal;
2525
address optimismMintableERC20Factory;
26+
address delayedWETH;
2627
}
2728

2829
error ReinitializableBase_ZeroInitVersion();
@@ -39,6 +40,7 @@ interface ISystemConfig is IProxyAdminOwnedBase {
3940
function L1_STANDARD_BRIDGE_SLOT() external view returns (bytes32);
4041
function OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT() external view returns (bytes32);
4142
function OPTIMISM_PORTAL_SLOT() external view returns (bytes32);
43+
function DELAYED_WETH_SLOT() external view returns (bytes32);
4244
function START_BLOCK_SLOT() external view returns (bytes32);
4345
function UNSAFE_BLOCK_SIGNER_SLOT() external view returns (bytes32);
4446
function VERSION() external view returns (uint256);
@@ -76,6 +78,7 @@ interface ISystemConfig is IProxyAdminOwnedBase {
7678
function operatorFeeScalar() external view returns (uint32);
7779
function minBaseFee() external view returns (uint64);
7880
function daFootprintGasScalar() external view returns (uint16);
81+
function delayedWETH() external view returns (address addr_);
7982
function optimismMintableERC20Factory() external view returns (address addr_);
8083
function optimismPortal() external view returns (address addr_);
8184
function overhead() external view returns (uint256);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
interface IStorageSetter {
5+
struct Slot {
6+
bytes32 key;
7+
bytes32 value;
8+
}
9+
10+
function version() external view returns (string memory);
11+
function setBytes32(bytes32 _slot, bytes32 _value) external;
12+
function setBytes32(Slot[] calldata _slots) external;
13+
function getBytes32(bytes32 _slot) external view returns (bytes32 value_);
14+
function setUint(bytes32 _slot, uint256 _value) external;
15+
function getUint(bytes32 _slot) external view returns (uint256 value_);
16+
function setAddress(bytes32 _slot, address _address) external;
17+
function getAddress(bytes32 _slot) external view returns (address addr_);
18+
function setBool(bytes32 _slot, bool _value) external;
19+
function getBool(bytes32 _slot) external view returns (bool value_);
20+
21+
function __constructor__() external;
22+
}

0 commit comments

Comments
 (0)