Skip to content

Commit

Permalink
build: deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Jun 22, 2024
1 parent bf385b6 commit df733e2
Show file tree
Hide file tree
Showing 9 changed files with 726 additions and 12 deletions.
18 changes: 11 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
ETH_RPC_URL=
AVAX_RPC_URL=https://api.avax.network/ext/bc/C/rpc
FTM_RPC_URL=https://rpcapi.fantom.network
ARBI_RPC_URL=https://arb1.arbitrum.io/rpc
GC_RPC_URL=https://xdai.poanetwork.dev
BSC_RPC_URL=https://bsc-dataseed.binance.org
MATIC_RPC_URL=
ETH_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/K2zwNCeLzhJtRf9vungUur-PdRWmIdBt
CHAIN=mainnet
WALLET_TYPE=local
L2_DEPLOYER=0x0000000000000000000000000000000000000000
L2_RPC_URL=
ROLLUP_ID=
L2_ADMIN=
L2_RISK_MANAGER=
L2_ESCROW_MANAGER=
L1_ESCROW_MANAGER=
PRIVATE_KEY=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ out/
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
broadcast/

# Docs
docs/
Expand Down
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
[submodule "lib/yearn-vaults-v3"]
path = lib/yearn-vaults-v3
url = https://github.com/yearn/yearn-vaults-v3
release = v3.0.2-1
[submodule "lib/forge-safe"]
path = lib/forge-safe
url = https://github.com/ind-igo/forge-safe
release = v3.0.2-1
1 change: 0 additions & 1 deletion lib/forge-safe
Submodule forge-safe deleted from 4ce820
81 changes: 81 additions & 0 deletions scripts/SetupDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;

import "forge-std/console.sol";
import {BatchScript, console2} from "./lib/BatchScript.sol";

import {L1Deployer, IPolygonRollupContract, IPolygonRollupManager} from "../src/L1Deployer.sol";
import {L2Deployer} from "../src/L2Deployer.sol";

contract SetupDeployer is BatchScript {

address public ZK_EVM_BRIDGE = 0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe;

L1Deployer public L1_DEPLOYER = L1Deployer(0x49dC846d5EDA92dDC4985b7B7BBaD4F9b05B7597);

address public safe;

function run() external {

// Get all args
address l2Deployer = vm.envAddress("L2_DEPLOYER");
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

if(l2Deployer == address(0)) {

console.log("Deploying an L2 Deployer...");

address l2Admin = vm.envAddress("L2_ADMIN");
require(l2Admin != address(0), "L2 Admin ZERO_ADDRESS");
address l2RiskManager = vm.envAddress("L2_RISK_MANAGER");
require(l2RiskManager != address(0), "L2 Risk Manager ZERO_ADDRESS");
address l2EscrowManager = vm.envAddress("L2_ESCROW_MANAGER");
require(l2EscrowManager != address(0), "L2 Escrow Manager ZERO_ADDRESS");

// Start L2 RPC
vm.createSelectFork(vm.envString("L2_RPC_URL"));

vm.startBroadcast(deployerPrivateKey);

// Deploy L2 Deployer
l2Deployer = address(new L2Deployer(
l2Admin,
address(L1_DEPLOYER),
l2RiskManager,
l2EscrowManager,
ZK_EVM_BRIDGE
));

vm.stopBroadcast();

console.log("L2 Deployer deployed to ", address(l2Deployer));
}

// Take L2 deployer address
// Start Mainnet RPC
vm.createSelectFork(vm.envString("ETH_RPC_URL"));

uint32 rollupID = uint32(vm.envUint("ROLLUP_ID"));
address l1EscrowManager = vm.envAddress("L1_ESCROW_MANAGER");

console.log("Registering Rollup with ID ", rollupID);
console.log("Using ", l2Deployer, " as the L2 Deployer");

require(L1_DEPLOYER.getRollupContract(rollupID) == address(0), "Already registered");

safe = L1_DEPLOYER.rollupManager()
.rollupIDToRollupData(rollupID)
.rollupContract.admin();

bytes memory txn = abi.encodeCall(
L1Deployer.testRegisterRollup,
(rollupID, address(l2Deployer), l1EscrowManager)
);

addToBatch(address(L1_DEPLOYER), txn);

executeBatch(safe, true);

require(L1_DEPLOYER.getRollupContract(rollupID) != address(0), "txn failed");
}
}
Loading

0 comments on commit df733e2

Please sign in to comment.