Skip to content

Commit

Permalink
Merge branch 'develop' into feat/optimize_get_task_1
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao authored Sep 21, 2023
2 parents 83aefa6 + 4d903bc commit 38b62e7
Show file tree
Hide file tree
Showing 9 changed files with 763 additions and 18 deletions.
66 changes: 66 additions & 0 deletions contracts/scripts/foundry/DeployL1ScrollOwner.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;

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

import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";

import {ScrollOwner} from "../../src/misc/ScrollOwner.sol";

// solhint-disable state-visibility
// solhint-disable var-name-mixedcase

contract DeployL1ScrollOwner is Script {
string NETWORK = vm.envString("NETWORK");

uint256 L1_DEPLOYER_PRIVATE_KEY = vm.envUint("L1_DEPLOYER_PRIVATE_KEY");

address SCROLL_MULTISIG_ADDR = vm.envAddress("L1_SCROLL_MULTISIG_ADDR");

address SECURITY_COUNCIL_ADDR = vm.envAddress("L1_SECURITY_COUNCIL_ADDR");

address L1_PROPOSAL_EXECUTOR_ADDR = vm.envAddress("L1_PROPOSAL_EXECUTOR_ADDR");

function run() external {
vm.startBroadcast(L1_DEPLOYER_PRIVATE_KEY);

deployScrollOwner();

if (keccak256(abi.encodePacked(NETWORK)) == keccak256(abi.encodePacked("sepolia"))) {
// for sepolia
deployTimelockController("1D", 1 minutes);
deployTimelockController("7D", 7 minutes);
deployTimelockController("14D", 14 minutes);
} else if (keccak256(abi.encodePacked(NETWORK)) == keccak256(abi.encodePacked("mainnet"))) {
// for mainnet
deployTimelockController("1D", 1 days);
deployTimelockController("7D", 7 days);
deployTimelockController("14D", 14 days);
}

vm.stopBroadcast();
}

function deployScrollOwner() internal {
ScrollOwner owner = new ScrollOwner();

logAddress("L1_SCROLL_OWNER_ADDR", address(owner));
}

function deployTimelockController(string memory label, uint256 delay) internal {
address[] memory proposers = new address[](1);
address[] memory executors = new address[](1);

proposers[0] = SCROLL_MULTISIG_ADDR;
executors[0] = L1_PROPOSAL_EXECUTOR_ADDR;

TimelockController timelock = new TimelockController(delay, proposers, executors, SECURITY_COUNCIL_ADDR);

logAddress(string(abi.encodePacked("L1_", label, "_TIMELOCK_ADDR")), address(timelock));
}

function logAddress(string memory name, address addr) internal view {
console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr)))));
}
}
49 changes: 49 additions & 0 deletions contracts/scripts/foundry/DeployL2RateLimiter.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;

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

import {ScrollGatewayBase} from "../../src/libraries/gateway/ScrollGatewayBase.sol";
import {ScrollMessengerBase} from "../../src/libraries/ScrollMessengerBase.sol";

import {ETHRateLimiter} from "../../src/rate-limiter/ETHRateLimiter.sol";
import {TokenRateLimiter} from "../../src/rate-limiter/TokenRateLimiter.sol";

contract DeployL2RateLimiter is Script {
uint256 L2_DEPLOYER_PRIVATE_KEY = vm.envUint("L2_DEPLOYER_PRIVATE_KEY");

address L2_SCROLL_MESSENGER_PROXY_ADDR = vm.envAddress("L2_SCROLL_MESSENGER_PROXY_ADDR");

uint256 RATE_LIMITER_PERIOD_LENGTH = vm.envUint("RATE_LIMITER_PERIOD_LENGTH");
uint104 ETH_TOTAL_LIMIT = uint104(vm.envUint("ETH_TOTAL_LIMIT"));

function run() external {
vm.startBroadcast(L2_DEPLOYER_PRIVATE_KEY);

deployETHRateLimiter();
deployTokenRateLimiter();

vm.stopBroadcast();
}

function deployETHRateLimiter() internal {
ETHRateLimiter limiter = new ETHRateLimiter(
RATE_LIMITER_PERIOD_LENGTH,
L2_SCROLL_MESSENGER_PROXY_ADDR,
ETH_TOTAL_LIMIT
);

logAddress("L2_ETH_RATE_LIMITER_ADDR", address(limiter));
}

function deployTokenRateLimiter() internal {
TokenRateLimiter limiter = new TokenRateLimiter(RATE_LIMITER_PERIOD_LENGTH);

logAddress("L2_TOKEN_RATE_LIMITER_ADDR", address(limiter));
}

function logAddress(string memory name, address addr) internal view {
console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr)))));
}
}
66 changes: 66 additions & 0 deletions contracts/scripts/foundry/DeployL2ScrollOwner.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;

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

import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";

import {ScrollOwner} from "../../src/misc/ScrollOwner.sol";

// solhint-disable state-visibility
// solhint-disable var-name-mixedcase

contract DeployL2ScrollOwner is Script {
string NETWORK = vm.envString("NETWORK");

uint256 L2_DEPLOYER_PRIVATE_KEY = vm.envUint("L2_DEPLOYER_PRIVATE_KEY");

address SCROLL_MULTISIG_ADDR = vm.envAddress("L2_SCROLL_MULTISIG_ADDR");

address SECURITY_COUNCIL_ADDR = vm.envAddress("L2_SECURITY_COUNCIL_ADDR");

address L2_PROPOSAL_EXECUTOR_ADDR = vm.envAddress("L2_PROPOSAL_EXECUTOR_ADDR");

function run() external {
vm.startBroadcast(L2_DEPLOYER_PRIVATE_KEY);

deployScrollOwner();

if (keccak256(abi.encodePacked(NETWORK)) == keccak256(abi.encodePacked("sepolia"))) {
// for sepolia
deployTimelockController("1D", 1 minutes);
deployTimelockController("7D", 7 minutes);
deployTimelockController("14D", 14 minutes);
} else if (keccak256(abi.encodePacked(NETWORK)) == keccak256(abi.encodePacked("mainnet"))) {
// for mainnet
deployTimelockController("1D", 1 days);
deployTimelockController("7D", 7 days);
deployTimelockController("14D", 14 days);
}

vm.stopBroadcast();
}

function deployScrollOwner() internal {
ScrollOwner owner = new ScrollOwner();

logAddress("L2_SCROLL_OWNER_ADDR", address(owner));
}

function deployTimelockController(string memory label, uint256 delay) internal {
address[] memory proposers = new address[](1);
address[] memory executors = new address[](1);

proposers[0] = SCROLL_MULTISIG_ADDR;
executors[0] = L2_PROPOSAL_EXECUTOR_ADDR;

TimelockController timelock = new TimelockController(delay, proposers, executors, SECURITY_COUNCIL_ADDR);

logAddress(string(abi.encodePacked("L2_", label, "_TIMELOCK_ADDR")), address(timelock));
}

function logAddress(string memory name, address addr) internal view {
console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr)))));
}
}
Loading

0 comments on commit 38b62e7

Please sign in to comment.