From c5934cefa7bfe18aee337bab6ebad7fa8ce775c3 Mon Sep 17 00:00:00 2001 From: kelemeno Date: Fri, 25 Oct 2024 15:30:35 +0100 Subject: [PATCH] fix: N-03 Unnecessary Code --- .../contracts/bridge/L2SharedBridgeLegacy.sol | 4 +-- .../bridge/ntv/L2NativeTokenVault.sol | 4 +-- .../contracts/common/L2ContractAddresses.sol | 3 -- .../common/interfaces/IL2ContractDeployer.sol | 32 ------------------- .../test/foundry/l2/unit/utils/L2Utils.sol | 8 ++--- 5 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol diff --git a/l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol b/l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol index 61e6141c2..8753703b0 100644 --- a/l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol +++ b/l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol @@ -7,7 +7,7 @@ import {UpgradeableBeacon} from "@openzeppelin/contracts-v4/proxy/beacon/Upgrade import {BridgedStandardERC20} from "./BridgedStandardERC20.sol"; -import {DEPLOYER_SYSTEM_CONTRACT, L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "../common/L2ContractAddresses.sol"; +import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "../common/L2ContractAddresses.sol"; import {SystemContractsCaller} from "../common/libraries/SystemContractsCaller.sol"; import {L2ContractHelper, IContractDeployer} from "../common/libraries/L2ContractHelper.sol"; @@ -143,7 +143,7 @@ contract L2SharedBridgeLegacy is IL2SharedBridgeLegacy, Initializable { function deployBeaconProxy(bytes32 salt) external onlyNTV returns (address proxy) { (bool success, bytes memory returndata) = SystemContractsCaller.systemCallWithReturndata( uint32(gasleft()), - DEPLOYER_SYSTEM_CONTRACT, + L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, 0, abi.encodeCall( IContractDeployer.create2, diff --git a/l1-contracts/contracts/bridge/ntv/L2NativeTokenVault.sol b/l1-contracts/contracts/bridge/ntv/L2NativeTokenVault.sol index e96a6d289..b308b8d7b 100644 --- a/l1-contracts/contracts/bridge/ntv/L2NativeTokenVault.sol +++ b/l1-contracts/contracts/bridge/ntv/L2NativeTokenVault.sol @@ -16,7 +16,7 @@ import {NativeTokenVault} from "./NativeTokenVault.sol"; import {IL2SharedBridgeLegacy} from "../interfaces/IL2SharedBridgeLegacy.sol"; import {BridgedStandardERC20} from "../BridgedStandardERC20.sol"; -import {DEPLOYER_SYSTEM_CONTRACT, L2_ASSET_ROUTER_ADDR} from "../../common/L2ContractAddresses.sol"; +import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, L2_ASSET_ROUTER_ADDR} from "../../common/L2ContractAddresses.sol"; import {L2ContractHelper, IContractDeployer} from "../../common/libraries/L2ContractHelper.sol"; import {SystemContractsCaller} from "../../common/libraries/SystemContractsCaller.sol"; @@ -136,7 +136,7 @@ contract L2NativeTokenVault is IL2NativeTokenVault, NativeTokenVault { (bool success, bytes memory returndata) = SystemContractsCaller.systemCallWithReturndata( uint32(gasleft()), - DEPLOYER_SYSTEM_CONTRACT, + L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, 0, abi.encodeCall( IContractDeployer.create2, diff --git a/l1-contracts/contracts/common/L2ContractAddresses.sol b/l1-contracts/contracts/common/L2ContractAddresses.sol index a8fba013c..d2459e443 100644 --- a/l1-contracts/contracts/common/L2ContractAddresses.sol +++ b/l1-contracts/contracts/common/L2ContractAddresses.sol @@ -75,9 +75,6 @@ address constant L2_MESSAGE_ROOT_ADDR = address(0x10005); /// @dev the offset for the system contracts uint160 constant SYSTEM_CONTRACTS_OFFSET = 0x8000; // 2^15 -/// @dev the address of the deployer system contract -address constant DEPLOYER_SYSTEM_CONTRACT = address(SYSTEM_CONTRACTS_OFFSET + 0x06); - /// @dev the address of the l2 messenger system contract IL2Messenger constant L2_MESSENGER = IL2Messenger(address(SYSTEM_CONTRACTS_OFFSET + 0x08)); diff --git a/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol b/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol deleted file mode 100644 index 015442dd9..000000000 --- a/l1-contracts/contracts/common/interfaces/IL2ContractDeployer.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -// We use a floating point pragma here so it can be used within other projects that interact with the ZKsync ecosystem without using our exact pragma version. -pragma solidity ^0.8.21; - -/** - * @author Matter Labs - * @notice System smart contract that is responsible for deploying other smart contracts on a ZK chain. - */ -interface IL2ContractDeployer { - /// @notice A struct that describes a forced deployment on an address. - /// @param bytecodeHash The bytecode hash to put on an address. - /// @param newAddress The address on which to deploy the bytecodehash to. - /// @param callConstructor Whether to run the constructor on the force deployment. - /// @param value The `msg.value` with which to initialize a contract. - /// @param input The constructor calldata. - struct ForceDeployment { - bytes32 bytecodeHash; - address newAddress; - bool callConstructor; - uint256 value; - bytes input; - } - - /// @notice This method is to be used only during an upgrade to set bytecodes on specific addresses. - function forceDeployOnAddresses(ForceDeployment[] calldata _deployParams) external; - - /// @notice Deploys a contract with similar address derivation rules to the EVM's `CREATE2` opcode. - /// @param _salt The create2 salt. - /// @param _bytecodeHash The correctly formatted hash of the bytecode. - /// @param _input The constructor calldata. - function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external; -} diff --git a/l1-contracts/test/foundry/l2/unit/utils/L2Utils.sol b/l1-contracts/test/foundry/l2/unit/utils/L2Utils.sol index 2c46774f4..7f1fec1ea 100644 --- a/l1-contracts/test/foundry/l2/unit/utils/L2Utils.sol +++ b/l1-contracts/test/foundry/l2/unit/utils/L2Utils.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import {Vm} from "forge-std/Vm.sol"; -import {DEPLOYER_SYSTEM_CONTRACT, L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "contracts/common/L2ContractAddresses.sol"; +import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, L2_ASSET_ROUTER_ADDR, L2_NATIVE_TOKEN_VAULT_ADDR} from "contracts/common/L2ContractAddresses.sol"; import {IContractDeployer, L2ContractHelper} from "contracts/common/libraries/L2ContractHelper.sol"; import {L2AssetRouter} from "contracts/bridge/asset-router/L2AssetRouter.sol"; @@ -55,7 +55,7 @@ library L2Utils { */ function initSystemContracts() internal { bytes memory contractDeployerBytecode = readSystemContractsBytecode("ContractDeployer"); - vm.etch(DEPLOYER_SYSTEM_CONTRACT, contractDeployerBytecode); + vm.etch(L2_DEPLOYER_SYSTEM_CONTRACT_ADDR, contractDeployerBytecode); } /// @notice Deploys the L2AssetRouter contract. @@ -89,7 +89,7 @@ library L2Utils { }); vm.prank(L2_FORCE_DEPLOYER_ADDR); - IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).forceDeployOnAddresses(deployments); + IContractDeployer(L2_DEPLOYER_SYSTEM_CONTRACT_ADDR).forceDeployOnAddresses(deployments); } /// @notice Deploys the L2NativeTokenVault contract. @@ -146,7 +146,7 @@ library L2Utils { }); vm.prank(L2_FORCE_DEPLOYER_ADDR); - IContractDeployer(DEPLOYER_SYSTEM_CONTRACT).forceDeployOnAddresses(deployments); + IContractDeployer(L2_DEPLOYER_SYSTEM_CONTRACT_ADDR).forceDeployOnAddresses(deployments); } /// @notice Encodes the token data.