Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Thegaram committed Aug 30, 2024
1 parent 3b5ddcd commit 4ad655b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 112 deletions.
8 changes: 4 additions & 4 deletions docs/manual-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This repository requires `node` version>=20.12.2, `yarn` and `foundry` to be pre

### Config

1. Create directory `volume` on the root directory of the repo (all config file will be put or generated under this directory)
1. Create directory `volume` on the root directory of the repo (all config files will be put or generated under this directory)

```bash
mkdir volume
Expand All @@ -26,8 +26,8 @@ mkdir volume
cp ./docker/config-example.toml ./volume/config.toml
```

If you've previously launched Scroll chain cocomponents using Scroll-SDK, you may already have a config.toml file. If so directly copy it to `./volume/config.toml`.
**Important Note: If you are launching a scroll chain through scroll-sdk, make sure this config.toml file stay same as the one used in scroll-sdk.**
If you've previously launched Scroll chain components using Scroll-SDK, you may already have a `config.toml` file. If so directly copy it to `./volume/config.toml`.
**Important Note: If you are launching a scroll chain through scroll-sdk, make sure this config.toml file is the same as the one used in scroll-sdk.**

Details about the some important variables you may want to change:

Expand Down Expand Up @@ -73,7 +73,7 @@ export L1_RPC_ENDPOINT=http://l1-devnet.scrollsdk
export L2_RPC_ENDPOINT=http://l2-rpc.scrollsdk
```

4. Generate predicted contract addresses (This step required mainly because we are checking if every contracts deployed as we expected)
1. Generate predicted contract addresses (This step is required mainly because we check if each contract is deployed as we expected)

```bash
forge script scripts/deterministic/DeployScroll.s.sol:DeployScroll --sig "run(string,string)" "none" "write-config"
Expand Down
173 changes: 65 additions & 108 deletions scripts/deterministic/DeployScroll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ contract DeployScroll is DeterminsticDeployment {
}
}

function transferOwnership(address addr, address newOwner) private {
if (Ownable(addr).owner() != newOwner) {
Ownable(addr).transferOwnership(newOwner);
}
}

function deployAllContracts() private {
deployL1Contracts1stPass();
deployL2Contracts1stPass();
Expand Down Expand Up @@ -726,6 +732,8 @@ contract DeployScroll is DeterminsticDeployment {
10**28 // _amount
);

// deploy gas token contract on L1,
// note: if an override address is configured, then we will use that instead
L1_GAS_TOKEN_ADDR = deploy("L1_GAS_TOKEN", type(GasTokenExample).creationCode, args);
}

Expand Down Expand Up @@ -1202,6 +1210,7 @@ contract DeployScroll is DeterminsticDeployment {
if (!ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).isSequencer(L1_COMMIT_SENDER_ADDR)) {
ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).addSequencer(L1_COMMIT_SENDER_ADDR);
}

if (!ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).isProver(L1_FINALIZE_SENDER_ADDR)) {
ScrollChain(L1_SCROLL_CHAIN_PROXY_ADDR).addProver(L1_FINALIZE_SENDER_ADDR);
}
Expand All @@ -1216,6 +1225,7 @@ contract DeployScroll is DeterminsticDeployment {
16 // _nonZeroGas
);
}

