Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Sep 27, 2024
1 parent 2b5b058 commit 0e65b90
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 57 deletions.
24 changes: 11 additions & 13 deletions l1-contracts/contracts/bridge/L2SharedBridgeLegacy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {IL2AssetRouter} from "./asset-router/IL2AssetRouter.sol";
import {IL2NativeTokenVault} from "./ntv/IL2NativeTokenVault.sol";

import {IL2SharedBridgeLegacy} from "./interfaces/IL2SharedBridgeLegacy.sol";
import {ZeroAddress, EmptyBytes32, Unauthorized, AmountMustBeGreaterThanZero, DeployFailed} from "../common/L1ContractErrors.sol";
import {InvalidCaller, ZeroAddress, EmptyBytes32, Unauthorized, AmountMustBeGreaterThanZero, DeployFailed} from "../common/L1ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact [email protected]
Expand Down Expand Up @@ -120,19 +120,17 @@ contract L2SharedBridgeLegacy is IL2SharedBridgeLegacy, Initializable {
bytes calldata _data
) external {
// Only the L1 bridge counterpart can initiate and finalize the deposit.
require(
AddressAliasHelper.undoL1ToL2Alias(msg.sender) == l1Bridge ||
AddressAliasHelper.undoL1ToL2Alias(msg.sender) == l1SharedBridge,
"mq"
);
if (AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1Bridge && AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1SharedBridge) {
revert InvalidCaller(msg.sender);
}

IL2AssetRouter(L2_ASSET_ROUTER_ADDR).finalizeDepositLegacyBridge(
_l1Sender,
_l2Receiver,
_l1Token,
_amount,
_data
);
IL2AssetRouter(L2_ASSET_ROUTER_ADDR).finalizeDepositLegacyBridge({
_l1Sender: _l1Sender,
_l2Receiver: _l2Receiver,
_l1Token: _l1Token,
_amount: _amount,
_data: _data
});


address l2Token = IL2NativeTokenVault(L2_NATIVE_TOKEN_VAULT_ADDR).l2TokenAddress(_l1Token);
Expand Down
29 changes: 15 additions & 14 deletions l1-contracts/contracts/bridge/asset-router/L2AssetRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,14 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter {
uint256 _amount,
bytes calldata _data
) external onlyAssetRouterCounterpart(L1_CHAIN_ID) {
_translateLegacyFinalizeDeposit(
_l1Sender,
_l2Receiver,
_l1Token,
_amount,
_data
);
_translateLegacyFinalizeDeposit({
_l1Sender: _l1Sender,
_l2Receiver: _l2Receiver,
_l1Token: _l1Token,
_amount: _amount,
_data: _data

});
}

function finalizeDepositLegacyBridge(
Expand All @@ -231,13 +232,13 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter {
uint256 _amount,
bytes calldata _data
) external onlyLegacyBridge {
_translateLegacyFinalizeDeposit(
_l1Sender,
_l2Receiver,
_l1Token,
_amount,
_data
);
_translateLegacyFinalizeDeposit({
_l1Sender: _l1Sender,
_l2Receiver: _l2Receiver,
_l1Token: _l1Token,
_amount: _amount,
_data: _data
});
}

function _translateLegacyFinalizeDeposit(
Expand Down
1 change: 0 additions & 1 deletion l1-contracts/contracts/bridgehub/Bridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
address chainAddress = IChainTypeManager(_chainTypeManager).createNewChain({
_chainId: _chainId,
_baseTokenAssetId: _baseTokenAssetId,
_assetRouter: assetRouter,
_admin: _admin,
_initData: _initData,
_factoryDeps: _factoryDeps
Expand Down
7 changes: 1 addition & 6 deletions l1-contracts/contracts/state-transition/ChainTypeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,11 @@ contract ChainTypeManager is IChainTypeManager, ReentrancyGuard, Ownable2StepUpg
/// @notice deploys a full set of chains contracts
/// @param _chainId the chain's id
/// @param _baseTokenAssetId the base token asset id used to pay for gas fees
/// @param _sharedBridge the shared bridge address, used as base token bridge
/// @param _admin the chain's admin address
/// @param _diamondCut the diamond cut data that initializes the chains Diamond Proxy
function _deployNewChain(
uint256 _chainId,
bytes32 _baseTokenAssetId,
address _sharedBridge,
address _admin,
bytes memory _diamondCut
) internal returns (address zkChainAddress) {
Expand Down Expand Up @@ -399,23 +397,21 @@ contract ChainTypeManager is IChainTypeManager, ReentrancyGuard, Ownable2StepUpg
/// @notice called by Bridgehub when a chain registers
/// @param _chainId the chain's id
/// @param _baseTokenAssetId the base token asset id used to pay for gas fees
/// @param _assetRouter the shared bridge address, used as base token bridge
/// @param _admin the chain's admin address
/// @param _initData the diamond cut data, force deployments and factoryDeps encoded
/// @param _factoryDeps the factory dependencies used for the genesis upgrade
/// that initializes the chains Diamond Proxy
function createNewChain(
uint256 _chainId,
bytes32 _baseTokenAssetId,
address _assetRouter,
address _admin,
bytes calldata _initData,
bytes[] calldata _factoryDeps
) external onlyBridgehub returns (address zkChainAddress) {
(bytes memory _diamondCut, bytes memory _forceDeploymentData) = abi.decode(_initData, (bytes, bytes));

// solhint-disable-next-line func-named-parameters
zkChainAddress = _deployNewChain(_chainId, _baseTokenAssetId, _assetRouter, _admin, _diamondCut);
zkChainAddress = _deployNewChain(_chainId, _baseTokenAssetId, _admin, _diamondCut);

{
// check input
Expand Down Expand Up @@ -491,7 +487,6 @@ contract ChainTypeManager is IChainTypeManager, ReentrancyGuard, Ownable2StepUpg
chainAddress = _deployNewChain({
_chainId: _chainId,
_baseTokenAssetId: _baseTokenAssetId,
_sharedBridge: address(IBridgehub(BRIDGE_HUB).sharedBridge()),
_admin: _admin,
_diamondCut: _diamondCut
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ interface IChainTypeManager {
function createNewChain(
uint256 _chainId,
bytes32 _baseTokenAssetId,
address _assetRouter,
address _admin,
bytes calldata _initData,
bytes[] calldata _factoryDeps
Expand Down
7 changes: 1 addition & 6 deletions l1-contracts/contracts/upgrades/GatewayUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

pragma solidity 0.8.24;

import {Initializable} from "@openzeppelin/contracts-upgradeable-v4/proxy/utils/Initializable.sol";

import {BaseZkSyncUpgrade, ProposedUpgrade} from "./BaseZkSyncUpgrade.sol";

import {DataEncoding} from "../common/libraries/DataEncoding.sol";
Expand All @@ -17,7 +15,6 @@ import {IL1SharedBridgeLegacy} from "../bridge/interfaces/IL1SharedBridgeLegacy.
import {IComplexUpgrader} from "../state-transition/l2-deps/IComplexUpgrader.sol";
import {IL2GatewayUpgrade} from "../state-transition/l2-deps/IL2GatewayUpgrade.sol";
import {IBridgehub} from "../bridgehub/IBridgehub.sol";
import {ZKChainSpecificForceDeploymentsData} from "../state-transition/l2-deps/IL2GenesisUpgrade.sol";

import {IL2ContractDeployer} from "../common/interfaces/IL2ContractDeployer.sol";

Expand All @@ -26,10 +23,10 @@ import {GatewayHelper} from "./GatewayHelper.sol";
struct GatewayUpgradeEncodedInput {
IL2ContractDeployer.ForceDeployment[] baseForceDeployments;
address ctmDeployer;
bytes fixedForceDeploymentsData;
address l2GatewayUpgrade;
address oldValidatorTimelock;
address newValidatorTimelock;
bytes fixedForceDeploymentsData;
}

/// @author Matter Labs
Expand Down Expand Up @@ -57,9 +54,7 @@ contract GatewayUpgrade is BaseZkSyncUpgrade {
s.validators[encodedInput.oldValidatorTimelock] = false;
s.validators[encodedInput.newValidatorTimelock] = true;
IBridgehub bridgehub = IBridgehub(s.bridgehub);
address sharedBridge = bridgehub.sharedBridge();
ProposedUpgrade memory proposedUpgrade = _proposedUpgrade;
address l2LegacyBridge = IL1SharedBridgeLegacy(sharedBridge).l2BridgeAddress(s.chainId);

bytes memory gatewayUpgradeCalldata = abi.encodeCall(
IL2GatewayUpgrade.upgrade,
Expand Down
2 changes: 0 additions & 2 deletions l1-contracts/contracts/upgrades/L1GenesisUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {ProposedUpgrade} from "./IDefaultUpgrade.sol";
import {L2CanonicalTransaction} from "../common/Messaging.sol";
import {IL2GenesisUpgrade} from "../state-transition/l2-deps/IL2GenesisUpgrade.sol";
import {IL1GenesisUpgrade} from "./IL1GenesisUpgrade.sol";
import {IL1Nullifier} from "../bridge/interfaces/IL1Nullifier.sol";
import {IL1AssetRouter} from "../bridge/asset-router/IL1AssetRouter.sol";
import {IComplexUpgrader} from "../state-transition/l2-deps/IComplexUpgrader.sol";
import {L2_FORCE_DEPLOYER_ADDR, L2_COMPLEX_UPGRADER_ADDR, L2_GENESIS_UPGRADE_ADDR} from "../common/L2ContractAddresses.sol"; //, COMPLEX_UPGRADER_ADDR, GENESIS_UPGRADE_ADDR
import {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, SYSTEM_UPGRADE_L2_TX_TYPE, PRIORITY_TX_MAX_GAS_LIMIT} from "../common/Config.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ contract ExperimentalBridgeTest is Test {
mockCTM.createNewChain.selector,
chainId,
tokenAssetId,
sharedBridgeAddress,
admin,
mockInitCalldata,
factoryDeps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ contract createNewChainTest is ChainTypeManagerTest {
chainContractAddress.createNewChain({
_chainId: chainId,
_baseTokenAssetId: DataEncoding.encodeNTVAssetId(block.chainid, baseToken),
_assetRouter: sharedBridge,
_admin: admin,
_initData: abi.encode(abi.encode(initialDiamondCutData), bytes("")),
_factoryDeps: new bytes[](0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ contract ChainTypeManagerTest is Test {
chainContractAddress.createNewChain({
_chainId: chainId,
_baseTokenAssetId: DataEncoding.encodeNTVAssetId(block.chainid, baseToken),
_assetRouter: sharedBridge,
_admin: newChainAdmin,
_initData: abi.encode(abi.encode(_diamondCut), bytes("")),
_factoryDeps: new bytes[](0)
Expand Down
5 changes: 2 additions & 3 deletions system-contracts/contracts/GatewayUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

pragma solidity 0.8.24;

import {DEPLOYER_SYSTEM_CONTRACT, SYSTEM_CONTEXT_CONTRACT, L2_BRIDGE_HUB, L2_ASSET_ROUTER, L2_MESSAGE_ROOT, L2_NATIVE_TOKEN_VAULT_ADDR} from "./Constants.sol";
import {DEPLOYER_SYSTEM_CONTRACT, L2_BRIDGE_HUB, L2_ASSET_ROUTER, L2_MESSAGE_ROOT, L2_NATIVE_TOKEN_VAULT_ADDR} from "./Constants.sol";
import {IContractDeployer, ForceDeployment} from "./interfaces/IContractDeployer.sol";
import {SystemContractHelper} from "./libraries/SystemContractHelper.sol";
import {ISystemContext} from "./interfaces/ISystemContext.sol";
import {IL2GenesisUpgrade, FixedForceDeploymentsData, ZKChainSpecificForceDeploymentsData} from "./interfaces/IL2GenesisUpgrade.sol";
import {FixedForceDeploymentsData, ZKChainSpecificForceDeploymentsData} from "./interfaces/IL2GenesisUpgrade.sol";

abstract contract GatewayUpgrade {
function performGatewayContractsInit(
Expand Down
2 changes: 1 addition & 1 deletion system-contracts/contracts/L2GatewayUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.24;

import {DEPLOYER_SYSTEM_CONTRACT, SYSTEM_CONTEXT_CONTRACT, L2_BRIDGE_HUB, L2_ASSET_ROUTER, L2_MESSAGE_ROOT, L2_NATIVE_TOKEN_VAULT_ADDR} from "./Constants.sol";
import {DEPLOYER_SYSTEM_CONTRACT} from "./Constants.sol";
import {IContractDeployer, ForceDeployment} from "./interfaces/IContractDeployer.sol";
import {SystemContractHelper} from "./libraries/SystemContractHelper.sol";
import {ISystemContext} from "./interfaces/ISystemContext.sol";
Expand Down
6 changes: 2 additions & 4 deletions system-contracts/contracts/L2GenesisUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

pragma solidity 0.8.24;

import {DEPLOYER_SYSTEM_CONTRACT, SYSTEM_CONTEXT_CONTRACT, L2_BRIDGE_HUB, L2_ASSET_ROUTER, L2_MESSAGE_ROOT, L2_NATIVE_TOKEN_VAULT_ADDR} from "./Constants.sol";
import {IContractDeployer, ForceDeployment} from "./interfaces/IContractDeployer.sol";
import {SystemContractHelper} from "./libraries/SystemContractHelper.sol";
import {SYSTEM_CONTEXT_CONTRACT} from "./Constants.sol";
import {ISystemContext} from "./interfaces/ISystemContext.sol";
import {IL2GenesisUpgrade, FixedForceDeploymentsData, ZKChainSpecificForceDeploymentsData} from "./interfaces/IL2GenesisUpgrade.sol";
import {IL2GenesisUpgrade} from "./interfaces/IL2GenesisUpgrade.sol";

import {GatewayUpgrade} from "./GatewayUpgrade.sol";

Expand Down
6 changes: 3 additions & 3 deletions system-contracts/contracts/interfaces/IL2GenesisUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ struct ZKChainSpecificForceDeploymentsData {
struct FixedForceDeploymentsData {
uint256 l1ChainId;
uint256 eraChainId;
address l1AssetRouter;
bytes32 l2TokenProxyBytecodeHash;
address aliasedL1Governance;
uint256 maxNumberOfZKChains;
bytes32 l2TokenProxyBytecodeHash;
bytes32 bridgehubBytecodeHash;
bytes32 l2AssetRouterBytecodeHash;
bytes32 l2NtvBytecodeHash;
bytes32 messageRootBytecodeHash;
address l1AssetRouter;
address aliasedL1Governance;
address l2SharedBridgeLegacyImpl;
address l2BridgedStandardERC20Impl;
address l2BridgeProxyOwnerAddress;
Expand Down

0 comments on commit 0e65b90

Please sign in to comment.