From 4ad655b59986374d36d125cec50d2cb1e6c9970e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Fri, 30 Aug 2024 13:27:38 +0200 Subject: [PATCH] clean up --- docs/manual-deployment.md | 8 +- scripts/deterministic/DeployScroll.s.sol | 173 +++++++++-------------- 2 files changed, 69 insertions(+), 112 deletions(-) diff --git a/docs/manual-deployment.md b/docs/manual-deployment.md index e33164b..86363e0 100644 --- a/docs/manual-deployment.md +++ b/docs/manual-deployment.md @@ -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 @@ -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: @@ -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" diff --git a/scripts/deterministic/DeployScroll.s.sol b/scripts/deterministic/DeployScroll.s.sol index 9ba03e6..07bd0cc 100644 --- a/scripts/deterministic/DeployScroll.s.sol +++ b/scripts/deterministic/DeployScroll.s.sol @@ -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(); @@ -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); } @@ -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); } @@ -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); } @@ -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), @@ -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); } @@ -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); } } @@ -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); } } }