Skip to content

Commit

Permalink
fix: remove L2GasPriceOracle from deterministic deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
yiweichi committed Sep 19, 2024
1 parent 0c993a7 commit 4a9caa2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 48 deletions.
2 changes: 0 additions & 2 deletions docker/templates/config-contracts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ L1_WETH_ADDR = ""
L1_PROXY_ADMIN_ADDR = ""
L1_PROXY_IMPLEMENTATION_PLACEHOLDER_ADDR = ""
L1_WHITELIST_ADDR = ""
L2_GAS_PRICE_ORACLE_IMPLEMENTATION_ADDR = ""
L2_GAS_PRICE_ORACLE_PROXY_ADDR = ""
L1_SCROLL_CHAIN_PROXY_ADDR = ""
L1_SCROLL_MESSENGER_PROXY_ADDR = ""
L1_ENFORCED_TX_GATEWAY_IMPLEMENTATION_ADDR = ""
Expand Down
51 changes: 8 additions & 43 deletions scripts/deterministic/DeployScroll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ contract DeployScroll is DeterministicDeployment {
address internal L1_WETH_GATEWAY_PROXY_ADDR;
address internal L1_WHITELIST_ADDR;
address internal L1_ZKEVM_VERIFIER_V2_ADDR;
address internal L2_GAS_PRICE_ORACLE_IMPLEMENTATION_ADDR;
address internal L2_GAS_PRICE_ORACLE_PROXY_ADDR;
address internal L1_GAS_TOKEN_ADDR;
address internal L1_GAS_TOKEN_GATEWAY_IMPLEMENTATION_ADDR;
address internal L1_GAS_TOKEN_GATEWAY_PROXY_ADDR;
Expand Down Expand Up @@ -362,7 +360,6 @@ contract DeployScroll is DeterministicDeployment {
deployL1ProxyAdmin();
deployL1PlaceHolder();
deployL1Whitelist();
deployL2GasPriceOracle();
deployL1ScrollChainProxy();
deployL1ScrollMessengerProxy();
deployL1EnforcedTxGateway();
Expand Down Expand Up @@ -433,7 +430,6 @@ contract DeployScroll is DeterministicDeployment {
// @notice initializeL1Contracts initializes contracts deployed on L1.
function initializeL1Contracts() private broadcast(Layer.L1) only(Layer.L1) {
initializeScrollChain();
initializeL2GasPriceOracle();
initializeL1MessageQueue();
initializeL1ScrollMessenger();
initializeEnforcedTxGateway();
Expand Down Expand Up @@ -501,25 +497,6 @@ contract DeployScroll is DeterministicDeployment {
L1_WHITELIST_ADDR = deploy("L1_WHITELIST", type(Whitelist).creationCode, args);
}

function deployL2GasPriceOracle() private {
L2_GAS_PRICE_ORACLE_IMPLEMENTATION_ADDR = deploy(
"L2_GAS_PRICE_ORACLE_IMPLEMENTATION",
type(L2GasPriceOracle).creationCode
);

bytes memory args = abi.encode(
notnull(L2_GAS_PRICE_ORACLE_IMPLEMENTATION_ADDR),
notnull(L1_PROXY_ADMIN_ADDR),
new bytes(0)
);

L2_GAS_PRICE_ORACLE_PROXY_ADDR = deploy(
"L2_GAS_PRICE_ORACLE_PROXY",
type(TransparentUpgradeableProxy).creationCode,
args
);
}

function deployL1ScrollChainProxy() private {
bytes memory args = abi.encode(
notnull(L1_PROXY_IMPLEMENTATION_PLACEHOLDER_ADDR),
Expand Down Expand Up @@ -1238,35 +1215,24 @@ contract DeployScroll is DeterministicDeployment {
}
}

function initializeL2GasPriceOracle() private {
if (getInitializeCount(L2_GAS_PRICE_ORACLE_PROXY_ADDR) == 0) {
L2GasPriceOracle(L2_GAS_PRICE_ORACLE_PROXY_ADDR).initialize(
21000, // _txGas
53000, // _txGasContractCreation
4, // _zeroGas
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);
}
}

function initializeL1MessageQueue() private {
if (getInitializeCount(L1_MESSAGE_QUEUE_PROXY_ADDR) == 0) {
L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initialize(
notnull(L1_SCROLL_MESSENGER_PROXY_ADDR),
notnull(L1_SCROLL_CHAIN_PROXY_ADDR),
notnull(L1_ENFORCED_TX_GATEWAY_PROXY_ADDR),
notnull(L2_GAS_PRICE_ORACLE_PROXY_ADDR),
// note: this should be the address of L2GasPriceOracle,
// but since we are using L1MessageQueueWithGasPriceOracle, so we set an all zero address here
address(0),
MAX_L1_MESSAGE_GAS_LIMIT
);
}

if (getInitializeCount(L1_MESSAGE_QUEUE_PROXY_ADDR) < 2) {
L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initializeV2();
}
// note: since we are using L1MessageQueueWithGasPriceOracle,
// and we don't have a L2GasPriceOracle deploy, so we skip it.
// if (getInitializeCount(L1_MESSAGE_QUEUE_PROXY_ADDR) < 2) {
// L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initializeV2();
// }

if (getInitializeCount(L1_MESSAGE_QUEUE_PROXY_ADDR) < 3) {
L1MessageQueueWithGasPriceOracle(L1_MESSAGE_QUEUE_PROXY_ADDR).initializeV3();
Expand Down Expand Up @@ -1436,7 +1402,6 @@ contract DeployScroll is DeterministicDeployment {
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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/deterministic/GenerateConfigs.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract GenerateRollupConfig is DeployScroll {
vm.writeJson(vm.toString(L1_GAS_PRICE_ORACLE_ADDR), ROLLUP_CONFIG_PATH, ".l1_config.relayer_config.gas_price_oracle_contract_address");
vm.writeJson(vm.toString(L2_MESSAGE_QUEUE_ADDR), ROLLUP_CONFIG_PATH, ".l2_config.l2_message_queue_address");
vm.writeJson(vm.toString(L1_SCROLL_CHAIN_PROXY_ADDR), ROLLUP_CONFIG_PATH, ".l2_config.relayer_config.rollup_contract_address");
vm.writeJson(vm.toString(L2_GAS_PRICE_ORACLE_PROXY_ADDR), ROLLUP_CONFIG_PATH, ".l2_config.relayer_config.gas_price_oracle_contract_address");
vm.writeJson(vm.toString(L1_MESSAGE_QUEUE_PROXY_ADDR), ROLLUP_CONFIG_PATH, ".l2_config.relayer_config.gas_price_oracle_contract_address");

// other
vm.writeJson(vm.toString(TEST_ENV_MOCK_FINALIZE_ENABLED), ROLLUP_CONFIG_PATH, ".l2_config.relayer_config.enable_test_env_bypass_features");
Expand Down
2 changes: 0 additions & 2 deletions src/test/deterministic/DeployScroll.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ contract DeployScrollTest is TestBase, StdAssertions, DeployScroll {
assertEq(0x4Bd916ecac9c5DBd6f15208c8632802Fd2c49e82, L1_PROXY_ADMIN_ADDR);
assertEq(0x28b7e53497D08F70476001cc41C719e68425D161, L1_PROXY_IMPLEMENTATION_PLACEHOLDER_ADDR);
assertEq(0x602EEf44E8898cC7Cd2e1f54B01E77B4Ca855b8C, L1_WHITELIST_ADDR);
assertEq(0xC8894eF4aA8f141138Be9CF7161aD0A5afFC4a58, L2_GAS_PRICE_ORACLE_IMPLEMENTATION_ADDR);
assertEq(0x13629E678a8Cb5e532270104EcB5648B77ca91fc, L2_GAS_PRICE_ORACLE_PROXY_ADDR);
assertEq(0x7C68fab1e8c32A321069866b6F1D4403F05C5f44, L1_SCROLL_CHAIN_PROXY_ADDR);
assertEq(0xC97658507021A2EB494298CAA815B83BC3DE935b, L1_SCROLL_MESSENGER_PROXY_ADDR);
assertEq(0x02476A470215Bd2F268179492431230C5Dc607C8, L1_ENFORCED_TX_GATEWAY_IMPLEMENTATION_ADDR);
Expand Down

0 comments on commit 4a9caa2

Please sign in to comment.