Commit 6cfa9b4e authored by Maurelian's avatar Maurelian Committed by GitHub

Deploy Cleanup: Make Artifacts stand alone and etch into global state (#13648)

* Make Artifacts stand alone and etch into global state

* fix the things

* Remove extra artifacts etch

* feat: label and allowCheatCodes on artifacts

feat: restore deploy config label

* fix typo

* fix import

* fix import
parent b9382028
......@@ -6,8 +6,7 @@ import { stdJson } from "forge-std/StdJson.sol";
import { Vm } from "forge-std/Vm.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Config } from "scripts/libraries/Config.sol";
import { StorageSlot } from "scripts/libraries/ForgeArtifacts.sol";
import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol";
import { ForgeArtifacts, StorageSlot } from "scripts/libraries/ForgeArtifacts.sol";
import { Process } from "scripts/libraries/Process.sol";
/// @notice Represents a deployment. Is serialized to JSON as a key/value
......@@ -21,7 +20,7 @@ struct Deployment {
/// @notice Useful for accessing deployment artifacts from within scripts.
/// When a contract is deployed, call the `save` function to write its name and
/// contract address to disk. Inspired by `forge-deploy`.
abstract contract Artifacts {
contract Artifacts {
/// @notice Foundry cheatcode VM.
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
......
......@@ -100,9 +100,9 @@ contract L2Genesis is Deployer {
function artifactDependencies() internal view returns (L1Dependencies memory l1Dependencies_) {
return L1Dependencies({
l1CrossDomainMessengerProxy: mustGetAddress("L1CrossDomainMessengerProxy"),
l1StandardBridgeProxy: mustGetAddress("L1StandardBridgeProxy"),
l1ERC721BridgeProxy: mustGetAddress("L1ERC721BridgeProxy")
l1CrossDomainMessengerProxy: artifacts.mustGetAddress("L1CrossDomainMessengerProxy"),
l1StandardBridgeProxy: artifacts.mustGetAddress("L1StandardBridgeProxy"),
l1ERC721BridgeProxy: artifacts.mustGetAddress("L1ERC721BridgeProxy")
});
}
......
......@@ -85,12 +85,12 @@ contract DeployOwnership is Deploy {
/// @notice Returns a GuardianConfig similar to that of the Guardian Safe on Mainnet.
function _getExampleGuardianConfig() internal view returns (GuardianConfig memory guardianConfig_) {
address[] memory exampleGuardianOwners = new address[](1);
exampleGuardianOwners[0] = mustGetAddress("SecurityCouncilSafe");
exampleGuardianOwners[0] = artifacts.mustGetAddress("SecurityCouncilSafe");
guardianConfig_ = GuardianConfig({
safeConfig: SafeConfig({ threshold: 1, owners: exampleGuardianOwners }),
deputyGuardianModuleConfig: DeputyGuardianModuleConfig({
deputyGuardian: mustGetAddress("FoundationOperationsSafe"),
superchainConfig: ISuperchainConfig(mustGetAddress("SuperchainConfigImpl"))
deputyGuardian: artifacts.mustGetAddress("FoundationOperationsSafe"),
superchainConfig: ISuperchainConfig(artifacts.mustGetAddress("SuperchainConfigImpl"))
})
});
}
......@@ -108,7 +108,7 @@ contract DeployOwnership is Deploy {
livenessInterval: 14 weeks,
thresholdPercentage: 75,
minOwners: 8,
fallbackOwner: mustGetAddress("FoundationUpgradeSafe")
fallbackOwner: artifacts.mustGetAddress("FoundationUpgradeSafe")
})
});
}
......@@ -174,14 +174,14 @@ contract DeployOwnership is Deploy {
);
addr_ = address(safeProxyFactory.createProxyWithNonce(address(safeSingleton), initData, uint256(salt)));
save(_name, addr_);
artifacts.save(_name, addr_);
console.log("New safe: %s deployed at %s\n Note that this safe is owned by the deployer key", _name, addr_);
}
/// @notice If the keepDeployer option was used with deploySafe(), this function can be used to remove the deployer.
/// Note this function does not have the broadcast modifier.
function removeDeployerFromSafe(string memory _name, uint256 _newThreshold) public {
Safe safe = Safe(mustGetAddress(_name));
Safe safe = Safe(artifacts.mustGetAddress(_name));
// The sentinel address is used to mark the start and end of the linked list of owners in the Safe.
address sentinelOwners = address(0x1);
......@@ -198,10 +198,10 @@ contract DeployOwnership is Deploy {
/// @notice Gets the address of the SafeProxyFactory and Safe singleton for use in deploying a new GnosisSafe.
function _getSafeFactory() internal returns (SafeProxyFactory safeProxyFactory_, Safe safeSingleton_) {
if (getAddress("SafeProxyFactory") != address(0)) {
if (artifacts.getAddress("SafeProxyFactory") != address(0)) {
// The SafeProxyFactory is already saved, we can just use it.
safeProxyFactory_ = SafeProxyFactory(getAddress("SafeProxyFactory"));
safeSingleton_ = Safe(getAddress("SafeSingleton"));
safeProxyFactory_ = SafeProxyFactory(artifacts.getAddress("SafeProxyFactory"));
safeSingleton_ = Safe(artifacts.getAddress("SafeSingleton"));
return (safeProxyFactory_, safeSingleton_);
}
......@@ -216,8 +216,8 @@ contract DeployOwnership is Deploy {
safeSingleton.code.length == 0 ? safeSingleton_ = new Safe() : safeSingleton_ = Safe(payable(safeSingleton));
save("SafeProxyFactory", address(safeProxyFactory_));
save("SafeSingleton", address(safeSingleton_));
artifacts.save("SafeProxyFactory", address(safeProxyFactory_));
artifacts.save("SafeSingleton", address(safeSingleton_));
}
/// @notice Deploys a Safe with a configuration similar to that of the Foundation Safe on Mainnet.
......@@ -245,18 +245,18 @@ contract DeployOwnership is Deploy {
/// @notice Deploy a LivenessGuard for use on the Security Council Safe.
/// Note this function does not have the broadcast modifier.
function deployLivenessGuard() public returns (address addr_) {
Safe councilSafe = Safe(payable(mustGetAddress("SecurityCouncilSafe")));
Safe councilSafe = Safe(payable(artifacts.mustGetAddress("SecurityCouncilSafe")));
addr_ = address(new LivenessGuard(councilSafe));
save("LivenessGuard", address(addr_));
artifacts.save("LivenessGuard", address(addr_));
console.log("New LivenessGuard deployed at %s", address(addr_));
}
/// @notice Deploy a LivenessModule for use on the Security Council Safe
/// Note this function does not have the broadcast modifier.
function deployLivenessModule() public returns (address addr_) {
Safe councilSafe = Safe(payable(mustGetAddress("SecurityCouncilSafe")));
address guard = mustGetAddress("LivenessGuard");
Safe councilSafe = Safe(payable(artifacts.mustGetAddress("SecurityCouncilSafe")));
address guard = artifacts.mustGetAddress("LivenessGuard");
LivenessModuleConfig memory livenessModuleConfig = _getExampleCouncilConfig().livenessModuleConfig;
addr_ = address(
......@@ -270,14 +270,14 @@ contract DeployOwnership is Deploy {
})
);
save("LivenessModule", address(addr_));
artifacts.save("LivenessModule", address(addr_));
console.log("New LivenessModule deployed at %s", address(addr_));
}
/// @notice Deploy a DeputyGuardianModule for use on the Security Council Safe.
/// Note this function does not have the broadcast modifier.
function deployDeputyGuardianModule() public returns (address addr_) {
Safe guardianSafe = Safe(payable(mustGetAddress("GuardianSafe")));
Safe guardianSafe = Safe(payable(artifacts.mustGetAddress("GuardianSafe")));
DeputyGuardianModuleConfig memory deputyGuardianModuleConfig =
_getExampleGuardianConfig().deputyGuardianModuleConfig;
addr_ = address(
......@@ -288,7 +288,7 @@ contract DeployOwnership is Deploy {
})
);
save("DeputyGuardianModule", addr_);
artifacts.save("DeputyGuardianModule", addr_);
console.log("New DeputyGuardianModule deployed at %s", addr_);
}
......@@ -310,7 +310,7 @@ contract DeployOwnership is Deploy {
function deployGuardianSafe() public broadcast returns (address addr_) {
// Config is hardcoded here as the Guardian Safe's configuration is inflexible.
address[] memory owners = new address[](1);
owners[0] = mustGetAddress("SecurityCouncilSafe");
owners[0] = artifacts.mustGetAddress("SecurityCouncilSafe");
addr_ = deploySafe({ _name: "GuardianSafe", _owners: owners, _threshold: 1, _keepDeployer: true });
console.log("Deployed and configured the Guardian Safe!");
......@@ -320,7 +320,7 @@ contract DeployOwnership is Deploy {
function deploySuperchainConfig() public broadcast {
ISuperchainConfig superchainConfig = ISuperchainConfig(
DeployUtils.create2AndSave({
_save: this,
_save: artifacts,
_salt: _implSalt(),
_name: "SuperchainConfig",
_nick: "SuperchainConfigImpl",
......@@ -335,7 +335,7 @@ contract DeployOwnership is Deploy {
/// @notice Configure the Guardian Safe with the DeputyGuardianModule.
function configureGuardianSafe() public broadcast returns (address addr_) {
addr_ = mustGetAddress("GuardianSafe");
addr_ = artifacts.mustGetAddress("GuardianSafe");
address deputyGuardianModule = deployDeputyGuardianModule();
_callViaSafe({
_safe: Safe(payable(addr_)),
......@@ -352,7 +352,7 @@ contract DeployOwnership is Deploy {
function configureSecurityCouncilSafe() public broadcast returns (address addr_) {
// Deploy and add the Deputy Guardian Module.
SecurityCouncilConfig memory exampleCouncilConfig = _getExampleCouncilConfig();
Safe safe = Safe(mustGetAddress("SecurityCouncilSafe"));
Safe safe = Safe(artifacts.mustGetAddress("SecurityCouncilSafe"));
// Deploy and add the Liveness Guard.
address guard = deployLivenessGuard();
......
......@@ -11,13 +11,19 @@ import { Process } from "scripts/libraries/Process.sol";
/// @title Deployer
/// @author tynes
/// @notice A contract that can make deploying and interacting with deployments easy.
abstract contract Deployer is Script, Artifacts {
abstract contract Deployer is Script {
DeployConfig public constant cfg =
DeployConfig(address(uint160(uint256(keccak256(abi.encode("optimism.deployconfig"))))));
Artifacts public constant artifacts =
Artifacts(address(uint160(uint256(keccak256(abi.encode("optimism.artifacts"))))));
/// @notice Sets up the artifacts contract.
function setUp() public virtual override {
Artifacts.setUp();
function setUp() public virtual {
vm.etch(address(artifacts), vm.getDeployedCode("Artifacts.s.sol:Artifacts"));
vm.label(address(cfg), "Artifacts");
vm.allowCheatcodes(address(artifacts));
artifacts.setUp();
console.log("Commit hash: %s", gitCommitHash());
......
......@@ -23,16 +23,21 @@ import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
/// @title DeployPeriphery
/// @notice Script used to deploy periphery contracts.
contract DeployPeriphery is Script, Artifacts {
contract DeployPeriphery is Script {
/// @notice Error emitted when an address mismatch is detected.
error AddressMismatch(string, address, address);
/// @notice Deployment configuration.
PeripheryDeployConfig cfg;
Artifacts public constant artifacts =
Artifacts(address(uint160(uint256(keccak256(abi.encode("optimism.artifacts"))))));
/// @notice Sets up the deployment script.
function setUp() public override {
Artifacts.setUp();
function setUp() public {
vm.etch(address(artifacts), vm.getDeployedCode("Artifacts.s.sol:Artifacts"));
artifacts.setUp();
cfg = new PeripheryDeployConfig(Config.deployConfigPath());
console.log("Config path: %s", Config.deployConfigPath());
}
......@@ -94,12 +99,12 @@ contract DeployPeriphery is Script, Artifacts {
addr_ = _deployCreate2({
_name: "FaucetProxy",
_creationCode: type(Proxy).creationCode,
_constructorParams: abi.encode(mustGetAddress("ProxyAdmin"))
_constructorParams: abi.encode(artifacts.mustGetAddress("ProxyAdmin"))
});
Proxy proxy = Proxy(payable(addr_));
require(
EIP1967Helper.getAdmin(address(proxy)) == mustGetAddress("ProxyAdmin"),
EIP1967Helper.getAdmin(address(proxy)) == artifacts.mustGetAddress("ProxyAdmin"),
"DeployPeriphery: FaucetProxy admin mismatch"
);
}
......@@ -206,9 +211,9 @@ contract DeployPeriphery is Script, Artifacts {
/// @notice Initialize the Faucet.
function initializeFaucet() public broadcast {
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address faucetProxy = mustGetAddress("FaucetProxy");
address faucet = mustGetAddress("Faucet");
ProxyAdmin proxyAdmin = ProxyAdmin(artifacts.mustGetAddress("ProxyAdmin"));
address faucetProxy = artifacts.mustGetAddress("FaucetProxy");
address faucet = artifacts.mustGetAddress("Faucet");
address implementationAddress = proxyAdmin.getProxyImplementation(faucetProxy);
if (implementationAddress == faucet) {
console.log("Faucet proxy implementation already set");
......@@ -225,7 +230,7 @@ contract DeployPeriphery is Script, Artifacts {
/// @notice Installs the OnChain AuthModule on the Faucet contract.
function installOnChainAuthModule() public broadcast {
_installAuthModule({
_faucet: Faucet(mustGetAddress("FaucetProxy")),
_faucet: Faucet(artifacts.mustGetAddress("FaucetProxy")),
_name: "OnChainAuthModule",
_config: Faucet.ModuleConfig({
name: "OnChainAuthModule",
......@@ -239,7 +244,7 @@ contract DeployPeriphery is Script, Artifacts {
/// @notice Installs the OffChain AuthModule on the Faucet contract.
function installOffChainAuthModule() public broadcast {
_installAuthModule({
_faucet: Faucet(mustGetAddress("FaucetProxy")),
_faucet: Faucet(artifacts.mustGetAddress("FaucetProxy")),
_name: "OffChainAuthModule",
_config: Faucet.ModuleConfig({
name: "OffChainAuthModule",
......@@ -252,7 +257,7 @@ contract DeployPeriphery is Script, Artifacts {
/// @notice Installs all of the auth modules in the faucet contract.
function installFaucetAuthModulesConfigs() public {
Faucet faucet = Faucet(mustGetAddress("FaucetProxy"));
Faucet faucet = Faucet(artifacts.mustGetAddress("FaucetProxy"));
console.log("Installing auth modules at %s", address(faucet));
installOnChainAuthModule();
installOffChainAuthModule();
......@@ -276,9 +281,9 @@ contract DeployPeriphery is Script, Artifacts {
address preComputedAddress = vm.computeCreate2Address(salt, keccak256(initCode));
if (preComputedAddress.code.length > 0) {
console.log("%s already deployed at %s", _name, preComputedAddress);
address savedAddress = getAddress(_name);
address savedAddress = artifacts.getAddress(_name);
if (savedAddress == address(0)) {
save(_name, preComputedAddress);
artifacts.save(_name, preComputedAddress);
} else if (savedAddress != preComputedAddress) {
revert AddressMismatch(_name, preComputedAddress, savedAddress);
}
......@@ -288,7 +293,7 @@ contract DeployPeriphery is Script, Artifacts {
addr_ := create2(0, add(initCode, 0x20), mload(initCode), salt)
}
require(addr_ != address(0), "DeployPeriphery: deployment failed");
save(_name, addr_);
artifacts.save(_name, addr_);
console.log("%s deployed at %s", _name, addr_);
}
}
......@@ -298,7 +303,7 @@ contract DeployPeriphery is Script, Artifacts {
/// @param _name The name of the auth module.
/// @param _config The configuration of the auth module.
function _installAuthModule(Faucet _faucet, string memory _name, Faucet.ModuleConfig memory _config) internal {
AdminFaucetAuthModule module = AdminFaucetAuthModule(mustGetAddress(_name));
AdminFaucetAuthModule module = AdminFaucetAuthModule(artifacts.mustGetAddress(_name));
if (_faucet.isModuleEnabled(module)) {
console.log("%s already installed.", _name);
} else {
......
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7567)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5567)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175677)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175722)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5144)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369309)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967471)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564458)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369264)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967493)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564413)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076606)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467070)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467092)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512819)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72667)
\ No newline at end of file
......@@ -57,7 +57,7 @@ contract DataAvailabilityChallengeTest is CommonTest {
// EntryPoint will revert if using amount > type(uint112).max.
vm.assume(sender != Preinstalls.EntryPoint_v060);
vm.assume(sender != address(dataAvailabilityChallenge));
vm.assume(sender != deploy.mustGetAddress("DataAvailabilityChallengeImpl"));
vm.assume(sender != artifacts.mustGetAddress("DataAvailabilityChallengeImpl"));
vm.deal(sender, amount);
vm.prank(sender);
......
......@@ -29,7 +29,7 @@ contract L1CrossDomainMessenger_Test is CommonTest {
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
function test_constructor_succeeds() external virtual {
IL1CrossDomainMessenger impl = IL1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessengerImpl"));
IL1CrossDomainMessenger impl = IL1CrossDomainMessenger(artifacts.mustGetAddress("L1CrossDomainMessengerImpl"));
assertEq(address(impl.superchainConfig()), address(0));
assertEq(address(impl.PORTAL()), address(0));
assertEq(address(impl.portal()), address(0));
......
......@@ -69,7 +69,7 @@ contract L1ERC721Bridge_Test is CommonTest {
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
function test_constructor_succeeds() public virtual {
IL1ERC721Bridge impl = IL1ERC721Bridge(deploy.mustGetAddress("L1ERC721BridgeImpl"));
IL1ERC721Bridge impl = IL1ERC721Bridge(artifacts.mustGetAddress("L1ERC721BridgeImpl"));
assertEq(address(impl.MESSENGER()), address(0));
assertEq(address(impl.messenger()), address(0));
assertEq(address(impl.superchainConfig()), address(0));
......
......@@ -38,7 +38,7 @@ contract L1StandardBridge_Initialize_Test is CommonTest {
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
function test_constructor_succeeds() external virtual {
IL1StandardBridge impl = IL1StandardBridge(deploy.mustGetAddress("L1StandardBridgeImpl"));
IL1StandardBridge impl = IL1StandardBridge(artifacts.mustGetAddress("L1StandardBridgeImpl"));
assertEq(address(impl.superchainConfig()), address(0));
// The constructor now uses _disableInitializers, whereas OP Mainnet has these values in storage
......
......@@ -42,7 +42,7 @@ contract OptimismPortal2_Test is CommonTest {
/// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol
function test_constructor_succeeds() external virtual {
IOptimismPortal2 opImpl = IOptimismPortal2(payable(deploy.mustGetAddress("OptimismPortal2Impl")));
IOptimismPortal2 opImpl = IOptimismPortal2(payable(artifacts.mustGetAddress("OptimismPortal2Impl")));
assertEq(address(opImpl.disputeGameFactory()), address(0));
assertEq(address(opImpl.systemConfig()), address(0));
assertEq(address(opImpl.superchainConfig()), address(0));
......
......@@ -28,7 +28,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
skipIfForkTest(
"ProtocolVersions_Initialize_Test: cannot test initialization on forked network against hardhat config"
);
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsImpl"));
IProtocolVersions protocolVersionsImpl = IProtocolVersions(artifacts.mustGetAddress("ProtocolVersionsImpl"));
address owner = deploy.cfg().finalSystemOwner();
assertEq(ProtocolVersion.unwrap(protocolVersions.required()), ProtocolVersion.unwrap(required));
......@@ -42,7 +42,7 @@ contract ProtocolVersions_Initialize_Test is ProtocolVersions_Init {
/// @dev Ensures that the events are emitted during initialization.
function test_initialize_events_succeeds() external {
IProtocolVersions protocolVersionsImpl = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsImpl"));
IProtocolVersions protocolVersionsImpl = IProtocolVersions(artifacts.mustGetAddress("ProtocolVersionsImpl"));
// Wipe out the initialized slot so the proxy can be initialized again
vm.store(address(protocolVersions), bytes32(0), bytes32(0));
......
......@@ -42,8 +42,8 @@ contract SystemConfig_Initialize_Test is SystemConfig_Init {
batcherHash = bytes32(uint256(uint160(deploy.cfg().batchSenderAddress())));
gasLimit = uint64(deploy.cfg().l2GenesisBlockGasLimit());
unsafeBlockSigner = deploy.cfg().p2pSequencerAddress();
systemConfigImpl = deploy.mustGetAddress("SystemConfigImpl");
optimismMintableERC20Factory = deploy.mustGetAddress("OptimismMintableERC20FactoryProxy");
systemConfigImpl = artifacts.mustGetAddress("SystemConfigImpl");
optimismMintableERC20Factory = artifacts.mustGetAddress("OptimismMintableERC20FactoryProxy");
}
/// @dev Tests that constructor sets the correct values.
......
......@@ -24,7 +24,7 @@ contract L2CrossDomainMessenger_Test is CommonTest {
/// @dev Tests that the implementation is initialized correctly.
function test_constructor_succeeds() external view {
IL2CrossDomainMessenger impl =
IL2CrossDomainMessenger(EIP1967Helper.getImplementation(deploy.mustGetAddress("L2CrossDomainMessenger")));
IL2CrossDomainMessenger(EIP1967Helper.getImplementation(artifacts.mustGetAddress("L2CrossDomainMessenger")));
assertEq(address(impl.OTHER_MESSENGER()), address(0));
assertEq(address(impl.otherMessenger()), address(0));
assertEq(address(impl.l1CrossDomainMessenger()), address(0));
......
......@@ -27,7 +27,7 @@ contract L2StandardBridge_Test is CommonTest {
/// @dev Test that the bridge's constructor sets the correct values.
function test_constructor_succeeds() external view {
IL2StandardBridge impl =
IL2StandardBridge(payable(EIP1967Helper.getImplementation(deploy.mustGetAddress("L2StandardBridge"))));
IL2StandardBridge(payable(EIP1967Helper.getImplementation(artifacts.mustGetAddress("L2StandardBridge"))));
// The implementation contract is initialized with a 0 L1 bridge address,
// but the L2 cross-domain-messenger is always set to the predeploy address for both proxy and implementation.
assertEq(address(impl.MESSENGER()), Predeploys.L2_CROSS_DOMAIN_MESSENGER, "constructor zero check MESSENGER");
......
......@@ -106,7 +106,7 @@ contract PredeploysBaseTest is CommonTest {
}
if (_isInitializable(addr)) {
assertEq(l2Genesis.loadInitializedSlot({ _sourceName: cname, _deploymentName: cname }), uint8(1));
assertEq(artifacts.loadInitializedSlot({ _sourceName: cname, _deploymentName: cname }), uint8(1));
}
}
}
......
......@@ -43,8 +43,8 @@ contract DeployOwnershipTest is Test, DeployOwnership {
/// @dev Test the example Foundation Safe configurations, against the expected configuration, and
/// check that they both have the same configuration.
function test_exampleFoundationSafes_configuration_succeeds() public {
Safe upgradeSafe = Safe(payable(mustGetAddress("FoundationUpgradeSafe")));
Safe operationsSafe = Safe(payable(mustGetAddress("FoundationOperationsSafe")));
Safe upgradeSafe = Safe(payable(artifacts.mustGetAddress("FoundationUpgradeSafe")));
Safe operationsSafe = Safe(payable(artifacts.mustGetAddress("FoundationOperationsSafe")));
SafeConfig memory exampleFoundationConfig = _getExampleFoundationConfig();
// Ensure the safes both match the example configuration
......@@ -58,13 +58,13 @@ contract DeployOwnershipTest is Test, DeployOwnership {
/// @dev Test the example Security Council Safe configuration.
function test_exampleSecurityCouncilSafe_configuration_succeeds() public {
Safe securityCouncilSafe = Safe(payable(mustGetAddress("SecurityCouncilSafe")));
Safe securityCouncilSafe = Safe(payable(artifacts.mustGetAddress("SecurityCouncilSafe")));
SecurityCouncilConfig memory exampleSecurityCouncilConfig = _getExampleCouncilConfig();
_checkSafeConfig(exampleSecurityCouncilConfig.safeConfig, securityCouncilSafe);
// Guard Checks
address livenessGuard = mustGetAddress("LivenessGuard");
address livenessGuard = artifacts.mustGetAddress("LivenessGuard");
// The Safe's getGuard method is internal, so we read directly from storage
// https://github.com/safe-global/safe-contracts/blob/v1.4.0/contracts/base/GuardManager.sol#L66-L72
......@@ -77,7 +77,7 @@ contract DeployOwnershipTest is Test, DeployOwnership {
}
// Module Checks
address livenessModule = mustGetAddress("LivenessModule");
address livenessModule = artifacts.mustGetAddress("LivenessModule");
(address[] memory modules, address nextModule) =
ModuleManager(securityCouncilSafe).getModulesPaginated(SENTINEL_MODULES, 2);
assertEq(modules.length, 1);
......@@ -97,14 +97,14 @@ contract DeployOwnershipTest is Test, DeployOwnership {
/// @dev Test the example Guardian Safe configuration.
function test_exampleGuardianSafe_configuration_succeeds() public view {
Safe guardianSafe = Safe(payable(mustGetAddress("GuardianSafe")));
Safe guardianSafe = Safe(payable(artifacts.mustGetAddress("GuardianSafe")));
address[] memory owners = new address[](1);
owners[0] = mustGetAddress("SecurityCouncilSafe");
owners[0] = artifacts.mustGetAddress("SecurityCouncilSafe");
GuardianConfig memory guardianConfig = _getExampleGuardianConfig();
_checkSafeConfig(guardianConfig.safeConfig, guardianSafe);
// DeputyGuardianModule checks
address deputyGuardianModule = mustGetAddress("DeputyGuardianModule");
address deputyGuardianModule = artifacts.mustGetAddress("DeputyGuardianModule");
(address[] memory modules, address nextModule) =
ModuleManager(guardianSafe).getModulesPaginated(SENTINEL_MODULES, 2);
assertEq(modules.length, 1);
......
......@@ -57,21 +57,25 @@ contract ForkLive is Deployer {
// Superchain shared contracts
saveProxyAndImpl("SuperchainConfig", superchainToml, ".superchain_config_addr");
saveProxyAndImpl("ProtocolVersions", superchainToml, ".protocol_versions_addr");
save("OPContractsManager", vm.parseTomlAddress(superchainToml, ".op_contracts_manager_proxy_addr"));
artifacts.save("OPContractsManager", vm.parseTomlAddress(superchainToml, ".op_contracts_manager_proxy_addr"));
// Core contracts
save("ProxyAdmin", vm.parseTomlAddress(opToml, ".addresses.ProxyAdmin"));
artifacts.save("ProxyAdmin", vm.parseTomlAddress(opToml, ".addresses.ProxyAdmin"));
saveProxyAndImpl("SystemConfig", opToml, ".addresses.SystemConfigProxy");
// Bridge contracts
address optimismPortal = vm.parseTomlAddress(opToml, ".addresses.OptimismPortalProxy");
save("OptimismPortalProxy", optimismPortal);
save("OptimismPortal2Impl", EIP1967Helper.getImplementation(optimismPortal));
artifacts.save("OptimismPortalProxy", optimismPortal);
artifacts.save("OptimismPortal2Impl", EIP1967Helper.getImplementation(optimismPortal));
address addressManager = vm.parseTomlAddress(opToml, ".addresses.AddressManager");
save("AddressManager", addressManager);
save("L1CrossDomainMessengerImpl", IAddressManager(addressManager).getAddress("OVM_L1CrossDomainMessenger"));
save("L1CrossDomainMessengerProxy", vm.parseTomlAddress(opToml, ".addresses.L1CrossDomainMessengerProxy"));
artifacts.save("AddressManager", addressManager);
artifacts.save(
"L1CrossDomainMessengerImpl", IAddressManager(addressManager).getAddress("OVM_L1CrossDomainMessenger")
);
artifacts.save(
"L1CrossDomainMessengerProxy", vm.parseTomlAddress(opToml, ".addresses.L1CrossDomainMessengerProxy")
);
saveProxyAndImpl("OptimismMintableERC20Factory", opToml, ".addresses.OptimismMintableERC20FactoryProxy");
saveProxyAndImpl("L1StandardBridge", opToml, ".addresses.L1StandardBridgeProxy");
saveProxyAndImpl("L1ERC721Bridge", opToml, ".addresses.L1ERC721BridgeProxy");
......@@ -82,16 +86,17 @@ contract ForkLive is Deployer {
saveProxyAndImpl("DelayedWETH", opToml, ".addresses.DelayedWETHProxy");
// Fault proof non-proxied contracts
save("PreimageOracle", vm.parseTomlAddress(opToml, ".addresses.PreimageOracle"));
save("MipsSingleton", vm.parseTomlAddress(opToml, ".addresses.MIPS"));
IDisputeGameFactory disputeGameFactory = IDisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
save("FaultDisputeGame", vm.parseTomlAddress(opToml, ".addresses.FaultDisputeGame"));
artifacts.save("PreimageOracle", vm.parseTomlAddress(opToml, ".addresses.PreimageOracle"));
artifacts.save("MipsSingleton", vm.parseTomlAddress(opToml, ".addresses.MIPS"));
IDisputeGameFactory disputeGameFactory =
IDisputeGameFactory(artifacts.mustGetAddress("DisputeGameFactoryProxy"));
artifacts.save("FaultDisputeGame", vm.parseTomlAddress(opToml, ".addresses.FaultDisputeGame"));
// The PermissionedDisputeGame and PermissionedDelayedWETHProxy are not listed in the registry for OP, so we
// look it up onchain
IFaultDisputeGame permissionedDisputeGame =
IFaultDisputeGame(address(disputeGameFactory.gameImpls(GameTypes.PERMISSIONED_CANNON)));
save("PermissionedDisputeGame", address(permissionedDisputeGame));
save("PermissionedDelayedWETHProxy", address(permissionedDisputeGame.weth()));
artifacts.save("PermissionedDisputeGame", address(permissionedDisputeGame));
artifacts.save("PermissionedDelayedWETHProxy", address(permissionedDisputeGame.weth()));
}
/// @notice Saves the proxy and implementation addresses for a contract name
......@@ -100,9 +105,9 @@ contract ForkLive is Deployer {
/// @param _tomlKey The key in the superchain config file to get the proxy address
function saveProxyAndImpl(string memory _contractName, string memory _tomlPath, string memory _tomlKey) internal {
address proxy = vm.parseTomlAddress(_tomlPath, _tomlKey);
save(string.concat(_contractName, "Proxy"), proxy);
artifacts.save(string.concat(_contractName, "Proxy"), proxy);
address impl = EIP1967Helper.getImplementation(proxy);
require(impl != address(0), "Upgrade: Implementation address is zero");
save(string.concat(_contractName, "Impl"), impl);
artifacts.save(string.concat(_contractName, "Impl"), impl);
}
}
......@@ -11,7 +11,7 @@ import { ForkLive } from "test/setup/ForkLive.s.sol";
import { Fork, LATEST_FORK } from "scripts/libraries/Config.sol";
import { L2Genesis, L1Dependencies } from "scripts/L2Genesis.s.sol";
import { OutputMode, Fork, ForkUtils } from "scripts/libraries/Config.sol";
import { Artifacts } from "scripts/Artifacts.s.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
import { Preinstalls } from "src/libraries/Preinstalls.sol";
......@@ -65,6 +65,11 @@ contract Setup {
/// mutating any nonces. MUST not have constructor logic.
Deploy internal constant deploy = Deploy(address(uint160(uint256(keccak256(abi.encode("optimism.deploy"))))));
/// @notice The address of the Artifacts contract. Set into state by Deployer.setUp() with `etch` to avoid
/// mutating any nonces. MUST not have constructor logic.
Artifacts public constant artifacts =
Artifacts(address(uint160(uint256(keccak256(abi.encode("optimism.artifacts"))))));
L2Genesis internal constant l2Genesis =
L2Genesis(address(uint160(uint256(keccak256(abi.encode("optimism.l2genesis"))))));
......@@ -149,7 +154,7 @@ contract Setup {
// deploy.setUp() will either:
// 1. deploy a fresh system or
// 2. fork from L1
// It will then save the appropriate name/address pairs to disk using Artifacts.save()
// It will then save the appropriate name/address pairs to disk using artifacts.save()
deploy.setUp();
console.log("Setup: L1 setup done!");
......@@ -197,26 +202,26 @@ contract Setup {
deploy.run();
console.log("Setup: completed L1 deployment, registering addresses now");
optimismPortal2 = IOptimismPortal2(deploy.mustGetAddress("OptimismPortalProxy"));
systemConfig = ISystemConfig(deploy.mustGetAddress("SystemConfigProxy"));
l1StandardBridge = IL1StandardBridge(deploy.mustGetAddress("L1StandardBridgeProxy"));
l1CrossDomainMessenger = IL1CrossDomainMessenger(deploy.mustGetAddress("L1CrossDomainMessengerProxy"));
optimismPortal2 = IOptimismPortal2(artifacts.mustGetAddress("OptimismPortalProxy"));
systemConfig = ISystemConfig(artifacts.mustGetAddress("SystemConfigProxy"));
l1StandardBridge = IL1StandardBridge(artifacts.mustGetAddress("L1StandardBridgeProxy"));
l1CrossDomainMessenger = IL1CrossDomainMessenger(artifacts.mustGetAddress("L1CrossDomainMessengerProxy"));
vm.label(
AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)), "L1CrossDomainMessengerProxy_aliased"
);
addressManager = IAddressManager(deploy.mustGetAddress("AddressManager"));
l1ERC721Bridge = IL1ERC721Bridge(deploy.mustGetAddress("L1ERC721BridgeProxy"));
addressManager = IAddressManager(artifacts.mustGetAddress("AddressManager"));
l1ERC721Bridge = IL1ERC721Bridge(artifacts.mustGetAddress("L1ERC721BridgeProxy"));
l1OptimismMintableERC20Factory =
IOptimismMintableERC20Factory(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
protocolVersions = IProtocolVersions(deploy.mustGetAddress("ProtocolVersionsProxy"));
superchainConfig = ISuperchainConfig(deploy.mustGetAddress("SuperchainConfigProxy"));
anchorStateRegistry = IAnchorStateRegistry(deploy.mustGetAddress("AnchorStateRegistryProxy"));
disputeGameFactory = IDisputeGameFactory(deploy.mustGetAddress("DisputeGameFactoryProxy"));
delayedWeth = IDelayedWETH(deploy.mustGetAddress("DelayedWETHProxy"));
IOptimismMintableERC20Factory(artifacts.mustGetAddress("OptimismMintableERC20FactoryProxy"));
protocolVersions = IProtocolVersions(artifacts.mustGetAddress("ProtocolVersionsProxy"));
superchainConfig = ISuperchainConfig(artifacts.mustGetAddress("SuperchainConfigProxy"));
anchorStateRegistry = IAnchorStateRegistry(artifacts.mustGetAddress("AnchorStateRegistryProxy"));
disputeGameFactory = IDisputeGameFactory(artifacts.mustGetAddress("DisputeGameFactoryProxy"));
delayedWeth = IDelayedWETH(artifacts.mustGetAddress("DelayedWETHProxy"));
if (deploy.cfg().useAltDA()) {
dataAvailabilityChallenge =
IDataAvailabilityChallenge(deploy.mustGetAddress("DataAvailabilityChallengeProxy"));
IDataAvailabilityChallenge(artifacts.mustGetAddress("DataAvailabilityChallengeProxy"));
}
console.log("Setup: registered L1 deployments");
}
......
......@@ -33,7 +33,7 @@ contract OptimismMintableTokenFactory_Test is CommonTest {
/// @notice Tests that the upgrade is successful.
function test_upgrading_succeeds() external {
IProxy proxy = IProxy(deploy.mustGetAddress("OptimismMintableERC20FactoryProxy"));
IProxy proxy = IProxy(artifacts.mustGetAddress("OptimismMintableERC20FactoryProxy"));
// Check an unused slot before upgrading.
bytes32 slot21Before = vm.load(address(l1OptimismMintableERC20Factory), bytes32(uint256(21)));
assertEq(bytes32(0), slot21Before);
......
......@@ -57,7 +57,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "SuperchainConfigImpl",
target: deploy.mustGetAddress("SuperchainConfigImpl"),
target: artifacts.mustGetAddress("SuperchainConfigImpl"),
initCalldata: abi.encodeCall(superchainConfig.initialize, (address(0), false))
})
);
......@@ -73,7 +73,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "L1CrossDomainMessengerImpl",
target: deploy.mustGetAddress("L1CrossDomainMessengerImpl"),
target: artifacts.mustGetAddress("L1CrossDomainMessengerImpl"),
initCalldata: abi.encodeCall(
l1CrossDomainMessenger.initialize, (superchainConfig, optimismPortal2, systemConfig)
)
......@@ -93,7 +93,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "DisputeGameFactoryImpl",
target: deploy.mustGetAddress("DisputeGameFactoryImpl"),
target: artifacts.mustGetAddress("DisputeGameFactoryImpl"),
initCalldata: abi.encodeCall(disputeGameFactory.initialize, (address(0)))
})
);
......@@ -109,7 +109,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "DelayedWETHImpl",
target: deploy.mustGetAddress("DelayedWETHImpl"),
target: artifacts.mustGetAddress("DelayedWETHImpl"),
initCalldata: abi.encodeCall(delayedWeth.initialize, (address(0), ISuperchainConfig(address(0))))
})
);
......@@ -125,7 +125,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "OptimismPortal2Impl",
target: deploy.mustGetAddress("OptimismPortal2Impl"),
target: artifacts.mustGetAddress("OptimismPortal2Impl"),
initCalldata: abi.encodeCall(
optimismPortal2.initialize,
(
......@@ -157,7 +157,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "SystemConfigImpl",
target: deploy.mustGetAddress("SystemConfigImpl"),
target: artifacts.mustGetAddress("SystemConfigImpl"),
initCalldata: abi.encodeCall(
systemConfig.initialize,
(
......@@ -229,7 +229,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "ProtocolVersionsImpl",
target: deploy.mustGetAddress("ProtocolVersionsImpl"),
target: artifacts.mustGetAddress("ProtocolVersionsImpl"),
initCalldata: abi.encodeCall(
protocolVersions.initialize, (address(0), ProtocolVersion.wrap(1), ProtocolVersion.wrap(2))
)
......@@ -249,7 +249,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "L1StandardBridgeImpl",
target: deploy.mustGetAddress("L1StandardBridgeImpl"),
target: artifacts.mustGetAddress("L1StandardBridgeImpl"),
initCalldata: abi.encodeCall(
l1StandardBridge.initialize, (l1CrossDomainMessenger, superchainConfig, systemConfig)
)
......@@ -269,7 +269,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "L1ERC721BridgeImpl",
target: deploy.mustGetAddress("L1ERC721BridgeImpl"),
target: artifacts.mustGetAddress("L1ERC721BridgeImpl"),
initCalldata: abi.encodeCall(l1ERC721Bridge.initialize, (l1CrossDomainMessenger, superchainConfig))
})
);
......@@ -285,7 +285,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "OptimismMintableERC20FactoryImpl",
target: deploy.mustGetAddress("OptimismMintableERC20FactoryImpl"),
target: artifacts.mustGetAddress("OptimismMintableERC20FactoryImpl"),
initCalldata: abi.encodeCall(l1OptimismMintableERC20Factory.initialize, (address(l1StandardBridge)))
})
);
......@@ -301,7 +301,7 @@ contract Initializer_Test is CommonTest {
contracts.push(
InitializeableContract({
name: "DataAvailabilityChallengeImpl",
target: deploy.mustGetAddress("DataAvailabilityChallengeImpl"),
target: artifacts.mustGetAddress("DataAvailabilityChallengeImpl"),
initCalldata: abi.encodeCall(dataAvailabilityChallenge.initialize, (address(0), 0, 0, 0, 0))
})
);
......@@ -418,7 +418,7 @@ contract Initializer_Test is CommonTest {
string memory deploymentName = _getRealContractName(_contract.name);
// Grab the value of the "initialized" storage slot.
uint8 initializedSlotVal = deploy.loadInitializedSlot({
uint8 initializedSlotVal = artifacts.loadInitializedSlot({
_sourceName: _removeSuffix(deploymentName),
_deploymentName: deploymentName
});
......
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