Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions script/DeployRehearsalContracts.s.sol
Original file line number Diff line number Diff line change
@@ -1,61 +1,69 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// Importing necessary contracts and libraries
import {Deployer} from "@eth-optimism-bedrock/scripts/Deployer.sol";
import {GnosisSafe} from "safe-contracts/GnosisSafe.sol";
import {ProxyAdmin} from "@eth-optimism-bedrock/src/universal/ProxyAdmin.sol";
import {Proxy} from "@eth-optimism-bedrock/src/universal/Proxy.sol";
import {EIP1967Helper} from "@eth-optimism-bedrock/test/mocks/EIP1967Helper.sol";
import {Script} from "forge-std/Script.sol";

// Importing console utility for logging
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary? the code itself is pretty self-explanatory

import {console2 as console} from "forge-std/console2.sol";

// forge script scripts/Deploy.s.sol:Deploy --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL
// forge script scripts/Deploy.s.sol:Deploy --sig 'sync()' --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

// Contract declaration
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel this comment is useful. WDYT?

contract DeployRehearsalContracts is Deployer {
// State variables to manage contract ownership and proxy administration
GnosisSafe owner_safe;
GnosisSafe council_safe;
ProxyAdmin proxy_admin;

/// @notice The name of the script, used to ensure the right deploy artifacts
/// are used.
/// @notice Overridden to specify the script name for deployment artifacts
function name() public pure override returns (string memory name_) {
name_ = "DeployRehearsalContracts";
}

// Initial setup function
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel this comment is useful. WDYT?

function setUp() public override {
super.setUp();

// Initializing GnosisSafe contracts for owner and council
owner_safe = GnosisSafe(payable(vm.envAddress("OWNER_SAFE")));
council_safe = GnosisSafe(payable(vm.envAddress("COUNCIL_SAFE")));

require(owner_safe.isOwner(address(council_safe)));
// Ensuring council_safe is an owner of owner_safe
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for adding that new error message. With that being added, I don't think we need to also add this comment any more?

require(owner_safe.isOwner(address(council_safe)), "Council safe is not an owner of the owner safe");

// Logging deployment details
console.log("Deploying from %s", deployScript);
console.log("Deployment context: %s", deploymentContext);
}

// Main function to orchestrate contract deployment and ownership transfer
function run() public {
console.log("Deploying contracts for rehearsal");
deployProxyAdmin();
deployL1ERC721BridgeProxy();
deployOptimismPortalProxy();
transferProxyAdmin();
// todo: ensure that the necessary artifacts are still saved.
// TODO: Ensure necessary artifacts are saved
// sync();
}

// Function to deploy a ProxyAdmin contract
function deployProxyAdmin() public broadcast {
ProxyAdmin admin = new ProxyAdmin({_owner: msg.sender});
require(admin.owner() == msg.sender);
require(admin.owner() == msg.sender, "Deployer is not the owner of the ProxyAdmin");
save("ProxyAdmin", address(admin));
console.log("ProxyAdmin deployed at %s", address(admin));
proxy_admin = admin;
}

// Function to deploy a L1ERC721BridgeProxy contract
function deployL1ERC721BridgeProxy() public broadcast {
Proxy proxy = new Proxy({_admin: address(proxy_admin)});
require(EIP1967Helper.getAdmin(address(proxy)) == address(proxy_admin));
require(EIP1967Helper.getAdmin(address(proxy)) == address(proxy_admin), "ProxyAdmin is not the admin of the proxy");

address reusedOldL1ERC721Bridge = 0x3268Ed09f76e619331528270B6267D4d2C5Ab5C2;
proxy_admin.upgrade(payable(proxy), reusedOldL1ERC721Bridge);
Expand All @@ -64,9 +72,10 @@ contract DeployRehearsalContracts is Deployer {
console.log("L1ERC721BridgeProxy deployed at %s", address(proxy));
}

// Function to deploy an OptimismPortalProxy contract
function deployOptimismPortalProxy() public broadcast {
Proxy proxy = new Proxy({_admin: address(proxy_admin)});
require(EIP1967Helper.getAdmin(address(proxy)) == address(proxy_admin));
require(EIP1967Helper.getAdmin(address(proxy)) == address(proxy_admin), "ProxyAdmin is not the admin of the proxy");

address reusedOldOptimismPortal = 0x28a55488fef40005309e2DA0040DbE9D300a64AB;
proxy_admin.upgrade(payable(proxy), reusedOldOptimismPortal);
Expand All @@ -75,6 +84,7 @@ contract DeployRehearsalContracts is Deployer {
console.log("OptimismPortalProxy deployed at %s", address(proxy));
}

// Function to transfer ownership of ProxyAdmin to owner_safe
function transferProxyAdmin() public broadcast {
address new_owner = address(owner_safe);

Expand All @@ -84,7 +94,7 @@ contract DeployRehearsalContracts is Deployer {
}
}

/// @notice Modifier that wraps a function in broadcasting.
/// @notice Modifier for broadcasting function calls
modifier broadcast() {
vm.startBroadcast();
_;
Expand Down