if (L2GasPriceOracle(L2_GAS_PRICE_ORACLE_PROXY_ADDR).whitelist() != L1_WHITELIST_ADDR) {
L2GasPriceOracle(L2_GAS_PRICE_ORACLE_PROXY_ADDR).updateWhitelist(L1_WHITELIST_ADDR);
}
Expand Down Expand Up @@ -1268,11 +1278,13 @@ contract DeployScroll is DeterminsticDeployment {

function initializeL1GatewayRouter() private {
address L2_ETH_GATEWAY_COUNTERPART;

if (ALTERNATIVE_GAS_TOKEN_ENABLED) {
L2_ETH_GATEWAY_COUNTERPART = L1_GAS_TOKEN_GATEWAY_PROXY_ADDR;
} else {
L2_ETH_GATEWAY_COUNTERPART = L1_ETH_GATEWAY_PROXY_ADDR;
}

if (getInitializeCount(L1_GATEWAY_ROUTER_PROXY_ADDR) == 0) {
L1GatewayRouter(L1_GATEWAY_ROUTER_PROXY_ADDR).initialize(
notnull(L2_ETH_GATEWAY_COUNTERPART),
Expand Down Expand Up @@ -1341,20 +1353,20 @@ contract DeployScroll is DeterminsticDeployment {
}

// set WETH gateway in router
{
address[] memory _tokens = new address[](1);
_tokens[0] = notnull(L1_WETH_ADDR);
address[] memory _gateways = new address[](1);
_gateways[0] = notnull(L1_WETH_GATEWAY_PROXY_ADDR);
if (L1GatewayRouter(L1_GATEWAY_ROUTER_PROXY_ADDR).ERC20Gateway(_tokens[0]) != _gateways[0]) {
L1GatewayRouter(L1_GATEWAY_ROUTER_PROXY_ADDR).setERC20Gateway(_tokens, _gateways);
}
address[] memory _tokens = new address[](1);
_tokens[0] = notnull(L1_WETH_ADDR);
address[] memory _gateways = new address[](1);
_gateways[0] = notnull(L1_WETH_GATEWAY_PROXY_ADDR);

if (L1GatewayRouter(L1_GATEWAY_ROUTER_PROXY_ADDR).ERC20Gateway(_tokens[0]) != _gateways[0]) {
L1GatewayRouter(L1_GATEWAY_ROUTER_PROXY_ADDR).setERC20Gateway(_tokens, _gateways);
}
}

function initializeL1Whitelist() private {
address[] memory accounts = new address[](1);
accounts[0] = L1_GAS_ORACLE_SENDER_ADDR;

if (!Whitelist(L1_WHITELIST_ADDR).isSenderAllowed(accounts[0])) {
Whitelist(L1_WHITELIST_ADDR).updateWhitelistStatus(accounts, true);
}
Expand Down Expand Up @@ -1394,53 +1406,25 @@ contract DeployScroll is DeterminsticDeployment {
}

function transferL1ContractOwnership() private {
if (Ownable(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_ERC1155_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_ERC1155_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_ERC721_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_ERC721_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (!ALTERNATIVE_GAS_TOKEN_ENABLED && Ownable(L1_ETH_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_ETH_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_GATEWAY_ROUTER_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_GATEWAY_ROUTER_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_MESSAGE_QUEUE_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_MESSAGE_QUEUE_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_SCROLL_MESSENGER_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_SCROLL_MESSENGER_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (!ALTERNATIVE_GAS_TOKEN_ENABLED && Ownable(L1_WETH_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_WETH_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_GAS_PRICE_ORACLE_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_GAS_PRICE_ORACLE_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_PROXY_ADMIN_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_PROXY_ADMIN_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_SCROLL_CHAIN_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_SCROLL_CHAIN_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L1_WHITELIST_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_WHITELIST_ADDR).transferOwnership(OWNER_ADDR);
}
if (ALTERNATIVE_GAS_TOKEN_ENABLED && Ownable(L1_GAS_TOKEN_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_GAS_TOKEN_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
transferOwnership(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_ERC1155_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_ERC721_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_GATEWAY_ROUTER_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_MESSAGE_QUEUE_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_SCROLL_MESSENGER_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_STANDARD_ERC20_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_GAS_PRICE_ORACLE_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR, OWNER_ADDR);
transferOwnership(L1_PROXY_ADMIN_ADDR, OWNER_ADDR);
transferOwnership(L1_SCROLL_CHAIN_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_WHITELIST_ADDR, OWNER_ADDR);

if (!ALTERNATIVE_GAS_TOKEN_ENABLED) {
transferOwnership(L1_ETH_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L1_WETH_GATEWAY_PROXY_ADDR, OWNER_ADDR);
} else {
transferOwnership(L1_GAS_TOKEN_GATEWAY_PROXY_ADDR, OWNER_ADDR);
}
}

Expand Down Expand Up @@ -1548,75 +1532,48 @@ contract DeployScroll is DeterminsticDeployment {
}

// set WETH gateway in router
{
address[] memory _tokens = new address[](1);
_tokens[0] = notnull(L2_WETH_ADDR);
address[] memory _gateways = new address[](1);
_gateways[0] = notnull(L2_WETH_GATEWAY_PROXY_ADDR);
if (L2GatewayRouter(L2_GATEWAY_ROUTER_PROXY_ADDR).ERC20Gateway(_tokens[0]) != _gateways[0]) {
L2GatewayRouter(L2_GATEWAY_ROUTER_PROXY_ADDR).setERC20Gateway(_tokens, _gateways);
}
address[] memory _tokens = new address[](1);
_tokens[0] = notnull(L2_WETH_ADDR);
address[] memory _gateways = new address[](1);
_gateways[0] = notnull(L2_WETH_GATEWAY_PROXY_ADDR);

if (L2GatewayRouter(L2_GATEWAY_ROUTER_PROXY_ADDR).ERC20Gateway(_tokens[0]) != _gateways[0]) {
L2GatewayRouter(L2_GATEWAY_ROUTER_PROXY_ADDR).setERC20Gateway(_tokens, _gateways);
}
}

function initializeScrollStandardERC20Factory() private {
if (
ScrollStandardERC20Factory(L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR).owner() !=
transferOwnership(
notnull(L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR),
notnull(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR)
) {
ScrollStandardERC20Factory(L2_SCROLL_STANDARD_ERC20_FACTORY_ADDR).transferOwnership(
L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR
);
}
);
}

function initializeL2Whitelist() private {
address[] memory accounts = new address[](1);
accounts[0] = L2_GAS_ORACLE_SENDER_ADDR;

if (!Whitelist(L2_WHITELIST_ADDR).isSenderAllowed(accounts[0])) {
Whitelist(L2_WHITELIST_ADDR).updateWhitelistStatus(accounts, true);
}
}

function transferL2ContractOwnership() private {
if (Ownable(L1_GAS_PRICE_ORACLE_ADDR).owner() != OWNER_ADDR) {
Ownable(L1_GAS_PRICE_ORACLE_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_ERC1155_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_ERC1155_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_ERC721_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_ERC721_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_ETH_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_ETH_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_GATEWAY_ROUTER_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_GATEWAY_ROUTER_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_MESSAGE_QUEUE_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_MESSAGE_QUEUE_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_SCROLL_MESSENGER_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_SCROLL_MESSENGER_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_TX_FEE_VAULT_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_TX_FEE_VAULT_ADDR).transferOwnership(OWNER_ADDR);
}
if (!ALTERNATIVE_GAS_TOKEN_ENABLED && Ownable(L2_WETH_GATEWAY_PROXY_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_WETH_GATEWAY_PROXY_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_PROXY_ADMIN_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_PROXY_ADMIN_ADDR).transferOwnership(OWNER_ADDR);
}
if (Ownable(L2_WHITELIST_ADDR).owner() != OWNER_ADDR) {
Ownable(L2_WHITELIST_ADDR).transferOwnership(OWNER_ADDR);
transferOwnership(L1_GAS_PRICE_ORACLE_ADDR, OWNER_ADDR);
transferOwnership(L2_CUSTOM_ERC20_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_ERC1155_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_ERC721_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_ETH_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_GATEWAY_ROUTER_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_MESSAGE_QUEUE_ADDR, OWNER_ADDR);
transferOwnership(L2_SCROLL_MESSENGER_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_STANDARD_ERC20_GATEWAY_PROXY_ADDR, OWNER_ADDR);
transferOwnership(L2_TX_FEE_VAULT_ADDR, OWNER_ADDR);
transferOwnership(L2_PROXY_ADMIN_ADDR, OWNER_ADDR);
transferOwnership(L2_WHITELIST_ADDR, OWNER_ADDR);

if (!ALTERNATIVE_GAS_TOKEN_ENABLED) {
transferOwnership(L2_WETH_GATEWAY_PROXY_ADDR, OWNER_ADDR);
}
}
}

0 comments on commit 4ad655b

Please sign in to comment.