Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ contract DeployConfig is Script {

bool public useInterop;

address public systemConfigProxy;
address public l1CrossDomainMessengerProxy;

function read(string memory _path) public {
console.log("DeployConfig: reading file %s", _path);
try vm.readFile(_path) returns (string memory data) {
Expand Down Expand Up @@ -174,6 +177,9 @@ contract DeployConfig is Script {
customGasTokenAddress = _readOr(_json, "$.customGasTokenAddress", address(0));

useInterop = _readOr(_json, "$.useInterop", false);

l1CrossDomainMessengerProxy = stdJson.readAddress(_json, "$.l1CrossDomainMessengerProxy");
systemConfigProxy = stdJson.readAddress(_json, "$.systemConfigProxy");
}

function fork() public view returns (Fork fork_) {
Expand Down
166 changes: 166 additions & 0 deletions packages/contracts-bedrock/scripts/DeployDedicatedBridge.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { VmSafe } from "forge-std/Vm.sol";
import { Script } from "forge-std/Script.sol";

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

import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol";

import { Deploy } from "scripts/Deploy.s.sol";

import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { DedicatedBridge } from "src/universal/DedicatedBridge.sol";
import { L1DedicatedBridge } from "src/L1/L1DedicatedBridge.sol";
import { L1DedicatedUSDCBridge } from "src/L1/L1DedicatedUSDCBridge.sol";
import { L2DedicatedBridge } from "src/L2/L2DedicatedBridge.sol";
import { L1ChugSplashProxy } from "src/legacy/L1ChugSplashProxy.sol";
import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol";
import { SuperchainConfig } from "src/L1/SuperchainConfig.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { Proxy } from "src/universal/Proxy.sol";


import "src/dispute/lib/Types.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";

/// @title DeployDedicatedBridge
/// @notice Script used to deploy a dedicated bridge.
contract DeployDedicatedBridge is Deploy {
using stdJson for string;


////////////////////////////////////////////////////////////////
// High Level Deployment Functions //
////////////////////////////////////////////////////////////////

/// @notice Deploy L1 dedicated bridge
function runL1DedicatedBridgeDeployment(address _otherBridge, address _l1Token, address _l2Token) public {
console.log("Deploying L1 Dedicated bridge");

deploySafe("SystemOwnerSafe");

// Deploy a new ProxyAdmin and AddressManager
// This proxy will be used on the SuperchainConfig and ProtocolVersions contracts, as well as the contracts
// in the OP Chain system.
deployAddressManager();
deployProxyAdmin();
transferProxyAdminOwnership();

// Deploy the SuperchainConfigProxy
deployERC1967Proxy("SuperchainConfigProxy");
deploySuperchainConfig();
initializeSuperchainConfig();

deployL1DedicatedBridgeProxy();
transferAddressManagerOwnership(); // to the ProxyAdmin
deployL1DedicatedBridge();
initializeL1DedicatedBridge(_otherBridge, _l1Token, _l2Token);
console.log("Done!");
}

////////////////////////////////////////////////////////////////
// Proxy Deployment Functions //
////////////////////////////////////////////////////////////////

/// @notice Deploy the L1DedicatedBridgeProxy using a ChugSplashProxy
function deployL1DedicatedBridgeProxy() public broadcast returns (address addr_) {
console.log("Deploying proxy for L1DedicatedUSDCBridge");
address proxyAdmin = mustGetAddress("ProxyAdmin");
L1ChugSplashProxy proxy = new L1ChugSplashProxy(proxyAdmin);

require(EIP1967Helper.getAdmin(address(proxy)) == proxyAdmin);

save("L1DedicatedBridgeProxy", address(proxy));
console.log("L1DedicatedBridgeProxy deployed at %s", address(proxy));
addr_ = address(proxy);
}

/// @notice Deploy the L2DedicatedBridgeProxy using a Proxy
function deployL2DedicatedBridgeProxy() public returns (address addr_) {
console.log("Deploying proxy for L2DedicatedBridge");
addr_ = deployERC1967ProxyWithOwner("L2DedicatedBridgeProxy", msg.sender);
}

/// @notice Deploy the L1DedicatedUSDCBridge
function deployL1DedicatedBridge() public broadcast returns (address addr_) {
console.log("Deploying L1DedicatedUSDCBridge implementation");

L1DedicatedUSDCBridge bridge = new L1DedicatedUSDCBridge{ salt: _implSalt() }();

save("L1DedicatedUSDCBridge", address(bridge));
console.log("L1DedicatedUSDCBridge deployed at %s", address(bridge));

addr_ = address(bridge);
}

/// @notice Deploy the L2DedicatedBridge
function deployL2DedicatedBridge() public broadcast returns (address addr_) {
console.log("Deploying L2DedicatedBridge implementation");

L2DedicatedBridge bridge = new L2DedicatedBridge{ salt: _implSalt() }();

save("L2DedicatedBridge", address(bridge));
console.log("L2DedicatedBridge deployed at %s", address(bridge));

addr_ = address(bridge);
}

////////////////////////////////////////////////////////////////
// Initialize Functions //
////////////////////////////////////////////////////////////////

/// @notice Initialize the L1DedicatedUSDCBridge
function initializeL1DedicatedBridge(address _otherBridge, address _l1Token, address _l2Token) public broadcast {
console.log("Upgrading and initializing L1DedicatedUSDCBridge proxy");
ProxyAdmin proxyAdmin = ProxyAdmin(mustGetAddress("ProxyAdmin"));
address l1DedicatedBridgeProxy = mustGetAddress("L1DedicatedBridgeProxy");

uint256 proxyType = uint256(proxyAdmin.proxyType(l1DedicatedBridgeProxy));
Safe safe = Safe(mustGetAddress("SystemOwnerSafe"));
if (proxyType != uint256(ProxyAdmin.ProxyType.CHUGSPLASH)) {
_callViaSafe({
_safe: safe,
_target: address(proxyAdmin),
_data: abi.encodeCall(ProxyAdmin.setProxyType, (l1DedicatedBridgeProxy, ProxyAdmin.ProxyType.CHUGSPLASH))
});
}
require(uint256(proxyAdmin.proxyType(l1DedicatedBridgeProxy)) == uint256(ProxyAdmin.ProxyType.CHUGSPLASH));

_upgradeAndCallViaSafe({
_proxy: payable(l1DedicatedBridgeProxy),
_implementation: mustGetAddress("L1DedicatedUSDCBridge"),
_innerCallData: abi.encodeCall(
L1DedicatedBridge.initialize,
(
L1CrossDomainMessenger(cfg.l1CrossDomainMessengerProxy()),
SuperchainConfig(mustGetAddress("SuperchainConfigProxy")),
SystemConfig(cfg.systemConfigProxy()),
_otherBridge,
_l1Token,
_l2Token
)
)
});

string memory version = L1DedicatedUSDCBridge(payable(l1DedicatedBridgeProxy)).version();
console.log("L1DedicatedUSDCBridge version: %s", version);
}

/// @notice Initialize the L2DedicatedBridge
function initializeL2DedicatedBridge(
address _proxy,
address _implementation,
address _otherBridge,
address _l1Token,
address _l2Token
)
public
broadcast
{
bytes memory _data = abi.encodeCall(L2DedicatedBridge.initialize, (_otherBridge, _l1Token, _l2Token));
Proxy(payable(_proxy)).upgradeToAndCall(_implementation, _data);
}
}
46 changes: 46 additions & 0 deletions packages/contracts-bedrock/scripts/usdc_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
DEPLOY_CONFIG_PATH="deploy-config/usdc-sepolia-devnet.json"
USDC_L1_ADDRESS=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
USDC_L2_ADDRESS=0x85977F663949E5AC21334F2219E2B4048EF74A80

# source .env for PRIVATE_KEY
source ../.env

export IMPL_SALT="avocado magnetico salato"

L1_VERIFIER_URL=https://eth-sepolia.blockscout.com/api\?
L2_VERIFIER_URL=https://sepolia-blockscout.lisk.com/api\?

# L1_RPC_URL=wss://ethereum-sepolia-rpc.publicnode.com
# L2_RPC_URL=https://rpc.sepolia-api.lisk.com

L1_RPC_URL=http://localhost:8545
L2_RPC_URL=http://localhost:8546

# outputs L2DedicatedBridgeProxy
forge script -vvv DeployDedicatedBridge.s.sol:DeployDedicatedBridge --sig 'deployL2DedicatedBridgeProxy()' --rpc-url "$L2_RPC_URL" --broadcast --private-key $PRIVATE_KEY
L2DedicatedBridgeProxy=$(cat ../deployments/4202-deploy.json | grep -Eo '"L2DedicatedBridgeProxy": "(\d*?,|.*?[^\\])"' | awk -F'"' '{print $4}' )

# outputs USDC_L1_BRIDGE_PROXY and USDC_L1_BRIDGE_DEPLOYMENT
forge script -vvv DeployDedicatedBridge.s.sol:DeployDedicatedBridge $L2DedicatedBridgeProxy $USDC_L1_ADDRESS $USDC_L2_ADDRESS --sig 'runL1DedicatedBridgeDeployment(address,address,address)' --rpc-url "$L1_RPC_URL" --broadcast --private-key $PRIVATE_KEY
L1DedicatedBridgeProxy=$(cat ../deployments/11155111-deploy.json | grep -Eo '"L1DedicatedBridgeProxy": "(\d*?,|.*?[^\\])"' | awk -F'"' '{print $4}' )
L1DedicatedUSDCBridge=$(cat ../deployments/11155111-deploy.json | grep -Eo '"L1DedicatedUSDCBridge": "(\d*?,|.*?[^\\])"' | awk -F'"' '{print $4}' )


# outputs USDC_L2_BRIDGE_DEPLOYMENT
forge script -vvv DeployDedicatedBridge.s.sol:DeployDedicatedBridge --sig 'deployL2DedicatedBridge()' --rpc-url "$L2_RPC_URL" --broadcast --private-key $PRIVATE_KEY
L2DedicatedBridge=$(cat ../deployments/4202-deploy.json | grep -Eo '"L2DedicatedBridge": "(\d*?,|.*?[^\\])"' | awk -F'"' '{print $4}' )

forge script -vvv DeployDedicatedBridge.s.sol:DeployDedicatedBridge $L2DedicatedBridgeProxy $L2DedicatedBridge $L1DedicatedBridgeProxy $USDC_L1_ADDRESS $USDC_L2_ADDRESS --sig 'initializeL2DedicatedBridge(address,address,address,address,address)' --rpc-url "$L2_RPC_URL" --broadcast --private-key $PRIVATE_KEY


# forge verify-contract $USDC_L1_BRIDGE_DEPLOYMENT src/L1/L1DedicatedUSDCBridge.sol:L1DedicatedUSDCBridge --compiler-version 0.8.15 --rpc-url "$L1_RPC_URL" --verifier blockscout --verifier-url $L1_VERIFIER_URL
# forge verify-contract $USDC_L2_BRIDGE_DEPLOYMENT src/L2/L2DedicatedBridge.sol:L2DedicatedBridge --compiler-version 0.8.15 --rpc-url "$L2_RPC_URL" --verifier blockscout --verifier-url $L2_VERIFIER_URL




echo "All done!"
echo "L1DedicatedBridgeProxy", $L1DedicatedBridgeProxy
echo "L1DedicatedUSDCBridge", $L1DedicatedUSDCBridge
echo "L2DedicatedBridgeProxy", $L2DedicatedBridgeProxy
echo "L2DedicatedBridge", $L2DedicatedBridge
Loading