Commit 290dde27 authored by Matt Solomon's avatar Matt Solomon Committed by GitHub

OPSM: DeployOPChain assertions (#11943)

* chore: add BaseDeployIO for the deploy input and output contracts

* test: add assertions to DeployOPChain

* chore: semver lock

* pr feedback
parent 110a31db
......@@ -2,7 +2,6 @@
pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";
import { CommonBase } from "forge-std/Base.sol";
import { LibString } from "@solady/utils/LibString.sol";
......@@ -36,9 +35,10 @@ import { Blueprint } from "src/libraries/Blueprint.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { Solarray } from "scripts/libraries/Solarray.sol";
import { BaseDeployIO } from "scripts/utils/BaseDeployIO.sol";
// See DeploySuperchain.s.sol for detailed comments on the script architecture used here.
contract DeployImplementationsInput is CommonBase {
contract DeployImplementationsInput is BaseDeployIO {
bytes32 internal _salt;
uint256 internal _withdrawalDelaySeconds;
uint256 internal _minProposalSizeBytes;
......@@ -153,7 +153,7 @@ contract DeployImplementationsInput is CommonBase {
}
}
contract DeployImplementationsOutput {
contract DeployImplementationsOutput is BaseDeployIO {
OPStackManager internal _opsm;
DelayedWETH internal _delayedWETHImpl;
OptimismPortal2 internal _optimismPortalImpl;
......@@ -205,6 +205,8 @@ contract DeployImplementationsOutput {
address(this.disputeGameFactoryImpl())
);
DeployUtils.assertValidContractAddresses(addrs);
// TODO Also add the assertions for the implementation contracts from ChainAssertions.sol
}
function opsm() public returns (OPStackManager) {
......
......@@ -2,7 +2,6 @@
pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";
import { CommonBase } from "forge-std/Base.sol";
import { stdToml } from "forge-std/StdToml.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
......@@ -12,6 +11,7 @@ import { Proxy } from "src/universal/Proxy.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { Solarray } from "scripts/libraries/Solarray.sol";
import { BaseDeployIO } from "scripts/utils/BaseDeployIO.sol";
// This comment block defines the requirements and rationale for the architecture used in this forge
// script, along with other scripts that are being written as new Superchain-first deploy scripts to
......@@ -65,7 +65,10 @@ import { Solarray } from "scripts/libraries/Solarray.sol";
// - `doo` for DeployOPChainInput
// - `doo` for DeployOPChainOutput
// - etc.
contract DeploySuperchainInput is CommonBase {
// All contracts of the form `Deploy<X>Input` should inherit from `BaseDeployIO`, as it provides
// shared functionality for all deploy scripts, such as access to cheat codes.
contract DeploySuperchainInput is BaseDeployIO {
using stdToml for string;
// All inputs are set in storage individually. We put any roles first, followed by the remaining
......@@ -169,7 +172,9 @@ contract DeploySuperchainInput is CommonBase {
}
}
contract DeploySuperchainOutput is CommonBase {
// All contracts of the form `Deploy<X>Output` should inherit from `BaseDeployIO`, as it provides
// shared functionality for all deploy scripts, such as access to cheat codes.
contract DeploySuperchainOutput is BaseDeployIO {
// All outputs are stored in storage individually, with the same rationale as doing so for
// inputs, and the same pattern is used below to expose the outputs.
ProtocolVersions internal _protocolVersionsImpl;
......@@ -223,6 +228,8 @@ contract DeploySuperchainOutput is CommonBase {
require(actualSuperchainConfigImpl == address(_superchainConfigImpl), "100");
require(actualProtocolVersionsImpl == address(_protocolVersionsImpl), "200");
// TODO Also add the assertions for the implementation contracts from ChainAssertions.sol
}
function superchainProxyAdmin() public view returns (ProxyAdmin) {
......
......@@ -47,4 +47,14 @@ library DeployUtils {
}
}
}
// Asserts that for a given contract the value of a storage slot at an offset is 1. This
// is used to assert that a contract is initialized.
function assertInitialized(address _contractAddress, uint256 _slot, uint256 _offset) internal view {
bytes32 slotVal = vm.load(_contractAddress, bytes32(_slot));
require(
uint8((uint256(slotVal) >> (_offset * 8)) & 0xFF) == uint8(1),
"Storage value is not 1 at the given slot and offset"
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { CommonBase } from "forge-std/Base.sol";
/// @notice All contracts of the form `Deploy<X>Input` and `Deploy<X>Output` should inherit from this contract.
/// It provides a base set of functionality, such as access to cheat codes, that these scripts may need.
/// See the comments in `DeploySuperchain.s.sol` for more information on this pattern.
abstract contract BaseDeployIO is CommonBase { }
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