{"file_path":"contracts/ZkLinkLegacyPaused.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLinkLegacyPaused is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @dev Whether eth is the gas token\n    bool public immutable IS_ETH_GAS_TOKEN;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor(bool _isEthGasToken) {\n        IS_ETH_GAS_TOKEN = _isEthGasToken;\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!IS_ETH_GAS_TOKEN) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(IS_ETH_GAS_TOKEN, \"Not allow eth withdraw\");\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        if (_toBatchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _toBatchNumber;\n        }\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view whenNotPaused returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        bool callSuccess;\n        // Low-level assembly call, to avoid any memory copying (save gas)\n        assembly {\n            callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n        }\n        require(callSuccess, \"pz\");\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n","deployed_bytecode":"0x6080604052600436101561001257600080fd5b60003560e01c8062e969a814610338578063042901c7146103335780630ec6b0b71461032e578063116191b6146103105780631dd26496146103295780632425b3a4146103245780633659cfe61461031f57806336e2e3f31461031a5780633f4ba83a1461031557806342bf3cc1146103105780634623c91d1461030b5780634ecf53e9146103065780634f1ef286146103015780634fc07d75146102b157806351ef251b1461029d57806352d1902d146102fc578063534ca054146102f75780635a425fcd146102f25780635a9f55b0146102ed5780635c975abb146102e85780635e78d327146102e3578063637c9d9d146102de57806363b434941461028e57806364bf8d66146102d95780636c0960f9146102d4578063715018a6146102cf5780637666f125146102ca5780637adbe273146102c55780638129fc1c146102c057806383864ac4146102a25780638456cb59146102bb5780638aa50991146102b65780638da5cb5b146102b157806390646b4a146102ac5780639242164f146102a75780639cd939e4146102a2578063a1954fc51461029d578063af32a0a714610298578063b473318e14610293578063b8c2f66f1461028e578063ba745e5314610289578063bc5455d014610284578063bd7c54121461027f578063be3bc8ea1461027a578063ca98ef4f14610275578063cfe6128214610270578063e0a1bf721461026b578063e4948f4314610266578063eb67241914610261578063f2fde38b1461025c578063fa52c7d8146102575763facd743b1461025757600080fd5b612247565b6121b6565b611dd9565b611d24565b611cb7565b611b7d565b611b5e565b611953565b611913565b6118a8565b611889565b611040565b611855565b611836565b610c69565b61159e565b6117c8565b6116d7565b610c40565b611625565b6115cb565b6114b6565b611479565b6113fd565b61139c565b611144565b61105f565b611013565b610f75565b610f52565b610f25565b610d6c565b610d4d565b610c88565b610afd565b61092f565b61089e565b610511565b6107e2565b6107ac565b61065f565b610576565b61053b565b6104f2565b6103f3565b61034d565b600091031261034857565b600080fd5b346103485760003660031901126103485760206040517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c8152f35b6064359061ffff8216820361034857565b6044359061ffff8216820361034857565b359061ffff8216820361034857565b9181601f84011215610348578235916001600160401b038311610348576020808501948460051b01011161034857565b6002111561034857565b346103485760c03660031901126103485761040c610388565b6084356001600160401b0381116103485761042b9036906004016103b9565b60a4359291610439846103e9565b6004356000526101376020526040600020549283156104b857846104a2946104636104b4976117a8565b61048561046e610a12565b60008152600160208201529361ffff166040850152565b6180016060840152608083015260a082015260443560243561386b565b60405190151581529081906020820190565b0390f35b60405162461bcd60e51b8152602060048201526012602482015271092dcecc2d8d2c840d86440e8f040d0c2e6d60731b6044820152606490fd5b3461034857600036600319011261034857602060405163044aa2008152f35b346103485760003660031901126103485761012d546040516001600160a01b039091168152602090f35b346103485760003660031901126103485761013b546040516001600160a01b039091168152602090f35b6001600160a01b0381160361034857565b346103485760203660031901126103485760043561059381610565565b61059b61228a565b6001600160a01b039080821680156106265761013b546001600160a01b0316928316036105c457005b61013b80546001600160a01b0319166001600160a01b0383161790557f98ac3b973026c0d730e72f023f161bebb4ba504d9b1c6b83d849d3cbaf7f51f491604080516001600160a01b039283168152929091166020830152819081015b0390a1005b60405162461bcd60e51b815260206004820152601160248201527024b73b30b634b21030b63637b1b0ba37b960791b6044820152606490fd5b346103485760203660031901126103485760043561067c81610565565b6001600160a01b037f000000000000000000000000fcc8ea6970efb1c167c833123d7c999e7b379dbe811691906106b53084141561232b565b6106d2600080516020613f1883398151915293828554161461238c565b6106da61228a565b6106e26123ed565b9061070e7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1690565b1561072157505061071f91506124dd565b005b6020600491604094939451928380926352d1902d60e01b825286165afa6000918161077c575b506107695760405162461bcd60e51b8152806107656004820161248e565b0390fd5b61071f936107779114612430565b61256d565b61079e91925060203d81116107a5575b61079681836109f1565b810190612415565b9038610747565b503d61078c565b34610348576020366003190112610348576004356000526101346020526040806000206001815491015482519182526020820152f35b34610348576000366003190112610348576107fb61228a565b60fb5460ff81161561083a5760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b60409060031901126103485760043561088e81610565565b9060243580151581036103485790565b34610348576108ac36610876565b61012d5490916001600160a01b03916108c89083163314612914565b16908160005261012e60205260406000209060ff82541681151580911515036108ed57005b6109266020927f065b77b53864e46fda3d8986acb51696223d6dde7ced42441eb150bae6d48136949060ff801983541691151516179055565b604051908152a2005b346103485760203660031901126103485760043561094c81610565565b60018060a01b031660005261012f602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161099b57604052565b610972565b606081019081106001600160401b0382111761099b57604052565b60c081019081106001600160401b0382111761099b57604052565b604081019081106001600160401b0382111761099b57604052565b90601f801991011681019081106001600160401b0382111761099b57604052565b60405190610a1f826109bb565b565b60405190610a1f826109a0565b6040519061016082018281106001600160401b0382111761099b57604052565b6040519061020082018281106001600160401b0382111761099b57604052565b60405190608082018281106001600160401b0382111761099b57604052565b6001600160401b03811161099b57601f01601f191660200190565b929192610ab482610a8d565b91610ac260405193846109f1565b829481845281830111610348578281602093846000960137010152565b9080601f8301121561034857816020610afa93359101610aa8565b90565b604036600319011261034857600435610b1581610565565b6024356001600160401b03811161034857610b34903690600401610adf565b6001600160a01b037f000000000000000000000000fcc8ea6970efb1c167c833123d7c999e7b379dbe8116929190610b6e3085141561232b565b610b8b600080516020613f1883398151915294828654161461238c565b610b9361228a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610bc957505061071f91506124dd565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610c20575b50610c0d5760405162461bcd60e51b8152806107656004820161248e565b61071f93610c1b9114612430565b612629565b610c3991925060203d81116107a55761079681836109f1565b9038610bef565b34610348576000366003190112610348576033546040516001600160a01b039091168152602090f35b3461034857600036600319011261034857602061013254604051908152f35b34610348576000366003190112610348577f000000000000000000000000fcc8ea6970efb1c167c833123d7c999e7b379dbe6001600160a01b03163003610ce257604051600080516020613f188339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b3461034857600036600319011261034857602061013054604051908152f35b34610348576060366003190112610348576004356024356044356001600160401b03811161034857610da29036906004016103b9565b9290923360005261012e602052610dc060ff60406000205416613281565b610dcc8284101561335a565b6040805160208101848152918101859052610df481606081015b03601f1981018352826109f1565b51902093610e0d8560005261013c602052604060002090565b5491610e1a831515613396565b610e36610e2f610e2a8688613002565b612d79565b82146133e2565b610e40818361342e565b359182610e5886600052610136602052604060002090565b5560019081925b808410610edf577fddf6b2cf5bdb04a03cb3f7663b72571336626b1e586a3a047942e4860cf7e12b88886000610eab8d610e9a8c8c1461345d565b60005261013c602052604060002090565b55610135548211610ed0575b6040805191825260208201929092529081908101610621565b610eda8261013555565b610eb7565b9091610f1b8495610ef28396858761344d565b359081610f0c898c01600052610136602052604060002090565b55600052602052604060002090565b9401929190610e5f565b34610348576020366003190112610348576004356000526101376020526020604060002054604051908152f35b3461034857600036600319011261034857602060ff60fb54166040519015158152f35b6060366003190112610348577fab53214e3a56f049923c5f5532ea4657bba51b870850593c4dc0eceb3b61feed60043560243590610621604435610fc560018060a01b0361012d54163314612914565b610fd0813414613315565b826101358054821161100b575b5060005261013660205283604060002055604051938493846040919493926060820195825260208201520152565b558238610fdd565b346103485760203660031901126103485760043560005261013c6020526020604060002054604051908152f35b3461034857600036600319011261034857602061013554604051908152f35b346103485760c03660031901126103485761108660018060a01b0361012d54163314612914565b6044356110928161294e565b60843561109e8161294e565b63ffffffff8091169116106110ed577fc8b245ac8b138b17b6b1dbbbb8860adc66b373afa000d99f3cdc775d8ae0bbed6106216110d961295c565b6110e16129dd565b60405191829182612ad7565b60405162461bcd60e51b8152602060048201526002602482015261371b60f11b6044820152606490fd5b9181601f84011215610348578235916001600160401b038311610348576020838186019501011161034857565b346103485760a036600319011261034857602435600435611163610399565b916001600160401b039160643583811161034857611185903690600401611117565b929091608435948511610348576112556112506111a7600497369089016103b9565b9590966111b2613153565b6111db7f00000000000000000000000000000000000000000000000000000000000000016131a9565b61121c61121761121361120c896111fd8a60005261013a602052604060002090565b90600052602052604060002090565b5460ff1690565b1590565b6131ee565b611231611227610a21565b61ffff909b168b52565b61800a60208b0152611244368284610aa8565b60408b01523691610aa8565b6139e1565b9491959097602061127d61127161012d5460018060a01b031690565b6001600160a01b031690565b60405163388e611f60e11b8152998a9182905afa968715611397577f26464d64ddb13f6d187de632d165bd1065382ec0b66c25c648957116e7bc25c898600098611341575b506112fe61132196946111fd946112f761131498956112f26113039660018060a01b039e8f80911691161461321f565b6137e9565b878661386b565b613250565b60005261013a602052604060002090565b805460ff19166001179055565b61132b8482613aa0565b6040519384521691602090a261071f600160c955565b61130391985061132196946111fd946112f761131498956112f261137e6112fe9660203d8111611390575b61137681836109f1565b810190612de2565b9d9650509598505094509496506112c2565b503d61136c565b612424565b34610348576000806003193601126113fa576113b661228a565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346103485761140b36610876565b9061141461228a565b60018060a01b0316908160005261012f60205260406000209060ff825416811515809115150361144057005b6109266020927f1f8e549bdb5108ba50ebcc80bb64a20ea98bfbd9378a87380d29f3c87cdcbb2c949060ff801983541691151516179055565b346103485760003660031901126103485760206040517f000000000000000000000000000000000000000000000000000000000000000115158152f35b34610348576000806003193601126113fa5780546114eb60ff8260081c161580928193611590575b8115611570575b50612781565b806114fe600160ff196000541617600055565b611557575b61150b6127e4565b6115125780f35b61152261ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081015b0390a180f35b61156b61010061ff00196000541617600055565b611503565b303b15915081611582575b50386114e5565b6001915060ff16143861157b565b600160ff82161091506114de565b34610348576020366003190112610348576004356000526101366020526020604060002054604051908152f35b34610348576000366003190112610348576115e461228a565b6115ec612892565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b6080366003190112610348577f427754a95a2d34153366ec8bcea3939ce044aaf5c185a86149c9f6d80c4402b960806004356024356044356064359161167760018060a01b0361012d54163314612914565b6116838482101561335a565b61168e833414613315565b60408051602081018681529181018390526116ac8160608101610de6565b51902060005261013c60205281604060002055604051938452602084015260408301526060820152a1005b34610348576020366003190112610348576004356116f481610565565b6116fc61228a565b61012d546001600160a01b0390811661176a57611743908216916117218315156128d6565b61012d80546001600160a01b0319166001600160a01b03909216919091179055565b7f860df2b5ed762095deab38be8b5aa5acfbfa8d4d209e083fa00246d31b715e29600080a2005b60405162461bcd60e51b81526020600482015260166024820152754475706c696361746520696e6974206761746577617960501b6044820152606490fd5b600211156117b257565b634e487b7160e01b600052602160045260246000fd5b346103485760003660031901126103485760c0610131546001600160401b0360ff821691604051926117f9816117a8565b835263ffffffff808260081c166020850152808260281c166040850152808260481c1660608501528160681c16608084015260881c1660a0820152f35b3461034857600036600319011261034857602061013854604051908152f35b3461034857606036600319011261034857602061188160243561187c60443560043561353b565b612c00565b604051908152f35b3461034857600036600319011261034857602061013354604051908152f35b34610348576020366003190112610348576004356118c461228a565b6101309081548181036118d357005b817f208ba37ba4e5fc3f236a9c289aa28898330c1f2ec9102d54821a1ffb59e8f1d793556106216040519283928360209093929193604081019481520152565b346103485760403660031901126103485760043560005261013a6020526040600020602435600052602052602060ff604060002054166040519015158152f35b602080600319360112610348576004359060009133835261012e825261197f60ff604085205416613281565b6101325481111580611b52575b611995906132bd565b61199d612fda565b906101335480611b39575b506119e06119d16119cc6119bb84612ff3565b600052610134602052604060002090565b61300f565b92848085015191015190613002565b916119eb8261013355565b61012d54611a01906001600160a01b0316611271565b60405163388e611f60e11b815290948082600481895afa9081156113975787928392611b16575b5083516040516318d0d57560e01b928101929092526001600160a01b03909216602482015260448101859052606481019190915260848101859052611a708160a48101610de6565b611a7a8534612d95565b95803b15611b1257611aa39160405197888094819363e289adcd60e01b83528a600484016132fe565b03925af1908115611397577fba9fdc955504f0973215993a882822edf5e2b4561df97340b4d5632e64e24a0f9461155192611af9575b505192604051938493846040919493926060820195825260208201520152565b80611b06611b0c92610988565b8061033d565b38611ad9565b8280fd5b819250611b3290611a70923d85116113905761137681836109f1565b9190611a28565b611b4b9192506119bb6119cc91612ff3565b90386119a8565b5061013354811161198c565b3461034857600036600319011261034857602061013954604051908152f35b3461034857604036600319011261034857600435611b9a81610565565b602435611ba5613153565b61013b546001600160a01b039081163303611c72578115611c3c577f8f37daeecdc35f2a03da8794b025ea44e3f7c6f4e2265630836db89ff3f2f2b790611c07611bf28461013954612d95565b611c018161013854101561349f565b61013955565b600093611c238580808088865af1611c1d61267c565b506134dd565b6040519384521691602090a2611c39600160c955565b80f35b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606490fd5b60405162461bcd60e51b815260206004820152601960248201527f4e6f7420666f72776172642066656520616c6c6f6361746f72000000000000006044820152606490fd5b34610348576040366003190112610348577fdfb8da952dba6c9ec993b8f2ca8cc6ac22596f6e179520fea3fc78202e87090c6040600435602435611d0760018060a01b0361012d54163314612914565b8160005261013760205280836000205582519182526020820152a1005b3461034857600319608036820112610348576044356001600160401b03918282116103485760609082360301126103485760405190611d62826109a0565b611d6e816004016103aa565b82526024810135611d7e81610565565b6020830152604481013590838211610348576004611d9f9236920101610adf565b604082015260643591821161034857611dce6104a291611dc66104b49436906004016103b9565b9290916137e9565b60243560043561386b565b60e036600319011261034857600435611df181610565565b602435906001600160401b0360443581811161034857611e15903690600401611117565b90916064359360843560a43592831161034857611e37879336906004016103b9565b60c43592611e4484610565565b611e4c613153565b611e54612892565b7f0000000000000000000000000000000000000000000000000000000000000001156121a7575b33986000328b14612193575089611eb5611eb061120c60049a9b9c9d60018060a01b031660005261012f602052604060002090565b612ca0565b61111161111160901b01016001600160a01b0316996001995b611edb6103208514612cec565b611f24611f1e60209b611ef08d891115612d37565b611f15611f0e611f078861187c8b6101305461353b565b9283612d95565b3414612da2565b61013854612d95565b61013855565b6001600160a01b039680881661218d57508b965b87803b612176575b50506101325461012d54909c90611f5f906001600160a01b0316611271565b9b8b60409d8e519c8d809263388e611f60e11b82525afa9a8b156113975760009b612157575b50611f8e610a2e565b6001600160a01b03909b168b5215158a8c01526001600160a01b0316898c0152606089018c81526001600160a01b0390981660808a01528c60a08a01523690611fd692610aa8565b60c088015260e08701526101008601523690611ff192612e0e565b6101208401526001600160a01b031661014083015261200f8261371e565b8451908161201f82878301612ed9565b0391601f1992838101825261203490826109f1565b6101315460681c63ffffffff1663ffffffff169061205192613dda565b8461205b84613aeb565b968792612066612fda565b6104b49a7fbf5630c2adfa5e47b882a9ead657ffc6a22ce010513a3efac7245066bcad17dd986120d1966120cb96610e2a95876120fb57505083528201525b6120ba83600052610134602052604060002090565b906020600191805184550151910155565b61013255565b516120e0845192839283613089565b0390a16120ed600160c955565b519081529081906020820190565b61215093929550612141612135916121186119cc6119bb8c612ff3565b978851945193849187830196879091604092825260208201520190565b039081018352826109f1565b51902084528301918251612d95565b90526120a5565b61216f919b508c8d3d106113905761137681836109f1565b9938611f85565b811661111161111160901b01011696503880611f40565b96611f38565b98886121a26004999a15612c54565b611ece565b6121b18615612c13565b611e7b565b34610348576020366003190112610348576004356121d381610565565b6121db61228a565b6001600160a01b038116156121f35761071f906122e2565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346103485760203660031901126103485760043561226481610565565b60018060a01b031660005261012e602052602060ff604060002054166040519015158152f35b6033546001600160a01b0316330361229e57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561233257565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561239357565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b604051602081018181106001600160401b0382111761099b5760405260008152906000368137565b90816020910312610348575190565b6040513d6000823e3d90fd5b1561243757565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b803b1561251257600080516020613f1883398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b90612577826124dd565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590612621575b6125b9575050565b61261e91600080604051936125cd856109a0565b602785527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020860152660819985a5b195960ca1b6040860152602081519101845af461261861267c565b916126ac565b50565b5060006125b1565b90612633826124dd565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590612674576125b9575050565b5060016125b1565b3d156126a7573d9061268d82610a8d565b9161269b60405193846109f1565b82523d6000602084013e565b606090565b9192901561270e57508151156126c0575090565b3b156126c95790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156127215750805190602001fd5b60405162461bcd60e51b8152602060048201529081906107659060248301905b919082519283825260005b84811061276d575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520161274c565b1561278857565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b6127f560ff60005460081c16612832565b6127fe336122e2565b61282660ff60005460081c1661281381612832565b61281c81612832565b600160c955612832565b60ff1960fb541660fb55565b1561283957565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb541661289e57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b156128dd57565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206761746577617960881b6044820152606490fd5b1561291b57565b60405162461bcd60e51b815260206004820152600b60248201526a4e6f74206761746577617960a81b6044820152606490fd5b63ffffffff81160361034857565b60405190612969826109bb565b8160a06001600160401b036101315460ff8116612985816117a8565b845263ffffffff808260081c166020860152808260281c166040860152808260481c1660608601528160681c16608085015260881c16910152565b6001600160401b0381160361034857565b60a435610afa816129c0565b6004356129e9816103e9565b6129f2816117a8565b6101319081546cffffffff000000000000000000602435612a128161294e565b68ffffffff000000000060443591612a298361294e565b64ffffffff0060643595612a3c8761294e565b60ff608435612a4a8161294e565b63ffffffff60681b9060681b1698169070ffffffffffffffffffffffffffffffffff1916179160081b16179160281b16179160481b1617179055610a1f612a8f6129d1565b610131805467ffffffffffffffff60881b191660889290921b67ffffffffffffffff60881b16919091179055565b60843590610a1f8261294e565b60a43590610a1f826129c0565b815161018082019392610a1f9291612aee816117a8565b82526001600160401b0360a063ffffffff9283602082015116602086015283604082015116604086015283606082015116606086015283608082015116608086015201511660a0830152600435612b44816103e9565b612b4d816117a8565b60c083015280602435612b5f8161294e565b1660e083015280604435612b728161294e565b16610100830152606435612b858161294e565b16610120820152612ba5612b97612abd565b63ffffffff16610140830152565b610160612bb0612aca565b6001600160401b0316910152565b634e487b7160e01b600052601160045260246000fd5b9081605802916058830403612be557565b612bbe565b908160061b9180830460401490151715612be557565b81810292918115918404141715612be557565b15612c1a57565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420616c6c6f77206c322076616c756560701b6044820152606490fd5b15612c5b57565b60405162461bcd60e51b815260206004820152601a60248201527f4e6f7420616c6c6f7720746f2063616c6c20636f6e74726163740000000000006044820152606490fd5b15612ca757565b60405162461bcd60e51b815260206004820152601c60248201527f4e6f7420616c6c6f7720746f2073656e64204c322072657175657374000000006044820152606490fd5b15612cf357565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206c3247617350657250756264617461427974654c696d69746044820152fd5b15612d3e57565b60405162461bcd60e51b8152602060048201526013602482015272496e76616c696420666163746f72794465707360681b6044820152606490fd5b9060018201809211612be557565b9060208201809211612be557565b91908201809211612be557565b15612da957565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964206d73672076616c756560781b6044820152606490fd5b908160209103126103485751610afa81610565565b6001600160401b03811161099b5760051b60200190565b92919092612e1b84612df7565b91612e2960405193846109f1565b829480845260208094019060051b8301928284116103485780915b848310612e5357505050505050565b82356001600160401b038111610348578691612e728684938601610adf565b815201920191612e44565b6000915b60048310612e8e57505050565b600190825181526020809101920192019190612e81565b90815180825260208080930193019160005b828110612ec5575050505090565b835185529381019392810192600101612eb7565b90610afa916020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e082015260e0820151610100908183015282015161012090818301528201516101409081830152820151612f5b6101609182840190612e7d565b82015190610260612f796101e0938285850152610280840190612741565b92612fca612fb4612f9e61018088015196601f19978888830301610200890152612741565b6101a08801518787830301610220880152612ea5565b6101c08701518686830301610240870152612741565b9401519282850301910152612741565b60405190612fe7826109d6565b60006020838281520152565b600019810191908211612be557565b91908203918211612be557565b9060405161301c816109d6565b602060018294805484520154910152565b908082519081815260208091019281808460051b8301019501936000915b84831061305b5750505050505090565b9091929394958480613079600193601f198682030187528a51612741565b980193019301919493929061304b565b90815260406020820181905282516001600160a01b031690820152610afa9060208301511515606082015260408301516001600160a01b03166080820152606083015160a082015260808301516001600160a01b031660c082015260a083015160e082015261018060c08401516131426101606131136101009382858801526101a0870190612741565b9060e088015193610120948588015288015193610140948588015288015190603f19878403019087015261302d565b9401516001600160a01b0316910152565b600260c9541461316457600260c955565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b156131b057565b60405162461bcd60e51b81526020600482015260166024820152754e6f7420616c6c6f772065746820776974686472617760501b6044820152606490fd5b156131f557565b60405162461bcd60e51b8152602060048201526002602482015261353560f11b6044820152606490fd5b1561322657565b60405162461bcd60e51b8152602060048201526002602482015261726760f01b6044820152606490fd5b1561325757565b60405162461bcd60e51b8152602060048201526002602482015261706960f01b6044820152606490fd5b1561328857565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606490fd5b156132c457565b60405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a59081cde5b98c81c1bda5b9d60721b6044820152606490fd5b604090610afa939281528160208201520190612741565b1561331c57565b60405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199bdc9dd85c9908185b5bdd5b9d60521b6044820152606490fd5b1561336157565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b6044820152606490fd5b1561339d57565b60405162461bcd60e51b815260206004820152601f60248201527f52616e676520626174636820726f6f742068617368206e6f74206578697374006044820152606490fd5b156133e957565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726f6f7420686173686573206c656e6774680000000000006044820152606490fd5b90156134375790565b634e487b7160e01b600052603260045260246000fd5b91908110156134375760051b0190565b1561346457565b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dee4e4cac6e840e4dedee840d0c2e6d606b1b6044820152606490fd5b156134a657565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc8195e18d95959608a1b6044820152606490fd5b156134e457565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b8115613525570490565b634e487b7160e01b600052601260045260246000fd5b61354361295c565b916000918351613552816117a8565b61355b816117a8565b15613615575b9061360a613605826135ff876001600160401b036135f86135c961359c61360f9a61187c63ffffffff610afa9f602001511663ffffffff1690565b9a6135c36135bd6135b4604088015163ffffffff1690565b63ffffffff1690565b8d61351b565b90612d95565b996135f26135b460606135e660a08801516001600160401b031690565b96015163ffffffff1690565b9061351b565b9116612d95565b95612d95565b612ff3565b61351b565b90613642565b80925060110290601182048303612be5579091613561565b6202a5ac8082111561363d575090565b905090565b908082111561363d575090565b60405190608082018281106001600160401b0382111761099b576040526080368337565b61367b610a4e565b90600080835280602084015280604084015260609080828501528060808501528060a08501528060c08501528060e0850152806101008501526101208401526136c261364f565b6101408401528061016084015280610180840152806101a0840152806101c08401526101e0830152565b906136f682612df7565b61370360405191826109f1565b8281528092613714601f1991612df7565b0190602036910137565b604090613729613673565b5060e0810151906101008082015191613740610a6e565b600090818152816020820152818782015281606082015260c0830151916137656123ed565b938161377761012080930151516136ec565b966137806123ed565b986137896123ed565b9a83613793610a4e565b9d8e828152826020820152015260608d015260808c01528160a08c01528160c08c01528160e08c01528a01528801526101408701526101608601526101808501526101a08401526101c08301526101e082015290565b60a0906040516137f8816109bb565b6000928184809352826020820152826040820152826060820152826080820152015261ffff81511690604060018060a01b03602083015116910151602081519101209160405193613848856109bb565b84526001602085015260408401526180086060840152608083015260a082015290565b939290613876612892565b61013554851161398657613981938361389361396f955160ff1690565b9061393a6138a46020830151151590565b610de66138b6604085015161ffff1690565b60608501519094906001600160a01b0316608082015160a09092015160405160f898891b6001600160f81b0319166020820190815295151590981b602189015260f09690961b6001600160f01b031916602288015260601b6bffffffffffffffffffffffff1916602487015260388601526058850193909352929182906078820190565b5190209261396a7f72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba8514156139b0565b613c7b565b91600052610136602052604060002090565b541490565b60405162461bcd60e51b81526020600482015260026024820152610f0f60f31b6044820152606490fd5b156139b757565b60405162461bcd60e51b8152602060048201526002602482015261747760f01b6044820152606490fd5b606c815103613a765760048101516393f69f0760e01b60e09190911b6001600160e01b03191601613a4c57613a3391613a4882613a24613a3b9460188091015191565b60208184018101519297910190565b949094612d87565b6014908181019201015191565b5090565b60405162461bcd60e51b8152602060048201526002602482015261697360f01b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261706d60f01b6044820152606490fd5b600080809381935af115613ab057565b60405162461bcd60e51b8152602060048201526002602482015261383d60f11b6044820152606490fd5b906020610afa92818152019061302d565b80516001600160a01b03166020820151151560408301519092906001600160a01b0316606082015160808301519093906001600160a01b031660a08401519360c08101518051906020012060e0820151610100830151916101208401519760405198896020810191613b5d9083613ada565b0399601f199a8b81018252613b7290826109f1565b51902061014095860151604080517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c602082019081526001600160a01b039b8c16928201929092529d151560608f015299891660808e015260a08d019b909b5295871660c08c015260e08b01526101008a0152610120890152908701526101608601529092166101808401526101a09081018352909190613c1390826109f1565b51902090565b15613c2057565b60405162461bcd60e51b8152602060048201526002602482015261189d60f21b6044820152606490fd5b15613c5157565b60405162461bcd60e51b81526020600482015260026024820152610e0f60f31b6044820152606490fd5b9092918315613d1d57919092613c946101008210613c19565b600191613ca483831b8510613c4a565b9360009182915b818310613cbb5750505050505090565b9091929380959681881615600014613cfa57613cec90613cdc86868661344d565b3590600052602052604060002090565b96811c959493019190613cab565b613d1890613d0986868661344d565b35600052602052604060002090565b613cec565b60405162461bcd60e51b8152602060048201526002602482015261786360f01b6044820152606490fd5b15613d4e57565b60405162461bcd60e51b8152602060048201526002602482015261756960f01b6044820152606490fd5b15613d7f57565b60405162461bcd60e51b8152602060048201526002602482015261756b60f01b6044820152606490fd5b15613db057565b60405162461bcd60e51b8152602060048201526002602482015261075760f41b6044820152606490fd5b91606083015192825180600a0290600a820403612be5576127109080821115613e7c5750915b828510613e52576101a0613e4b93610a1f960394613e2463044aa200871115613d47565b613e3e6080850193613e3785518961351b565b1115613d78565b5192015151905191613e84565b1115613da9565b60405162461bcd60e51b81526020600482015260026024820152616d7960f01b6044820152606490fd5b905091613e00565b91909161067890818102918183041490151715612be55780613ef557506000915b62028cf5928301809311612be5576109a990818102918183041481151715612be5576135c3613ee2613edd6135c394610afa97612d95565b61362d565b9361187c613eef82612bd4565b93612bea565b6000198101908111612be557610220900460018101809111612be55791613ea556fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca264697066735822122092e1a4f03af3a59346fdcd982b3424c55fe1a42e04e26008b49bc6e54df5643e64736f6c63430008120033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"libraries":{},"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"":["*"],"*":["*"]}},"viaIR":true},"optimization_runs":200,"sourcify_repo_url":null,"decoded_constructor_args":[["true",{"internalType":"bool","name":"_isEthGasToken","type":"bool"}]],"compiler_version":"v0.8.18+commit.87f61d96","is_verified_via_verifier_alliance":false,"verified_at":"2026-10-29T10:30:02.052611Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x60c0346200013e57601f620040c738819003918201601f19168301916001600160401b0383118484101762000143578084926020946040528339810103126200013e575180151581036200013e573060805260a05260005460ff8160081c16620000e95760ff80821603620000ad575b604051613f6d90816200015a823960805181818161068601528181610b3e0152610c9b015260a0518181816111b7015281816114910152611e560152f35b60ff90811916176000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160ff8152a1386200006f565b60405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c8062e969a814610338578063042901c7146103335780630ec6b0b71461032e578063116191b6146103105780631dd26496146103295780632425b3a4146103245780633659cfe61461031f57806336e2e3f31461031a5780633f4ba83a1461031557806342bf3cc1146103105780634623c91d1461030b5780634ecf53e9146103065780634f1ef286146103015780634fc07d75146102b157806351ef251b1461029d57806352d1902d146102fc578063534ca054146102f75780635a425fcd146102f25780635a9f55b0146102ed5780635c975abb146102e85780635e78d327146102e3578063637c9d9d146102de57806363b434941461028e57806364bf8d66146102d95780636c0960f9146102d4578063715018a6146102cf5780637666f125146102ca5780637adbe273146102c55780638129fc1c146102c057806383864ac4146102a25780638456cb59146102bb5780638aa50991146102b65780638da5cb5b146102b157806390646b4a146102ac5780639242164f146102a75780639cd939e4146102a2578063a1954fc51461029d578063af32a0a714610298578063b473318e14610293578063b8c2f66f1461028e578063ba745e5314610289578063bc5455d014610284578063bd7c54121461027f578063be3bc8ea1461027a578063ca98ef4f14610275578063cfe6128214610270578063e0a1bf721461026b578063e4948f4314610266578063eb67241914610261578063f2fde38b1461025c578063fa52c7d8146102575763facd743b1461025757600080fd5b612247565b6121b6565b611dd9565b611d24565b611cb7565b611b7d565b611b5e565b611953565b611913565b6118a8565b611889565b611040565b611855565b611836565b610c69565b61159e565b6117c8565b6116d7565b610c40565b611625565b6115cb565b6114b6565b611479565b6113fd565b61139c565b611144565b61105f565b611013565b610f75565b610f52565b610f25565b610d6c565b610d4d565b610c88565b610afd565b61092f565b61089e565b610511565b6107e2565b6107ac565b61065f565b610576565b61053b565b6104f2565b6103f3565b61034d565b600091031261034857565b600080fd5b346103485760003660031901126103485760206040517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c8152f35b6064359061ffff8216820361034857565b6044359061ffff8216820361034857565b359061ffff8216820361034857565b9181601f84011215610348578235916001600160401b038311610348576020808501948460051b01011161034857565b6002111561034857565b346103485760c03660031901126103485761040c610388565b6084356001600160401b0381116103485761042b9036906004016103b9565b60a4359291610439846103e9565b6004356000526101376020526040600020549283156104b857846104a2946104636104b4976117a8565b61048561046e610a12565b60008152600160208201529361ffff166040850152565b6180016060840152608083015260a082015260443560243561386b565b60405190151581529081906020820190565b0390f35b60405162461bcd60e51b8152602060048201526012602482015271092dcecc2d8d2c840d86440e8f040d0c2e6d60731b6044820152606490fd5b3461034857600036600319011261034857602060405163044aa2008152f35b346103485760003660031901126103485761012d546040516001600160a01b039091168152602090f35b346103485760003660031901126103485761013b546040516001600160a01b039091168152602090f35b6001600160a01b0381160361034857565b346103485760203660031901126103485760043561059381610565565b61059b61228a565b6001600160a01b039080821680156106265761013b546001600160a01b0316928316036105c457005b61013b80546001600160a01b0319166001600160a01b0383161790557f98ac3b973026c0d730e72f023f161bebb4ba504d9b1c6b83d849d3cbaf7f51f491604080516001600160a01b039283168152929091166020830152819081015b0390a1005b60405162461bcd60e51b815260206004820152601160248201527024b73b30b634b21030b63637b1b0ba37b960791b6044820152606490fd5b346103485760203660031901126103485760043561067c81610565565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811691906106b53084141561232b565b6106d2600080516020613f1883398151915293828554161461238c565b6106da61228a565b6106e26123ed565b9061070e7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1690565b1561072157505061071f91506124dd565b005b6020600491604094939451928380926352d1902d60e01b825286165afa6000918161077c575b506107695760405162461bcd60e51b8152806107656004820161248e565b0390fd5b61071f936107779114612430565b61256d565b61079e91925060203d81116107a5575b61079681836109f1565b810190612415565b9038610747565b503d61078c565b34610348576020366003190112610348576004356000526101346020526040806000206001815491015482519182526020820152f35b34610348576000366003190112610348576107fb61228a565b60fb5460ff81161561083a5760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b60409060031901126103485760043561088e81610565565b9060243580151581036103485790565b34610348576108ac36610876565b61012d5490916001600160a01b03916108c89083163314612914565b16908160005261012e60205260406000209060ff82541681151580911515036108ed57005b6109266020927f065b77b53864e46fda3d8986acb51696223d6dde7ced42441eb150bae6d48136949060ff801983541691151516179055565b604051908152a2005b346103485760203660031901126103485760043561094c81610565565b60018060a01b031660005261012f602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161099b57604052565b610972565b606081019081106001600160401b0382111761099b57604052565b60c081019081106001600160401b0382111761099b57604052565b604081019081106001600160401b0382111761099b57604052565b90601f801991011681019081106001600160401b0382111761099b57604052565b60405190610a1f826109bb565b565b60405190610a1f826109a0565b6040519061016082018281106001600160401b0382111761099b57604052565b6040519061020082018281106001600160401b0382111761099b57604052565b60405190608082018281106001600160401b0382111761099b57604052565b6001600160401b03811161099b57601f01601f191660200190565b929192610ab482610a8d565b91610ac260405193846109f1565b829481845281830111610348578281602093846000960137010152565b9080601f8301121561034857816020610afa93359101610aa8565b90565b604036600319011261034857600435610b1581610565565b6024356001600160401b03811161034857610b34903690600401610adf565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116929190610b6e3085141561232b565b610b8b600080516020613f1883398151915294828654161461238c565b610b9361228a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610bc957505061071f91506124dd565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610c20575b50610c0d5760405162461bcd60e51b8152806107656004820161248e565b61071f93610c1b9114612430565b612629565b610c3991925060203d81116107a55761079681836109f1565b9038610bef565b34610348576000366003190112610348576033546040516001600160a01b039091168152602090f35b3461034857600036600319011261034857602061013254604051908152f35b34610348576000366003190112610348577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610ce257604051600080516020613f188339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b3461034857600036600319011261034857602061013054604051908152f35b34610348576060366003190112610348576004356024356044356001600160401b03811161034857610da29036906004016103b9565b9290923360005261012e602052610dc060ff60406000205416613281565b610dcc8284101561335a565b6040805160208101848152918101859052610df481606081015b03601f1981018352826109f1565b51902093610e0d8560005261013c602052604060002090565b5491610e1a831515613396565b610e36610e2f610e2a8688613002565b612d79565b82146133e2565b610e40818361342e565b359182610e5886600052610136602052604060002090565b5560019081925b808410610edf577fddf6b2cf5bdb04a03cb3f7663b72571336626b1e586a3a047942e4860cf7e12b88886000610eab8d610e9a8c8c1461345d565b60005261013c602052604060002090565b55610135548211610ed0575b6040805191825260208201929092529081908101610621565b610eda8261013555565b610eb7565b9091610f1b8495610ef28396858761344d565b359081610f0c898c01600052610136602052604060002090565b55600052602052604060002090565b9401929190610e5f565b34610348576020366003190112610348576004356000526101376020526020604060002054604051908152f35b3461034857600036600319011261034857602060ff60fb54166040519015158152f35b6060366003190112610348577fab53214e3a56f049923c5f5532ea4657bba51b870850593c4dc0eceb3b61feed60043560243590610621604435610fc560018060a01b0361012d54163314612914565b610fd0813414613315565b826101358054821161100b575b5060005261013660205283604060002055604051938493846040919493926060820195825260208201520152565b558238610fdd565b346103485760203660031901126103485760043560005261013c6020526020604060002054604051908152f35b3461034857600036600319011261034857602061013554604051908152f35b346103485760c03660031901126103485761108660018060a01b0361012d54163314612914565b6044356110928161294e565b60843561109e8161294e565b63ffffffff8091169116106110ed577fc8b245ac8b138b17b6b1dbbbb8860adc66b373afa000d99f3cdc775d8ae0bbed6106216110d961295c565b6110e16129dd565b60405191829182612ad7565b60405162461bcd60e51b8152602060048201526002602482015261371b60f11b6044820152606490fd5b9181601f84011215610348578235916001600160401b038311610348576020838186019501011161034857565b346103485760a036600319011261034857602435600435611163610399565b916001600160401b039160643583811161034857611185903690600401611117565b929091608435948511610348576112556112506111a7600497369089016103b9565b9590966111b2613153565b6111db7f00000000000000000000000000000000000000000000000000000000000000006131a9565b61121c61121761121361120c896111fd8a60005261013a602052604060002090565b90600052602052604060002090565b5460ff1690565b1590565b6131ee565b611231611227610a21565b61ffff909b168b52565b61800a60208b0152611244368284610aa8565b60408b01523691610aa8565b6139e1565b9491959097602061127d61127161012d5460018060a01b031690565b6001600160a01b031690565b60405163388e611f60e11b8152998a9182905afa968715611397577f26464d64ddb13f6d187de632d165bd1065382ec0b66c25c648957116e7bc25c898600098611341575b506112fe61132196946111fd946112f761131498956112f26113039660018060a01b039e8f80911691161461321f565b6137e9565b878661386b565b613250565b60005261013a602052604060002090565b805460ff19166001179055565b61132b8482613aa0565b6040519384521691602090a261071f600160c955565b61130391985061132196946111fd946112f761131498956112f261137e6112fe9660203d8111611390575b61137681836109f1565b810190612de2565b9d9650509598505094509496506112c2565b503d61136c565b612424565b34610348576000806003193601126113fa576113b661228a565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346103485761140b36610876565b9061141461228a565b60018060a01b0316908160005261012f60205260406000209060ff825416811515809115150361144057005b6109266020927f1f8e549bdb5108ba50ebcc80bb64a20ea98bfbd9378a87380d29f3c87cdcbb2c949060ff801983541691151516179055565b346103485760003660031901126103485760206040517f000000000000000000000000000000000000000000000000000000000000000015158152f35b34610348576000806003193601126113fa5780546114eb60ff8260081c161580928193611590575b8115611570575b50612781565b806114fe600160ff196000541617600055565b611557575b61150b6127e4565b6115125780f35b61152261ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081015b0390a180f35b61156b61010061ff00196000541617600055565b611503565b303b15915081611582575b50386114e5565b6001915060ff16143861157b565b600160ff82161091506114de565b34610348576020366003190112610348576004356000526101366020526020604060002054604051908152f35b34610348576000366003190112610348576115e461228a565b6115ec612892565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b6080366003190112610348577f427754a95a2d34153366ec8bcea3939ce044aaf5c185a86149c9f6d80c4402b960806004356024356044356064359161167760018060a01b0361012d54163314612914565b6116838482101561335a565b61168e833414613315565b60408051602081018681529181018390526116ac8160608101610de6565b51902060005261013c60205281604060002055604051938452602084015260408301526060820152a1005b34610348576020366003190112610348576004356116f481610565565b6116fc61228a565b61012d546001600160a01b0390811661176a57611743908216916117218315156128d6565b61012d80546001600160a01b0319166001600160a01b03909216919091179055565b7f860df2b5ed762095deab38be8b5aa5acfbfa8d4d209e083fa00246d31b715e29600080a2005b60405162461bcd60e51b81526020600482015260166024820152754475706c696361746520696e6974206761746577617960501b6044820152606490fd5b600211156117b257565b634e487b7160e01b600052602160045260246000fd5b346103485760003660031901126103485760c0610131546001600160401b0360ff821691604051926117f9816117a8565b835263ffffffff808260081c166020850152808260281c166040850152808260481c1660608501528160681c16608084015260881c1660a0820152f35b3461034857600036600319011261034857602061013854604051908152f35b3461034857606036600319011261034857602061188160243561187c60443560043561353b565b612c00565b604051908152f35b3461034857600036600319011261034857602061013354604051908152f35b34610348576020366003190112610348576004356118c461228a565b6101309081548181036118d357005b817f208ba37ba4e5fc3f236a9c289aa28898330c1f2ec9102d54821a1ffb59e8f1d793556106216040519283928360209093929193604081019481520152565b346103485760403660031901126103485760043560005261013a6020526040600020602435600052602052602060ff604060002054166040519015158152f35b602080600319360112610348576004359060009133835261012e825261197f60ff604085205416613281565b6101325481111580611b52575b611995906132bd565b61199d612fda565b906101335480611b39575b506119e06119d16119cc6119bb84612ff3565b600052610134602052604060002090565b61300f565b92848085015191015190613002565b916119eb8261013355565b61012d54611a01906001600160a01b0316611271565b60405163388e611f60e11b815290948082600481895afa9081156113975787928392611b16575b5083516040516318d0d57560e01b928101929092526001600160a01b03909216602482015260448101859052606481019190915260848101859052611a708160a48101610de6565b611a7a8534612d95565b95803b15611b1257611aa39160405197888094819363e289adcd60e01b83528a600484016132fe565b03925af1908115611397577fba9fdc955504f0973215993a882822edf5e2b4561df97340b4d5632e64e24a0f9461155192611af9575b505192604051938493846040919493926060820195825260208201520152565b80611b06611b0c92610988565b8061033d565b38611ad9565b8280fd5b819250611b3290611a70923d85116113905761137681836109f1565b9190611a28565b611b4b9192506119bb6119cc91612ff3565b90386119a8565b5061013354811161198c565b3461034857600036600319011261034857602061013954604051908152f35b3461034857604036600319011261034857600435611b9a81610565565b602435611ba5613153565b61013b546001600160a01b039081163303611c72578115611c3c577f8f37daeecdc35f2a03da8794b025ea44e3f7c6f4e2265630836db89ff3f2f2b790611c07611bf28461013954612d95565b611c018161013854101561349f565b61013955565b600093611c238580808088865af1611c1d61267c565b506134dd565b6040519384521691602090a2611c39600160c955565b80f35b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606490fd5b60405162461bcd60e51b815260206004820152601960248201527f4e6f7420666f72776172642066656520616c6c6f6361746f72000000000000006044820152606490fd5b34610348576040366003190112610348577fdfb8da952dba6c9ec993b8f2ca8cc6ac22596f6e179520fea3fc78202e87090c6040600435602435611d0760018060a01b0361012d54163314612914565b8160005261013760205280836000205582519182526020820152a1005b3461034857600319608036820112610348576044356001600160401b03918282116103485760609082360301126103485760405190611d62826109a0565b611d6e816004016103aa565b82526024810135611d7e81610565565b6020830152604481013590838211610348576004611d9f9236920101610adf565b604082015260643591821161034857611dce6104a291611dc66104b49436906004016103b9565b9290916137e9565b60243560043561386b565b60e036600319011261034857600435611df181610565565b602435906001600160401b0360443581811161034857611e15903690600401611117565b90916064359360843560a43592831161034857611e37879336906004016103b9565b60c43592611e4484610565565b611e4c613153565b611e54612892565b7f0000000000000000000000000000000000000000000000000000000000000000156121a7575b33986000328b14612193575089611eb5611eb061120c60049a9b9c9d60018060a01b031660005261012f602052604060002090565b612ca0565b61111161111160901b01016001600160a01b0316996001995b611edb6103208514612cec565b611f24611f1e60209b611ef08d891115612d37565b611f15611f0e611f078861187c8b6101305461353b565b9283612d95565b3414612da2565b61013854612d95565b61013855565b6001600160a01b039680881661218d57508b965b87803b612176575b50506101325461012d54909c90611f5f906001600160a01b0316611271565b9b8b60409d8e519c8d809263388e611f60e11b82525afa9a8b156113975760009b612157575b50611f8e610a2e565b6001600160a01b03909b168b5215158a8c01526001600160a01b0316898c0152606089018c81526001600160a01b0390981660808a01528c60a08a01523690611fd692610aa8565b60c088015260e08701526101008601523690611ff192612e0e565b6101208401526001600160a01b031661014083015261200f8261371e565b8451908161201f82878301612ed9565b0391601f1992838101825261203490826109f1565b6101315460681c63ffffffff1663ffffffff169061205192613dda565b8461205b84613aeb565b968792612066612fda565b6104b49a7fbf5630c2adfa5e47b882a9ead657ffc6a22ce010513a3efac7245066bcad17dd986120d1966120cb96610e2a95876120fb57505083528201525b6120ba83600052610134602052604060002090565b906020600191805184550151910155565b61013255565b516120e0845192839283613089565b0390a16120ed600160c955565b519081529081906020820190565b61215093929550612141612135916121186119cc6119bb8c612ff3565b978851945193849187830196879091604092825260208201520190565b039081018352826109f1565b51902084528301918251612d95565b90526120a5565b61216f919b508c8d3d106113905761137681836109f1565b9938611f85565b811661111161111160901b01011696503880611f40565b96611f38565b98886121a26004999a15612c54565b611ece565b6121b18615612c13565b611e7b565b34610348576020366003190112610348576004356121d381610565565b6121db61228a565b6001600160a01b038116156121f35761071f906122e2565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346103485760203660031901126103485760043561226481610565565b60018060a01b031660005261012e602052602060ff604060002054166040519015158152f35b6033546001600160a01b0316330361229e57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561233257565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561239357565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b604051602081018181106001600160401b0382111761099b5760405260008152906000368137565b90816020910312610348575190565b6040513d6000823e3d90fd5b1561243757565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b803b1561251257600080516020613f1883398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b90612577826124dd565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590612621575b6125b9575050565b61261e91600080604051936125cd856109a0565b602785527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020860152660819985a5b195960ca1b6040860152602081519101845af461261861267c565b916126ac565b50565b5060006125b1565b90612633826124dd565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590612674576125b9575050565b5060016125b1565b3d156126a7573d9061268d82610a8d565b9161269b60405193846109f1565b82523d6000602084013e565b606090565b9192901561270e57508151156126c0575090565b3b156126c95790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156127215750805190602001fd5b60405162461bcd60e51b8152602060048201529081906107659060248301905b919082519283825260005b84811061276d575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520161274c565b1561278857565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b6127f560ff60005460081c16612832565b6127fe336122e2565b61282660ff60005460081c1661281381612832565b61281c81612832565b600160c955612832565b60ff1960fb541660fb55565b1561283957565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb541661289e57565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b156128dd57565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206761746577617960881b6044820152606490fd5b1561291b57565b60405162461bcd60e51b815260206004820152600b60248201526a4e6f74206761746577617960a81b6044820152606490fd5b63ffffffff81160361034857565b60405190612969826109bb565b8160a06001600160401b036101315460ff8116612985816117a8565b845263ffffffff808260081c166020860152808260281c166040860152808260481c1660608601528160681c16608085015260881c16910152565b6001600160401b0381160361034857565b60a435610afa816129c0565b6004356129e9816103e9565b6129f2816117a8565b6101319081546cffffffff000000000000000000602435612a128161294e565b68ffffffff000000000060443591612a298361294e565b64ffffffff0060643595612a3c8761294e565b60ff608435612a4a8161294e565b63ffffffff60681b9060681b1698169070ffffffffffffffffffffffffffffffffff1916179160081b16179160281b16179160481b1617179055610a1f612a8f6129d1565b610131805467ffffffffffffffff60881b191660889290921b67ffffffffffffffff60881b16919091179055565b60843590610a1f8261294e565b60a43590610a1f826129c0565b815161018082019392610a1f9291612aee816117a8565b82526001600160401b0360a063ffffffff9283602082015116602086015283604082015116604086015283606082015116606086015283608082015116608086015201511660a0830152600435612b44816103e9565b612b4d816117a8565b60c083015280602435612b5f8161294e565b1660e083015280604435612b728161294e565b16610100830152606435612b858161294e565b16610120820152612ba5612b97612abd565b63ffffffff16610140830152565b610160612bb0612aca565b6001600160401b0316910152565b634e487b7160e01b600052601160045260246000fd5b9081605802916058830403612be557565b612bbe565b908160061b9180830460401490151715612be557565b81810292918115918404141715612be557565b15612c1a57565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420616c6c6f77206c322076616c756560701b6044820152606490fd5b15612c5b57565b60405162461bcd60e51b815260206004820152601a60248201527f4e6f7420616c6c6f7720746f2063616c6c20636f6e74726163740000000000006044820152606490fd5b15612ca757565b60405162461bcd60e51b815260206004820152601c60248201527f4e6f7420616c6c6f7720746f2073656e64204c322072657175657374000000006044820152606490fd5b15612cf357565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206c3247617350657250756264617461427974654c696d69746044820152fd5b15612d3e57565b60405162461bcd60e51b8152602060048201526013602482015272496e76616c696420666163746f72794465707360681b6044820152606490fd5b9060018201809211612be557565b9060208201809211612be557565b91908201809211612be557565b15612da957565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964206d73672076616c756560781b6044820152606490fd5b908160209103126103485751610afa81610565565b6001600160401b03811161099b5760051b60200190565b92919092612e1b84612df7565b91612e2960405193846109f1565b829480845260208094019060051b8301928284116103485780915b848310612e5357505050505050565b82356001600160401b038111610348578691612e728684938601610adf565b815201920191612e44565b6000915b60048310612e8e57505050565b600190825181526020809101920192019190612e81565b90815180825260208080930193019160005b828110612ec5575050505090565b835185529381019392810192600101612eb7565b90610afa916020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e082015260e0820151610100908183015282015161012090818301528201516101409081830152820151612f5b6101609182840190612e7d565b82015190610260612f796101e0938285850152610280840190612741565b92612fca612fb4612f9e61018088015196601f19978888830301610200890152612741565b6101a08801518787830301610220880152612ea5565b6101c08701518686830301610240870152612741565b9401519282850301910152612741565b60405190612fe7826109d6565b60006020838281520152565b600019810191908211612be557565b91908203918211612be557565b9060405161301c816109d6565b602060018294805484520154910152565b908082519081815260208091019281808460051b8301019501936000915b84831061305b5750505050505090565b9091929394958480613079600193601f198682030187528a51612741565b980193019301919493929061304b565b90815260406020820181905282516001600160a01b031690820152610afa9060208301511515606082015260408301516001600160a01b03166080820152606083015160a082015260808301516001600160a01b031660c082015260a083015160e082015261018060c08401516131426101606131136101009382858801526101a0870190612741565b9060e088015193610120948588015288015193610140948588015288015190603f19878403019087015261302d565b9401516001600160a01b0316910152565b600260c9541461316457600260c955565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b156131b057565b60405162461bcd60e51b81526020600482015260166024820152754e6f7420616c6c6f772065746820776974686472617760501b6044820152606490fd5b156131f557565b60405162461bcd60e51b8152602060048201526002602482015261353560f11b6044820152606490fd5b1561322657565b60405162461bcd60e51b8152602060048201526002602482015261726760f01b6044820152606490fd5b1561325757565b60405162461bcd60e51b8152602060048201526002602482015261706960f01b6044820152606490fd5b1561328857565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606490fd5b156132c457565b60405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a59081cde5b98c81c1bda5b9d60721b6044820152606490fd5b604090610afa939281528160208201520190612741565b1561331c57565b60405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199bdc9dd85c9908185b5bdd5b9d60521b6044820152606490fd5b1561336157565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b6044820152606490fd5b1561339d57565b60405162461bcd60e51b815260206004820152601f60248201527f52616e676520626174636820726f6f742068617368206e6f74206578697374006044820152606490fd5b156133e957565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726f6f7420686173686573206c656e6774680000000000006044820152606490fd5b90156134375790565b634e487b7160e01b600052603260045260246000fd5b91908110156134375760051b0190565b1561346457565b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dee4e4cac6e840e4dedee840d0c2e6d606b1b6044820152606490fd5b156134a657565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc8195e18d95959608a1b6044820152606490fd5b156134e457565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b8115613525570490565b634e487b7160e01b600052601260045260246000fd5b61354361295c565b916000918351613552816117a8565b61355b816117a8565b15613615575b9061360a613605826135ff876001600160401b036135f86135c961359c61360f9a61187c63ffffffff610afa9f602001511663ffffffff1690565b9a6135c36135bd6135b4604088015163ffffffff1690565b63ffffffff1690565b8d61351b565b90612d95565b996135f26135b460606135e660a08801516001600160401b031690565b96015163ffffffff1690565b9061351b565b9116612d95565b95612d95565b612ff3565b61351b565b90613642565b80925060110290601182048303612be5579091613561565b6202a5ac8082111561363d575090565b905090565b908082111561363d575090565b60405190608082018281106001600160401b0382111761099b576040526080368337565b61367b610a4e565b90600080835280602084015280604084015260609080828501528060808501528060a08501528060c08501528060e0850152806101008501526101208401526136c261364f565b6101408401528061016084015280610180840152806101a0840152806101c08401526101e0830152565b906136f682612df7565b61370360405191826109f1565b8281528092613714601f1991612df7565b0190602036910137565b604090613729613673565b5060e0810151906101008082015191613740610a6e565b600090818152816020820152818782015281606082015260c0830151916137656123ed565b938161377761012080930151516136ec565b966137806123ed565b986137896123ed565b9a83613793610a4e565b9d8e828152826020820152015260608d015260808c01528160a08c01528160c08c01528160e08c01528a01528801526101408701526101608601526101808501526101a08401526101c08301526101e082015290565b60a0906040516137f8816109bb565b6000928184809352826020820152826040820152826060820152826080820152015261ffff81511690604060018060a01b03602083015116910151602081519101209160405193613848856109bb565b84526001602085015260408401526180086060840152608083015260a082015290565b939290613876612892565b61013554851161398657613981938361389361396f955160ff1690565b9061393a6138a46020830151151590565b610de66138b6604085015161ffff1690565b60608501519094906001600160a01b0316608082015160a09092015160405160f898891b6001600160f81b0319166020820190815295151590981b602189015260f09690961b6001600160f01b031916602288015260601b6bffffffffffffffffffffffff1916602487015260388601526058850193909352929182906078820190565b5190209261396a7f72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba8514156139b0565b613c7b565b91600052610136602052604060002090565b541490565b60405162461bcd60e51b81526020600482015260026024820152610f0f60f31b6044820152606490fd5b156139b757565b60405162461bcd60e51b8152602060048201526002602482015261747760f01b6044820152606490fd5b606c815103613a765760048101516393f69f0760e01b60e09190911b6001600160e01b03191601613a4c57613a3391613a4882613a24613a3b9460188091015191565b60208184018101519297910190565b949094612d87565b6014908181019201015191565b5090565b60405162461bcd60e51b8152602060048201526002602482015261697360f01b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261706d60f01b6044820152606490fd5b600080809381935af115613ab057565b60405162461bcd60e51b8152602060048201526002602482015261383d60f11b6044820152606490fd5b906020610afa92818152019061302d565b80516001600160a01b03166020820151151560408301519092906001600160a01b0316606082015160808301519093906001600160a01b031660a08401519360c08101518051906020012060e0820151610100830151916101208401519760405198896020810191613b5d9083613ada565b0399601f199a8b81018252613b7290826109f1565b51902061014095860151604080517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c602082019081526001600160a01b039b8c16928201929092529d151560608f015299891660808e015260a08d019b909b5295871660c08c015260e08b01526101008a0152610120890152908701526101608601529092166101808401526101a09081018352909190613c1390826109f1565b51902090565b15613c2057565b60405162461bcd60e51b8152602060048201526002602482015261189d60f21b6044820152606490fd5b15613c5157565b60405162461bcd60e51b81526020600482015260026024820152610e0f60f31b6044820152606490fd5b9092918315613d1d57919092613c946101008210613c19565b600191613ca483831b8510613c4a565b9360009182915b818310613cbb5750505050505090565b9091929380959681881615600014613cfa57613cec90613cdc86868661344d565b3590600052602052604060002090565b96811c959493019190613cab565b613d1890613d0986868661344d565b35600052602052604060002090565b613cec565b60405162461bcd60e51b8152602060048201526002602482015261786360f01b6044820152606490fd5b15613d4e57565b60405162461bcd60e51b8152602060048201526002602482015261756960f01b6044820152606490fd5b15613d7f57565b60405162461bcd60e51b8152602060048201526002602482015261756b60f01b6044820152606490fd5b15613db057565b60405162461bcd60e51b8152602060048201526002602482015261075760f41b6044820152606490fd5b91606083015192825180600a0290600a820403612be5576127109080821115613e7c5750915b828510613e52576101a0613e4b93610a1f960394613e2463044aa200871115613d47565b613e3e6080850193613e3785518961351b565b1115613d78565b5192015151905191613e84565b1115613da9565b60405162461bcd60e51b81526020600482015260026024820152616d7960f01b6044820152606490fd5b905091613e00565b91909161067890818102918183041490151715612be55780613ef557506000915b62028cf5928301809311612be5576109a990818102918183041481151715612be5576135c3613ee2613edd6135c394610afa97612d95565b61362d565b9361187c613eef82612bd4565b93612bea565b6000198101908111612be557610220900460018101809111612be55791613ea556fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca264697066735822122092e1a4f03af3a59346fdcd982b3424c55fe1a42e04e26008b49bc6e54df5643e64736f6c634300081200330000000000000000000000000000000000000000000000000000000000000001","name":"ZkLinkLegacyPaused","is_blueprint":false,"license_type":"none","is_fully_verified":true,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"default","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"contracts/zksync/l1-contracts/bridge/interfaces/IL1Bridge.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title L1 Bridge contract interface\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IL1Bridge {\n    event DepositInitiated(\n        bytes32 indexed l2DepositTxHash,\n        address indexed from,\n        address indexed to,\n        address l1Token,\n        uint256 amount\n    );\n\n    event DepositToMergeInitiated(\n        bytes32 indexed l2DepositTxHash,\n        address indexed from,\n        address indexed to,\n        address l1Token,\n        uint256 amount,\n        bool toMerge\n    );\n\n    event WithdrawalFinalized(address indexed to, address indexed l1Token, uint256 amount);\n\n    event ClaimedFailedDeposit(address indexed to, address indexed l1Token, uint256 amount);\n\n    function isWithdrawalFinalized(uint256 _l2BatchNumber, uint256 _l2MessageIndex) external view returns (bool);\n\n    function deposit(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte,\n        address _refundRecipient\n    ) external payable returns (bytes32 txHash);\n\n    function depositToMerge(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte,\n        address _refundRecipient\n    ) external payable returns (bytes32 txHash);\n\n    function claimFailedDeposit(\n        address _depositSender,\n        address _l1Token,\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof\n    ) external;\n\n    function finalizeWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external;\n\n    function l2TokenAddress(address _l1Token) external view returns (address);\n\n    function l2Bridge() external view returns (address);\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/libraries/UncheckedMath.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @author Matter Labs\n * @custom:security-contact security@matterlabs.dev\n * @notice The library for unchecked math.\n */\nlibrary UncheckedMath {\n    function uncheckedInc(uint256 _number) internal pure returns (uint256) {\n        unchecked {\n            return _number + 1;\n        }\n    }\n\n    function uncheckedAdd(uint256 _lhs, uint256 _rhs) internal pure returns (uint256) {\n        unchecked {\n            return _lhs + _rhs;\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/IERC1967Upgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport {Initializable} from \"../utils/Initializable.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    function __ERC1967Upgrade_init() internal onlyInitializing {\n    }\n\n    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            AddressUpgradeable.functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n        }\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"contracts/zksync/l1-contracts/bridge/interfaces/IL2ERC20Bridge.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author Matter Labs\ninterface IL2ERC20Bridge {\n    function initialize(address _l1Bridge, bytes32 _l2TokenProxyBytecodeHash, address _governor) external;\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/ERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the default value returned by this function, unless\n     * it's overridden.\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address to, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, amount);\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, allowance(owner, spender) + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        uint256 currentAllowance = allowance(owner, spender);\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(owner, spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(address from, address to, uint256 amount) internal virtual {\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, amount);\n\n        uint256 fromBalance = _balances[from];\n        require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[from] = fromBalance - amount;\n            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n            // decrementing then incrementing.\n            _balances[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        _afterTokenTransfer(from, to, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        unchecked {\n            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n            _balances[account] += amount;\n        }\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n            // Overflow not possible: amount <= accountBalance <= totalSupply.\n            _totalSupply -= amount;\n        }\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(address owner, address spender, uint256 amount) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n            unchecked {\n                _approve(owner, spender, currentAllowance - amount);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}\n}\n"},{"file_path":"@openzeppelin/contracts/proxy/beacon/IBeacon.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/IERC1967.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967 {\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Emitted when the beacon is changed.\n     */\n    event BeaconUpgraded(address indexed beacon);\n}\n"},{"file_path":"contracts/ZkLinkMantlePaused.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLinkMantlePaused is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n    using SafeERC20 for IERC20;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor() {\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!gateway.isEthGasToken()) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        if (_toBatchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _toBatchNumber;\n        }\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view whenNotPaused returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        if (gateway.isEthGasToken()) {\n            bool callSuccess;\n            // Low-level assembly call, to avoid any memory copying (save gas)\n            assembly {\n                callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n            }\n            require(callSuccess, \"pz\");\n        } else {\n            SafeERC20.safeTransfer(gateway.ethToken(), _to, _amount);\n        }\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == _ENTERED;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/interfaces/IAdmin.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {FeeParams} from \"../Storage.sol\";\nimport {IL2Gateway} from \"../../../../interfaces/IL2Gateway.sol\";\n\n/// @title The interface of the Admin Contract that controls access rights for contract management.\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IAdmin {\n    /// @notice Init gateway\n    /// @param _gateway The gateway on local chain\n    function setGateway(IL2Gateway _gateway) external;\n\n    /// @notice Change validator status (active or not active)\n    /// @param _validator Validator address\n    /// @param _active Active flag\n    function setValidator(address _validator, bool _active) external;\n\n    /// @notice Change the fee params for L1->L2 transactions\n    /// @param _newFeeParams The new fee params\n    function changeFeeParams(FeeParams calldata _newFeeParams) external;\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/interfaces/IGetters.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {IL2Gateway} from \"../../../../interfaces/IL2Gateway.sol\";\n\n/// @title The interface of the Getters Contract that implements functions for getting contract state from outside the blockchain.\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IGetters {\n    /*//////////////////////////////////////////////////////////////\n                            CUSTOM GETTERS\n    //////////////////////////////////////////////////////////////*/\n\n    /// @return The gateway on local chain\n    function getGateway() external view returns (IL2Gateway);\n\n    /// @return The address of the current governor\n    function getGovernor() external view returns (address);\n\n    /// @return The total number of batches that were committed & verified & executed\n    function getTotalBatchesExecuted() external view returns (uint256);\n\n    /// @return The total number of priority operations that were added to the priority queue, including all processed ones\n    function getTotalPriorityTxs() external view returns (uint256);\n\n    /// @return Whether the address has a validator access\n    function isValidator(address _address) external view returns (bool);\n\n    /// @return merkleRoot Merkle root of the tree with L2 logs for the selected batch\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot);\n\n    /// @return The maximum number of L2 gas that a user can request for L1 -> L2 transactions\n    function getPriorityTxMaxGasLimit() external view returns (uint256);\n\n    /// @return Whether a withdrawal has been finalized.\n    /// @param _l2BatchNumber The L2 batch number within which the withdrawal happened.\n    /// @param _l2MessageIndex The index of the L2->L1 message denoting the withdrawal.\n    function isEthWithdrawalFinalized(uint256 _l2BatchNumber, uint256 _l2MessageIndex) external view returns (bool);\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967Upgradeable {\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Emitted when the beacon is changed.\n     */\n    event BeaconUpgraded(address indexed beacon);\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlotUpgradeable {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/interfaces/IZkSync.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\ninterface IZkSync {\n    /// @notice Update secondary chain status\n    /// @param _gateway The secondary chain gateway\n    /// @param _active Active flag\n    function setSecondaryChainGateway(address _gateway, bool _active) external;\n\n    /// @notice Receive sync status from secondary chain\n    /// @param _secondaryChainGateway The secondary chain gateway address\n    /// @param _newTotalSyncedPriorityTxs New sync point\n    /// @param _syncHash New sync hash\n    /// @param _forwardEthAmount The difference eth amount between two sync points\n    function syncL2Requests(\n        address _secondaryChainGateway,\n        uint256 _newTotalSyncedPriorityTxs,\n        bytes32 _syncHash,\n        uint256 _forwardEthAmount\n    ) external payable;\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/ReentrancyGuard.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @custom:security-contact security@matterlabs.dev\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n *\n * _Since v2.5.0:_ this module is now much more gas efficient, given net gas\n * metering changes introduced in the Istanbul hardfork.\n */\nabstract contract ReentrancyGuard {\n    /// @dev Address of lock flag variable.\n    /// @dev Flag is placed at random memory location to not interfere with Storage contract.\n    // keccak256(\"ReentrancyGuard\") - 1;\n    uint256 private constant LOCK_FLAG_ADDRESS = 0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4;\n\n    // solhint-disable-next-line max-line-length\n    // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/566a774222707e424896c0c390a84dc3c13bdcb2/contracts/security/ReentrancyGuard.sol\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    modifier reentrancyGuardInitializer() {\n        _initializeReentrancyGuard();\n        _;\n    }\n\n    function _initializeReentrancyGuard() private {\n        uint256 lockSlotOldValue;\n\n        // Storing an initial non-zero value makes deployment a bit more\n        // expensive but in exchange every call to nonReentrant\n        // will be cheaper.\n        assembly {\n            lockSlotOldValue := sload(LOCK_FLAG_ADDRESS)\n            sstore(LOCK_FLAG_ADDRESS, _NOT_ENTERED)\n        }\n\n        // Check that storage slot for reentrancy guard is empty to rule out possibility of slot conflict\n        require(lockSlotOldValue == 0, \"1B\");\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and make it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        uint256 _status;\n        assembly {\n            _status := sload(LOCK_FLAG_ADDRESS)\n        }\n\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status == _NOT_ENTERED, \"r1\");\n\n        // Any calls to nonReentrant after this point will fail\n        assembly {\n            sstore(LOCK_FLAG_ADDRESS, _ENTERED)\n        }\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        assembly {\n            sstore(LOCK_FLAG_ADDRESS, _NOT_ENTERED)\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/libraries/L2ContractHelper.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @author Matter Labs\n * @custom:security-contact security@matterlabs.dev\n * @notice Helper library for working with L2 contracts on L1.\n */\nlibrary L2ContractHelper {\n    /// @dev The prefix used to create CREATE2 addresses.\n    bytes32 private constant CREATE2_PREFIX = keccak256(\"zksyncCreate2\");\n\n    /// @notice Validate the bytecode format and calculate its hash.\n    /// @param _bytecodeLength The bytecode length.\n    /// @param _bytecodeHash The bytecode hash.\n    /// @return hashedBytecode The 32-byte hash of the bytecode.\n    /// Note: The function reverts the execution if the bytecode has non expected format:\n    /// - Bytecode bytes length is not a multiple of 32\n    /// - Bytecode bytes length is not less than 2^21 bytes (2^16 words)\n    /// - Bytecode words length is not odd\n    function hashL2Bytecode(\n        uint256 _bytecodeLength,\n        bytes32 _bytecodeHash\n    ) internal pure returns (bytes32 hashedBytecode) {\n        // Note that the length of the bytecode must be provided in 32-byte words.\n        require(_bytecodeLength % 32 == 0, \"pq\");\n\n        uint256 bytecodeLenInWords = _bytecodeLength / 32;\n        require(bytecodeLenInWords < 2 ** 16, \"pp\"); // bytecode length must be less than 2^16 words\n        require(bytecodeLenInWords % 2 == 1, \"ps\"); // bytecode length in words must be odd\n        hashedBytecode = _bytecodeHash & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n        // Setting the version of the hash\n        hashedBytecode = (hashedBytecode | bytes32(uint256(1 << 248)));\n        // Setting the length\n        hashedBytecode = hashedBytecode | bytes32(bytecodeLenInWords << 224);\n    }\n\n    /// @notice Validates the format of the given bytecode hash.\n    /// @dev Due to the specification of the L2 bytecode hash, not every 32 bytes could be a legit bytecode hash.\n    /// @dev The function reverts on invalid bytecode hash formam.\n    /// @param _bytecodeHash The hash of the bytecode to validate.\n    function validateBytecodeHash(bytes32 _bytecodeHash) internal pure {\n        uint8 version = uint8(_bytecodeHash[0]);\n        require(version == 1 && _bytecodeHash[1] == bytes1(0), \"zf\"); // Incorrectly formatted bytecodeHash\n\n        require(_bytecodeLen(_bytecodeHash) % 2 == 1, \"uy\"); // Code length in words must be odd\n    }\n\n    /// @notice Returns the length of the bytecode associated with the given hash.\n    /// @param _bytecodeHash The hash of the bytecode.\n    /// @return codeLengthInWords The length of the bytecode in words.\n    function _bytecodeLen(bytes32 _bytecodeHash) private pure returns (uint256 codeLengthInWords) {\n        codeLengthInWords = uint256(uint8(_bytecodeHash[2])) * 256 + uint256(uint8(_bytecodeHash[3]));\n    }\n\n    /// @notice Computes the create2 address for a Layer 2 contract.\n    /// @param _sender The address of the sender.\n    /// @param _salt The salt value to use in the create2 address computation.\n    /// @param _bytecodeHash The contract bytecode hash.\n    /// @param _constructorInputHash The hash of the constructor input data.\n    /// @return The create2 address of the contract.\n    /// NOTE: L2 create2 derivation is different from L1 derivation!\n    function computeCreate2Address(\n        address _sender,\n        bytes32 _salt,\n        bytes32 _bytecodeHash,\n        bytes32 _constructorInputHash\n    ) internal pure returns (address) {\n        bytes32 senderBytes = bytes32(uint256(uint160(_sender)));\n        bytes32 data = keccak256(\n            bytes.concat(CREATE2_PREFIX, senderBytes, _salt, _bytecodeHash, _constructorInputHash)\n        );\n\n        return address(uint160(uint256(data)));\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822ProxiableUpgradeable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"},{"file_path":"contracts/ZkLinkBefore.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLinkBefore is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n    using SafeERC20 for IERC20;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor() {\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!gateway.isEthGasToken()) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        // The first open or the next open\n        require(totalBatchesExecuted == 0 || _fromBatchNumber == totalBatchesExecuted + 1, \"Invalid open\");\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        totalBatchesExecuted = _toBatchNumber;\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        if (gateway.isEthGasToken()) {\n            bool callSuccess;\n            // Low-level assembly call, to avoid any memory copying (save gas)\n            assembly {\n                callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n            }\n            require(callSuccess, \"pz\");\n        } else {\n            SafeERC20.safeTransfer(gateway.ethToken(), _to, _amount);\n        }\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/StorageSlot.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"},{"file_path":"contracts/interfaces/IL2Gateway.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity ^0.8.0;\n\nimport {IGateway} from \"./IGateway.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IL2Gateway is IGateway {\n    /// @notice Emit when sending a message\n    event L2GatewayMessageSent(uint256 value, bytes callData);\n\n    /// @notice Send message to remote gateway\n    /// @param _value The msg value\n    /// @param _callData The call data\n    function sendMessage(uint256 _value, bytes calldata _callData) external payable;\n\n    function isEthGasToken() external view returns (bool);\n\n    function ethToken() external view returns (IERC20);\n}\n"},{"file_path":"@openzeppelin/contracts/proxy/Proxy.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n     * and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _beforeFallback();\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n     * is empty.\n     */\n    receive() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n     * call, or as part of the Solidity `fallback` or `receive` functions.\n     *\n     * If overridden should call `super._beforeFallback()`.\n     */\n    function _beforeFallback() internal virtual {}\n}\n"},{"file_path":"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n    /**\n     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n     *\n     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n     * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n     */\n    constructor(address _logic, bytes memory _data) payable {\n        _upgradeToAndCall(_logic, _data, false);\n    }\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _implementation() internal view virtual override returns (address impl) {\n        return ERC1967Upgrade._getImplementation();\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/Config.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @dev `keccak256(\"\")`\nbytes32 constant EMPTY_STRING_KECCAK = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\n/// @dev Bytes in raw L2 log\n/// @dev Equal to the bytes size of the tuple - (uint8 ShardId, bool isService, uint16 txNumberInBatch, address sender,\n/// bytes32 key, bytes32 value)\nuint256 constant L2_TO_L1_LOG_SERIALIZE_SIZE = 88;\n\n/// @dev The maximum length of the bytes array with L2 -> L1 logs\nuint256 constant MAX_L2_TO_L1_LOGS_COMMITMENT_BYTES = 4 + L2_TO_L1_LOG_SERIALIZE_SIZE * 512;\n\n/// @dev The value of default leaf hash for L2 -> L1 logs Merkle tree\n/// @dev An incomplete fixed-size tree is filled with this value to be a full binary tree\n/// @dev Actually equal to the `keccak256(new bytes(L2_TO_L1_LOG_SERIALIZE_SIZE))`\nbytes32 constant L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH = 0x72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba;\n\n// TODO: change constant to the real root hash of empty Merkle tree (SMA-184)\nbytes32 constant DEFAULT_L2_LOGS_TREE_ROOT_HASH = bytes32(0);\n\n/// @dev Denotes the type of the zkSync transaction that came from L1.\nuint256 constant PRIORITY_OPERATION_L2_TX_TYPE = 255;\n\n/// @dev Denotes the type of the zkSync transaction that is used for system upgrades.\nuint256 constant SYSTEM_UPGRADE_L2_TX_TYPE = 254;\n\n/// @dev The maximal allowed difference between protocol versions in an upgrade. The 100 gap is needed\n/// in case a protocol version has been tested on testnet, but then not launched on mainnet, e.g.\n/// due to a bug found.\nuint256 constant MAX_ALLOWED_PROTOCOL_VERSION_DELTA = 100;\n\n/// @dev The amount of time in seconds the validator has to process the priority transaction\n/// NOTE: The constant is set to zero for the Alpha release period\nuint256 constant PRIORITY_EXPIRATION = 0 days;\n\n/// @dev Timestamp - seconds since unix epoch.\nuint256 constant COMMIT_TIMESTAMP_NOT_OLDER = 3 days;\n\n/// @dev Maximum available error between real commit batch timestamp and analog used in the verifier (in seconds)\n/// @dev Must be used cause miner's `block.timestamp` value can differ on some small value (as we know - 12 seconds)\nuint256 constant COMMIT_TIMESTAMP_APPROXIMATION_DELTA = 1 hours;\n\n/// @dev Shift to apply to verify public input before verifying.\nuint256 constant PUBLIC_INPUT_SHIFT = 32;\n\n/// @dev The maximum number of L2 gas that a user can request for an L2 transaction\nuint256 constant MAX_GAS_PER_TRANSACTION = 80000000;\n\n/// @dev Even though the price for 1 byte of pubdata is 16 L1 gas, we have a slightly increased\n/// value.\nuint256 constant L1_GAS_PER_PUBDATA_BYTE = 17;\n\n/// @dev The intrinsic cost of the L1->l2 transaction in computational L2 gas\nuint256 constant L1_TX_INTRINSIC_L2_GAS = 167157;\n\n/// @dev The intrinsic cost of the L1->l2 transaction in pubdata\nuint256 constant L1_TX_INTRINSIC_PUBDATA = 88;\n\n/// @dev The minimal base price for L1 transaction\nuint256 constant L1_TX_MIN_L2_GAS_BASE = 173484;\n\n/// @dev The number of L2 gas the transaction starts costing more with each 544 bytes of encoding\nuint256 constant L1_TX_DELTA_544_ENCODING_BYTES = 1656;\n\n/// @dev The number of L2 gas an L1->L2 transaction gains with each new factory dependency\nuint256 constant L1_TX_DELTA_FACTORY_DEPS_L2_GAS = 2473;\n\n/// @dev The number of L2 gas an L1->L2 transaction gains with each new factory dependency\nuint256 constant L1_TX_DELTA_FACTORY_DEPS_PUBDATA = 64;\n\n/// @dev The number of pubdata an L1->L2 transaction requires with each new factory dependency\nuint256 constant MAX_NEW_FACTORY_DEPS = 32;\n\n/// @dev The L2 gasPricePerPubdata required to be used in bridges.\nuint256 constant REQUIRED_L2_GAS_PRICE_PER_PUBDATA = 800;\n\n/// @dev The mask which should be applied to the packed batch and L2 block timestamp in order\n/// to obtain the L2 block timestamp. Applying this mask is equivalent to calculating modulo 2**128\nuint256 constant PACKED_L2_BLOCK_TIMESTAMP_MASK = 0xffffffffffffffffffffffffffffffff;\n\n/// @dev The overhead for a transaction slot in L2 gas.\n/// It is roughly equal to 80kk/MAX_TRANSACTIONS_IN_BATCH, i.e. how many gas would an L1->L2 transaction\n/// need to pay to compensate for the batch being closed.\n/// @dev It is expected that the L1 contracts will enforce that the L2 gas price will be high enough to compensate\n/// the operator in case the batch is closed because of tx slots filling up.\nuint256 constant TX_SLOT_OVERHEAD_L2_GAS = 10000;\n\n/// @dev The overhead for each byte of the bootloader memory that the encoding of the transaction.\n/// It is roughly equal to 80kk/BOOTLOADER_MEMORY_FOR_TXS, i.e. how many gas would an L1->L2 transaction\n/// need to pay to compensate for the batch being closed.\n/// @dev It is expected that the L1 contracts will enforce that the L2 gas price will be high enough to compensate\n/// the operator in case the batch is closed because of the memory for transactions being filled up.\nuint256 constant MEMORY_OVERHEAD_GAS = 10;\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},{"file_path":"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/IERC1967.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n */\nabstract contract ERC1967Upgrade is IERC1967 {\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            Address.isContract(IBeacon(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n        }\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/libraries/UnsafeBytes.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @author Matter Labs\n * @custom:security-contact security@matterlabs.dev\n * @dev The library provides a set of functions that help read data from an \"abi.encodePacked\" byte array.\n * @dev Each of the functions accepts the `bytes memory` and the offset where data should be read and returns a value of a certain type.\n *\n * @dev WARNING!\n * 1) Functions don't check the length of the bytes array, so it can go out of bounds.\n * The user of the library must check for bytes length before using any functions from the library!\n *\n * 2) Read variables are not cleaned up - https://docs.soliditylang.org/en/v0.8.16/internals/variable_cleanup.html.\n * Using data in inline assembly can lead to unexpected behavior!\n */\nlibrary UnsafeBytes {\n    function readUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32 result, uint256 offset) {\n        assembly {\n            offset := add(_start, 4)\n            result := mload(add(_bytes, offset))\n        }\n    }\n\n    function readAddress(bytes memory _bytes, uint256 _start) internal pure returns (address result, uint256 offset) {\n        assembly {\n            offset := add(_start, 20)\n            result := mload(add(_bytes, offset))\n        }\n    }\n\n    function readUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256 result, uint256 offset) {\n        assembly {\n            offset := add(_start, 32)\n            result := mload(add(_bytes, offset))\n        }\n    }\n\n    function readBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32 result, uint256 offset) {\n        assembly {\n            offset := add(_start, 32)\n            result := mload(add(_bytes, offset))\n        }\n    }\n\n    // Original source code: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol#L228\n    // Get slice from bytes arrays\n    // Returns the newly created 'bytes memory'\n    // NOTE: theoretically possible overflow of (_start + _length)\n    function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {\n        require(_bytes.length >= (_start + _length), \"Z\"); // bytes length is less then start byte + length bytes\n\n        bytes memory tempBytes = new bytes(_length);\n\n        if (_length != 0) {\n            assembly {\n                let slice_curr := add(tempBytes, 0x20)\n                let slice_end := add(slice_curr, _length)\n\n                for {\n                    let array_current := add(_bytes, add(_start, 0x20))\n                } lt(slice_curr, slice_end) {\n                    slice_curr := add(slice_curr, 0x20)\n                    array_current := add(array_current, 0x20)\n                } {\n                    mstore(slice_curr, mload(array_current))\n                }\n            }\n        }\n\n        return tempBytes;\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/libraries/TransactionValidator.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\nimport {IMailbox} from \"../interfaces/IMailbox.sol\";\nimport {TX_SLOT_OVERHEAD_L2_GAS, MEMORY_OVERHEAD_GAS, L1_TX_INTRINSIC_L2_GAS, L1_TX_DELTA_544_ENCODING_BYTES, L1_TX_DELTA_FACTORY_DEPS_L2_GAS, L1_TX_MIN_L2_GAS_BASE, L1_TX_INTRINSIC_PUBDATA, L1_TX_DELTA_FACTORY_DEPS_PUBDATA, MAX_GAS_PER_TRANSACTION} from \"../Config.sol\";\n\n/// @title zkSync Library for validating L1 -> L2 transactions\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\nlibrary TransactionValidator {\n    /// @dev Used to validate key properties of an L1->L2 transaction\n    /// @param _transaction The transaction to validate\n    /// @param _encoded The abi encoded bytes of the transaction\n    /// @param _priorityTxMaxGasLimit The max gas limit, generally provided from Storage.sol\n    /// @param _priorityTxMaxPubdata The maximal amount of pubdata that a single L1->L2 transaction can emit\n    function validateL1ToL2Transaction(\n        IMailbox.L2CanonicalTransaction memory _transaction,\n        bytes memory _encoded,\n        uint256 _priorityTxMaxGasLimit,\n        uint256 _priorityTxMaxPubdata\n    ) internal pure {\n        uint256 l2GasForTxBody = getTransactionBodyGasLimit(_transaction.gasLimit, _encoded.length);\n\n        // Ensuring that the transaction is provable\n        require(l2GasForTxBody <= _priorityTxMaxGasLimit, \"ui\");\n        // Ensuring that the transaction cannot output more pubdata than is processable\n        require(l2GasForTxBody / _transaction.gasPerPubdataByteLimit <= _priorityTxMaxPubdata, \"uk\");\n\n        // Ensuring that the transaction covers the minimal costs for its processing:\n        // hashing its content, publishing the factory dependencies, etc.\n        require(\n            getMinimalPriorityTransactionGasLimit(\n                _encoded.length,\n                _transaction.factoryDeps.length,\n                _transaction.gasPerPubdataByteLimit\n            ) <= l2GasForTxBody,\n            \"up\"\n        );\n    }\n\n    /// @dev Used to validate upgrade transactions\n    /// @param _transaction The transaction to validate\n    function validateUpgradeTransaction(IMailbox.L2CanonicalTransaction memory _transaction) internal pure {\n        // Restrict from to be within system contract range (0...2^16 - 1)\n        require(_transaction.from <= type(uint16).max, \"ua\");\n        require(_transaction.to <= type(uint160).max, \"ub\");\n        require(_transaction.paymaster == 0, \"uc\");\n        require(_transaction.value == 0, \"ud\");\n        require(_transaction.maxFeePerGas == 0, \"uq\");\n        require(_transaction.maxPriorityFeePerGas == 0, \"ux\");\n        require(_transaction.reserved[0] == 0, \"ue\");\n        require(_transaction.reserved[1] <= type(uint160).max, \"uf\");\n        require(_transaction.reserved[2] == 0, \"ug\");\n        require(_transaction.reserved[3] == 0, \"uo\");\n        require(_transaction.signature.length == 0, \"uh\");\n        require(_transaction.paymasterInput.length == 0, \"ul\");\n        require(_transaction.reservedDynamic.length == 0, \"um\");\n    }\n\n    /// @dev Calculates the approximate minimum gas limit required for executing a priority transaction.\n    /// @param _encodingLength The length of the priority transaction encoding in bytes.\n    /// @param _numberOfFactoryDependencies The number of new factory dependencies that will be added.\n    /// @param _l2GasPricePerPubdata The L2 gas price for publishing the priority transaction on L2.\n    /// @return The minimum gas limit required to execute the priority transaction.\n    /// Note: The calculation includes the main cost of the priority transaction, however, in reality, the operator can spend a little more gas on overheads.\n    function getMinimalPriorityTransactionGasLimit(\n        uint256 _encodingLength,\n        uint256 _numberOfFactoryDependencies,\n        uint256 _l2GasPricePerPubdata\n    ) internal pure returns (uint256) {\n        uint256 costForComputation;\n        {\n            // Adding the intrinsic cost for the transaction, i.e. auxiliary prices which cannot be easily accounted for\n            costForComputation = L1_TX_INTRINSIC_L2_GAS;\n\n            // Taking into account the hashing costs that depend on the length of the transaction\n            // Note that L1_TX_DELTA_544_ENCODING_BYTES is the delta in the price for every 544 bytes of\n            // the transaction's encoding. It is taken as LCM between 136 and 32 (the length for each keccak256 round\n            // and the size of each new encoding word).\n            costForComputation += Math.ceilDiv(_encodingLength * L1_TX_DELTA_544_ENCODING_BYTES, 544);\n\n            // Taking into the account the additional costs of providing new factory dependencies\n            costForComputation += _numberOfFactoryDependencies * L1_TX_DELTA_FACTORY_DEPS_L2_GAS;\n\n            // There is a minimal amount of computational L2 gas that the transaction should cover\n            costForComputation = Math.max(costForComputation, L1_TX_MIN_L2_GAS_BASE);\n        }\n\n        uint256 costForPubdata = 0;\n        {\n            // Adding the intrinsic cost for the transaction, i.e. auxiliary prices which cannot be easily accounted for\n            costForPubdata = L1_TX_INTRINSIC_PUBDATA * _l2GasPricePerPubdata;\n\n            // Taking into the account the additional costs of providing new factory dependencies\n            costForPubdata += _numberOfFactoryDependencies * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * _l2GasPricePerPubdata;\n        }\n\n        return costForComputation + costForPubdata;\n    }\n\n    /// @notice Based on the full L2 gas limit (that includes the batch overhead) and other\n    /// properties of the transaction, returns the l2GasLimit for the body of the transaction (the actual execution).\n    /// @param _totalGasLimit The L2 gas limit that includes both the overhead for processing the batch\n    /// and the L2 gas needed to process the transaction itself (i.e. the actual l2GasLimit that will be used for the transaction).\n    /// @param _encodingLength The length of the ABI-encoding of the transaction.\n    function getTransactionBodyGasLimit(\n        uint256 _totalGasLimit,\n        uint256 _encodingLength\n    ) internal pure returns (uint256 txBodyGasLimit) {\n        uint256 overhead = getOverheadForTransaction(_encodingLength);\n\n        require(_totalGasLimit >= overhead, \"my\"); // provided gas limit doesn't cover transaction overhead\n        unchecked {\n            // We enforce the fact that `_totalGasLimit >= overhead` explicitly above.\n            txBodyGasLimit = _totalGasLimit - overhead;\n        }\n    }\n\n    /// @notice Based on the total L2 gas limit and several other parameters of the transaction\n    /// returns the part of the L2 gas that will be spent on the batch's overhead.\n    /// @dev The details of how this function works can be checked in the documentation\n    /// of the fee model of zkSync. The appropriate comments are also present\n    /// in the Rust implementation description of function `get_maximal_allowed_overhead`.\n    /// @param _encodingLength The length of the binary encoding of the transaction in bytes\n    function getOverheadForTransaction(\n        uint256 _encodingLength\n    ) internal pure returns (uint256 batchOverheadForTransaction) {\n        // The overhead from taking up the transaction's slot\n        batchOverheadForTransaction = TX_SLOT_OVERHEAD_L2_GAS;\n\n        // The overhead for occupying the bootloader memory can be derived from encoded_len\n        uint256 overheadForLength = MEMORY_OVERHEAD_GAS * _encodingLength;\n        batchOverheadForTransaction = Math.max(batchOverheadForTransaction, overheadForLength);\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/interfaces/IMailbox.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {L2Message} from \"../Storage.sol\";\n\n/// @dev The enum that represents the transaction execution status\n/// @param Failure The transaction execution failed\n/// @param Success The transaction execution succeeded\nenum TxStatus {\n    Failure,\n    Success\n}\n\n/// @title The interface of the zkSync Mailbox contract that provides interfaces for L1 <-> L2 interaction.\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IMailbox {\n    /// @dev Structure that includes all fields of the L2 transaction\n    /// @dev The hash of this structure is the \"canonical L2 transaction hash\" and can be used as a unique identifier of a tx\n    /// @param txType The tx type number, depending on which the L2 transaction can be interpreted differently\n    /// @param from The sender's address. `uint256` type for possible address format changes and maintaining backward compatibility\n    /// @param to The recipient's address. `uint256` type for possible address format changes and maintaining backward compatibility\n    /// @param gasLimit The L2 gas limit for L2 transaction. Analog to the `gasLimit` on an L1 transactions\n    /// @param gasPerPubdataByteLimit Maximum number of L2 gas that will cost one byte of pubdata (every piece of data that will be stored on L1 as calldata)\n    /// @param maxFeePerGas The absolute maximum sender willing to pay per unit of L2 gas to get the transaction included in a batch. Analog to the EIP-1559 `maxFeePerGas` on an L1 transactions\n    /// @param maxPriorityFeePerGas The additional fee that is paid directly to the validator to incentivize them to include the transaction in a batch. Analog to the EIP-1559 `maxPriorityFeePerGas` on an L1 transactions\n    /// @param paymaster The address of the EIP-4337 paymaster, that will pay fees for the transaction. `uint256` type for possible address format changes and maintaining backward compatibility\n    /// @param nonce The nonce of the transaction. For L1->L2 transactions it is the priority operation Id.\n    /// @param value The value to pass with the transaction\n    /// @param reserved The fixed-length fields for usage in a future extension of transaction formats\n    /// @param data The calldata that is transmitted for the transaction call\n    /// @param signature An abstract set of bytes that are used for transaction authorization\n    /// @param factoryDeps The set of L2 bytecode hashes whose preimages were shown on L1\n    /// @param paymasterInput The arbitrary-length data that is used as a calldata to the paymaster pre-call\n    /// @param reservedDynamic The arbitrary-length field for usage in a future extension of transaction formats\n    struct L2CanonicalTransaction {\n        uint256 txType;\n        uint256 from;\n        uint256 to;\n        uint256 gasLimit;\n        uint256 gasPerPubdataByteLimit;\n        uint256 maxFeePerGas;\n        uint256 maxPriorityFeePerGas;\n        uint256 paymaster;\n        uint256 nonce;\n        uint256 value;\n        // In the future, we might want to add some\n        // new fields to the struct. The `txData` struct\n        // is to be passed to account and any changes to its structure\n        // would mean a breaking change to these accounts. To prevent this,\n        // we should keep some fields as \"reserved\".\n        // It is also recommended that their length is fixed, since\n        // it would allow easier proof integration (in case we will need\n        // some special circuit for preprocessing transactions).\n        uint256[4] reserved;\n        bytes data;\n        bytes signature;\n        uint256[] factoryDeps;\n        bytes paymasterInput;\n        // Reserved dynamic type for the future use-case. Using it should be avoided,\n        // But it is still here, just in case we want to enable some additional functionality.\n        bytes reservedDynamic;\n    }\n\n    /// @dev Internal structure that contains the parameters for the forwardRequestL2Transaction\n    /// @param gateway The secondary chain gateway;\n    /// @param isContractCall It's true when the request come from a contract.\n    /// @param sender The sender's address.\n    /// @param txId The id of the priority transaction.\n    /// @param contractAddressL2 The address of the contract on L2 to call.\n    /// @param l2Value The msg.value of the L2 transaction.\n    /// @param l2CallData The call data of the L2 transaction.\n    /// @param l2GasLimit The limit of the L2 gas for the L2 transaction\n    /// @param l2GasPrice The price of the L2 gas in Wei to be used for this transaction.\n    /// @param l2GasPricePerPubdata The price for a single pubdata byte in L2 gas.\n    /// @param refundRecipient The recipient of the refund for the transaction on L2. If the transaction fails, then\n    /// this address will receive the `l2Value`.\n    struct ForwardL2Request {\n        address gateway;\n        bool isContractCall;\n        address sender;\n        uint256 txId;\n        address contractAddressL2;\n        uint256 l2Value;\n        bytes l2CallData;\n        uint256 l2GasLimit;\n        uint256 l2GasPricePerPubdata;\n        bytes[] factoryDeps;\n        address refundRecipient;\n    }\n\n    /// @notice Prove that a specific arbitrary-length message was sent in a specific L2 batch number\n    /// @param _l2BatchNumber The executed L2 batch number in which the message appeared\n    /// @param _index The position in the L2 logs Merkle tree of the l2Log that was sent with the message\n    /// @param _message Information about the sent message: sender address, the message itself, tx index in the L2 batch where the message was sent\n    /// @param _proof Merkle proof for inclusion of L2 log that was sent with the message\n    /// @return Whether the proof is valid\n    function proveL2MessageInclusion(\n        uint256 _l2BatchNumber,\n        uint256 _index,\n        L2Message calldata _message,\n        bytes32[] calldata _proof\n    ) external view returns (bool);\n\n    /// @notice Prove that the L1 -> L2 transaction was processed with the specified status.\n    /// @param _l2TxHash The L2 canonical transaction hash\n    /// @param _l2BatchNumber The L2 batch number where the transaction was processed\n    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message\n    /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent\n    /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction\n    /// @param _status The execution status of the L1 -> L2 transaction (true - success & 0 - fail)\n    /// @return Whether the proof is correct and the transaction was actually executed with provided status\n    /// NOTE: It may return `false` for incorrect proof, but it doesn't mean that the L1 -> L2 transaction has an opposite status!\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) external view returns (bool);\n\n    /// @notice Request execution of L2 transaction from L1.\n    /// @param _contractL2 The L2 receiver address\n    /// @param _l2Value `msg.value` of L2 transaction\n    /// @param _calldata The input of the L2 transaction\n    /// @param _l2GasLimit Maximum amount of L2 gas that transaction can consume during execution on L2\n    /// @param _l2GasPerPubdataByteLimit The maximum amount L2 gas that the operator may charge the user for single byte of pubdata.\n    /// @param _factoryDeps An array of L2 bytecodes that will be marked as known on L2\n    /// @param _refundRecipient The address on L2 that will receive the refund for the transaction.\n    /// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`.\n    /// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses out of control.\n    /// - If `_refundRecipient` is a contract on L1, the refund will be sent to the aliased `_refundRecipient`.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has NO deployed bytecode on L1, the refund will be sent to the `msg.sender` address.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has deployed bytecode on L1, the refund will be sent to the aliased `msg.sender` address.\n    /// @dev The address aliasing of L1 contracts as refund recipient on L2 is necessary to guarantee that the funds are controllable,\n    /// since address aliasing to the from address for the L2 tx will be applied if the L1 `msg.sender` is a contract.\n    /// Without address aliasing for L1 contracts as refund recipients they would not be able to make proper L2 tx requests\n    /// through the Mailbox to use or withdraw the funds from L2, and the funds would be lost.\n    /// @return canonicalTxHash The hash of the requested L2 transaction. This hash can be used to follow the transaction status\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable returns (bytes32 canonicalTxHash);\n\n    /// @notice Finalize the withdrawal and release funds\n    /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed\n    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message\n    /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent\n    /// @param _message The L2 withdraw data, stored in an L2 -> L1 message\n    /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external;\n\n    /// @notice Estimates the cost in Ether of requesting execution of an L2 transaction from L1\n    /// @param _gasPrice expected L1 gas price at which the user requests the transaction execution\n    /// @param _l2GasLimit Maximum amount of L2 gas that transaction can consume during execution on L2\n    /// @param _l2GasPerPubdataByteLimit The maximum amount of L2 gas that the operator may charge the user for a single byte of pubdata.\n    /// @return The estimated ETH spent on L2 gas for the transaction\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) external view returns (uint256);\n}\n"},{"file_path":"contracts/zksync/l1-contracts/bridge/interfaces/IL2Bridge.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author Matter Labs\ninterface IL2Bridge {\n    function finalizeDeposit(\n        address _l1Sender,\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        bytes calldata _data\n    ) external payable;\n\n    function finalizeDepositToMerge(\n        address _l1Sender,\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        bytes calldata _data\n    ) external payable;\n\n    function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external;\n\n    function l1TokenAddress(address _l2Token) external view returns (address);\n\n    function l2TokenAddress(address _l1Token) external view returns (address);\n\n    function l1Bridge() external view returns (address);\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/interfaces/IL2ContractDeployer.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @author Matter Labs\n * @notice System smart contract that is responsible for deploying other smart contracts on zkSync.\n */\ninterface IL2ContractDeployer {\n    /// @notice A struct that describes a forced deployment on an address.\n    /// @param bytecodeHash The bytecode hash to put on an address.\n    /// @param newAddress The address on which to deploy the bytecodehash to.\n    /// @param callConstructor Whether to run the constructor on the force deployment.\n    /// @param value The `msg.value` with which to initialize a contract.\n    /// @param input The constructor calldata.\n    struct ForceDeployment {\n        bytes32 bytecodeHash;\n        address newAddress;\n        bool callConstructor;\n        uint256 value;\n        bytes input;\n    }\n\n    /// @notice This method is to be used only during an upgrade to set bytecodes on specific addresses.\n    function forceDeployOnAddresses(ForceDeployment[] calldata _deployParams) external;\n\n    /// @notice Deploys a contract with similar address derivation rules to the EVM's `CREATE2` opcode.\n    /// @param _salt The create2 salt.\n    /// @param _bytecodeHash The correctly formatted hash of the bytecode.\n    /// @param _input The constructor calldata.\n    function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external;\n}\n"},{"file_path":"contracts/PauseHarness.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\nimport './ZkLink.sol';\nimport './ZkLinkBefore.sol';\nimport './zksync/l1-contracts/bridge/L1ERC20Bridge.sol';\nimport '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol';\nimport '@openzeppelin/contracts/token/ERC20/ERC20.sol';\ncontract PauseGateway {\n    bool public isEthGasToken;\n    IERC20 public ethToken;\n    constructor(bool nativeEth, IERC20 token) {isEthGasToken=nativeEth;ethToken=token;}\n    function getRemoteGateway() external view returns(address){return address(this);}\n    function sync(address zk,uint256 batch,bytes32 root) external {ZkLink(zk).syncBatchRoot(batch,root,0);}\n    function syncTx(address zk,bytes32 txHash) external {ZkLink(zk).syncL2TxHash(txHash,txHash);}\n}\n// Test-only setup, production withdrawal and refund functions are inherited unchanged.\ncontract PauseBridgeHarness is L1ERC20Bridge {\n    constructor(IMailbox zk,address remote) L1ERC20Bridge(zk){l2Bridge=remote;}\n    function seedDeposit(address user,address token,bytes32 txHash,uint256 amount) external {depositAmount[user][token][txHash]=amount;}\n}\ncontract PauseToken is ERC20 {\n    constructor() ERC20('Test','TEST'){}\n    function mint(address to,uint256 value) external {_mint(to,value);}\n}\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/libraries/Merkle.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {UncheckedMath} from \"../../common/libraries/UncheckedMath.sol\";\n\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\nlibrary Merkle {\n    using UncheckedMath for uint256;\n\n    /// @dev Calculate Merkle root by the provided Merkle proof.\n    /// NOTE: When using this function, check that the _path length is equal to the tree height to prevent shorter/longer paths attack\n    /// @param _path Merkle path from the leaf to the root\n    /// @param _index Leaf index in the tree\n    /// @param _itemHash Hash of leaf content\n    /// @return The Merkle root\n    function calculateRoot(\n        bytes32[] calldata _path,\n        uint256 _index,\n        bytes32 _itemHash\n    ) internal pure returns (bytes32) {\n        uint256 pathLength = _path.length;\n        require(pathLength > 0, \"xc\");\n        require(pathLength < 256, \"bt\");\n        require(_index < (1 << pathLength), \"px\");\n\n        bytes32 currentHash = _itemHash;\n        for (uint256 i; i < pathLength; i = i.uncheckedInc()) {\n            currentHash = (_index % 2 == 0)\n                ? _efficientHash(currentHash, _path[i])\n                : _efficientHash(_path[i], currentHash);\n            _index /= 2;\n        }\n\n        return currentHash;\n    }\n\n    /// @dev Keccak hash of the concatenation of two 32-byte words\n    function _efficientHash(bytes32 _lhs, bytes32 _rhs) internal pure returns (bytes32 result) {\n        assembly {\n            mstore(0x00, _lhs)\n            mstore(0x20, _rhs)\n            result := keccak256(0x00, 0x40)\n        }\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/Context.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/interfaces/draft-IERC1822.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"},{"file_path":"@openzeppelin/contracts/token/ERC20/IERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"},{"file_path":"contracts/zksync/l1-contracts/vendor/AddressAliasHelper.sol","source_code":"// SPDX-License-Identifier: Apache-2.0\n\n/*\n * Copyright 2019-2021, Offchain Labs, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npragma solidity ^0.8.0;\n\nlibrary AddressAliasHelper {\n    uint160 internal constant OFFSET = uint160(0x1111000000000000000000000000000000001111);\n\n    /// @notice Utility function converts the address that submitted a tx\n    /// to the inbox on L1 to the msg.sender viewed on L2\n    /// @param l1Address the address in the L1 that triggered the tx to L2\n    /// @return l2Address L2 address as viewed in msg.sender\n    function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {\n        unchecked {\n            l2Address = address(uint160(l1Address) + OFFSET);\n        }\n    }\n\n    /// @notice Utility function that converts the msg.sender viewed on L2 to the\n    /// address that submitted a tx to the inbox on L1\n    /// @param l2Address L2 address as viewed in msg.sender\n    /// @return l1Address the address in the L1 that triggered the tx to L2\n    function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {\n        unchecked {\n            l1Address = address(uint160(l2Address) - OFFSET);\n        }\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/bridge/interfaces/IL1BridgeLegacy.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title L1 Bridge contract legacy interface\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\ninterface IL1BridgeLegacy {\n    function deposit(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte\n    ) external payable returns (bytes32 txHash);\n}\n"},{"file_path":"contracts/zksync/l1-contracts/bridge/libraries/BridgeInitializationHelper.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../../zksync/interfaces/IMailbox.sol\";\nimport \"../../vendor/AddressAliasHelper.sol\";\nimport \"../../common/libraries/L2ContractHelper.sol\";\nimport {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR} from \"../../common/L2ContractAddresses.sol\";\nimport \"../../common/interfaces/IL2ContractDeployer.sol\";\n\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\n/// @dev A helper library for initializing L2 bridges in zkSync L2 network.\nlibrary BridgeInitializationHelper {\n    /// @dev The L2 gas limit for requesting L1 -> L2 transaction of deploying L2 bridge instance.\n    /// @dev It is big enough to deploy any contract, so we can use the same value for all bridges.\n    /// NOTE: this constant will be accurately calculated in the future.\n    uint256 constant DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000;\n\n    /// @dev The default l2GasPricePerPubdata to be used in bridges.\n    uint256 constant REQUIRED_L2_GAS_PRICE_PER_PUBDATA = 800;\n\n    /// @notice Requests L2 transaction that will deploy a contract with a given bytecode hash and constructor data.\n    /// NOTE: it is always used to deploy via create2 with ZERO salt\n    /// @param _zkSync The address of the zkSync contract\n    /// @param _deployTransactionFee The fee that will be paid for the L1 -> L2 transaction\n    /// @param _bytecodeHash The hash of the bytecode of the contract to be deployed\n    /// @param _constructorData The data to be passed to the contract constructor\n    /// @param _factoryDeps A list of raw bytecodes that are needed for deployment\n    function requestDeployTransaction(\n        IMailbox _zkSync,\n        uint256 _deployTransactionFee,\n        bytes32 _bytecodeHash,\n        bytes memory _constructorData,\n        bytes[] memory _factoryDeps\n    ) internal returns (address deployedAddress) {\n        bytes memory deployCalldata = abi.encodeCall(\n            IL2ContractDeployer.create2,\n            (bytes32(0), _bytecodeHash, _constructorData)\n        );\n        _zkSync.requestL2Transaction{value: _deployTransactionFee}(\n            L2_DEPLOYER_SYSTEM_CONTRACT_ADDR,\n            0,\n            deployCalldata,\n            DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,\n            REQUIRED_L2_GAS_PRICE_PER_PUBDATA,\n            _factoryDeps,\n            msg.sender\n        );\n\n        deployedAddress = L2ContractHelper.computeCreate2Address(\n            // Apply the alias to the address of the bridge contract, to get the `msg.sender` in L2.\n            AddressAliasHelper.applyL1ToL2Alias(address(this)),\n            bytes32(0), // Zero salt\n            _bytecodeHash,\n            keccak256(_constructorData)\n        );\n    }\n}\n"},{"file_path":"contracts/ZkLinkMantle.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLinkMantle is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n    using SafeERC20 for IERC20;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor() {\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!gateway.isEthGasToken()) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        if (_toBatchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _toBatchNumber;\n        }\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        if (gateway.isEthGasToken()) {\n            bool callSuccess;\n            // Low-level assembly call, to avoid any memory copying (save gas)\n            assembly {\n                callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n            }\n            require(callSuccess, \"pz\");\n        } else {\n            SafeERC20.safeTransfer(gateway.ethToken(), _to, _amount);\n        }\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport {Initializable} from \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n    address private immutable __self = address(this);\n\n    /**\n     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n     * fail.\n     */\n    modifier onlyProxy() {\n        require(address(this) != __self, \"Function must be called through delegatecall\");\n        require(_getImplementation() == __self, \"Function must be called through active proxy\");\n        _;\n    }\n\n    /**\n     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n     * callable on the implementing contract but not through proxies.\n     */\n    modifier notDelegated() {\n        require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n        _;\n    }\n\n    function __UUPSUpgradeable_init() internal onlyInitializing {\n    }\n\n    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n     */\n    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n        return _IMPLEMENTATION_SLOT;\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     *\n     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n     */\n    function upgradeTo(address newImplementation) public virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n     * encoded in `data`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     *\n     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, data, true);\n    }\n\n    /**\n     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n     * {upgradeTo} and {upgradeToAndCall}.\n     *\n     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n     *\n     * ```solidity\n     * function _authorizeUpgrade(address) internal override onlyOwner {}\n     * ```\n     */\n    function _authorizeUpgrade(address newImplementation) internal virtual;\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"},{"file_path":"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport {Initializable} from \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    function __Pausable_init() internal onlyInitializing {\n        __Pausable_init_unchained();\n    }\n\n    function __Pausable_init_unchained() internal onlyInitializing {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"},{"file_path":"contracts/interfaces/IGateway.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity ^0.8.0;\n\ninterface IGateway {\n    /// @return Remote gateway\n    function getRemoteGateway() external view returns (address);\n}\n"},{"file_path":"contracts/ZkLinkLegacy.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLinkLegacy is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @dev Whether eth is the gas token\n    bool public immutable IS_ETH_GAS_TOKEN;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor(bool _isEthGasToken) {\n        IS_ETH_GAS_TOKEN = _isEthGasToken;\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!IS_ETH_GAS_TOKEN) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(IS_ETH_GAS_TOKEN, \"Not allow eth withdraw\");\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        if (_toBatchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _toBatchNumber;\n        }\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        bool callSuccess;\n        // Low-level assembly call, to avoid any memory copying (save gas)\n        assembly {\n            callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n        }\n        require(callSuccess, \"pz\");\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n"},{"file_path":"@openzeppelin/contracts/utils/math/Math.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"},{"file_path":"contracts/ZkLink.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {ReentrancyGuardUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {PausableUpgradeable} from \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AddressAliasHelper} from \"./zksync/l1-contracts/vendor/AddressAliasHelper.sol\";\nimport {IZkLink} from \"./interfaces/IZkLink.sol\";\nimport {IL2Gateway} from \"./interfaces/IL2Gateway.sol\";\nimport {IMailbox, TxStatus} from \"./zksync/l1-contracts/zksync/interfaces/IMailbox.sol\";\nimport {IAdmin} from \"./zksync/l1-contracts/zksync/interfaces/IAdmin.sol\";\nimport {IZkSync} from \"./zksync/l1-contracts/zksync/interfaces/IZkSync.sol\";\nimport {Merkle} from \"./zksync/l1-contracts/zksync/libraries/Merkle.sol\";\nimport {TransactionValidator} from \"./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol\";\nimport {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from \"./zksync/l1-contracts/zksync/Storage.sol\";\nimport {UncheckedMath} from \"./zksync/l1-contracts/common/libraries/UncheckedMath.sol\";\nimport {UnsafeBytes} from \"./zksync/l1-contracts/common/libraries/UnsafeBytes.sol\";\nimport {REQUIRED_L2_GAS_PRICE_PER_PUBDATA, MAX_NEW_FACTORY_DEPS, L1_GAS_PER_PUBDATA_BYTE, L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH} from \"./zksync/l1-contracts/zksync/Config.sol\";\nimport {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from \"./zksync/l1-contracts/common/L2ContractAddresses.sol\";\nimport {IGetters} from \"./zksync/l1-contracts/zksync/interfaces/IGetters.sol\";\n\n/// @title ZkLink contract\n/// @author zk.link\ncontract ZkLink is\n    IZkLink,\n    IMailbox,\n    IAdmin,\n    IGetters,\n    OwnableUpgradeable,\n    UUPSUpgradeable,\n    ReentrancyGuardUpgradeable,\n    PausableUpgradeable\n{\n    using UncheckedMath for uint256;\n    using SafeERC20 for IERC20;\n\n    /// @dev The forward request type hash\n    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =\n        keccak256(\n            \"ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)\"\n        );\n\n    /// @dev The length of withdraw message sent to secondary chain\n    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;\n\n    /// @notice The gateway is used for communicating with L1\n    IL2Gateway public gateway;\n    /// @notice List of permitted validators\n    mapping(address validatorAddress => bool isValidator) public validators;\n    /// @dev The white list allow to send request L2 request\n    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;\n    /// @dev Gas price of primary chain\n    uint256 public txGasPrice;\n    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,\n    /// the bootloader gives enough freedom to the operator.\n    FeeParams public feeParams;\n    /// @dev The total number of priority operations that were added to the priority queue\n    uint256 public totalPriorityTxs;\n    /// @dev The total number of synced priority operations\n    uint256 public totalSyncedPriorityTxs;\n    /// @dev The sync status for each priority operation\n    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;\n    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch\n    /// (batch 0 is genesis)\n    uint256 public totalBatchesExecuted;\n    /// @dev Stored root hashes of L2 -> L1 logs\n    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;\n    /// @dev Stored the l2 tx hash map from secondary chain to primary chain\n    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;\n    /// @dev The total forward fee payed to validator\n    uint256 public totalValidatorForwardFee;\n    /// @dev The total forward fee withdrawn by validator\n    uint256 public totalValidatorForwardFeeWithdrawn;\n    /// @dev A mapping L2 batch number => message number => flag.\n    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as\n    /// a flag to indicate that the message was already processed.\n    /// @dev Used to indicate that eth withdrawal was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isEthWithdrawalFinalized;\n    /// @dev The forward fee allocator\n    address public forwardFeeAllocator;\n    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]\n    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))\n    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n\n    /// @notice Gateway init\n    event InitGateway(IL2Gateway indexed gateway);\n    /// @notice Contract's permit status changed\n    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);\n    /// @notice Tx gas price changed\n    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);\n    /// @notice Validator's status changed\n    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);\n    /// @notice Fee params for L1->L2 transactions changed\n    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);\n    /// @notice New priority request event. Emitted when a request is placed into the priority queue\n    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);\n    /// @notice Emitted send sync status to primary chain.\n    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive batch root from primary chain.\n    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);\n    /// @notice Emitted when receive range batch root hash from primary chain.\n    event SyncRangeBatchRoot(\n        uint256 fromBatchNumber,\n        uint256 toBatchNumber,\n        bytes32 rangeBatchRootHash,\n        uint256 forwardEthAmount\n    );\n    /// @notice Emitted when open range batch root hash.\n    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);\n    /// @notice Emitted when receive l2 tx hash from primary chain.\n    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);\n    /// @notice Emitted when validator withdraw forward fee\n    event WithdrawForwardFee(address indexed receiver, uint256 amount);\n    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.\n    /// @param to The address to which the funds were sent\n    /// @param amount The amount of funds that were sent\n    event EthWithdrawalFinalized(address indexed to, uint256 amount);\n    /// @notice Forward fee allocator changed\n    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);\n\n    /// @notice Check if msg sender is gateway\n    modifier onlyGateway() {\n        require(msg.sender == address(gateway), \"Not gateway\");\n        _;\n    }\n\n    /// @notice Checks if validator is active\n    modifier onlyValidator() {\n        require(validators[msg.sender], \"Not validator\"); // validator is not active\n        _;\n    }\n\n    /// @notice Checks if msg sender is forward fee allocator\n    modifier onlyForwardFeeAllocator() {\n        require(msg.sender == forwardFeeAllocator, \"Not forward fee allocator\");\n        _;\n    }\n\n    constructor() {\n        _disableInitializers();\n    }\n\n    function initialize() external initializer {\n        __Ownable_init_unchained();\n        __UUPSUpgradeable_init_unchained();\n        __ReentrancyGuard_init_unchained();\n        __Pausable_init_unchained();\n    }\n\n    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\n        // can only called by owner\n    }\n\n    /// @dev Pause the contract, can only be called by the owner\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    /// @dev Unpause the contract, can only be called by the owner\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    function getGateway() external view returns (IL2Gateway) {\n        return gateway;\n    }\n\n    function getGovernor() external view returns (address) {\n        return owner();\n    }\n\n    function getTotalBatchesExecuted() external view returns (uint256) {\n        return totalBatchesExecuted;\n    }\n\n    function getTotalPriorityTxs() external view returns (uint256) {\n        return totalPriorityTxs;\n    }\n\n    function isValidator(address _address) external view returns (bool) {\n        return validators[_address];\n    }\n\n    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {\n        return l2LogsRootHashes[_batchNumber];\n    }\n\n    function getPriorityTxMaxGasLimit() public pure returns (uint256) {\n        return 72000000;\n    }\n\n    /// @dev Init gateway, can only be called by the owner\n    function setGateway(IL2Gateway _gateway) external onlyOwner {\n        require(address(gateway) == address(0), \"Duplicate init gateway\");\n        require(address(_gateway) != address(0), \"Invalid gateway\");\n        gateway = _gateway;\n        emit InitGateway(_gateway);\n    }\n\n    /// @dev Update the permit status of contract, can only be called by the owner\n    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {\n        if (allowLists[_contractAddress] != _permitted) {\n            allowLists[_contractAddress] = _permitted;\n            emit ContractAllowStatusUpdate(_contractAddress, _permitted);\n        }\n    }\n\n    /// @dev Update the tx gas price\n    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {\n        uint256 oldTxGasPrice = txGasPrice;\n        if (oldTxGasPrice != _newTxGasPrice) {\n            txGasPrice = _newTxGasPrice;\n            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);\n        }\n    }\n\n    function setValidator(address _validator, bool _active) external onlyGateway {\n        if (validators[_validator] != _active) {\n            validators[_validator] = _active;\n            emit ValidatorStatusUpdate(_validator, _active);\n        }\n    }\n\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88\n    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {\n        // Double checking that the new fee params are valid, i.e.\n        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.\n        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, \"n6\");\n\n        FeeParams memory oldFeeParams = feeParams;\n        feeParams = _newFeeParams;\n\n        emit NewFeeParams(oldFeeParams, _newFeeParams);\n    }\n\n    /// @dev Update the forward fee allocator\n    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {\n        require(_newForwardFeeAllocator != address(0), \"Invalid allocator\");\n        address oldAllocator = forwardFeeAllocator;\n        if (oldAllocator != _newForwardFeeAllocator) {\n            forwardFeeAllocator = _newForwardFeeAllocator;\n            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);\n        }\n    }\n\n    function l2TransactionBaseCost(\n        uint256 _gasPrice,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit\n    ) public view returns (uint256) {\n        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);\n        return l2GasPrice * _l2GasLimit;\n    }\n\n    function requestL2Transaction(\n        address _contractL2,\n        uint256 _l2Value,\n        bytes calldata _calldata,\n        uint256 _l2GasLimit,\n        uint256 _l2GasPerPubdataByteLimit,\n        bytes[] calldata _factoryDeps,\n        address _refundRecipient\n    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {\n        // Disable l2 value if eth is not the gas token\n        if (!gateway.isEthGasToken()) {\n            require(_l2Value == 0, \"Not allow l2 value\");\n        }\n        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.\n        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.\n        address sender = msg.sender;\n        bool isContractCall = false;\n        // solhint-disable-next-line avoid-tx-origin\n        if (sender != tx.origin) {\n            // Check contract call is allowed for safe reasons\n            require(allowLists[sender], \"Not allow to send L2 request\");\n            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n            isContractCall = true;\n        } else {\n            // Temporarily prohibit contract calls from EOA address for safe reasons\n            require(_calldata.length == 0, \"Not allow to call contract\");\n        }\n\n        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed\n        // to ensure that users do not get used to using \"exotic\" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.\n        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the\n        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.\n        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.\n        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, \"Invalid l2GasPerPubdataByteLimit\");\n        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, \"Invalid factoryDeps\");\n\n        // Checking that the user provided enough ether to pay for the transaction.\n        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);\n        uint256 baseCost = l2GasPrice * _l2GasLimit;\n        require(msg.value == baseCost + _l2Value, \"Invalid msg value\"); // The `msg.value` doesn't cover the transaction cost\n        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;\n\n        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.\n        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;\n        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.\n        if (refundRecipient.code.length > 0) {\n            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);\n        }\n\n        // Build l2 request params\n        uint256 _totalPriorityTxs = totalPriorityTxs;\n        ForwardL2Request memory request = ForwardL2Request(\n            gateway.getRemoteGateway(),\n            isContractCall,\n            sender,\n            _totalPriorityTxs,\n            _contractL2,\n            _l2Value,\n            _calldata,\n            _l2GasLimit,\n            _l2GasPerPubdataByteLimit,\n            _factoryDeps,\n            refundRecipient\n        );\n        // Validate l2 transaction\n        {\n            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);\n            bytes memory transactionEncoding = abi.encode(transaction);\n            TransactionValidator.validateL1ToL2Transaction(\n                transaction,\n                transactionEncoding,\n                getPriorityTxMaxGasLimit(),\n                feeParams.priorityTxMaxPubdata\n            );\n        }\n        canonicalTxHash = hashForwardL2Request(request);\n\n        // Accumulate sync status\n        SecondaryChainSyncStatus memory syncStatus;\n        if (_totalPriorityTxs == 0) {\n            syncStatus.hash = canonicalTxHash;\n            syncStatus.amount = _l2Value;\n        } else {\n            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];\n            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));\n            syncStatus.amount = syncStatus.amount + _l2Value;\n        }\n        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;\n        totalPriorityTxs = _totalPriorityTxs + 1;\n\n        emit NewPriorityRequest(request.txId, request);\n    }\n\n    function finalizeEthWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"jj\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,\n            data: _message\n        });\n\n        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);\n        require(_l1Gateway == gateway.getRemoteGateway(), \"rg\");\n\n        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n        require(proofValid, \"pi\"); // Failed to verify that withdrawal was actually initialized on L2\n\n        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        _withdrawFunds(_l1WithdrawReceiver, _amount);\n\n        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);\n    }\n\n    function proveL2MessageInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Message memory _message,\n        bytes32[] calldata _proof\n    ) public view returns (bool) {\n        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);\n    }\n\n    function proveL1ToL2TransactionStatus(\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof,\n        TxStatus _status\n    ) public view returns (bool) {\n        // Get l2 tx hash on primary chain\n        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];\n        require(primaryChainL2TxHash != bytes32(0), \"Invalid l2 tx hash\");\n\n        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.\n        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.\n        //\n        // The semantics of such L2 -> L1 log is always:\n        // - sender = L2_BOOTLOADER_ADDRESS\n        // - key = hash(L1ToL2Transaction)\n        // - value = status of the processing transaction (1 - success & 0 - fail)\n        // - isService = true (just a conventional value)\n        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)\n        // - txNumberInBatch = number of transaction in the batch\n        L2Log memory l2Log = L2Log({\n            l2ShardId: 0,\n            isService: true,\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: L2_BOOTLOADER_ADDRESS,\n            key: primaryChainL2TxHash,\n            value: bytes32(uint256(_status))\n        });\n        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);\n    }\n\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {\n        // Check newTotalSyncedPriorityTxs\n        require(\n            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,\n            \"Invalid sync point\"\n        );\n\n        // Forward eth amount is the difference of two accumulate amount\n        SecondaryChainSyncStatus memory lastSyncStatus;\n        if (totalSyncedPriorityTxs > 0) {\n            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];\n        }\n        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];\n        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;\n\n        // Update synced priority txs\n        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;\n\n        // Send sync status to L1 gateway\n        bytes memory callData = abi.encodeCall(\n            IZkSync.syncL2Requests,\n            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)\n        );\n        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);\n\n        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);\n    }\n\n    function syncBatchRoot(\n        uint256 _batchNumber,\n        bytes32 _l2LogsRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        // Allows repeated sending of the forward amount of the batch\n        if (_batchNumber > totalBatchesExecuted) {\n            totalBatchesExecuted = _batchNumber;\n        }\n        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;\n        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);\n    }\n\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable onlyGateway {\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        if (gateway.isEthGasToken()) {\n            require(msg.value == _forwardEthAmount, \"Invalid forward amount\");\n        }\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        rangeBatchRootHashes[range] = _rangeBatchRootHash;\n        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);\n    }\n\n    /// @dev Unzip the root hashes in the range\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    function openRangeBatchRootHash(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32[] calldata _l2LogsRootHashes\n    ) external onlyValidator {\n        // The first open or the next open\n        require(totalBatchesExecuted == 0 || _fromBatchNumber == totalBatchesExecuted + 1, \"Invalid open\");\n        require(_toBatchNumber >= _fromBatchNumber, \"Invalid range\");\n        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));\n        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];\n        require(rangeBatchRootHash != bytes32(0), \"Range batch root hash not exist\");\n        uint256 rootHashesLength = _l2LogsRootHashes.length;\n        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, \"Invalid root hashes length\");\n        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];\n        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;\n        unchecked {\n            for (uint256 i = 1; i < rootHashesLength; ++i) {\n                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];\n                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;\n                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);\n            }\n        }\n        require(_rangeBatchRootHash == rangeBatchRootHash, \"Incorrect root hash\");\n        delete rangeBatchRootHashes[range];\n        totalBatchesExecuted = _toBatchNumber;\n        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);\n    }\n\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {\n        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;\n        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);\n    }\n\n    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {\n        require(_amount > 0, \"Invalid amount\");\n        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;\n        require(totalValidatorForwardFee >= newWithdrawnFee, \"Withdraw exceed\");\n\n        // Update withdrawn fee\n        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = _receiver.call{value: _amount}(\"\");\n        require(success, \"Withdraw failed\");\n        emit WithdrawForwardFee(_receiver, _amount);\n    }\n\n    /// @notice Derives the price for L2 gas in ETH to be paid.\n    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147\n    /// @param _l1GasPrice The gas price on L1.\n    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas\n    /// @return The price of L2 gas in ETH\n    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {\n        FeeParams memory _feeParams = feeParams;\n\n        uint256 pubdataPriceETH;\n        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {\n            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;\n        }\n\n        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;\n        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);\n\n        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);\n        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;\n\n        return Math.max(l2GasPrice, minL2GasPriceETH);\n    }\n\n    function _serializeL2Transaction(\n        ForwardL2Request memory _request\n    ) internal pure returns (L2CanonicalTransaction memory transaction) {\n        transaction = L2CanonicalTransaction({\n            txType: uint256(0),\n            from: uint256(0),\n            to: uint256(0),\n            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction\n            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction\n            maxFeePerGas: uint256(0),\n            maxPriorityFeePerGas: uint256(0),\n            paymaster: uint256(0),\n            nonce: uint256(0),\n            value: uint256(0),\n            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],\n            data: _request.l2CallData, // Length used in validate l2 transaction\n            signature: new bytes(0),\n            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction\n            paymasterInput: new bytes(0),\n            reservedDynamic: new bytes(0)\n        });\n    }\n\n    /// @dev Convert arbitrary-length message to the raw l2 log\n    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {\n        return\n            L2Log({\n                l2ShardId: 0,\n                isService: true,\n                txNumberInBatch: _message.txNumberInBatch,\n                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,\n                key: bytes32(uint256(uint160(_message.sender))),\n                value: keccak256(_message.data)\n            });\n    }\n\n    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number\n    function _proveL2LogInclusion(\n        uint256 _batchNumber,\n        uint256 _index,\n        L2Log memory _log,\n        bytes32[] calldata _proof\n    ) internal view whenNotPaused returns (bool) {\n        require(_batchNumber <= totalBatchesExecuted, \"xx\");\n\n        bytes32 hashedLog = keccak256(\n            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)\n        );\n        // Check that hashed log is not the default one,\n        // otherwise it means that the value is out of range of sent L2 -> L1 logs\n        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, \"tw\");\n\n        // It is ok to not check length of `_proof` array, as length\n        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not\n        // equal to the length of other nodes preimages (which are `2 * 32`)\n\n        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);\n        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];\n\n        return actualRootHash == calculatedRootHash;\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _message\n    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {\n        // We check that the message is long enough to read the data.\n        // Please note that there are two versions of the message:\n        // 1. The message that is sent by `withdraw(address _l1Receiver)`\n        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).\n        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`\n        // It should be equal to the length of the following:\n        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData\n        // (where the _additionalData = abi.encode(l1Receiver))\n        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).\n        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, \"pm\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);\n        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, \"is\");\n\n        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_message, offset);\n        // The additional data is l1 receiver address\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);\n    }\n\n    /// @notice Transfer ether from the contract to the receiver\n    /// @dev Reverts only if the transfer call failed\n    function _withdrawFunds(address _to, uint256 _amount) internal {\n        if (gateway.isEthGasToken()) {\n            bool callSuccess;\n            // Low-level assembly call, to avoid any memory copying (save gas)\n            assembly {\n                callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)\n            }\n            require(callSuccess, \"pz\");\n        } else {\n            SafeERC20.safeTransfer(gateway.ethToken(), _to, _amount);\n        }\n    }\n\n    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    FORWARD_REQUEST_TYPE_HASH,\n                    _request.gateway,\n                    _request.isContractCall,\n                    _request.sender,\n                    _request.txId,\n                    _request.contractAddressL2,\n                    _request.l2Value,\n                    keccak256(_request.l2CallData),\n                    _request.l2GasLimit,\n                    _request.l2GasPricePerPubdata,\n                    keccak256(abi.encode(_request.factoryDeps)),\n                    _request.refundRecipient\n                )\n            );\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/bridge/L1ERC20Bridge.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport {IERC20Metadata} from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport {IL1BridgeLegacy} from \"./interfaces/IL1BridgeLegacy.sol\";\nimport {IL1Bridge} from \"./interfaces/IL1Bridge.sol\";\nimport {IL2Bridge} from \"./interfaces/IL2Bridge.sol\";\nimport {IL2ERC20Bridge} from \"./interfaces/IL2ERC20Bridge.sol\";\n\nimport {BridgeInitializationHelper} from \"./libraries/BridgeInitializationHelper.sol\";\n\nimport {IMailbox, TxStatus} from \"../zksync/interfaces/IMailbox.sol\";\nimport {L2Message} from \"../zksync/Storage.sol\";\nimport {UnsafeBytes} from \"../common/libraries/UnsafeBytes.sol\";\nimport {L2ContractHelper} from \"../common/libraries/L2ContractHelper.sol\";\nimport {ReentrancyGuard} from \"../common/ReentrancyGuard.sol\";\nimport {AddressAliasHelper} from \"../vendor/AddressAliasHelper.sol\";\n\n/// @author Matter Labs\n/// @custom:security-contact security@matterlabs.dev\n/// @notice Smart contract that allows depositing ERC20 tokens from Ethereum to zkSync Era\n/// @dev It is standard implementation of ERC20 Bridge that can be used as a reference\n/// for any other custom token bridges.\ncontract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, ReentrancyGuard {\n    using SafeERC20 for IERC20;\n\n    /// @dev zkSync smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication\n    IMailbox internal immutable zkSync;\n\n    /// @dev A mapping L2 batch number => message number => flag\n    /// @dev Used to indicate that zkSync L2 -> L1 message was already processed\n    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))\n        public isWithdrawalFinalized;\n\n    /// @dev A mapping account => L1 token address => L2 deposit transaction hash => amount\n    /// @dev Used for saving the number of deposited funds, to claim them in case the deposit transaction will fail\n    mapping(address account => mapping(address l1Token => mapping(bytes32 depositL2TxHash => uint256 amount)))\n        internal depositAmount;\n\n    /// @dev The address of deployed L2 bridge counterpart\n    address public l2Bridge;\n\n    /// @dev The address that acts as a beacon for L2 tokens\n    address public l2TokenBeacon;\n\n    /// @dev The bytecode hash of the L2 token contract\n    bytes32 public l2TokenProxyBytecodeHash;\n\n    mapping(address => uint256) private __DEPRECATED_lastWithdrawalLimitReset;\n\n    /// @dev A mapping L1 token address => the accumulated withdrawn amount during the withdrawal limit window\n    mapping(address => uint256) private __DEPRECATED_withdrawnAmountInWindow;\n\n    /// @dev The accumulated deposited amount per user.\n    /// @dev A mapping L1 token address => user address => the total deposited amount by the user\n    mapping(address => mapping(address => uint256)) private __DEPRECATED_totalDepositedAmountPerUser;\n\n    /// @dev Contract is expected to be used as proxy implementation.\n    /// @dev Initialize the implementation to prevent Parity hack.\n    constructor(IMailbox _zkSync) reentrancyGuardInitializer {\n        zkSync = _zkSync;\n    }\n\n    /// @dev Initializes a contract bridge for later use. Expected to be used in the proxy\n    /// @dev During initialization deploys L2 bridge counterpart as well as provides some factory deps for it\n    /// @param _factoryDeps A list of raw bytecodes that are needed for deployment of the L2 bridge\n    /// @notice _factoryDeps[0] == a raw bytecode of L2 bridge implementation\n    /// @notice _factoryDeps[1] == a raw bytecode of proxy that is used as L2 bridge\n    /// @notice _factoryDeps[2] == a raw bytecode of token proxy\n    /// @param _factoryDepByteCodeHashes A list of raw bytecode sha256 hashes that are needed for deployment of the L2 bridge\n    /// @param _l2BridgeConstructorData The data that is needed for constructor of the L2 bridge\n    /// @param _l2TokenBeacon Pre-calculated address of the L2 token upgradeable beacon\n    /// @notice At the time of the function call, it is not yet deployed in L2, but knowledge of its address\n    /// @notice is necessary for determining L2 token address by L1 address, see `l2TokenAddress(address)` function\n    /// @param _governor Address which can change L2 token implementation and upgrade the bridge\n    /// @param _deployBridgeImplementationFee How much of the sent value should be allocated to deploying the L2 bridge\n    /// implementation\n    /// @param _deployBridgeProxyFee How much of the sent value should be allocated to deploying the L2 bridge proxy\n    function initialize(\n        bytes[] calldata _factoryDeps,\n        bytes32[] calldata _factoryDepByteCodeHashes,\n        bytes calldata _l2BridgeConstructorData,\n        address _l2TokenBeacon,\n        address _governor,\n        uint256 _deployBridgeImplementationFee,\n        uint256 _deployBridgeProxyFee\n    ) external payable reentrancyGuardInitializer {\n        require(_l2TokenBeacon != address(0), \"nf\");\n        require(_governor != address(0), \"nh\");\n        // We are expecting to see the exact three bytecodes that are needed to initialize the bridge\n        require(_factoryDeps.length == 3, \"mk\");\n        require(_factoryDeps.length == _factoryDepByteCodeHashes.length, \"mg\");\n        // The caller miscalculated deploy transactions fees\n        require(msg.value == _deployBridgeImplementationFee + _deployBridgeProxyFee, \"fee\");\n        l2TokenProxyBytecodeHash = L2ContractHelper.hashL2Bytecode(\n            _factoryDeps[2].length,\n            _factoryDepByteCodeHashes[2]\n        );\n        l2TokenBeacon = _l2TokenBeacon;\n\n        bytes32 l2BridgeImplementationBytecodeHash = L2ContractHelper.hashL2Bytecode(\n            _factoryDeps[0].length,\n            _factoryDepByteCodeHashes[0]\n        );\n        bytes32 l2BridgeProxyBytecodeHash = L2ContractHelper.hashL2Bytecode(\n            _factoryDeps[1].length,\n            _factoryDepByteCodeHashes[1]\n        );\n\n        // Deploy L2 bridge implementation contract\n        address bridgeImplementationAddr = BridgeInitializationHelper.requestDeployTransaction(\n            zkSync,\n            _deployBridgeImplementationFee,\n            l2BridgeImplementationBytecodeHash,\n            _l2BridgeConstructorData,\n            _factoryDeps // All factory deps are needed for L2 bridge\n        );\n\n        // Prepare the proxy constructor data\n        bytes memory l2BridgeProxyConstructorData;\n        {\n            // Data to be used in delegate call to initialize the proxy\n            bytes memory proxyInitializationParams = abi.encodeCall(\n                IL2ERC20Bridge.initialize,\n                (address(this), l2TokenProxyBytecodeHash, _governor)\n            );\n            l2BridgeProxyConstructorData = abi.encode(bridgeImplementationAddr, _governor, proxyInitializationParams);\n        }\n\n        // Deploy L2 bridge proxy contract\n        l2Bridge = BridgeInitializationHelper.requestDeployTransaction(\n            zkSync,\n            _deployBridgeProxyFee,\n            l2BridgeProxyBytecodeHash,\n            l2BridgeProxyConstructorData,\n            // No factory deps are needed for the L2 bridge proxy, because it is already passed in previous step\n            new bytes[](0)\n        );\n    }\n\n    /// @notice Legacy deposit method with refunding the fee to the caller, use another `deposit` method instead.\n    /// @dev Initiates a deposit by locking funds on the contract and sending the request\n    /// of processing an L2 transaction where tokens would be minted.\n    /// @dev If the token is bridged for the first time, the L2 token contract will be deployed. Note however, that the\n    /// newly-deployed token does not support any custom logic, i.e. rebase tokens' functionality is not supported.\n    /// @param _l2Receiver The account address that should receive funds on L2\n    /// @param _l1Token The L1 token address which is deposited\n    /// @param _amount The total amount of tokens to be bridged\n    /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction\n    /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction\n    /// @return l2TxHash The L2 transaction hash of deposit finalization\n    /// NOTE: the function doesn't use `nonreentrant` modifier, because the inner method does.\n    function deposit(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte\n    ) external payable returns (bytes32 l2TxHash) {\n        l2TxHash = deposit(_l2Receiver, _l1Token, _amount, _l2TxGasLimit, _l2TxGasPerPubdataByte, address(0));\n    }\n\n    /// @notice Initiates a deposit by locking funds on the contract and sending the request\n    /// of processing an L2 transaction where tokens would be minted\n    /// @dev If the token is bridged for the first time, the L2 token contract will be deployed. Note however, that the\n    /// newly-deployed token does not support any custom logic, i.e. rebase tokens' functionality is not supported.\n    /// @param _l2Receiver The account address that should receive funds on L2\n    /// @param _l1Token The L1 token address which is deposited\n    /// @param _amount The total amount of tokens to be bridged\n    /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction\n    /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction\n    /// @param _refundRecipient The address on L2 that will receive the refund for the transaction.\n    /// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`.\n    /// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses\n    /// out of control.\n    /// - If `_refundRecipient` is a contract on L1, the refund will be sent to the aliased `_refundRecipient`.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has NO deployed bytecode on L1, the refund will\n    /// be sent to the `msg.sender` address.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has deployed bytecode on L1, the refund will be\n    /// sent to the aliased `msg.sender` address.\n    /// @dev The address aliasing of L1 contracts as refund recipient on L2 is necessary to guarantee that the funds\n    /// are controllable through the Mailbox, since the Mailbox applies address aliasing to the from address for the\n    /// L2 tx if the L1 msg.sender is a contract. Without address aliasing for L1 contracts as refund recipients they\n    /// would not be able to make proper L2 tx requests through the Mailbox to use or withdraw the funds from L2, and\n    /// the funds would be lost.\n    /// @return l2TxHash The L2 transaction hash of deposit finalization\n    function deposit(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte,\n        address _refundRecipient\n    ) public payable nonReentrant returns (bytes32 l2TxHash) {\n        l2TxHash = _deposit(\n            _l2Receiver,\n            _l1Token,\n            _amount,\n            _l2TxGasLimit,\n            _l2TxGasPerPubdataByte,\n            _refundRecipient,\n            false\n        );\n    }\n\n    /// @notice Initiates a deposit by locking funds on the contract and sending the request\n    /// of processing an L2 transaction where merge tokens would be minted\n    /// @dev If the token is bridged for the first time, the L2 token and merge token contract will be deployed. Note however, that the\n    /// newly-deployed token does not support any custom logic, i.e. rebase tokens' functionality is not supported.\n    /// @param _l2Receiver The account address that should receive funds on L2\n    /// @param _l1Token The L1 token address which is deposited\n    /// @param _amount The total amount of tokens to be bridged\n    /// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction\n    /// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction\n    /// @param _refundRecipient The address on L2 that will receive the refund for the transaction.\n    /// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`.\n    /// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses\n    /// out of control.\n    /// - If `_refundRecipient` is a contract on L1, the refund will be sent to the aliased `_refundRecipient`.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has NO deployed bytecode on L1, the refund will\n    /// be sent to the `msg.sender` address.\n    /// - If `_refundRecipient` is set to `address(0)` and the sender has deployed bytecode on L1, the refund will be\n    /// sent to the aliased `msg.sender` address.\n    /// @dev The address aliasing of L1 contracts as refund recipient on L2 is necessary to guarantee that the funds\n    /// are controllable through the Mailbox, since the Mailbox applies address aliasing to the from address for the\n    /// L2 tx if the L1 msg.sender is a contract. Without address aliasing for L1 contracts as refund recipients they\n    /// would not be able to make proper L2 tx requests through the Mailbox to use or withdraw the funds from L2, and\n    /// the funds would be lost.\n    /// @return l2TxHash The L2 transaction hash of depositToMerge finalization\n    function depositToMerge(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte,\n        address _refundRecipient\n    ) external payable nonReentrant returns (bytes32 l2TxHash) {\n        l2TxHash = _deposit(\n            _l2Receiver,\n            _l1Token,\n            _amount,\n            _l2TxGasLimit,\n            _l2TxGasPerPubdataByte,\n            _refundRecipient,\n            true\n        );\n    }\n\n    function _deposit(\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        uint256 _l2TxGasLimit,\n        uint256 _l2TxGasPerPubdataByte,\n        address _refundRecipient,\n        bool _toMerge\n    ) internal returns (bytes32 l2TxHash) {\n        require(_amount != 0, \"2T\"); // empty deposit amount\n        uint256 amount = _depositFunds(msg.sender, IERC20(_l1Token), _amount);\n        require(amount == _amount, \"1T\"); // The token has non-standard transfer logic\n\n        bytes memory l2TxCalldata = _getDepositL2Calldata(msg.sender, _l2Receiver, _l1Token, amount, _toMerge);\n        // If the refund recipient is not specified, the refund will be sent to the sender of the transaction.\n        // Otherwise, the refund will be sent to the specified address.\n        // If the recipient is a contract on L1, the address alias will be applied.\n        address refundRecipient = _refundRecipient;\n        if (_refundRecipient == address(0)) {\n            refundRecipient = msg.sender != tx.origin ? AddressAliasHelper.applyL1ToL2Alias(msg.sender) : msg.sender;\n        }\n        l2TxHash = zkSync.requestL2Transaction{value: msg.value}(\n            l2Bridge,\n            0, // L2 msg.value\n            l2TxCalldata,\n            _l2TxGasLimit,\n            _l2TxGasPerPubdataByte,\n            new bytes[](0),\n            refundRecipient\n        );\n\n        // Save the deposited amount to claim funds on L1 if the deposit failed on L2\n        depositAmount[msg.sender][_l1Token][l2TxHash] = amount;\n        if (_toMerge) {\n            emit DepositToMergeInitiated(l2TxHash, msg.sender, _l2Receiver, _l1Token, amount, _toMerge);\n        } else {\n            emit DepositInitiated(l2TxHash, msg.sender, _l2Receiver, _l1Token, amount);\n        }\n    }\n\n    /// @dev Transfers tokens from the depositor address to the smart contract address\n    /// @return The difference between the contract balance before and after the transferring of funds\n    function _depositFunds(address _from, IERC20 _token, uint256 _amount) internal returns (uint256) {\n        uint256 balanceBefore = _token.balanceOf(address(this));\n        _token.safeTransferFrom(_from, address(this), _amount);\n        uint256 balanceAfter = _token.balanceOf(address(this));\n\n        return balanceAfter - balanceBefore;\n    }\n\n    /// @dev Generate a calldata for calling the deposit finalization on the L2 bridge contract\n    function _getDepositL2Calldata(\n        address _l1Sender,\n        address _l2Receiver,\n        address _l1Token,\n        uint256 _amount,\n        bool _toMerge\n    ) internal view returns (bytes memory txCalldata) {\n        bytes memory gettersData = _getERC20Getters(_l1Token);\n        if (_toMerge) {\n            txCalldata = abi.encodeCall(\n                IL2Bridge.finalizeDepositToMerge,\n                (_l1Sender, _l2Receiver, _l1Token, _amount, gettersData)\n            );\n        } else {\n            txCalldata = abi.encodeCall(\n                IL2Bridge.finalizeDeposit,\n                (_l1Sender, _l2Receiver, _l1Token, _amount, gettersData)\n            );\n        }\n    }\n\n    /// @dev Receives and parses (name, symbol, decimals) from the token contract\n    function _getERC20Getters(address _token) internal view returns (bytes memory data) {\n        (, bytes memory data1) = _token.staticcall(abi.encodeCall(IERC20Metadata.name, ()));\n        (, bytes memory data2) = _token.staticcall(abi.encodeCall(IERC20Metadata.symbol, ()));\n        (, bytes memory data3) = _token.staticcall(abi.encodeCall(IERC20Metadata.decimals, ()));\n        data = abi.encode(data1, data2, data3);\n    }\n\n    /// @dev Withdraw funds from the initiated deposit, that failed when finalizing on L2\n    /// @param _depositSender The address of the deposit initiator\n    /// @param _l1Token The address of the deposited L1 ERC20 token\n    /// @param _l2TxHash The L2 transaction hash of the failed deposit finalization\n    /// @param _l2BatchNumber The L2 batch number where the deposit finalization was processed\n    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message\n    /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent\n    /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction with deposit finalization\n    function claimFailedDeposit(\n        address _depositSender,\n        address _l1Token,\n        bytes32 _l2TxHash,\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        bool proofValid = zkSync.proveL1ToL2TransactionStatus(\n            _l2TxHash,\n            _l2BatchNumber,\n            _l2MessageIndex,\n            _l2TxNumberInBatch,\n            _merkleProof,\n            TxStatus.Failure\n        );\n        require(proofValid, \"yn\");\n\n        uint256 amount = depositAmount[_depositSender][_l1Token][_l2TxHash];\n        require(amount > 0, \"y1\");\n\n        delete depositAmount[_depositSender][_l1Token][_l2TxHash];\n        // Withdraw funds\n        IERC20(_l1Token).safeTransfer(_depositSender, amount);\n\n        emit ClaimedFailedDeposit(_depositSender, _l1Token, amount);\n    }\n\n    /// @notice Finalize the withdrawal and release funds\n    /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed\n    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message\n    /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent\n    /// @param _message The L2 withdraw data, stored in an L2 -> L1 message\n    /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization\n    function finalizeWithdrawal(\n        uint256 _l2BatchNumber,\n        uint256 _l2MessageIndex,\n        uint16 _l2TxNumberInBatch,\n        bytes calldata _message,\n        bytes32[] calldata _merkleProof\n    ) external nonReentrant {\n        require(!isWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], \"pw\");\n\n        L2Message memory l2ToL1Message = L2Message({\n            txNumberInBatch: _l2TxNumberInBatch,\n            sender: l2Bridge,\n            data: _message\n        });\n\n        (address l1Receiver, address l1Token, uint256 amount) = _parseL2WithdrawalMessage(l2ToL1Message.data);\n        // Preventing the stack too deep error\n        {\n            bool success = zkSync.proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);\n            require(success, \"nq\");\n        }\n\n        isWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;\n        // Withdraw funds\n        IERC20(l1Token).safeTransfer(l1Receiver, amount);\n\n        emit WithdrawalFinalized(l1Receiver, l1Token, amount);\n    }\n\n    /// @dev Decode the withdraw message that came from L2\n    function _parseL2WithdrawalMessage(\n        bytes memory _l2ToL1message\n    ) internal pure returns (address l1Receiver, address l1Token, uint256 amount) {\n        // Check that the message length is correct.\n        // It should be equal to the length of the function signature + address + address + uint256 = 4 + 20 + 20 + 32 =\n        // 76 (bytes).\n        require(_l2ToL1message.length == 76, \"kk\");\n\n        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_l2ToL1message, 0);\n        require(bytes4(functionSignature) == this.finalizeWithdrawal.selector, \"nt\");\n\n        (l1Receiver, offset) = UnsafeBytes.readAddress(_l2ToL1message, offset);\n        (l1Token, offset) = UnsafeBytes.readAddress(_l2ToL1message, offset);\n        (amount, offset) = UnsafeBytes.readUint256(_l2ToL1message, offset);\n    }\n\n    /// @return The L2 token address that would be minted for deposit of the given L1 token\n    function l2TokenAddress(address _l1Token) public view returns (address) {\n        bytes32 constructorInputHash = keccak256(abi.encode(l2TokenBeacon, \"\"));\n        bytes32 salt = bytes32(uint256(uint160(_l1Token)));\n\n        return L2ContractHelper.computeCreate2Address(l2Bridge, salt, l2TokenProxyBytecodeHash, constructorInputHash);\n    }\n}\n"},{"file_path":"contracts/zksync/l1-contracts/common/L2ContractAddresses.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @dev The address of the L2 deployer system contract.\naddress constant L2_DEPLOYER_SYSTEM_CONTRACT_ADDR = address(0x8006);\n\n/// @dev The special reserved L2 address. It is located in the system contracts space but doesn't have deployed\n/// bytecode.\n/// @dev The L2 deployer system contract allows changing bytecodes on any address if the `msg.sender` is this address.\n/// @dev So, whenever the governor wants to redeploy system contracts, it just initiates the L1 upgrade call deployer\n/// system contract\n/// via the L1 -> L2 transaction with `sender == L2_FORCE_DEPLOYER_ADDR`. For more details see the\n/// `diamond-initializers` contracts.\naddress constant L2_FORCE_DEPLOYER_ADDR = address(0x8007);\n\n/// @dev The address of the special smart contract that can send arbitrary length message as an L2 log\naddress constant L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR = address(0x8008);\n\n/// @dev The formal address of the initial program of the system: the bootloader\naddress constant L2_BOOTLOADER_ADDRESS = address(0x8001);\n\n/// @dev The address of the eth token system contract\naddress constant L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR = address(0x800a);\n\n/// @dev The address of the known code storage system contract\naddress constant L2_KNOWN_CODE_STORAGE_SYSTEM_CONTRACT_ADDR = address(0x8004);\n\n/// @dev The address of the context system contract\naddress constant L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT_ADDR = address(0x800b);\n"},{"file_path":"contracts/zksync/l1-contracts/zksync/Storage.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @dev The log passed from L2\n/// @param l2ShardId The shard identifier, 0 - rollup, 1 - porter. All other values are not used but are reserved for\n/// the future\n/// @param isService A boolean flag that is part of the log along with `key`, `value`, and `sender` address.\n/// This field is required formally but does not have any special meaning.\n/// @param txNumberInBatch The L2 transaction number in the batch, in which the log was sent\n/// @param sender The L2 address which sent the log\n/// @param key The 32 bytes of information that was sent in the log\n/// @param value The 32 bytes of information that was sent in the log\n// Both `key` and `value` are arbitrary 32-bytes selected by the log sender\nstruct L2Log {\n    uint8 l2ShardId;\n    bool isService;\n    uint16 txNumberInBatch;\n    address sender;\n    bytes32 key;\n    bytes32 value;\n}\n\n/// @dev An arbitrary length message passed from L2\n/// @notice Under the hood it is `L2Log` sent from the special system L2 contract\n/// @param txNumberInBatch The L2 transaction number in the batch, in which the message was sent\n/// @param sender The address of the L2 account from which the message was passed\n/// @param data An arbitrary length message\nstruct L2Message {\n    uint16 txNumberInBatch;\n    address sender;\n    bytes data;\n}\n\n/// @notice The struct that describes whether users will be charged for pubdata for L1->L2 transactions.\n/// @param Rollup The users are charged for pubdata & it is priced based on the gas price on Ethereum.\n/// @param Validium The pubdata is considered free with regard to the L1 gas price.\nenum PubdataPricingMode {\n    Rollup,\n    Validium\n}\n\n/// @notice The fee params for L1->L2 transactions for the network.\n/// @param pubdataPricingMode How the users will charged for pubdata in L1->L2 transactions.\n/// @param batchOverheadL1Gas The amount of L1 gas required to process the batch (except for the calldata).\n/// @param maxPubdataPerBatch The maximal number of pubdata that can be emitted per batch.\n/// @param priorityTxMaxPubdata The maximal amount of pubdata a priority transaction is allowed to publish.\n/// It can be slightly less than maxPubdataPerBatch in order to have some margin for the bootloader execution.\n/// @param minimalL2GasPrice The minimal L2 gas price to be used by L1->L2 transactions. It should represent\n/// the price that a single unit of compute costs.\nstruct FeeParams {\n    PubdataPricingMode pubdataPricingMode;\n    uint32 batchOverheadL1Gas;\n    uint32 maxPubdataPerBatch;\n    uint32 maxL2GasPerBatch;\n    uint32 priorityTxMaxPubdata;\n    uint64 minimalL2GasPrice;\n}\n\n/// @dev The sync status for priority op of secondary chain\n/// @param hash The cumulative canonicalTxHash\n/// @param amount The cumulative l2 value\nstruct SecondaryChainSyncStatus {\n    bytes32 hash;\n    uint256 amount;\n}\n"},{"file_path":"contracts/interfaces/IZkLink.sol","source_code":"// SPDX-License-Identifier: MIT OR Apache-2.0\n\npragma solidity ^0.8.0;\n\n/// @title ZkLink interface contract\n/// @author zk.link\ninterface IZkLink {\n    /// @notice Send l2 requests sync status to primary chain\n    /// @param _newTotalSyncedPriorityTxs New sync point\n    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable;\n\n    /// @notice Receive batch root from primary chain\n    /// @param _batchNumber The batch number\n    /// @param _l2LogsRootHash The L2 to L1 log root hash\n    /// @param _forwardEthAmount The forward eth amount\n    function syncBatchRoot(uint256 _batchNumber, bytes32 _l2LogsRootHash, uint256 _forwardEthAmount) external payable;\n\n    /// @notice Receive range batch root hash from primary chain\n    /// @param _fromBatchNumber The batch number from\n    /// @param _toBatchNumber The batch number to\n    /// @param _rangeBatchRootHash The accumulation hash of l2LogsRootHash in the range [`_fromBatchNumber`, `_toBatchNumber`]\n    /// @param _forwardEthAmount The forward eth amount\n    function syncRangeBatchRoot(\n        uint256 _fromBatchNumber,\n        uint256 _toBatchNumber,\n        bytes32 _rangeBatchRootHash,\n        uint256 _forwardEthAmount\n    ) external payable;\n\n    /// @notice Receive l2 tx hash from primary chain\n    /// @param _l2TxHash The l2 tx hash on local chain\n    /// @param _primaryChainL2TxHash The l2 tx hash on primary chain\n    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external;\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"bool","name":"_isEthGasToken","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isPermit","type":"bool"}],"name":"ContractAllowStatusUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EthWithdrawalFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAllocator","type":"address"},{"indexed":false,"internalType":"address","name":"newAllocator","type":"address"}],"name":"ForwardFeeAllocatorUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IL2Gateway","name":"gateway","type":"address"}],"name":"InitGateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"enum PubdataPricingMode","name":"pubdataPricingMode","type":"uint8"},{"internalType":"uint32","name":"batchOverheadL1Gas","type":"uint32"},{"internalType":"uint32","name":"maxPubdataPerBatch","type":"uint32"},{"internalType":"uint32","name":"maxL2GasPerBatch","type":"uint32"},{"internalType":"uint32","name":"priorityTxMaxPubdata","type":"uint32"},{"internalType":"uint64","name":"minimalL2GasPrice","type":"uint64"}],"indexed":false,"internalType":"struct FeeParams","name":"oldFeeParams","type":"tuple"},{"components":[{"internalType":"enum PubdataPricingMode","name":"pubdataPricingMode","type":"uint8"},{"internalType":"uint32","name":"batchOverheadL1Gas","type":"uint32"},{"internalType":"uint32","name":"maxPubdataPerBatch","type":"uint32"},{"internalType":"uint32","name":"maxL2GasPerBatch","type":"uint32"},{"internalType":"uint32","name":"priorityTxMaxPubdata","type":"uint32"},{"internalType":"uint64","name":"minimalL2GasPrice","type":"uint64"}],"indexed":false,"internalType":"struct FeeParams","name":"newFeeParams","type":"tuple"}],"name":"NewFeeParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"priorityOpId","type":"uint256"},{"components":[{"internalType":"address","name":"gateway","type":"address"},{"internalType":"bool","name":"isContractCall","type":"bool"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"txId","type":"uint256"},{"internalType":"address","name":"contractAddressL2","type":"address"},{"internalType":"uint256","name":"l2Value","type":"uint256"},{"internalType":"bytes","name":"l2CallData","type":"bytes"},{"internalType":"uint256","name":"l2GasLimit","type":"uint256"},{"internalType":"uint256","name":"l2GasPricePerPubdata","type":"uint256"},{"internalType":"bytes[]","name":"factoryDeps","type":"bytes[]"},{"internalType":"address","name":"refundRecipient","type":"address"}],"indexed":false,"internalType":"struct IMailbox.ForwardL2Request","name":"l2Request","type":"tuple"}],"name":"NewPriorityRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fromBatchNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toBatchNumber","type":"uint256"}],"name":"OpenRangeBatchRoot","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"batchNumber","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"l2LogsRootHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"forwardEthAmount","type":"uint256"}],"name":"SyncBatchRoot","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalSyncedPriorityTxs","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"syncHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"forwardEthAmount","type":"uint256"}],"name":"SyncL2Requests","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"l2TxHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"primaryChainL2TxHash","type":"bytes32"}],"name":"SyncL2TxHash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fromBatchNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toBatchNumber","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"rangeBatchRootHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"forwardEthAmount","type":"uint256"}],"name":"SyncRangeBatchRoot","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTxGasPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTxGasPrice","type":"uint256"}],"name":"TxGasPriceUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"validatorAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"ValidatorStatusUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawForwardFee","type":"event"},{"inputs":[],"name":"FORWARD_REQUEST_TYPE_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IS_ETH_GAS_TOKEN","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"allowLists","outputs":[{"internalType":"bool","name":"isPermitToSendL2Request","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum PubdataPricingMode","name":"pubdataPricingMode","type":"uint8"},{"internalType":"uint32","name":"batchOverheadL1Gas","type":"uint32"},{"internalType":"uint32","name":"maxPubdataPerBatch","type":"uint32"},{"internalType":"uint32","name":"maxL2GasPerBatch","type":"uint32"},{"internalType":"uint32","name":"priorityTxMaxPubdata","type":"uint32"},{"internalType":"uint64","name":"minimalL2GasPrice","type":"uint64"}],"internalType":"struct FeeParams","name":"_newFeeParams","type":"tuple"}],"name":"changeFeeParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeParams","outputs":[{"internalType":"enum PubdataPricingMode","name":"pubdataPricingMode","type":"uint8"},{"internalType":"uint32","name":"batchOverheadL1Gas","type":"uint32"},{"internalType":"uint32","name":"maxPubdataPerBatch","type":"uint32"},{"internalType":"uint32","name":"maxL2GasPerBatch","type":"uint32"},{"internalType":"uint32","name":"priorityTxMaxPubdata","type":"uint32"},{"internalType":"uint64","name":"minimalL2GasPrice","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_l2BatchNumber","type":"uint256"},{"internalType":"uint256","name":"_l2MessageIndex","type":"uint256"},{"internalType":"uint16","name":"_l2TxNumberInBatch","type":"uint16"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"}],"name":"finalizeEthWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"forwardFeeAllocator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gateway","outputs":[{"internalType":"contract IL2Gateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGateway","outputs":[{"internalType":"contract IL2Gateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGovernor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriorityTxMaxGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getTotalBatchesExecuted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalPriorityTxs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"l2BatchNumber","type":"uint256"},{"internalType":"uint256","name":"l2ToL1MessageNumber","type":"uint256"}],"name":"isEthWithdrawalFinalized","outputs":[{"internalType":"bool","name":"isFinalized","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isValidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchNumber","type":"uint256"}],"name":"l2LogsRootHash","outputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"batchNumber","type":"uint256"}],"name":"l2LogsRootHashes","outputs":[{"internalType":"bytes32","name":"l2LogsRootHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gasPrice","type":"uint256"},{"internalType":"uint256","name":"_l2GasLimit","type":"uint256"},{"internalType":"uint256","name":"_l2GasPerPubdataByteLimit","type":"uint256"}],"name":"l2TransactionBaseCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"l2TxHash","type":"bytes32"}],"name":"l2TxHashMap","outputs":[{"internalType":"bytes32","name":"primaryChainL2TxHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromBatchNumber","type":"uint256"},{"internalType":"uint256","name":"_toBatchNumber","type":"uint256"},{"internalType":"bytes32[]","name":"_l2LogsRootHashes","type":"bytes32[]"}],"name":"openRangeBatchRootHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"priorityOpId","type":"uint256"}],"name":"priorityOpSyncStatus","outputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_l2TxHash","type":"bytes32"},{"internalType":"uint256","name":"_l2BatchNumber","type":"uint256"},{"internalType":"uint256","name":"_l2MessageIndex","type":"uint256"},{"internalType":"uint16","name":"_l2TxNumberInBatch","type":"uint16"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"},{"internalType":"enum TxStatus","name":"_status","type":"uint8"}],"name":"proveL1ToL2TransactionStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchNumber","type":"uint256"},{"internalType":"uint256","name":"_index","type":"uint256"},{"components":[{"internalType":"uint16","name":"txNumberInBatch","type":"uint16"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct L2Message","name":"_message","type":"tuple"},{"internalType":"bytes32[]","name":"_proof","type":"bytes32[]"}],"name":"proveL2MessageInclusion","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"range","type":"bytes32"}],"name":"rangeBatchRootHashes","outputs":[{"internalType":"bytes32","name":"rangeBatchRootHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractL2","type":"address"},{"internalType":"uint256","name":"_l2Value","type":"uint256"},{"internalType":"bytes","name":"_calldata","type":"bytes"},{"internalType":"uint256","name":"_l2GasLimit","type":"uint256"},{"internalType":"uint256","name":"_l2GasPerPubdataByteLimit","type":"uint256"},{"internalType":"bytes[]","name":"_factoryDeps","type":"bytes[]"},{"internalType":"address","name":"_refundRecipient","type":"address"}],"name":"requestL2Transaction","outputs":[{"internalType":"bytes32","name":"canonicalTxHash","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"},{"internalType":"bool","name":"_permitted","type":"bool"}],"name":"setAllowList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newForwardFeeAllocator","type":"address"}],"name":"setForwardFeeAllocator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IL2Gateway","name":"_gateway","type":"address"}],"name":"setGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTxGasPrice","type":"uint256"}],"name":"setTxGasPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_validator","type":"address"},{"internalType":"bool","name":"_active","type":"bool"}],"name":"setValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_batchNumber","type":"uint256"},{"internalType":"bytes32","name":"_l2LogsRootHash","type":"bytes32"},{"internalType":"uint256","name":"_forwardEthAmount","type":"uint256"}],"name":"syncBatchRoot","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTotalSyncedPriorityTxs","type":"uint256"}],"name":"syncL2Requests","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_l2TxHash","type":"bytes32"},{"internalType":"bytes32","name":"_primaryChainL2TxHash","type":"bytes32"}],"name":"syncL2TxHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromBatchNumber","type":"uint256"},{"internalType":"uint256","name":"_toBatchNumber","type":"uint256"},{"internalType":"bytes32","name":"_rangeBatchRootHash","type":"bytes32"},{"internalType":"uint256","name":"_forwardEthAmount","type":"uint256"}],"name":"syncRangeBatchRoot","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"totalBatchesExecuted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPriorityTxs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSyncedPriorityTxs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValidatorForwardFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValidatorForwardFeeWithdrawn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"txGasPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"validatorAddress","type":"address"}],"name":"validators","outputs":[{"internalType":"bool","name":"isValidator","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawForwardFee","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":false,"constructor_args":"0000000000000000000000000000000000000000000000000000000000000001"}