MNT Price: $0.65 (+2.36%)

Contract

0x0C04046546C46652969Aa9eB4BFB758cFDf1e821
 

Overview

MNT Balance

Mantle Mainnet Network LogoMantle Mainnet Network LogoMantle Mainnet Network Logo0 MNT

MNT Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ZkLink

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 33 : ZkLink.sol
// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.8.0;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AddressAliasHelper} from "./zksync/l1-contracts/vendor/AddressAliasHelper.sol";
import {IZkLink} from "./interfaces/IZkLink.sol";
import {IL2Gateway} from "./interfaces/IL2Gateway.sol";
import {IMailbox, TxStatus} from "./zksync/l1-contracts/zksync/interfaces/IMailbox.sol";
import {IAdmin} from "./zksync/l1-contracts/zksync/interfaces/IAdmin.sol";
import {IZkSync} from "./zksync/l1-contracts/zksync/interfaces/IZkSync.sol";
import {Merkle} from "./zksync/l1-contracts/zksync/libraries/Merkle.sol";
import {TransactionValidator} from "./zksync/l1-contracts/zksync/libraries/TransactionValidator.sol";
import {L2Log, L2Message, PubdataPricingMode, FeeParams, SecondaryChainSyncStatus} from "./zksync/l1-contracts/zksync/Storage.sol";
import {UncheckedMath} from "./zksync/l1-contracts/common/libraries/UncheckedMath.sol";
import {UnsafeBytes} from "./zksync/l1-contracts/common/libraries/UnsafeBytes.sol";
import {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";
import {L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR, L2_BOOTLOADER_ADDRESS, L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR} from "./zksync/l1-contracts/common/L2ContractAddresses.sol";
import {IGetters} from "./zksync/l1-contracts/zksync/interfaces/IGetters.sol";

/// @title ZkLink contract
/// @author zk.link
contract ZkLink is
    IZkLink,
    IMailbox,
    IAdmin,
    IGetters,
    OwnableUpgradeable,
    UUPSUpgradeable,
    ReentrancyGuardUpgradeable,
    PausableUpgradeable
{
    using UncheckedMath for uint256;
    using SafeERC20 for IERC20;

    /// @dev The forward request type hash
    bytes32 public constant FORWARD_REQUEST_TYPE_HASH =
        keccak256(
            "ForwardL2Request(address gateway,bool isContractCall,address sender,uint256 txId,address contractAddressL2,uint256 l2Value,bytes32 l2CallDataHash,uint256 l2GasLimit,uint256 l2GasPricePerPubdata,bytes32 factoryDepsHash,address refundRecipient)"
        );

    /// @dev The length of withdraw message sent to secondary chain
    uint256 private constant L2_WITHDRAW_MESSAGE_LENGTH = 108;

    /// @notice The gateway is used for communicating with L1
    IL2Gateway public gateway;
    /// @notice List of permitted validators
    mapping(address validatorAddress => bool isValidator) public validators;
    /// @dev The white list allow to send request L2 request
    mapping(address contractAddress => bool isPermitToSendL2Request) public allowLists;
    /// @dev Gas price of primary chain
    uint256 public txGasPrice;
    /// @dev Fee params used to derive gasPrice for the L1->L2 transactions. For L2 transactions,
    /// the bootloader gives enough freedom to the operator.
    FeeParams public feeParams;
    /// @dev The total number of priority operations that were added to the priority queue
    uint256 public totalPriorityTxs;
    /// @dev The total number of synced priority operations
    uint256 public totalSyncedPriorityTxs;
    /// @dev The sync status for each priority operation
    mapping(uint256 priorityOpId => SecondaryChainSyncStatus) public priorityOpSyncStatus;
    /// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch
    /// (batch 0 is genesis)
    uint256 public totalBatchesExecuted;
    /// @dev Stored root hashes of L2 -> L1 logs
    mapping(uint256 batchNumber => bytes32 l2LogsRootHash) public l2LogsRootHashes;
    /// @dev Stored the l2 tx hash map from secondary chain to primary chain
    mapping(bytes32 l2TxHash => bytes32 primaryChainL2TxHash) public l2TxHashMap;
    /// @dev The total forward fee payed to validator
    uint256 public totalValidatorForwardFee;
    /// @dev The total forward fee withdrawn by validator
    uint256 public totalValidatorForwardFeeWithdrawn;
    /// @dev A mapping L2 batch number => message number => flag.
    /// @dev The L2 -> L1 log is sent for every withdrawal, so this mapping is serving as
    /// a flag to indicate that the message was already processed.
    /// @dev Used to indicate that eth withdrawal was already processed
    mapping(uint256 l2BatchNumber => mapping(uint256 l2ToL1MessageNumber => bool isFinalized))
        public isEthWithdrawalFinalized;
    /// @dev The forward fee allocator
    address public forwardFeeAllocator;
    /// @dev The range batch root hash of [fromBatchNumber, toBatchNumber]
    /// The key is keccak256(abi.encodePacked(fromBatchNumber, toBatchNumber))
    mapping(bytes32 range => bytes32 rangeBatchRootHash) public rangeBatchRootHashes;
    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;

    /// @notice Gateway init
    event InitGateway(IL2Gateway indexed gateway);
    /// @notice Contract's permit status changed
    event ContractAllowStatusUpdate(address indexed contractAddress, bool isPermit);
    /// @notice Tx gas price changed
    event TxGasPriceUpdate(uint256 oldTxGasPrice, uint256 newTxGasPrice);
    /// @notice Validator's status changed
    event ValidatorStatusUpdate(address indexed validatorAddress, bool isActive);
    /// @notice Fee params for L1->L2 transactions changed
    event NewFeeParams(FeeParams oldFeeParams, FeeParams newFeeParams);
    /// @notice New priority request event. Emitted when a request is placed into the priority queue
    event NewPriorityRequest(uint256 priorityOpId, ForwardL2Request l2Request);
    /// @notice Emitted send sync status to primary chain.
    event SyncL2Requests(uint256 totalSyncedPriorityTxs, bytes32 syncHash, uint256 forwardEthAmount);
    /// @notice Emitted when receive batch root from primary chain.
    event SyncBatchRoot(uint256 batchNumber, bytes32 l2LogsRootHash, uint256 forwardEthAmount);
    /// @notice Emitted when receive range batch root hash from primary chain.
    event SyncRangeBatchRoot(
        uint256 fromBatchNumber,
        uint256 toBatchNumber,
        bytes32 rangeBatchRootHash,
        uint256 forwardEthAmount
    );
    /// @notice Emitted when open range batch root hash.
    event OpenRangeBatchRoot(uint256 fromBatchNumber, uint256 toBatchNumber);
    /// @notice Emitted when receive l2 tx hash from primary chain.
    event SyncL2TxHash(bytes32 l2TxHash, bytes32 primaryChainL2TxHash);
    /// @notice Emitted when validator withdraw forward fee
    event WithdrawForwardFee(address indexed receiver, uint256 amount);
    /// @notice Emitted when the withdrawal is finalized on L1 and funds are released.
    /// @param to The address to which the funds were sent
    /// @param amount The amount of funds that were sent
    event EthWithdrawalFinalized(address indexed to, uint256 amount);
    /// @notice Forward fee allocator changed
    event ForwardFeeAllocatorUpdate(address oldAllocator, address newAllocator);

    /// @notice Check if msg sender is gateway
    modifier onlyGateway() {
        require(msg.sender == address(gateway), "Not gateway");
        _;
    }

    /// @notice Checks if validator is active
    modifier onlyValidator() {
        require(validators[msg.sender], "Not validator"); // validator is not active
        _;
    }

    /// @notice Checks if msg sender is forward fee allocator
    modifier onlyForwardFeeAllocator() {
        require(msg.sender == forwardFeeAllocator, "Not forward fee allocator");
        _;
    }

    constructor() {
        _disableInitializers();
    }

    function initialize() external initializer {
        __Ownable_init_unchained();
        __UUPSUpgradeable_init_unchained();
        __ReentrancyGuard_init_unchained();
        __Pausable_init_unchained();
    }

    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {
        // can only called by owner
    }

    /// @dev Pause the contract, can only be called by the owner
    function pause() external onlyOwner {
        _pause();
    }

    /// @dev Unpause the contract, can only be called by the owner
    function unpause() external onlyOwner {
        _unpause();
    }

    function getGateway() external view returns (IL2Gateway) {
        return gateway;
    }

    function getGovernor() external view returns (address) {
        return owner();
    }

    function getTotalBatchesExecuted() external view returns (uint256) {
        return totalBatchesExecuted;
    }

    function getTotalPriorityTxs() external view returns (uint256) {
        return totalPriorityTxs;
    }

    function isValidator(address _address) external view returns (bool) {
        return validators[_address];
    }

    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot) {
        return l2LogsRootHashes[_batchNumber];
    }

    function getPriorityTxMaxGasLimit() public pure returns (uint256) {
        return 72000000;
    }

    /// @dev Init gateway, can only be called by the owner
    function setGateway(IL2Gateway _gateway) external onlyOwner {
        require(address(gateway) == address(0), "Duplicate init gateway");
        require(address(_gateway) != address(0), "Invalid gateway");
        gateway = _gateway;
        emit InitGateway(_gateway);
    }

    /// @dev Update the permit status of contract, can only be called by the owner
    function setAllowList(address _contractAddress, bool _permitted) external onlyOwner {
        if (allowLists[_contractAddress] != _permitted) {
            allowLists[_contractAddress] = _permitted;
            emit ContractAllowStatusUpdate(_contractAddress, _permitted);
        }
    }

    /// @dev Update the tx gas price
    function setTxGasPrice(uint256 _newTxGasPrice) external onlyOwner {
        uint256 oldTxGasPrice = txGasPrice;
        if (oldTxGasPrice != _newTxGasPrice) {
            txGasPrice = _newTxGasPrice;
            emit TxGasPriceUpdate(oldTxGasPrice, _newTxGasPrice);
        }
    }

    function setValidator(address _validator, bool _active) external onlyGateway {
        if (validators[_validator] != _active) {
            validators[_validator] = _active;
            emit ValidatorStatusUpdate(_validator, _active);
        }
    }

    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Admin.sol#L88
    function changeFeeParams(FeeParams calldata _newFeeParams) external onlyGateway {
        // Double checking that the new fee params are valid, i.e.
        // the maximal pubdata per batch is not less than the maximal pubdata per priority transaction.
        require(_newFeeParams.maxPubdataPerBatch >= _newFeeParams.priorityTxMaxPubdata, "n6");

        FeeParams memory oldFeeParams = feeParams;
        feeParams = _newFeeParams;

        emit NewFeeParams(oldFeeParams, _newFeeParams);
    }

    /// @dev Update the forward fee allocator
    function setForwardFeeAllocator(address _newForwardFeeAllocator) external onlyOwner {
        require(_newForwardFeeAllocator != address(0), "Invalid allocator");
        address oldAllocator = forwardFeeAllocator;
        if (oldAllocator != _newForwardFeeAllocator) {
            forwardFeeAllocator = _newForwardFeeAllocator;
            emit ForwardFeeAllocatorUpdate(oldAllocator, _newForwardFeeAllocator);
        }
    }

    function l2TransactionBaseCost(
        uint256 _gasPrice,
        uint256 _l2GasLimit,
        uint256 _l2GasPerPubdataByteLimit
    ) public view returns (uint256) {
        uint256 l2GasPrice = _deriveL2GasPrice(_gasPrice, _l2GasPerPubdataByteLimit);
        return l2GasPrice * _l2GasLimit;
    }

    function requestL2Transaction(
        address _contractL2,
        uint256 _l2Value,
        bytes calldata _calldata,
        uint256 _l2GasLimit,
        uint256 _l2GasPerPubdataByteLimit,
        bytes[] calldata _factoryDeps,
        address _refundRecipient
    ) external payable nonReentrant whenNotPaused returns (bytes32 canonicalTxHash) {
        // Disable l2 value if eth is not the gas token
        if (!gateway.isEthGasToken()) {
            require(_l2Value == 0, "Not allow l2 value");
        }
        // Change the sender address if it is a smart contract to prevent address collision between L1 and L2.
        // Please note, currently zkSync address derivation is different from Ethereum one, but it may be changed in the future.
        address sender = msg.sender;
        bool isContractCall = false;
        // solhint-disable-next-line avoid-tx-origin
        if (sender != tx.origin) {
            // Check contract call is allowed for safe reasons
            require(allowLists[sender], "Not allow to send L2 request");
            sender = AddressAliasHelper.applyL1ToL2Alias(msg.sender);
            isContractCall = true;
        } else {
            // Temporarily prohibit contract calls from EOA address for safe reasons
            require(_calldata.length == 0, "Not allow to call contract");
        }

        // Enforcing that `_l2GasPerPubdataByteLimit` equals to a certain constant number. This is needed
        // to ensure that users do not get used to using "exotic" numbers for _l2GasPerPubdataByteLimit, e.g. 1-2, etc.
        // VERY IMPORTANT: nobody should rely on this constant to be fixed and every contract should give their users the ability to provide the
        // ability to provide `_l2GasPerPubdataByteLimit` for each independent transaction.
        // CHANGING THIS CONSTANT SHOULD BE A CLIENT-SIDE CHANGE.
        require(_l2GasPerPubdataByteLimit == REQUIRED_L2_GAS_PRICE_PER_PUBDATA, "Invalid l2GasPerPubdataByteLimit");
        require(_factoryDeps.length <= MAX_NEW_FACTORY_DEPS, "Invalid factoryDeps");

        // Checking that the user provided enough ether to pay for the transaction.
        uint256 l2GasPrice = _deriveL2GasPrice(txGasPrice, _l2GasPerPubdataByteLimit);
        uint256 baseCost = l2GasPrice * _l2GasLimit;
        require(msg.value == baseCost + _l2Value, "Invalid msg value"); // The `msg.value` doesn't cover the transaction cost
        totalValidatorForwardFee = totalValidatorForwardFee + baseCost;

        // If the `_refundRecipient` is not provided, we use the `sender` as the recipient.
        address refundRecipient = _refundRecipient == address(0) ? sender : _refundRecipient;
        // If the `_refundRecipient` is a smart contract, we apply the L1 to L2 alias to prevent foot guns.
        if (refundRecipient.code.length > 0) {
            refundRecipient = AddressAliasHelper.applyL1ToL2Alias(refundRecipient);
        }

        // Build l2 request params
        uint256 _totalPriorityTxs = totalPriorityTxs;
        ForwardL2Request memory request = ForwardL2Request(
            gateway.getRemoteGateway(),
            isContractCall,
            sender,
            _totalPriorityTxs,
            _contractL2,
            _l2Value,
            _calldata,
            _l2GasLimit,
            _l2GasPerPubdataByteLimit,
            _factoryDeps,
            refundRecipient
        );
        // Validate l2 transaction
        {
            L2CanonicalTransaction memory transaction = _serializeL2Transaction(request);
            bytes memory transactionEncoding = abi.encode(transaction);
            TransactionValidator.validateL1ToL2Transaction(
                transaction,
                transactionEncoding,
                getPriorityTxMaxGasLimit(),
                feeParams.priorityTxMaxPubdata
            );
        }
        canonicalTxHash = hashForwardL2Request(request);

        // Accumulate sync status
        SecondaryChainSyncStatus memory syncStatus;
        if (_totalPriorityTxs == 0) {
            syncStatus.hash = canonicalTxHash;
            syncStatus.amount = _l2Value;
        } else {
            syncStatus = priorityOpSyncStatus[_totalPriorityTxs - 1];
            syncStatus.hash = keccak256(abi.encodePacked(syncStatus.hash, canonicalTxHash));
            syncStatus.amount = syncStatus.amount + _l2Value;
        }
        priorityOpSyncStatus[_totalPriorityTxs] = syncStatus;
        totalPriorityTxs = _totalPriorityTxs + 1;

        emit NewPriorityRequest(request.txId, request);
    }

    function finalizeEthWithdrawal(
        uint256 _l2BatchNumber,
        uint256 _l2MessageIndex,
        uint16 _l2TxNumberInBatch,
        bytes calldata _message,
        bytes32[] calldata _merkleProof
    ) external nonReentrant {
        require(!isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex], "jj");

        L2Message memory l2ToL1Message = L2Message({
            txNumberInBatch: _l2TxNumberInBatch,
            sender: L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR,
            data: _message
        });

        (address _l1Gateway, uint256 _amount, address _l1WithdrawReceiver) = _parseL2WithdrawalMessage(_message);
        require(_l1Gateway == gateway.getRemoteGateway(), "rg");

        bool proofValid = proveL2MessageInclusion(_l2BatchNumber, _l2MessageIndex, l2ToL1Message, _merkleProof);
        require(proofValid, "pi"); // Failed to verify that withdrawal was actually initialized on L2

        isEthWithdrawalFinalized[_l2BatchNumber][_l2MessageIndex] = true;
        _withdrawFunds(_l1WithdrawReceiver, _amount);

        emit EthWithdrawalFinalized(_l1WithdrawReceiver, _amount);
    }

    function proveL2MessageInclusion(
        uint256 _batchNumber,
        uint256 _index,
        L2Message memory _message,
        bytes32[] calldata _proof
    ) public view returns (bool) {
        return _proveL2LogInclusion(_batchNumber, _index, _L2MessageToLog(_message), _proof);
    }

    function proveL1ToL2TransactionStatus(
        bytes32 _l2TxHash,
        uint256 _l2BatchNumber,
        uint256 _l2MessageIndex,
        uint16 _l2TxNumberInBatch,
        bytes32[] calldata _merkleProof,
        TxStatus _status
    ) public view returns (bool) {
        // Get l2 tx hash on primary chain
        bytes32 primaryChainL2TxHash = l2TxHashMap[_l2TxHash];
        require(primaryChainL2TxHash != bytes32(0), "Invalid l2 tx hash");

        // Bootloader sends an L2 -> L1 log only after processing the L1 -> L2 transaction.
        // Thus, we can verify that the L1 -> L2 transaction was included in the L2 batch with specified status.
        //
        // The semantics of such L2 -> L1 log is always:
        // - sender = L2_BOOTLOADER_ADDRESS
        // - key = hash(L1ToL2Transaction)
        // - value = status of the processing transaction (1 - success & 0 - fail)
        // - isService = true (just a conventional value)
        // - l2ShardId = 0 (means that L1 -> L2 transaction was processed in a rollup shard, other shards are not available yet anyway)
        // - txNumberInBatch = number of transaction in the batch
        L2Log memory l2Log = L2Log({
            l2ShardId: 0,
            isService: true,
            txNumberInBatch: _l2TxNumberInBatch,
            sender: L2_BOOTLOADER_ADDRESS,
            key: primaryChainL2TxHash,
            value: bytes32(uint256(_status))
        });
        return _proveL2LogInclusion(_l2BatchNumber, _l2MessageIndex, l2Log, _merkleProof);
    }

    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable onlyValidator {
        // Check newTotalSyncedPriorityTxs
        require(
            _newTotalSyncedPriorityTxs <= totalPriorityTxs && _newTotalSyncedPriorityTxs > totalSyncedPriorityTxs,
            "Invalid sync point"
        );

        // Forward eth amount is the difference of two accumulate amount
        SecondaryChainSyncStatus memory lastSyncStatus;
        if (totalSyncedPriorityTxs > 0) {
            lastSyncStatus = priorityOpSyncStatus[totalSyncedPriorityTxs - 1];
        }
        SecondaryChainSyncStatus memory currentSyncStatus = priorityOpSyncStatus[_newTotalSyncedPriorityTxs - 1];
        uint256 forwardAmount = currentSyncStatus.amount - lastSyncStatus.amount;

        // Update synced priority txs
        totalSyncedPriorityTxs = _newTotalSyncedPriorityTxs;

        // Send sync status to L1 gateway
        bytes memory callData = abi.encodeCall(
            IZkSync.syncL2Requests,
            (gateway.getRemoteGateway(), _newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount)
        );
        gateway.sendMessage{value: msg.value + forwardAmount}(forwardAmount, callData);

        emit SyncL2Requests(_newTotalSyncedPriorityTxs, currentSyncStatus.hash, forwardAmount);
    }

    function syncBatchRoot(
        uint256 _batchNumber,
        bytes32 _l2LogsRootHash,
        uint256 _forwardEthAmount
    ) external payable onlyGateway {
        if (gateway.isEthGasToken()) {
            require(msg.value == _forwardEthAmount, "Invalid forward amount");
        }
        // Allows repeated sending of the forward amount of the batch
        if (_batchNumber > totalBatchesExecuted) {
            totalBatchesExecuted = _batchNumber;
        }
        l2LogsRootHashes[_batchNumber] = _l2LogsRootHash;
        emit SyncBatchRoot(_batchNumber, _l2LogsRootHash, _forwardEthAmount);
    }

    function syncRangeBatchRoot(
        uint256 _fromBatchNumber,
        uint256 _toBatchNumber,
        bytes32 _rangeBatchRootHash,
        uint256 _forwardEthAmount
    ) external payable onlyGateway {
        require(_toBatchNumber >= _fromBatchNumber, "Invalid range");
        if (gateway.isEthGasToken()) {
            require(msg.value == _forwardEthAmount, "Invalid forward amount");
        }
        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));
        rangeBatchRootHashes[range] = _rangeBatchRootHash;
        emit SyncRangeBatchRoot(_fromBatchNumber, _toBatchNumber, _rangeBatchRootHash, _forwardEthAmount);
    }

    /// @dev Unzip the root hashes in the range
    /// @param _fromBatchNumber The batch number from
    /// @param _toBatchNumber The batch number to
    /// @param _l2LogsRootHashes The l2LogsRootHash list in the range [`_fromBatchNumber`, `_toBatchNumber`]
    function openRangeBatchRootHash(
        uint256 _fromBatchNumber,
        uint256 _toBatchNumber,
        bytes32[] calldata _l2LogsRootHashes
    ) external onlyValidator {
        require(_toBatchNumber >= _fromBatchNumber, "Invalid range");
        bytes32 range = keccak256(abi.encodePacked(_fromBatchNumber, _toBatchNumber));
        bytes32 rangeBatchRootHash = rangeBatchRootHashes[range];
        require(rangeBatchRootHash != bytes32(0), "Range batch root hash not exist");
        uint256 rootHashesLength = _l2LogsRootHashes.length;
        require(rootHashesLength == _toBatchNumber - _fromBatchNumber + 1, "Invalid root hashes length");
        bytes32 _rangeBatchRootHash = _l2LogsRootHashes[0];
        l2LogsRootHashes[_fromBatchNumber] = _rangeBatchRootHash;
        unchecked {
            for (uint256 i = 1; i < rootHashesLength; ++i) {
                bytes32 _l2LogsRootHash = _l2LogsRootHashes[i];
                l2LogsRootHashes[_fromBatchNumber + i] = _l2LogsRootHash;
                _rangeBatchRootHash = Merkle._efficientHash(_rangeBatchRootHash, _l2LogsRootHash);
            }
        }
        require(_rangeBatchRootHash == rangeBatchRootHash, "Incorrect root hash");
        delete rangeBatchRootHashes[range];
        if (_toBatchNumber > totalBatchesExecuted) {
            totalBatchesExecuted = _toBatchNumber;
        }
        emit OpenRangeBatchRoot(_fromBatchNumber, _toBatchNumber);
    }

    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external onlyGateway {
        l2TxHashMap[_l2TxHash] = _primaryChainL2TxHash;
        emit SyncL2TxHash(_l2TxHash, _primaryChainL2TxHash);
    }

    function withdrawForwardFee(address _receiver, uint256 _amount) external nonReentrant onlyForwardFeeAllocator {
        require(_amount > 0, "Invalid amount");
        uint256 newWithdrawnFee = totalValidatorForwardFeeWithdrawn + _amount;
        require(totalValidatorForwardFee >= newWithdrawnFee, "Withdraw exceed");

        // Update withdrawn fee
        totalValidatorForwardFeeWithdrawn = newWithdrawnFee;
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, ) = _receiver.call{value: _amount}("");
        require(success, "Withdraw failed");
        emit WithdrawForwardFee(_receiver, _amount);
    }

    /// @notice Derives the price for L2 gas in ETH to be paid.
    /// @dev https://github.com/matter-labs/era-contracts/blob/e0a33ce73c4decd381446a6eb812b14c2ff69c47/l1-contracts/contracts/zksync/facets/Mailbox.sol#L147
    /// @param _l1GasPrice The gas price on L1.
    /// @param _gasPerPubdata The price for each pubdata byte in L2 gas
    /// @return The price of L2 gas in ETH
    function _deriveL2GasPrice(uint256 _l1GasPrice, uint256 _gasPerPubdata) internal view returns (uint256) {
        FeeParams memory _feeParams = feeParams;

        uint256 pubdataPriceETH;
        if (_feeParams.pubdataPricingMode == PubdataPricingMode.Rollup) {
            pubdataPriceETH = L1_GAS_PER_PUBDATA_BYTE * _l1GasPrice;
        }

        uint256 batchOverheadETH = uint256(_feeParams.batchOverheadL1Gas) * _l1GasPrice;
        uint256 fullPubdataPriceETH = pubdataPriceETH + batchOverheadETH / uint256(_feeParams.maxPubdataPerBatch);

        uint256 l2GasPrice = _feeParams.minimalL2GasPrice + batchOverheadETH / uint256(_feeParams.maxL2GasPerBatch);
        uint256 minL2GasPriceETH = (fullPubdataPriceETH + _gasPerPubdata - 1) / _gasPerPubdata;

        return Math.max(l2GasPrice, minL2GasPriceETH);
    }

    function _serializeL2Transaction(
        ForwardL2Request memory _request
    ) internal pure returns (L2CanonicalTransaction memory transaction) {
        transaction = L2CanonicalTransaction({
            txType: uint256(0),
            from: uint256(0),
            to: uint256(0),
            gasLimit: _request.l2GasLimit, // Used in validate l2 transaction
            gasPerPubdataByteLimit: _request.l2GasPricePerPubdata, // Used in validate l2 transaction
            maxFeePerGas: uint256(0),
            maxPriorityFeePerGas: uint256(0),
            paymaster: uint256(0),
            nonce: uint256(0),
            value: uint256(0),
            reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],
            data: _request.l2CallData, // Length used in validate l2 transaction
            signature: new bytes(0),
            factoryDeps: new uint256[](_request.factoryDeps.length), // Length used in validate l2 transaction
            paymasterInput: new bytes(0),
            reservedDynamic: new bytes(0)
        });
    }

    /// @dev Convert arbitrary-length message to the raw l2 log
    function _L2MessageToLog(L2Message memory _message) internal pure returns (L2Log memory) {
        return
            L2Log({
                l2ShardId: 0,
                isService: true,
                txNumberInBatch: _message.txNumberInBatch,
                sender: L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR,
                key: bytes32(uint256(uint160(_message.sender))),
                value: keccak256(_message.data)
            });
    }

    /// @dev Prove that a specific L2 log was sent in a specific L2 batch number
    function _proveL2LogInclusion(
        uint256 _batchNumber,
        uint256 _index,
        L2Log memory _log,
        bytes32[] calldata _proof
    ) internal view returns (bool) {
        require(_batchNumber <= totalBatchesExecuted, "xx");

        bytes32 hashedLog = keccak256(
            abi.encodePacked(_log.l2ShardId, _log.isService, _log.txNumberInBatch, _log.sender, _log.key, _log.value)
        );
        // Check that hashed log is not the default one,
        // otherwise it means that the value is out of range of sent L2 -> L1 logs
        require(hashedLog != L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH, "tw");

        // It is ok to not check length of `_proof` array, as length
        // of leaf preimage (which is `L2_TO_L1_LOG_SERIALIZE_SIZE`) is not
        // equal to the length of other nodes preimages (which are `2 * 32`)

        bytes32 calculatedRootHash = Merkle.calculateRoot(_proof, _index, hashedLog);
        bytes32 actualRootHash = l2LogsRootHashes[_batchNumber];

        return actualRootHash == calculatedRootHash;
    }

    /// @dev Decode the withdraw message that came from L2
    function _parseL2WithdrawalMessage(
        bytes memory _message
    ) internal pure returns (address l1Gateway, uint256 amount, address l1Receiver) {
        // We check that the message is long enough to read the data.
        // Please note that there are two versions of the message:
        // 1. The message that is sent by `withdraw(address _l1Receiver)`
        // It should be equal to the length of the bytes4 function signature + address l1Receiver + uint256 amount = 4 + 20 + 32 = 56 (bytes).
        // 2. The message that is sent by `withdrawWithMessage(address _l1Receiver, bytes calldata _additionalData)`
        // It should be equal to the length of the following:
        // bytes4 function signature + address l1Gateway + uint256 amount + address l2Sender + bytes _additionalData
        // (where the _additionalData = abi.encode(l1Receiver))
        // = 4 + 20 + 32 + 20 + 32 == 108 (bytes).
        require(_message.length == L2_WITHDRAW_MESSAGE_LENGTH, "pm");

        (uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_message, 0);
        require(bytes4(functionSignature) == this.finalizeEthWithdrawal.selector, "is");

        (l1Gateway, offset) = UnsafeBytes.readAddress(_message, offset);
        (amount, offset) = UnsafeBytes.readUint256(_message, offset);
        // The additional data is l1 receiver address
        (l1Receiver, offset) = UnsafeBytes.readAddress(_message, offset + 32);
    }

    /// @notice Transfer ether from the contract to the receiver
    /// @dev Reverts only if the transfer call failed
    function _withdrawFunds(address _to, uint256 _amount) internal {
        if (gateway.isEthGasToken()) {
            bool callSuccess;
            // Low-level assembly call, to avoid any memory copying (save gas)
            assembly {
                callSuccess := call(gas(), _to, _amount, 0, 0, 0, 0)
            }
            require(callSuccess, "pz");
        } else {
            SafeERC20.safeTransfer(gateway.ethToken(), _to, _amount);
        }
    }

    function hashForwardL2Request(ForwardL2Request memory _request) internal pure returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    FORWARD_REQUEST_TYPE_HASH,
                    _request.gateway,
                    _request.isContractCall,
                    _request.sender,
                    _request.txId,
                    _request.contractAddressL2,
                    _request.l2Value,
                    keccak256(_request.l2CallData),
                    _request.l2GasLimit,
                    _request.l2GasPricePerPubdata,
                    keccak256(abi.encode(_request.factoryDeps)),
                    _request.refundRecipient
                )
            );
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {L2Message} from "../Storage.sol";

/// @dev The enum that represents the transaction execution status
/// @param Failure The transaction execution failed
/// @param Success The transaction execution succeeded
enum TxStatus {
    Failure,
    Success
}

/// @title The interface of the zkSync Mailbox contract that provides interfaces for L1 <-> L2 interaction.
/// @author Matter Labs
/// @custom:security-contact [email protected]
interface IMailbox {
    /// @dev Structure that includes all fields of the L2 transaction
    /// @dev The hash of this structure is the "canonical L2 transaction hash" and can be used as a unique identifier of a tx
    /// @param txType The tx type number, depending on which the L2 transaction can be interpreted differently
    /// @param from The sender's address. `uint256` type for possible address format changes and maintaining backward compatibility
    /// @param to The recipient's address. `uint256` type for possible address format changes and maintaining backward compatibility
    /// @param gasLimit The L2 gas limit for L2 transaction. Analog to the `gasLimit` on an L1 transactions
    /// @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)
    /// @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
    /// @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
    /// @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
    /// @param nonce The nonce of the transaction. For L1->L2 transactions it is the priority operation Id.
    /// @param value The value to pass with the transaction
    /// @param reserved The fixed-length fields for usage in a future extension of transaction formats
    /// @param data The calldata that is transmitted for the transaction call
    /// @param signature An abstract set of bytes that are used for transaction authorization
    /// @param factoryDeps The set of L2 bytecode hashes whose preimages were shown on L1
    /// @param paymasterInput The arbitrary-length data that is used as a calldata to the paymaster pre-call
    /// @param reservedDynamic The arbitrary-length field for usage in a future extension of transaction formats
    struct L2CanonicalTransaction {
        uint256 txType;
        uint256 from;
        uint256 to;
        uint256 gasLimit;
        uint256 gasPerPubdataByteLimit;
        uint256 maxFeePerGas;
        uint256 maxPriorityFeePerGas;
        uint256 paymaster;
        uint256 nonce;
        uint256 value;
        // In the future, we might want to add some
        // new fields to the struct. The `txData` struct
        // is to be passed to account and any changes to its structure
        // would mean a breaking change to these accounts. To prevent this,
        // we should keep some fields as "reserved".
        // It is also recommended that their length is fixed, since
        // it would allow easier proof integration (in case we will need
        // some special circuit for preprocessing transactions).
        uint256[4] reserved;
        bytes data;
        bytes signature;
        uint256[] factoryDeps;
        bytes paymasterInput;
        // Reserved dynamic type for the future use-case. Using it should be avoided,
        // But it is still here, just in case we want to enable some additional functionality.
        bytes reservedDynamic;
    }

    /// @dev Internal structure that contains the parameters for the forwardRequestL2Transaction
    /// @param gateway The secondary chain gateway;
    /// @param isContractCall It's true when the request come from a contract.
    /// @param sender The sender's address.
    /// @param txId The id of the priority transaction.
    /// @param contractAddressL2 The address of the contract on L2 to call.
    /// @param l2Value The msg.value of the L2 transaction.
    /// @param l2CallData The call data of the L2 transaction.
    /// @param l2GasLimit The limit of the L2 gas for the L2 transaction
    /// @param l2GasPrice The price of the L2 gas in Wei to be used for this transaction.
    /// @param l2GasPricePerPubdata The price for a single pubdata byte in L2 gas.
    /// @param refundRecipient The recipient of the refund for the transaction on L2. If the transaction fails, then
    /// this address will receive the `l2Value`.
    struct ForwardL2Request {
        address gateway;
        bool isContractCall;
        address sender;
        uint256 txId;
        address contractAddressL2;
        uint256 l2Value;
        bytes l2CallData;
        uint256 l2GasLimit;
        uint256 l2GasPricePerPubdata;
        bytes[] factoryDeps;
        address refundRecipient;
    }

    /// @notice Prove that a specific arbitrary-length message was sent in a specific L2 batch number
    /// @param _l2BatchNumber The executed L2 batch number in which the message appeared
    /// @param _index The position in the L2 logs Merkle tree of the l2Log that was sent with the message
    /// @param _message Information about the sent message: sender address, the message itself, tx index in the L2 batch where the message was sent
    /// @param _proof Merkle proof for inclusion of L2 log that was sent with the message
    /// @return Whether the proof is valid
    function proveL2MessageInclusion(
        uint256 _l2BatchNumber,
        uint256 _index,
        L2Message calldata _message,
        bytes32[] calldata _proof
    ) external view returns (bool);

    /// @notice Prove that the L1 -> L2 transaction was processed with the specified status.
    /// @param _l2TxHash The L2 canonical transaction hash
    /// @param _l2BatchNumber The L2 batch number where the transaction was processed
    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message
    /// @param _l2TxNumberInBatch The L2 transaction number in the batch, in which the log was sent
    /// @param _merkleProof The Merkle proof of the processing L1 -> L2 transaction
    /// @param _status The execution status of the L1 -> L2 transaction (true - success & 0 - fail)
    /// @return Whether the proof is correct and the transaction was actually executed with provided status
    /// NOTE: It may return `false` for incorrect proof, but it doesn't mean that the L1 -> L2 transaction has an opposite status!
    function proveL1ToL2TransactionStatus(
        bytes32 _l2TxHash,
        uint256 _l2BatchNumber,
        uint256 _l2MessageIndex,
        uint16 _l2TxNumberInBatch,
        bytes32[] calldata _merkleProof,
        TxStatus _status
    ) external view returns (bool);

    /// @notice Request execution of L2 transaction from L1.
    /// @param _contractL2 The L2 receiver address
    /// @param _l2Value `msg.value` of L2 transaction
    /// @param _calldata The input of the L2 transaction
    /// @param _l2GasLimit Maximum amount of L2 gas that transaction can consume during execution on L2
    /// @param _l2GasPerPubdataByteLimit The maximum amount L2 gas that the operator may charge the user for single byte of pubdata.
    /// @param _factoryDeps An array of L2 bytecodes that will be marked as known on L2
    /// @param _refundRecipient The address on L2 that will receive the refund for the transaction.
    /// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`.
    /// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses out of control.
    /// - If `_refundRecipient` is a contract on L1, the refund will be sent to the aliased `_refundRecipient`.
    /// - 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.
    /// - 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.
    /// @dev The address aliasing of L1 contracts as refund recipient on L2 is necessary to guarantee that the funds are controllable,
    /// since address aliasing to the from address for the L2 tx will be applied if the L1 `msg.sender` is a contract.
    /// Without address aliasing for L1 contracts as refund recipients they would not be able to make proper L2 tx requests
    /// through the Mailbox to use or withdraw the funds from L2, and the funds would be lost.
    /// @return canonicalTxHash The hash of the requested L2 transaction. This hash can be used to follow the transaction status
    function requestL2Transaction(
        address _contractL2,
        uint256 _l2Value,
        bytes calldata _calldata,
        uint256 _l2GasLimit,
        uint256 _l2GasPerPubdataByteLimit,
        bytes[] calldata _factoryDeps,
        address _refundRecipient
    ) external payable returns (bytes32 canonicalTxHash);

    /// @notice Finalize the withdrawal and release funds
    /// @param _l2BatchNumber The L2 batch number where the withdrawal was processed
    /// @param _l2MessageIndex The position in the L2 logs Merkle tree of the l2Log that was sent with the message
    /// @param _l2TxNumberInBatch The L2 transaction number in a batch, in which the log was sent
    /// @param _message The L2 withdraw data, stored in an L2 -> L1 message
    /// @param _merkleProof The Merkle proof of the inclusion L2 -> L1 message about withdrawal initialization
    function finalizeEthWithdrawal(
        uint256 _l2BatchNumber,
        uint256 _l2MessageIndex,
        uint16 _l2TxNumberInBatch,
        bytes calldata _message,
        bytes32[] calldata _merkleProof
    ) external;

    /// @notice Estimates the cost in Ether of requesting execution of an L2 transaction from L1
    /// @param _gasPrice expected L1 gas price at which the user requests the transaction execution
    /// @param _l2GasLimit Maximum amount of L2 gas that transaction can consume during execution on L2
    /// @param _l2GasPerPubdataByteLimit The maximum amount of L2 gas that the operator may charge the user for a single byte of pubdata.
    /// @return The estimated ETH spent on L2 gas for the transaction
    function l2TransactionBaseCost(
        uint256 _gasPrice,
        uint256 _l2GasLimit,
        uint256 _l2GasPerPubdataByteLimit
    ) external view returns (uint256);
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @author Matter Labs
 * @custom:security-contact [email protected]
 * @notice The library for unchecked math.
 */
library UncheckedMath {
    function uncheckedInc(uint256 _number) internal pure returns (uint256) {
        unchecked {
            return _number + 1;
        }
    }

    function uncheckedAdd(uint256 _lhs, uint256 _rhs) internal pure returns (uint256) {
        unchecked {
            return _lhs + _rhs;
        }
    }
}

File 5 of 33 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import {Initializable} from "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeTo(address newImplementation) public virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {IL2Gateway} from "../../../../interfaces/IL2Gateway.sol";

/// @title The interface of the Getters Contract that implements functions for getting contract state from outside the blockchain.
/// @author Matter Labs
/// @custom:security-contact [email protected]
interface IGetters {
    /*//////////////////////////////////////////////////////////////
                            CUSTOM GETTERS
    //////////////////////////////////////////////////////////////*/

    /// @return The gateway on local chain
    function getGateway() external view returns (IL2Gateway);

    /// @return The address of the current governor
    function getGovernor() external view returns (address);

    /// @return The total number of batches that were committed & verified & executed
    function getTotalBatchesExecuted() external view returns (uint256);

    /// @return The total number of priority operations that were added to the priority queue, including all processed ones
    function getTotalPriorityTxs() external view returns (uint256);

    /// @return Whether the address has a validator access
    function isValidator(address _address) external view returns (bool);

    /// @return merkleRoot Merkle root of the tree with L2 logs for the selected batch
    function l2LogsRootHash(uint256 _batchNumber) external view returns (bytes32 merkleRoot);

    /// @return The maximum number of L2 gas that a user can request for L1 -> L2 transactions
    function getPriorityTxMaxGasLimit() external view returns (uint256);

    /// @return Whether a withdrawal has been finalized.
    /// @param _l2BatchNumber The L2 batch number within which the withdrawal happened.
    /// @param _l2MessageIndex The index of the L2->L1 message denoting the withdrawal.
    function isEthWithdrawalFinalized(uint256 _l2BatchNumber, uint256 _l2MessageIndex) external view returns (bool);
}

File 9 of 33 : Storage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @dev The log passed from L2
/// @param l2ShardId The shard identifier, 0 - rollup, 1 - porter. All other values are not used but are reserved for
/// the future
/// @param isService A boolean flag that is part of the log along with `key`, `value`, and `sender` address.
/// This field is required formally but does not have any special meaning.
/// @param txNumberInBatch The L2 transaction number in the batch, in which the log was sent
/// @param sender The L2 address which sent the log
/// @param key The 32 bytes of information that was sent in the log
/// @param value The 32 bytes of information that was sent in the log
// Both `key` and `value` are arbitrary 32-bytes selected by the log sender
struct L2Log {
    uint8 l2ShardId;
    bool isService;
    uint16 txNumberInBatch;
    address sender;
    bytes32 key;
    bytes32 value;
}

/// @dev An arbitrary length message passed from L2
/// @notice Under the hood it is `L2Log` sent from the special system L2 contract
/// @param txNumberInBatch The L2 transaction number in the batch, in which the message was sent
/// @param sender The address of the L2 account from which the message was passed
/// @param data An arbitrary length message
struct L2Message {
    uint16 txNumberInBatch;
    address sender;
    bytes data;
}

/// @notice The struct that describes whether users will be charged for pubdata for L1->L2 transactions.
/// @param Rollup The users are charged for pubdata & it is priced based on the gas price on Ethereum.
/// @param Validium The pubdata is considered free with regard to the L1 gas price.
enum PubdataPricingMode {
    Rollup,
    Validium
}

/// @notice The fee params for L1->L2 transactions for the network.
/// @param pubdataPricingMode How the users will charged for pubdata in L1->L2 transactions.
/// @param batchOverheadL1Gas The amount of L1 gas required to process the batch (except for the calldata).
/// @param maxPubdataPerBatch The maximal number of pubdata that can be emitted per batch.
/// @param priorityTxMaxPubdata The maximal amount of pubdata a priority transaction is allowed to publish.
/// It can be slightly less than maxPubdataPerBatch in order to have some margin for the bootloader execution.
/// @param minimalL2GasPrice The minimal L2 gas price to be used by L1->L2 transactions. It should represent
/// the price that a single unit of compute costs.
struct FeeParams {
    PubdataPricingMode pubdataPricingMode;
    uint32 batchOverheadL1Gas;
    uint32 maxPubdataPerBatch;
    uint32 maxL2GasPerBatch;
    uint32 priorityTxMaxPubdata;
    uint64 minimalL2GasPrice;
}

/// @dev The sync status for priority op of secondary chain
/// @param hash The cumulative canonicalTxHash
/// @param amount The cumulative l2 value
struct SecondaryChainSyncStatus {
    bytes32 hash;
    uint256 amount;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {UncheckedMath} from "../../common/libraries/UncheckedMath.sol";

/// @author Matter Labs
/// @custom:security-contact [email protected]
library Merkle {
    using UncheckedMath for uint256;

    /// @dev Calculate Merkle root by the provided Merkle proof.
    /// NOTE: When using this function, check that the _path length is equal to the tree height to prevent shorter/longer paths attack
    /// @param _path Merkle path from the leaf to the root
    /// @param _index Leaf index in the tree
    /// @param _itemHash Hash of leaf content
    /// @return The Merkle root
    function calculateRoot(
        bytes32[] calldata _path,
        uint256 _index,
        bytes32 _itemHash
    ) internal pure returns (bytes32) {
        uint256 pathLength = _path.length;
        require(pathLength > 0, "xc");
        require(pathLength < 256, "bt");
        require(_index < (1 << pathLength), "px");

        bytes32 currentHash = _itemHash;
        for (uint256 i; i < pathLength; i = i.uncheckedInc()) {
            currentHash = (_index % 2 == 0)
                ? _efficientHash(currentHash, _path[i])
                : _efficientHash(_path[i], currentHash);
            _index /= 2;
        }

        return currentHash;
    }

    /// @dev Keccak hash of the concatenation of two 32-byte words
    function _efficientHash(bytes32 _lhs, bytes32 _rhs) internal pure returns (bytes32 result) {
        assembly {
            mstore(0x00, _lhs)
            mstore(0x20, _rhs)
            result := keccak256(0x00, 0x40)
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @author Matter Labs
 * @custom:security-contact [email protected]
 * @dev The library provides a set of functions that help read data from an "abi.encodePacked" byte array.
 * @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.
 *
 * @dev WARNING!
 * 1) Functions don't check the length of the bytes array, so it can go out of bounds.
 * The user of the library must check for bytes length before using any functions from the library!
 *
 * 2) Read variables are not cleaned up - https://docs.soliditylang.org/en/v0.8.16/internals/variable_cleanup.html.
 * Using data in inline assembly can lead to unexpected behavior!
 */
library UnsafeBytes {
    function readUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32 result, uint256 offset) {
        assembly {
            offset := add(_start, 4)
            result := mload(add(_bytes, offset))
        }
    }

    function readAddress(bytes memory _bytes, uint256 _start) internal pure returns (address result, uint256 offset) {
        assembly {
            offset := add(_start, 20)
            result := mload(add(_bytes, offset))
        }
    }

    function readUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256 result, uint256 offset) {
        assembly {
            offset := add(_start, 32)
            result := mload(add(_bytes, offset))
        }
    }

    function readBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32 result, uint256 offset) {
        assembly {
            offset := add(_start, 32)
            result := mload(add(_bytes, offset))
        }
    }

    // Original source code: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol#L228
    // Get slice from bytes arrays
    // Returns the newly created 'bytes memory'
    // NOTE: theoretically possible overflow of (_start + _length)
    function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {
        require(_bytes.length >= (_start + _length), "Z"); // bytes length is less then start byte + length bytes

        bytes memory tempBytes = new bytes(_length);

        if (_length != 0) {
            assembly {
                let slice_curr := add(tempBytes, 0x20)
                let slice_end := add(slice_curr, _length)

                for {
                    let array_current := add(_bytes, add(_start, 0x20))
                } lt(slice_curr, slice_end) {
                    slice_curr := add(slice_curr, 0x20)
                    array_current := add(array_current, 0x20)
                } {
                    mstore(slice_curr, mload(array_current))
                }
            }
        }

        return tempBytes;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 15 of 33 : Config.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @dev `keccak256("")`
bytes32 constant EMPTY_STRING_KECCAK = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

/// @dev Bytes in raw L2 log
/// @dev Equal to the bytes size of the tuple - (uint8 ShardId, bool isService, uint16 txNumberInBatch, address sender,
/// bytes32 key, bytes32 value)
uint256 constant L2_TO_L1_LOG_SERIALIZE_SIZE = 88;

/// @dev The maximum length of the bytes array with L2 -> L1 logs
uint256 constant MAX_L2_TO_L1_LOGS_COMMITMENT_BYTES = 4 + L2_TO_L1_LOG_SERIALIZE_SIZE * 512;

/// @dev The value of default leaf hash for L2 -> L1 logs Merkle tree
/// @dev An incomplete fixed-size tree is filled with this value to be a full binary tree
/// @dev Actually equal to the `keccak256(new bytes(L2_TO_L1_LOG_SERIALIZE_SIZE))`
bytes32 constant L2_L1_LOGS_TREE_DEFAULT_LEAF_HASH = 0x72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba;

// TODO: change constant to the real root hash of empty Merkle tree (SMA-184)
bytes32 constant DEFAULT_L2_LOGS_TREE_ROOT_HASH = bytes32(0);

/// @dev Denotes the type of the zkSync transaction that came from L1.
uint256 constant PRIORITY_OPERATION_L2_TX_TYPE = 255;

/// @dev Denotes the type of the zkSync transaction that is used for system upgrades.
uint256 constant SYSTEM_UPGRADE_L2_TX_TYPE = 254;

/// @dev The maximal allowed difference between protocol versions in an upgrade. The 100 gap is needed
/// in case a protocol version has been tested on testnet, but then not launched on mainnet, e.g.
/// due to a bug found.
uint256 constant MAX_ALLOWED_PROTOCOL_VERSION_DELTA = 100;

/// @dev The amount of time in seconds the validator has to process the priority transaction
/// NOTE: The constant is set to zero for the Alpha release period
uint256 constant PRIORITY_EXPIRATION = 0 days;

/// @dev Timestamp - seconds since unix epoch.
uint256 constant COMMIT_TIMESTAMP_NOT_OLDER = 3 days;

/// @dev Maximum available error between real commit batch timestamp and analog used in the verifier (in seconds)
/// @dev Must be used cause miner's `block.timestamp` value can differ on some small value (as we know - 12 seconds)
uint256 constant COMMIT_TIMESTAMP_APPROXIMATION_DELTA = 1 hours;

/// @dev Shift to apply to verify public input before verifying.
uint256 constant PUBLIC_INPUT_SHIFT = 32;

/// @dev The maximum number of L2 gas that a user can request for an L2 transaction
uint256 constant MAX_GAS_PER_TRANSACTION = 80000000;

/// @dev Even though the price for 1 byte of pubdata is 16 L1 gas, we have a slightly increased
/// value.
uint256 constant L1_GAS_PER_PUBDATA_BYTE = 17;

/// @dev The intrinsic cost of the L1->l2 transaction in computational L2 gas
uint256 constant L1_TX_INTRINSIC_L2_GAS = 167157;

/// @dev The intrinsic cost of the L1->l2 transaction in pubdata
uint256 constant L1_TX_INTRINSIC_PUBDATA = 88;

/// @dev The minimal base price for L1 transaction
uint256 constant L1_TX_MIN_L2_GAS_BASE = 173484;

/// @dev The number of L2 gas the transaction starts costing more with each 544 bytes of encoding
uint256 constant L1_TX_DELTA_544_ENCODING_BYTES = 1656;

/// @dev The number of L2 gas an L1->L2 transaction gains with each new factory dependency
uint256 constant L1_TX_DELTA_FACTORY_DEPS_L2_GAS = 2473;

/// @dev The number of L2 gas an L1->L2 transaction gains with each new factory dependency
uint256 constant L1_TX_DELTA_FACTORY_DEPS_PUBDATA = 64;

/// @dev The number of pubdata an L1->L2 transaction requires with each new factory dependency
uint256 constant MAX_NEW_FACTORY_DEPS = 32;

/// @dev The L2 gasPricePerPubdata required to be used in bridges.
uint256 constant REQUIRED_L2_GAS_PRICE_PER_PUBDATA = 800;

/// @dev The mask which should be applied to the packed batch and L2 block timestamp in order
/// to obtain the L2 block timestamp. Applying this mask is equivalent to calculating modulo 2**128
uint256 constant PACKED_L2_BLOCK_TIMESTAMP_MASK = 0xffffffffffffffffffffffffffffffff;

/// @dev The overhead for a transaction slot in L2 gas.
/// It is roughly equal to 80kk/MAX_TRANSACTIONS_IN_BATCH, i.e. how many gas would an L1->L2 transaction
/// need to pay to compensate for the batch being closed.
/// @dev It is expected that the L1 contracts will enforce that the L2 gas price will be high enough to compensate
/// the operator in case the batch is closed because of tx slots filling up.
uint256 constant TX_SLOT_OVERHEAD_L2_GAS = 10000;

/// @dev The overhead for each byte of the bootloader memory that the encoding of the transaction.
/// It is roughly equal to 80kk/BOOTLOADER_MEMORY_FOR_TXS, i.e. how many gas would an L1->L2 transaction
/// need to pay to compensate for the batch being closed.
/// @dev It is expected that the L1 contracts will enforce that the L2 gas price will be high enough to compensate
/// the operator in case the batch is closed because of the memory for transactions being filled up.
uint256 constant MEMORY_OVERHEAD_GAS = 10;

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {FeeParams} from "../Storage.sol";
import {IL2Gateway} from "../../../../interfaces/IL2Gateway.sol";

/// @title The interface of the Admin Contract that controls access rights for contract management.
/// @author Matter Labs
/// @custom:security-contact [email protected]
interface IAdmin {
    /// @notice Init gateway
    /// @param _gateway The gateway on local chain
    function setGateway(IL2Gateway _gateway) external;

    /// @notice Change validator status (active or not active)
    /// @param _validator Validator address
    /// @param _active Active flag
    function setValidator(address _validator, bool _active) external;

    /// @notice Change the fee params for L1->L2 transactions
    /// @param _newFeeParams The new fee params
    function changeFeeParams(FeeParams calldata _newFeeParams) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {IMailbox} from "../interfaces/IMailbox.sol";
import {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";

/// @title zkSync Library for validating L1 -> L2 transactions
/// @author Matter Labs
/// @custom:security-contact [email protected]
library TransactionValidator {
    /// @dev Used to validate key properties of an L1->L2 transaction
    /// @param _transaction The transaction to validate
    /// @param _encoded The abi encoded bytes of the transaction
    /// @param _priorityTxMaxGasLimit The max gas limit, generally provided from Storage.sol
    /// @param _priorityTxMaxPubdata The maximal amount of pubdata that a single L1->L2 transaction can emit
    function validateL1ToL2Transaction(
        IMailbox.L2CanonicalTransaction memory _transaction,
        bytes memory _encoded,
        uint256 _priorityTxMaxGasLimit,
        uint256 _priorityTxMaxPubdata
    ) internal pure {
        uint256 l2GasForTxBody = getTransactionBodyGasLimit(_transaction.gasLimit, _encoded.length);

        // Ensuring that the transaction is provable
        require(l2GasForTxBody <= _priorityTxMaxGasLimit, "ui");
        // Ensuring that the transaction cannot output more pubdata than is processable
        require(l2GasForTxBody / _transaction.gasPerPubdataByteLimit <= _priorityTxMaxPubdata, "uk");

        // Ensuring that the transaction covers the minimal costs for its processing:
        // hashing its content, publishing the factory dependencies, etc.
        require(
            getMinimalPriorityTransactionGasLimit(
                _encoded.length,
                _transaction.factoryDeps.length,
                _transaction.gasPerPubdataByteLimit
            ) <= l2GasForTxBody,
            "up"
        );
    }

    /// @dev Used to validate upgrade transactions
    /// @param _transaction The transaction to validate
    function validateUpgradeTransaction(IMailbox.L2CanonicalTransaction memory _transaction) internal pure {
        // Restrict from to be within system contract range (0...2^16 - 1)
        require(_transaction.from <= type(uint16).max, "ua");
        require(_transaction.to <= type(uint160).max, "ub");
        require(_transaction.paymaster == 0, "uc");
        require(_transaction.value == 0, "ud");
        require(_transaction.maxFeePerGas == 0, "uq");
        require(_transaction.maxPriorityFeePerGas == 0, "ux");
        require(_transaction.reserved[0] == 0, "ue");
        require(_transaction.reserved[1] <= type(uint160).max, "uf");
        require(_transaction.reserved[2] == 0, "ug");
        require(_transaction.reserved[3] == 0, "uo");
        require(_transaction.signature.length == 0, "uh");
        require(_transaction.paymasterInput.length == 0, "ul");
        require(_transaction.reservedDynamic.length == 0, "um");
    }

    /// @dev Calculates the approximate minimum gas limit required for executing a priority transaction.
    /// @param _encodingLength The length of the priority transaction encoding in bytes.
    /// @param _numberOfFactoryDependencies The number of new factory dependencies that will be added.
    /// @param _l2GasPricePerPubdata The L2 gas price for publishing the priority transaction on L2.
    /// @return The minimum gas limit required to execute the priority transaction.
    /// Note: The calculation includes the main cost of the priority transaction, however, in reality, the operator can spend a little more gas on overheads.
    function getMinimalPriorityTransactionGasLimit(
        uint256 _encodingLength,
        uint256 _numberOfFactoryDependencies,
        uint256 _l2GasPricePerPubdata
    ) internal pure returns (uint256) {
        uint256 costForComputation;
        {
            // Adding the intrinsic cost for the transaction, i.e. auxiliary prices which cannot be easily accounted for
            costForComputation = L1_TX_INTRINSIC_L2_GAS;

            // Taking into account the hashing costs that depend on the length of the transaction
            // Note that L1_TX_DELTA_544_ENCODING_BYTES is the delta in the price for every 544 bytes of
            // the transaction's encoding. It is taken as LCM between 136 and 32 (the length for each keccak256 round
            // and the size of each new encoding word).
            costForComputation += Math.ceilDiv(_encodingLength * L1_TX_DELTA_544_ENCODING_BYTES, 544);

            // Taking into the account the additional costs of providing new factory dependencies
            costForComputation += _numberOfFactoryDependencies * L1_TX_DELTA_FACTORY_DEPS_L2_GAS;

            // There is a minimal amount of computational L2 gas that the transaction should cover
            costForComputation = Math.max(costForComputation, L1_TX_MIN_L2_GAS_BASE);
        }

        uint256 costForPubdata = 0;
        {
            // Adding the intrinsic cost for the transaction, i.e. auxiliary prices which cannot be easily accounted for
            costForPubdata = L1_TX_INTRINSIC_PUBDATA * _l2GasPricePerPubdata;

            // Taking into the account the additional costs of providing new factory dependencies
            costForPubdata += _numberOfFactoryDependencies * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * _l2GasPricePerPubdata;
        }

        return costForComputation + costForPubdata;
    }

    /// @notice Based on the full L2 gas limit (that includes the batch overhead) and other
    /// properties of the transaction, returns the l2GasLimit for the body of the transaction (the actual execution).
    /// @param _totalGasLimit The L2 gas limit that includes both the overhead for processing the batch
    /// and the L2 gas needed to process the transaction itself (i.e. the actual l2GasLimit that will be used for the transaction).
    /// @param _encodingLength The length of the ABI-encoding of the transaction.
    function getTransactionBodyGasLimit(
        uint256 _totalGasLimit,
        uint256 _encodingLength
    ) internal pure returns (uint256 txBodyGasLimit) {
        uint256 overhead = getOverheadForTransaction(_encodingLength);

        require(_totalGasLimit >= overhead, "my"); // provided gas limit doesn't cover transaction overhead
        unchecked {
            // We enforce the fact that `_totalGasLimit >= overhead` explicitly above.
            txBodyGasLimit = _totalGasLimit - overhead;
        }
    }

    /// @notice Based on the total L2 gas limit and several other parameters of the transaction
    /// returns the part of the L2 gas that will be spent on the batch's overhead.
    /// @dev The details of how this function works can be checked in the documentation
    /// of the fee model of zkSync. The appropriate comments are also present
    /// in the Rust implementation description of function `get_maximal_allowed_overhead`.
    /// @param _encodingLength The length of the binary encoding of the transaction in bytes
    function getOverheadForTransaction(
        uint256 _encodingLength
    ) internal pure returns (uint256 batchOverheadForTransaction) {
        // The overhead from taking up the transaction's slot
        batchOverheadForTransaction = TX_SLOT_OVERHEAD_L2_GAS;

        // The overhead for occupying the bootloader memory can be derived from encoded_len
        uint256 overheadForLength = MEMORY_OVERHEAD_GAS * _encodingLength;
        batchOverheadForTransaction = Math.max(batchOverheadForTransaction, overheadForLength);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.8.0;

interface IZkSync {
    /// @notice Update secondary chain status
    /// @param _gateway The secondary chain gateway
    /// @param _active Active flag
    function setSecondaryChainGateway(address _gateway, bool _active) external;

    /// @notice Receive sync status from secondary chain
    /// @param _secondaryChainGateway The secondary chain gateway address
    /// @param _newTotalSyncedPriorityTxs New sync point
    /// @param _syncHash New sync hash
    /// @param _forwardEthAmount The difference eth amount between two sync points
    function syncL2Requests(
        address _secondaryChainGateway,
        uint256 _newTotalSyncedPriorityTxs,
        bytes32 _syncHash,
        uint256 _forwardEthAmount
    ) external payable;
}

File 23 of 33 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.0;

import {IGateway} from "./IGateway.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IL2Gateway is IGateway {
    /// @notice Emit when sending a message
    event L2GatewayMessageSent(uint256 value, bytes callData);

    /// @notice Send message to remote gateway
    /// @param _value The msg value
    /// @param _callData The call data
    function sendMessage(uint256 _value, bytes calldata _callData) external payable;

    function isEthGasToken() external view returns (bool);

    function ethToken() external view returns (IERC20);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 27 of 33 : L2ContractAddresses.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @dev The address of the L2 deployer system contract.
address constant L2_DEPLOYER_SYSTEM_CONTRACT_ADDR = address(0x8006);

/// @dev The special reserved L2 address. It is located in the system contracts space but doesn't have deployed
/// bytecode.
/// @dev The L2 deployer system contract allows changing bytecodes on any address if the `msg.sender` is this address.
/// @dev So, whenever the governor wants to redeploy system contracts, it just initiates the L1 upgrade call deployer
/// system contract
/// via the L1 -> L2 transaction with `sender == L2_FORCE_DEPLOYER_ADDR`. For more details see the
/// `diamond-initializers` contracts.
address constant L2_FORCE_DEPLOYER_ADDR = address(0x8007);

/// @dev The address of the special smart contract that can send arbitrary length message as an L2 log
address constant L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR = address(0x8008);

/// @dev The formal address of the initial program of the system: the bootloader
address constant L2_BOOTLOADER_ADDRESS = address(0x8001);

/// @dev The address of the eth token system contract
address constant L2_ETH_TOKEN_SYSTEM_CONTRACT_ADDR = address(0x800a);

/// @dev The address of the known code storage system contract
address constant L2_KNOWN_CODE_STORAGE_SYSTEM_CONTRACT_ADDR = address(0x8004);

/// @dev The address of the context system contract
address constant L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT_ADDR = address(0x800b);

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.0;

interface IGateway {
    /// @return Remote gateway
    function getRemoteGateway() external view returns (address);
}

// SPDX-License-Identifier: Apache-2.0

/*
 * Copyright 2019-2021, Offchain Labs, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

pragma solidity ^0.8.0;

library AddressAliasHelper {
    uint160 internal constant OFFSET = uint160(0x1111000000000000000000000000000000001111);

    /// @notice Utility function converts the address that submitted a tx
    /// to the inbox on L1 to the msg.sender viewed on L2
    /// @param l1Address the address in the L1 that triggered the tx to L2
    /// @return l2Address L2 address as viewed in msg.sender
    function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
        unchecked {
            l2Address = address(uint160(l1Address) + OFFSET);
        }
    }

    /// @notice Utility function that converts the msg.sender viewed on L2 to the
    /// address that submitted a tx to the inbox on L1
    /// @param l2Address L2 address as viewed in msg.sender
    /// @return l1Address the address in the L1 that triggered the tx to L2
    function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {
        unchecked {
            l1Address = address(uint160(l2Address) - OFFSET);
        }
    }
}

// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.8.0;

/// @title ZkLink interface contract
/// @author zk.link
interface IZkLink {
    /// @notice Send l2 requests sync status to primary chain
    /// @param _newTotalSyncedPriorityTxs New sync point
    function syncL2Requests(uint256 _newTotalSyncedPriorityTxs) external payable;

    /// @notice Receive batch root from primary chain
    /// @param _batchNumber The batch number
    /// @param _l2LogsRootHash The L2 to L1 log root hash
    /// @param _forwardEthAmount The forward eth amount
    function syncBatchRoot(uint256 _batchNumber, bytes32 _l2LogsRootHash, uint256 _forwardEthAmount) external payable;

    /// @notice Receive range batch root hash from primary chain
    /// @param _fromBatchNumber The batch number from
    /// @param _toBatchNumber The batch number to
    /// @param _rangeBatchRootHash The accumulation hash of l2LogsRootHash in the range [`_fromBatchNumber`, `_toBatchNumber`]
    /// @param _forwardEthAmount The forward eth amount
    function syncRangeBatchRoot(
        uint256 _fromBatchNumber,
        uint256 _toBatchNumber,
        bytes32 _rangeBatchRootHash,
        uint256 _forwardEthAmount
    ) external payable;

    /// @notice Receive l2 tx hash from primary chain
    /// @param _l2TxHash The l2 tx hash on local chain
    /// @param _primaryChainL2TxHash The l2 tx hash on primary chain
    function syncL2TxHash(bytes32 _l2TxHash, bytes32 _primaryChainL2TxHash) external;
}

File 32 of 33 : IERC1967Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 *
 * _Available since v4.8.3._
 */
interface IERC1967Upgradeable {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

Settings
{
  "libraries": {},
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "viaIR": true
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"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":[{"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"}]

60a08060405234620000e157306080526000549060ff8260081c166200008f575060ff8082160362000053575b60405161419a9081620000e7823960805181818161067601528181610b3e0152610c9b0152f35b60ff90811916176000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160ff8152a1386200002c565b62461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b600080fdfe6080604052600436101561001257600080fd5b60003560e01c8062e969a814610328578063042901c7146103235780630ec6b0b71461031e578063116191b6146103005780631dd26496146103195780632425b3a4146103145780633659cfe61461030f57806336e2e3f31461030a5780633f4ba83a1461030557806342bf3cc1146103005780634623c91d146102fb5780634ecf53e9146102f65780634f1ef286146102f15780634fc07d75146102a657806351ef251b1461029257806352d1902d146102ec578063534ca054146102e75780635a425fcd146102e25780635a9f55b0146102dd5780635c975abb146102d85780635e78d327146102d3578063637c9d9d146102ce57806363b434941461028357806364bf8d66146102c95780636c0960f9146102c4578063715018a6146102bf5780637666f125146102ba5780638129fc1c146102b557806383864ac4146102975780638456cb59146102b05780638aa50991146102ab5780638da5cb5b146102a657806390646b4a146102a15780639242164f1461029c5780639cd939e414610297578063a1954fc514610292578063af32a0a71461028d578063b473318e14610288578063b8c2f66f14610283578063ba745e531461027e578063bc5455d014610279578063bd7c541214610274578063be3bc8ea1461026f578063ca98ef4f1461026a578063cfe6128214610265578063e0a1bf7214610260578063e4948f431461025b578063eb67241914610256578063f2fde38b14610251578063fa52c7d81461024c5763facd743b1461024c57600080fd5b6122f2565b612261565b611e4b565b611d96565b611d29565b611bef565b611bd0565b6119c5565b611985565b61191a565b6118fb565b6110b6565b6118c7565b6118a8565b610c69565b6115a9565b61183a565b611749565b610c40565b611630565b6115d6565b6114c1565b611445565b6113e4565b6111ba565b6110d5565b611089565b610f75565b610f52565b610f25565b610d6c565b610d4d565b610c88565b610afd565b610929565b610898565b610501565b6107d2565b61079c565b61064f565b610566565b61052b565b6104e2565b6103e3565b61033d565b600091031261033857565b600080fd5b346103385760003660031901126103385760206040517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c8152f35b6064359061ffff8216820361033857565b6044359061ffff8216820361033857565b359061ffff8216820361033857565b9181601f84011215610338578235916001600160401b038311610338576020808501948460051b01011161033857565b6002111561033857565b346103385760c0366003190112610338576103fc610378565b6084356001600160401b0381116103385761041b9036906004016103a9565b60a4359291610429846103d9565b6004356000526101376020526040600020549283156104a85784610492946104536104a49761181a565b61047561045e610a27565b60008152600160208201529361ffff166040850152565b6180016060840152608083015260a0820152604435602435613907565b60405190151581529081906020820190565b0390f35b60405162461bcd60e51b8152602060048201526012602482015271092dcecc2d8d2c840d86440e8f040d0c2e6d60731b6044820152606490fd5b3461033857600036600319011261033857602060405163044aa2008152f35b346103385760003660031901126103385761012d546040516001600160a01b039091168152602090f35b346103385760003660031901126103385761013b546040516001600160a01b039091168152602090f35b6001600160a01b0381160361033857565b346103385760203660031901126103385760043561058381610555565b61058b612335565b6001600160a01b039080821680156106165761013b546001600160a01b0316928316036105b457005b61013b80546001600160a01b0319166001600160a01b0383161790557f98ac3b973026c0d730e72f023f161bebb4ba504d9b1c6b83d849d3cbaf7f51f491604080516001600160a01b039283168152929091166020830152819081015b0390a1005b60405162461bcd60e51b815260206004820152601160248201527024b73b30b634b21030b63637b1b0ba37b960791b6044820152606490fd5b346103385760203660031901126103385760043561066c81610555565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811691906106a5308414156123d6565b6106c2600080516020614145833981519152938285541614612437565b6106ca612335565b6106d2612498565b906106fe7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1690565b1561071157505061070f9150612588565b005b6020600491604094939451928380926352d1902d60e01b825286165afa6000918161076c575b506107595760405162461bcd60e51b81528061075560048201612539565b0390fd5b61070f9361076791146124db565b612618565b61078e91925060203d8111610795575b6107868183610a06565b8101906124c0565b9038610737565b503d61077c565b34610338576020366003190112610338576004356000526101346020526040806000206001815491015482519182526020820152f35b34610338576000366003190112610338576107eb612335565b60fb5460ff81161561082a5760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b8015150361033857565b60409060031901126103385760043561088881610555565b9060243561089581610866565b90565b34610338576108a636610870565b61012d5490916001600160a01b03916108c290831633146129bf565b16908160005261012e60205260406000209060ff82541681151580911515036108e757005b6109206020927f065b77b53864e46fda3d8986acb51696223d6dde7ced42441eb150bae6d48136949060ff801983541691151516179055565b604051908152a2005b346103385760203660031901126103385760043561094681610555565b60018060a01b031660005261012f602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161099557604052565b61096c565b606081019081106001600160401b0382111761099557604052565b60c081019081106001600160401b0382111761099557604052565b604081019081106001600160401b0382111761099557604052565b608081019081106001600160401b0382111761099557604052565b90601f801991011681019081106001600160401b0382111761099557604052565b60405190610a34826109b5565b565b60405190610a348261099a565b6040519061016082018281106001600160401b0382111761099557604052565b6040519061020082018281106001600160401b0382111761099557604052565b60405190610a34826109eb565b6001600160401b03811161099557601f01601f191660200190565b929192610ab782610a90565b91610ac56040519384610a06565b829481845281830111610338578281602093846000960137010152565b9080601f830112156103385781602061089593359101610aab565b604036600319011261033857600435610b1581610555565b6024356001600160401b03811161033857610b34903690600401610ae2565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116929190610b6e308514156123d6565b610b8b600080516020614145833981519152948286541614612437565b610b93612335565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610bc957505061070f9150612588565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610c20575b50610c0d5760405162461bcd60e51b81528061075560048201612539565b61070f93610c1b91146124db565b6126d4565b610c3991925060203d8111610795576107868183610a06565b9038610bef565b34610338576000366003190112610338576033546040516001600160a01b039091168152602090f35b3461033857600036600319011261033857602061013254604051908152f35b34610338576000366003190112610338577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610ce2576040516000805160206141458339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b3461033857600036600319011261033857602061013054604051908152f35b34610338576060366003190112610338576004356024356044356001600160401b03811161033857610da29036906004016103a9565b9290923360005261012e602052610dc060ff604060002054166132fc565b610dcc828410156133d5565b6040805160208101848152918101859052610df481606081015b03601f198101835282610a06565b51902093610e0d8560005261013c602052604060002090565b5491610e1a831515613411565b610e36610e2f610e2a86886130c2565b612e39565b821461345d565b610e4081836134a9565b359182610e5886600052610136602052604060002090565b5560019081925b808410610edf577fddf6b2cf5bdb04a03cb3f7663b72571336626b1e586a3a047942e4860cf7e12b88886000610eab8d610e9a8c8c146134d8565b60005261013c602052604060002090565b55610135548211610ed0575b6040805191825260208201929092529081908101610611565b610eda8261013555565b610eb7565b9091610f1b8495610ef2839685876134c8565b359081610f0c898c01600052610136602052604060002090565b55600052602052604060002090565b9401929190610e5f565b34610338576020366003190112610338576004356000526101376020526020604060002054604051908152f35b3461033857600036600319011261033857602060ff60fb54166040519015158152f35b60603660031901126103385761012d54604435906024359060048035916020906001600160a01b0316610fa93382146129bf565b6040516314aa259d60e31b815292839182905afa938415611084577fab53214e3a56f049923c5f5532ea4657bba51b870850593c4dc0eceb3b61feed9461061192600091611056575b50611046575b610135548311611037575b8361101984600052610136602052604060002090565b55604051938493846040919493926060820195825260208201520152565b6110418361013555565b611003565b611051813414613390565b610ff8565b611077915060203d811161107d575b61106f8183610a06565b810190612cbe565b38610ff2565b503d611065565b6124cf565b346103385760203660031901126103385760043560005261013c6020526020604060002054604051908152f35b3461033857600036600319011261033857602061013554604051908152f35b346103385760c0366003190112610338576110fc60018060a01b0361012d541633146129bf565b604435611108816129f9565b608435611114816129f9565b63ffffffff809116911610611163577fc8b245ac8b138b17b6b1dbbbb8860adc66b373afa000d99f3cdc775d8ae0bbed61061161114f612a07565b611157612a88565b60405191829182612b82565b60405162461bcd60e51b8152602060048201526002602482015261371b60f11b6044820152606490fd5b9181601f84011215610338578235916001600160401b038311610338576020838186019501011161033857565b346103385760a0366003190112610338576024356004356111d9610389565b916001600160401b0391606435838111610338576111fb90369060040161118d565b929091608435948511610338576112a261129d61121d600497369089016103a9565b959096611228613213565b6112696112646112606112598961124a8a60005261013a602052604060002090565b90600052602052604060002090565b5460ff1690565b1590565b613269565b61127e611274610a36565b61ffff909b168b52565b61800a60208b0152611291368284610aab565b60408b01523691610aab565b613a44565b949195909760206112ca6112be61012d5460018060a01b031690565b6001600160a01b031690565b60405163388e611f60e11b8152998a9182905afa968715611084577f26464d64ddb13f6d187de632d165bd1065382ec0b66c25c648957116e7bc25c89860009861138e575b5061134b61136e969461124a94611344611361989561133f6113509660018060a01b039e8f80911691161461329a565b613854565b8786613907565b6132cb565b60005261013a602052604060002090565b805460ff19166001179055565b6113788482613b34565b6040519384521691602090a261070f600160c955565b61135091985061136e969461124a94611344611361989561133f6113cb61134b9660203d81116113dd575b6113c38183610a06565b810190612ea2565b9d96505095985050945094965061130f565b503d6113b9565b3461033857600080600319360112611442576113fe612335565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346103385761145336610870565b9061145c612335565b60018060a01b0316908160005261012f60205260406000209060ff825416811515809115150361148857005b6109206020927f1f8e549bdb5108ba50ebcc80bb64a20ea98bfbd9378a87380d29f3c87cdcbb2c949060ff801983541691151516179055565b34610338576000806003193601126114425780546114f660ff8260081c16158092819361159b575b811561157b575b5061282c565b80611509600160ff196000541617600055565b611562575b61151661288f565b61151d5780f35b61152d61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081015b0390a180f35b61157661010061ff00196000541617600055565b61150e565b303b1591508161158d575b50386114f0565b6001915060ff161438611586565b600160ff82161091506114e9565b34610338576020366003190112610338576004356000526101366020526020604060002054604051908152f35b34610338576000366003190112610338576115ef612335565b6115f761293d565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b608036600319011261033857600435602435604435916004606435602060018060a01b0361012d54166116648133146129bf565b611670858710156133d5565b6040516314aa259d60e31b815293849182905afa948515611084577f427754a95a2d34153366ec8bcea3939ce044aaf5c185a86149c9f6d80c4402b9956106119360009161172b575b5061171b575b604080516020810186815291810187905282916116f7916116e38160608101610de6565b51902060005261013c602052604060002090565b55604051948594859094939260609260808301968352602083015260408201520152565b611726823414613390565b6116bf565b611743915060203d811161107d5761106f8183610a06565b386116b9565b346103385760203660031901126103385760043561176681610555565b61176e612335565b61012d546001600160a01b039081166117dc576117b590821691611793831515612981565b61012d80546001600160a01b0319166001600160a01b03909216919091179055565b7f860df2b5ed762095deab38be8b5aa5acfbfa8d4d209e083fa00246d31b715e29600080a2005b60405162461bcd60e51b81526020600482015260166024820152754475706c696361746520696e6974206761746577617960501b6044820152606490fd5b6002111561182457565b634e487b7160e01b600052602160045260246000fd5b346103385760003660031901126103385760c0610131546001600160401b0360ff8216916040519261186b8161181a565b835263ffffffff808260081c166020850152808260281c166040850152808260481c1660608501528160681c16608084015260881c1660a0820152f35b3461033857600036600319011261033857602061013854604051908152f35b346103385760603660031901126103385760206118f36024356118ee6044356004356135b6565b612cab565b604051908152f35b3461033857600036600319011261033857602061013354604051908152f35b3461033857602036600319011261033857600435611936612335565b61013090815481810361194557005b817f208ba37ba4e5fc3f236a9c289aa28898330c1f2ec9102d54821a1ffb59e8f1d793556106116040519283928360209093929193604081019481520152565b346103385760403660031901126103385760043560005261013a6020526040600020602435600052602052602060ff604060002054166040519015158152f35b602080600319360112610338576004359060009133835261012e82526119f160ff6040852054166132fc565b6101325481111580611bc4575b611a0790613338565b611a0f61309a565b906101335480611bab575b50611a52611a43611a3e611a2d846130b3565b600052610134602052604060002090565b6130cf565b928480850151910151906130c2565b91611a5d8261013355565b61012d54611a73906001600160a01b03166112be565b60405163388e611f60e11b815290948082600481895afa9081156110845787928392611b88575b5083516040516318d0d57560e01b928101929092526001600160a01b03909216602482015260448101859052606481019190915260848101859052611ae28160a48101610de6565b611aec8534612e55565b95803b15611b8457611b159160405197888094819363e289adcd60e01b83528a60048401613379565b03925af1908115611084577fba9fdc955504f0973215993a882822edf5e2b4561df97340b4d5632e64e24a0f9461155c92611b6b575b505192604051938493846040919493926060820195825260208201520152565b80611b78611b7e92610982565b8061032d565b38611b4b565b8280fd5b819250611ba490611ae2923d85116113dd576113c38183610a06565b9190611a9a565b611bbd919250611a2d611a3e916130b3565b9038611a1a565b506101335481116119fe565b3461033857600036600319011261033857602061013954604051908152f35b3461033857604036600319011261033857600435611c0c81610555565b602435611c17613213565b61013b546001600160a01b039081163303611ce4578115611cae577f8f37daeecdc35f2a03da8794b025ea44e3f7c6f4e2265630836db89ff3f2f2b790611c79611c648461013954612e55565b611c738161013854101561351a565b61013955565b600093611c958580808088865af1611c8f612727565b50613558565b6040519384521691602090a2611cab600160c955565b80f35b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606490fd5b60405162461bcd60e51b815260206004820152601960248201527f4e6f7420666f72776172642066656520616c6c6f6361746f72000000000000006044820152606490fd5b34610338576040366003190112610338577fdfb8da952dba6c9ec993b8f2ca8cc6ac22596f6e179520fea3fc78202e87090c6040600435602435611d7960018060a01b0361012d541633146129bf565b8160005261013760205280836000205582519182526020820152a1005b3461033857600319608036820112610338576044356001600160401b03918282116103385760609082360301126103385760405190611dd48261099a565b611de08160040161039a565b82526024810135611df081610555565b6020830152604481013590838211610338576004611e119236920101610ae2565b604082015260643591821161033857611e4061049291611e386104a49436906004016103a9565b929091613854565b602435600435613907565b60e036600319011261033857600435611e6381610555565b602435906001600160401b039060443582811161033857611e8890369060040161118d565b9091606435906084359460a43590811161033857611eaa9036906004016103a9565b9060c43591611eb883610555565b611ec0613213565b611ec861293d565b61012d8054909890611ee2906001600160a01b03166112be565b9560409889519889986314aa259d60e31b8a5289600460209c8d935afa8015611084578a99600091612244575b5015612235575b8c3360003282146122195750611fb081611f51611f4c611259611fb69560018060a01b031660005261012f602052604060002090565b612d60565b61111161111160901b0160018060a01b0391011692611f8260019d5b611f7a6103208b14612dac565b8a1115612df7565b611fa7611fa0611f99896118ee8c610130546135b6565b9283612e55565b3414612e62565b61013854612e55565b61013855565b6001600160a01b0397808916612213575080975b88803b6121fc575b5050610132549c548c5163388e611f60e11b81529a908c908c906001600160a01b0316815a91600492fa9a8b156110845760009b6121dd575b50612014610a43565b6001600160a01b03909b168b5215158a8c01526001600160a01b0316898c0152606089018c81526001600160a01b0390981660808a01528c60a08a0152369061205c92610aab565b60c088015260e0870152610100860152369061207792612ece565b6101208401526001600160a01b031661014083015261209582613789565b845190816120a582878301612f99565b0391601f199283810182526120ba9082610a06565b6101315460681c63ffffffff1663ffffffff16906120d792614007565b846120e184613d18565b9687926120ec61309a565b6104a49a7fbf5630c2adfa5e47b882a9ead657ffc6a22ce010513a3efac7245066bcad17dd986121579661215196610e2a958761218157505083528201525b61214083600052610134602052604060002090565b906020600191805184550151910155565b61013255565b51612166845192839283613149565b0390a1612173600160c955565b519081529081906020820190565b6121d6939295506121c76121bb9161219e611a3e611a2d8c6130b3565b978851945193849187830196879091604092825260208201520190565b03908101835282610a06565b51902084528301918251612e55565b905261212b565b6121f5919b508c8d3d106113dd576113c38183610a06565b993861200b565b811661111161111160901b01011697503880611fd2565b97611fca565b9a611fb69192611f82611fb0926122308715612d14565b611f6d565b61223f8d15612cd3565b611f16565b61225b91508a3d8c1161107d5761106f8183610a06565b38611f0f565b346103385760203660031901126103385760043561227e81610555565b612286612335565b6001600160a01b0381161561229e5761070f9061238d565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346103385760203660031901126103385760043561230f81610555565b60018060a01b031660005261012e602052602060ff604060002054166040519015158152f35b6033546001600160a01b0316330361234957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b156123dd57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561243e57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b604051602081018181106001600160401b038211176109955760405260008152906000368137565b90816020910312610338575190565b6040513d6000823e3d90fd5b156124e257565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b803b156125bd5760008051602061414583398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b9061262282612588565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28051158015906126cc575b612664575050565b6126c991600080604051936126788561099a565b602785527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020860152660819985a5b195960ca1b6040860152602081519101845af46126c3612727565b91612757565b50565b50600061265c565b906126de82612588565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a280511580159061271f57612664575050565b50600161265c565b3d15612752573d9061273882610a90565b916127466040519384610a06565b82523d6000602084013e565b606090565b919290156127b9575081511561276b575090565b3b156127745790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156127cc5750805190602001fd5b60405162461bcd60e51b8152602060048201529081906107559060248301905b919082519283825260005b848110612818575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016127f7565b1561283357565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b6128a060ff60005460081c166128dd565b6128a93361238d565b6128d160ff60005460081c166128be816128dd565b6128c7816128dd565b600160c9556128dd565b60ff1960fb541660fb55565b156128e457565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb541661294957565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b1561298857565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206761746577617960881b6044820152606490fd5b156129c657565b60405162461bcd60e51b815260206004820152600b60248201526a4e6f74206761746577617960a81b6044820152606490fd5b63ffffffff81160361033857565b60405190612a14826109b5565b8160a06001600160401b036101315460ff8116612a308161181a565b845263ffffffff808260081c166020860152808260281c166040860152808260481c1660608601528160681c16608085015260881c16910152565b6001600160401b0381160361033857565b60a43561089581612a6b565b600435612a94816103d9565b612a9d8161181a565b6101319081546cffffffff000000000000000000602435612abd816129f9565b68ffffffff000000000060443591612ad4836129f9565b64ffffffff0060643595612ae7876129f9565b60ff608435612af5816129f9565b63ffffffff60681b9060681b1698169070ffffffffffffffffffffffffffffffffff1916179160081b16179160281b16179160481b1617179055610a34612b3a612a7c565b610131805467ffffffffffffffff60881b191660889290921b67ffffffffffffffff60881b16919091179055565b60843590610a34826129f9565b60a43590610a3482612a6b565b815161018082019392610a349291612b998161181a565b82526001600160401b0360a063ffffffff9283602082015116602086015283604082015116604086015283606082015116606086015283608082015116608086015201511660a0830152600435612bef816103d9565b612bf88161181a565b60c083015280602435612c0a816129f9565b1660e083015280604435612c1d816129f9565b16610100830152606435612c30816129f9565b16610120820152612c50612c42612b68565b63ffffffff16610140830152565b610160612c5b612b75565b6001600160401b0316910152565b634e487b7160e01b600052601160045260246000fd5b9081605802916058830403612c9057565b612c69565b908160061b9180830460401490151715612c9057565b81810292918115918404141715612c9057565b90816020910312610338575161089581610866565b15612cda57565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420616c6c6f77206c322076616c756560701b6044820152606490fd5b15612d1b57565b60405162461bcd60e51b815260206004820152601a60248201527f4e6f7420616c6c6f7720746f2063616c6c20636f6e74726163740000000000006044820152606490fd5b15612d6757565b60405162461bcd60e51b815260206004820152601c60248201527f4e6f7420616c6c6f7720746f2073656e64204c322072657175657374000000006044820152606490fd5b15612db357565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206c3247617350657250756264617461427974654c696d69746044820152fd5b15612dfe57565b60405162461bcd60e51b8152602060048201526013602482015272496e76616c696420666163746f72794465707360681b6044820152606490fd5b9060018201809211612c9057565b9060208201809211612c9057565b91908201809211612c9057565b15612e6957565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964206d73672076616c756560781b6044820152606490fd5b90816020910312610338575161089581610555565b6001600160401b0381116109955760051b60200190565b92919092612edb84612eb7565b91612ee96040519384610a06565b829480845260208094019060051b8301928284116103385780915b848310612f1357505050505050565b82356001600160401b038111610338578691612f328684938601610ae2565b815201920191612f04565b6000915b60048310612f4e57505050565b600190825181526020809101920192019190612f41565b90815180825260208080930193019160005b828110612f85575050505090565b835185529381019392810192600101612f77565b90610895916020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e082015260e082015161010090818301528201516101209081830152820151610140908183015282015161301b6101609182840190612f3d565b820151906102606130396101e09382858501526102808401906127ec565b9261308a61307461305e61018088015196601f199788888303016102008901526127ec565b6101a08801518787830301610220880152612f65565b6101c087015186868303016102408701526127ec565b94015192828503019101526127ec565b604051906130a7826109d0565b60006020838281520152565b600019810191908211612c9057565b91908203918211612c9057565b906040516130dc816109d0565b602060018294805484520154910152565b908082519081815260208091019281808460051b8301019501936000915b84831061311b5750505050505090565b9091929394958480613139600193601f198682030187528a516127ec565b980193019301919493929061310b565b90815260406020820181905282516001600160a01b0316908201526108959060208301511515606082015260408301516001600160a01b03166080820152606083015160a082015260808301516001600160a01b031660c082015260a083015160e082015261018060c08401516132026101606131d36101009382858801526101a08701906127ec565b9060e088015193610120948588015288015193610140948588015288015190603f1987840301908701526130ed565b9401516001600160a01b0316910152565b600260c9541461322457600260c955565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b1561327057565b60405162461bcd60e51b8152602060048201526002602482015261353560f11b6044820152606490fd5b156132a157565b60405162461bcd60e51b8152602060048201526002602482015261726760f01b6044820152606490fd5b156132d257565b60405162461bcd60e51b8152602060048201526002602482015261706960f01b6044820152606490fd5b1561330357565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606490fd5b1561333f57565b60405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a59081cde5b98c81c1bda5b9d60721b6044820152606490fd5b6040906108959392815281602082015201906127ec565b1561339757565b60405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199bdc9dd85c9908185b5bdd5b9d60521b6044820152606490fd5b156133dc57565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b6044820152606490fd5b1561341857565b60405162461bcd60e51b815260206004820152601f60248201527f52616e676520626174636820726f6f742068617368206e6f74206578697374006044820152606490fd5b1561346457565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726f6f7420686173686573206c656e6774680000000000006044820152606490fd5b90156134b25790565b634e487b7160e01b600052603260045260246000fd5b91908110156134b25760051b0190565b156134df57565b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dee4e4cac6e840e4dedee840d0c2e6d606b1b6044820152606490fd5b1561352157565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc8195e18d95959608a1b6044820152606490fd5b1561355f57565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b81156135a0570490565b634e487b7160e01b600052601260045260246000fd5b6135be612a07565b9160009183516135cd8161181a565b6135d68161181a565b15613690575b906136856136808261367a876001600160401b0361367361364461361761368a9a6118ee63ffffffff6108959f602001511663ffffffff1690565b9a61363e61363861362f604088015163ffffffff1690565b63ffffffff1690565b8d613596565b90612e55565b9961366d61362f606061366160a08801516001600160401b031690565b96015163ffffffff1690565b90613596565b9116612e55565b95612e55565b6130b3565b613596565b906136bd565b80925060110290601182048303612c905790916135dc565b6202a5ac808211156136b8575090565b905090565b90808211156136b8575090565b604051906136d7826109eb565b6080368337565b6136e6610a63565b90600080835280602084015280604084015260609080828501528060808501528060a08501528060c08501528060e08501528061010085015261012084015261372d6136ca565b6101408401528061016084015280610180840152806101a0840152806101c08401526101e0830152565b9061376182612eb7565b61376e6040519182610a06565b828152809261377f601f1991612eb7565b0190602036910137565b6040906137946136de565b5060e08101519061010080820151916137ab610a83565b600090818152816020820152818782015281606082015260c0830151916137d0612498565b93816137e26101208093015151613757565b966137eb612498565b986137f4612498565b9a836137fe610a63565b9d8e828152826020820152015260608d015260808c01528160a08c01528160c08c01528160e08c01528a01528801526101408701526101608601526101808501526101a08401526101c08301526101e082015290565b60a090604051613863816109b5565b6000928184809352826020820152826040820152826060820152826080820152015261ffff81511690604060018060a01b036020830151169101516020815191012091604051936138b3856109b5565b84526001602085015260408401526180086060840152608083015260a082015290565b156138dd57565b60405162461bcd60e51b8152602060048201526002602482015261747760f01b6044820152606490fd5b939290610135548511613a1a57613a159383613927613a03955160ff1690565b906139ce6139386020830151151590565b610de661394a604085015161ffff1690565b60608501519094906001600160a01b0316608082015160a09092015160405160f898891b6001600160f81b0319166020820190815295151590981b602189015260f09690961b6001600160f01b031916602288015260601b6bffffffffffffffffffffffff1916602487015260388601526058850193909352929182906078820190565b519020926139fe7f72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba8514156138d6565b613ea8565b91600052610136602052604060002090565b541490565b60405162461bcd60e51b81526020600482015260026024820152610f0f60f31b6044820152606490fd5b606c815103613ad95760048101516393f69f0760e01b60e09190911b6001600160e01b03191601613aaf57613a9691613aab82613a87613a9e9460188091015191565b60208184018101519297910190565b949094612e47565b6014908181019201015191565b5090565b60405162461bcd60e51b8152602060048201526002602482015261697360f01b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261706d60f01b6044820152606490fd5b15613b0a57565b60405162461bcd60e51b8152602060048201526002602482015261383d60f11b6044820152606490fd5b61012d54909190613b4d906001600160a01b03166112be565b6040516314aa259d60e31b815260209391908481600481855afa90811561108457600091613bde575b5015613b905750610a349250600080809381935af1613b03565b8360049160405192838092637bf1a62760e01b82525afa90811561108457610a3494600092613bc1575b5050613bfb565b613bd79250803d106113dd576113c38183610a06565b3880613bba565b613bf59150853d871161107d5761106f8183610a06565b38613b76565b9190613c7f91600080604051936020968786019463a9059cbb60e01b865260018060a01b038093166024880152604487015260448652613c3a866109eb565b169260405194613c49866109d0565b8786527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488870152519082855af16126c3612727565b805190828215928315613cef575b50505015613c985750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b613cff9350820181019101612cbe565b388281613c8d565b9060206108959281815201906130ed565b80516001600160a01b03166020820151151560408301519092906001600160a01b0316606082015160808301519093906001600160a01b031660a08401519360c08101518051906020012060e0820151610100830151916101208401519760405198896020810191613d8a9083613d07565b0399601f199a8b81018252613d9f9082610a06565b51902061014095860151604080517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c602082019081526001600160a01b039b8c16928201929092529d151560608f015299891660808e015260a08d019b909b5295871660c08c015260e08b01526101008a0152610120890152908701526101608601529092166101808401526101a09081018352909190613e409082610a06565b51902090565b15613e4d57565b60405162461bcd60e51b8152602060048201526002602482015261189d60f21b6044820152606490fd5b15613e7e57565b60405162461bcd60e51b81526020600482015260026024820152610e0f60f31b6044820152606490fd5b9092918315613f4a57919092613ec16101008210613e46565b600191613ed183831b8510613e77565b9360009182915b818310613ee85750505050505090565b9091929380959681881615600014613f2757613f1990613f098686866134c8565b3590600052602052604060002090565b96811c959493019190613ed8565b613f4590613f368686866134c8565b35600052602052604060002090565b613f19565b60405162461bcd60e51b8152602060048201526002602482015261786360f01b6044820152606490fd5b15613f7b57565b60405162461bcd60e51b8152602060048201526002602482015261756960f01b6044820152606490fd5b15613fac57565b60405162461bcd60e51b8152602060048201526002602482015261756b60f01b6044820152606490fd5b15613fdd57565b60405162461bcd60e51b8152602060048201526002602482015261075760f41b6044820152606490fd5b91606083015192825180600a0290600a820403612c905761271090808211156140a95750915b82851061407f576101a061407893610a3496039461405163044aa200871115613f74565b61406b6080850193614064855189613596565b1115613fa5565b51920151519051916140b1565b1115613fd6565b60405162461bcd60e51b81526020600482015260026024820152616d7960f01b6044820152606490fd5b90509161402d565b91909161067890818102918183041490151715612c90578061412257506000915b62028cf5928301809311612c90576109a990818102918183041481151715612c905761363e61410f61410a61363e9461089597612e55565b6136a8565b936118ee61411c82612c7f565b93612c95565b6000198101908111612c9057610220900460018101809111612c9057916140d256fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220f73902d9069be8d7f5da094bc62a928bcca78cb473220bc97aa5a61889d7516464736f6c63430008120033

Deployed Bytecode

0x6080604052600436101561001257600080fd5b60003560e01c8062e969a814610328578063042901c7146103235780630ec6b0b71461031e578063116191b6146103005780631dd26496146103195780632425b3a4146103145780633659cfe61461030f57806336e2e3f31461030a5780633f4ba83a1461030557806342bf3cc1146103005780634623c91d146102fb5780634ecf53e9146102f65780634f1ef286146102f15780634fc07d75146102a657806351ef251b1461029257806352d1902d146102ec578063534ca054146102e75780635a425fcd146102e25780635a9f55b0146102dd5780635c975abb146102d85780635e78d327146102d3578063637c9d9d146102ce57806363b434941461028357806364bf8d66146102c95780636c0960f9146102c4578063715018a6146102bf5780637666f125146102ba5780638129fc1c146102b557806383864ac4146102975780638456cb59146102b05780638aa50991146102ab5780638da5cb5b146102a657806390646b4a146102a15780639242164f1461029c5780639cd939e414610297578063a1954fc514610292578063af32a0a71461028d578063b473318e14610288578063b8c2f66f14610283578063ba745e531461027e578063bc5455d014610279578063bd7c541214610274578063be3bc8ea1461026f578063ca98ef4f1461026a578063cfe6128214610265578063e0a1bf7214610260578063e4948f431461025b578063eb67241914610256578063f2fde38b14610251578063fa52c7d81461024c5763facd743b1461024c57600080fd5b6122f2565b612261565b611e4b565b611d96565b611d29565b611bef565b611bd0565b6119c5565b611985565b61191a565b6118fb565b6110b6565b6118c7565b6118a8565b610c69565b6115a9565b61183a565b611749565b610c40565b611630565b6115d6565b6114c1565b611445565b6113e4565b6111ba565b6110d5565b611089565b610f75565b610f52565b610f25565b610d6c565b610d4d565b610c88565b610afd565b610929565b610898565b610501565b6107d2565b61079c565b61064f565b610566565b61052b565b6104e2565b6103e3565b61033d565b600091031261033857565b600080fd5b346103385760003660031901126103385760206040517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c8152f35b6064359061ffff8216820361033857565b6044359061ffff8216820361033857565b359061ffff8216820361033857565b9181601f84011215610338578235916001600160401b038311610338576020808501948460051b01011161033857565b6002111561033857565b346103385760c0366003190112610338576103fc610378565b6084356001600160401b0381116103385761041b9036906004016103a9565b60a4359291610429846103d9565b6004356000526101376020526040600020549283156104a85784610492946104536104a49761181a565b61047561045e610a27565b60008152600160208201529361ffff166040850152565b6180016060840152608083015260a0820152604435602435613907565b60405190151581529081906020820190565b0390f35b60405162461bcd60e51b8152602060048201526012602482015271092dcecc2d8d2c840d86440e8f040d0c2e6d60731b6044820152606490fd5b3461033857600036600319011261033857602060405163044aa2008152f35b346103385760003660031901126103385761012d546040516001600160a01b039091168152602090f35b346103385760003660031901126103385761013b546040516001600160a01b039091168152602090f35b6001600160a01b0381160361033857565b346103385760203660031901126103385760043561058381610555565b61058b612335565b6001600160a01b039080821680156106165761013b546001600160a01b0316928316036105b457005b61013b80546001600160a01b0319166001600160a01b0383161790557f98ac3b973026c0d730e72f023f161bebb4ba504d9b1c6b83d849d3cbaf7f51f491604080516001600160a01b039283168152929091166020830152819081015b0390a1005b60405162461bcd60e51b815260206004820152601160248201527024b73b30b634b21030b63637b1b0ba37b960791b6044820152606490fd5b346103385760203660031901126103385760043561066c81610555565b6001600160a01b037f0000000000000000000000000c04046546c46652969aa9eb4bfb758cfdf1e821811691906106a5308414156123d6565b6106c2600080516020614145833981519152938285541614612437565b6106ca612335565b6106d2612498565b906106fe7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1690565b1561071157505061070f9150612588565b005b6020600491604094939451928380926352d1902d60e01b825286165afa6000918161076c575b506107595760405162461bcd60e51b81528061075560048201612539565b0390fd5b61070f9361076791146124db565b612618565b61078e91925060203d8111610795575b6107868183610a06565b8101906124c0565b9038610737565b503d61077c565b34610338576020366003190112610338576004356000526101346020526040806000206001815491015482519182526020820152f35b34610338576000366003190112610338576107eb612335565b60fb5460ff81161561082a5760ff191660fb557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b8015150361033857565b60409060031901126103385760043561088881610555565b9060243561089581610866565b90565b34610338576108a636610870565b61012d5490916001600160a01b03916108c290831633146129bf565b16908160005261012e60205260406000209060ff82541681151580911515036108e757005b6109206020927f065b77b53864e46fda3d8986acb51696223d6dde7ced42441eb150bae6d48136949060ff801983541691151516179055565b604051908152a2005b346103385760203660031901126103385760043561094681610555565b60018060a01b031660005261012f602052602060ff604060002054166040519015158152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161099557604052565b61096c565b606081019081106001600160401b0382111761099557604052565b60c081019081106001600160401b0382111761099557604052565b604081019081106001600160401b0382111761099557604052565b608081019081106001600160401b0382111761099557604052565b90601f801991011681019081106001600160401b0382111761099557604052565b60405190610a34826109b5565b565b60405190610a348261099a565b6040519061016082018281106001600160401b0382111761099557604052565b6040519061020082018281106001600160401b0382111761099557604052565b60405190610a34826109eb565b6001600160401b03811161099557601f01601f191660200190565b929192610ab782610a90565b91610ac56040519384610a06565b829481845281830111610338578281602093846000960137010152565b9080601f830112156103385781602061089593359101610aab565b604036600319011261033857600435610b1581610555565b6024356001600160401b03811161033857610b34903690600401610ae2565b6001600160a01b037f0000000000000000000000000c04046546c46652969aa9eb4bfb758cfdf1e8218116929190610b6e308514156123d6565b610b8b600080516020614145833981519152948286541614612437565b610b93612335565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610bc957505061070f9150612588565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610c20575b50610c0d5760405162461bcd60e51b81528061075560048201612539565b61070f93610c1b91146124db565b6126d4565b610c3991925060203d8111610795576107868183610a06565b9038610bef565b34610338576000366003190112610338576033546040516001600160a01b039091168152602090f35b3461033857600036600319011261033857602061013254604051908152f35b34610338576000366003190112610338577f0000000000000000000000000c04046546c46652969aa9eb4bfb758cfdf1e8216001600160a01b03163003610ce2576040516000805160206141458339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b3461033857600036600319011261033857602061013054604051908152f35b34610338576060366003190112610338576004356024356044356001600160401b03811161033857610da29036906004016103a9565b9290923360005261012e602052610dc060ff604060002054166132fc565b610dcc828410156133d5565b6040805160208101848152918101859052610df481606081015b03601f198101835282610a06565b51902093610e0d8560005261013c602052604060002090565b5491610e1a831515613411565b610e36610e2f610e2a86886130c2565b612e39565b821461345d565b610e4081836134a9565b359182610e5886600052610136602052604060002090565b5560019081925b808410610edf577fddf6b2cf5bdb04a03cb3f7663b72571336626b1e586a3a047942e4860cf7e12b88886000610eab8d610e9a8c8c146134d8565b60005261013c602052604060002090565b55610135548211610ed0575b6040805191825260208201929092529081908101610611565b610eda8261013555565b610eb7565b9091610f1b8495610ef2839685876134c8565b359081610f0c898c01600052610136602052604060002090565b55600052602052604060002090565b9401929190610e5f565b34610338576020366003190112610338576004356000526101376020526020604060002054604051908152f35b3461033857600036600319011261033857602060ff60fb54166040519015158152f35b60603660031901126103385761012d54604435906024359060048035916020906001600160a01b0316610fa93382146129bf565b6040516314aa259d60e31b815292839182905afa938415611084577fab53214e3a56f049923c5f5532ea4657bba51b870850593c4dc0eceb3b61feed9461061192600091611056575b50611046575b610135548311611037575b8361101984600052610136602052604060002090565b55604051938493846040919493926060820195825260208201520152565b6110418361013555565b611003565b611051813414613390565b610ff8565b611077915060203d811161107d575b61106f8183610a06565b810190612cbe565b38610ff2565b503d611065565b6124cf565b346103385760203660031901126103385760043560005261013c6020526020604060002054604051908152f35b3461033857600036600319011261033857602061013554604051908152f35b346103385760c0366003190112610338576110fc60018060a01b0361012d541633146129bf565b604435611108816129f9565b608435611114816129f9565b63ffffffff809116911610611163577fc8b245ac8b138b17b6b1dbbbb8860adc66b373afa000d99f3cdc775d8ae0bbed61061161114f612a07565b611157612a88565b60405191829182612b82565b60405162461bcd60e51b8152602060048201526002602482015261371b60f11b6044820152606490fd5b9181601f84011215610338578235916001600160401b038311610338576020838186019501011161033857565b346103385760a0366003190112610338576024356004356111d9610389565b916001600160401b0391606435838111610338576111fb90369060040161118d565b929091608435948511610338576112a261129d61121d600497369089016103a9565b959096611228613213565b6112696112646112606112598961124a8a60005261013a602052604060002090565b90600052602052604060002090565b5460ff1690565b1590565b613269565b61127e611274610a36565b61ffff909b168b52565b61800a60208b0152611291368284610aab565b60408b01523691610aab565b613a44565b949195909760206112ca6112be61012d5460018060a01b031690565b6001600160a01b031690565b60405163388e611f60e11b8152998a9182905afa968715611084577f26464d64ddb13f6d187de632d165bd1065382ec0b66c25c648957116e7bc25c89860009861138e575b5061134b61136e969461124a94611344611361989561133f6113509660018060a01b039e8f80911691161461329a565b613854565b8786613907565b6132cb565b60005261013a602052604060002090565b805460ff19166001179055565b6113788482613b34565b6040519384521691602090a261070f600160c955565b61135091985061136e969461124a94611344611361989561133f6113cb61134b9660203d81116113dd575b6113c38183610a06565b810190612ea2565b9d96505095985050945094965061130f565b503d6113b9565b3461033857600080600319360112611442576113fe612335565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346103385761145336610870565b9061145c612335565b60018060a01b0316908160005261012f60205260406000209060ff825416811515809115150361148857005b6109206020927f1f8e549bdb5108ba50ebcc80bb64a20ea98bfbd9378a87380d29f3c87cdcbb2c949060ff801983541691151516179055565b34610338576000806003193601126114425780546114f660ff8260081c16158092819361159b575b811561157b575b5061282c565b80611509600160ff196000541617600055565b611562575b61151661288f565b61151d5780f35b61152d61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081015b0390a180f35b61157661010061ff00196000541617600055565b61150e565b303b1591508161158d575b50386114f0565b6001915060ff161438611586565b600160ff82161091506114e9565b34610338576020366003190112610338576004356000526101366020526020604060002054604051908152f35b34610338576000366003190112610338576115ef612335565b6115f761293d565b600160ff1960fb54161760fb557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b608036600319011261033857600435602435604435916004606435602060018060a01b0361012d54166116648133146129bf565b611670858710156133d5565b6040516314aa259d60e31b815293849182905afa948515611084577f427754a95a2d34153366ec8bcea3939ce044aaf5c185a86149c9f6d80c4402b9956106119360009161172b575b5061171b575b604080516020810186815291810187905282916116f7916116e38160608101610de6565b51902060005261013c602052604060002090565b55604051948594859094939260609260808301968352602083015260408201520152565b611726823414613390565b6116bf565b611743915060203d811161107d5761106f8183610a06565b386116b9565b346103385760203660031901126103385760043561176681610555565b61176e612335565b61012d546001600160a01b039081166117dc576117b590821691611793831515612981565b61012d80546001600160a01b0319166001600160a01b03909216919091179055565b7f860df2b5ed762095deab38be8b5aa5acfbfa8d4d209e083fa00246d31b715e29600080a2005b60405162461bcd60e51b81526020600482015260166024820152754475706c696361746520696e6974206761746577617960501b6044820152606490fd5b6002111561182457565b634e487b7160e01b600052602160045260246000fd5b346103385760003660031901126103385760c0610131546001600160401b0360ff8216916040519261186b8161181a565b835263ffffffff808260081c166020850152808260281c166040850152808260481c1660608501528160681c16608084015260881c1660a0820152f35b3461033857600036600319011261033857602061013854604051908152f35b346103385760603660031901126103385760206118f36024356118ee6044356004356135b6565b612cab565b604051908152f35b3461033857600036600319011261033857602061013354604051908152f35b3461033857602036600319011261033857600435611936612335565b61013090815481810361194557005b817f208ba37ba4e5fc3f236a9c289aa28898330c1f2ec9102d54821a1ffb59e8f1d793556106116040519283928360209093929193604081019481520152565b346103385760403660031901126103385760043560005261013a6020526040600020602435600052602052602060ff604060002054166040519015158152f35b602080600319360112610338576004359060009133835261012e82526119f160ff6040852054166132fc565b6101325481111580611bc4575b611a0790613338565b611a0f61309a565b906101335480611bab575b50611a52611a43611a3e611a2d846130b3565b600052610134602052604060002090565b6130cf565b928480850151910151906130c2565b91611a5d8261013355565b61012d54611a73906001600160a01b03166112be565b60405163388e611f60e11b815290948082600481895afa9081156110845787928392611b88575b5083516040516318d0d57560e01b928101929092526001600160a01b03909216602482015260448101859052606481019190915260848101859052611ae28160a48101610de6565b611aec8534612e55565b95803b15611b8457611b159160405197888094819363e289adcd60e01b83528a60048401613379565b03925af1908115611084577fba9fdc955504f0973215993a882822edf5e2b4561df97340b4d5632e64e24a0f9461155c92611b6b575b505192604051938493846040919493926060820195825260208201520152565b80611b78611b7e92610982565b8061032d565b38611b4b565b8280fd5b819250611ba490611ae2923d85116113dd576113c38183610a06565b9190611a9a565b611bbd919250611a2d611a3e916130b3565b9038611a1a565b506101335481116119fe565b3461033857600036600319011261033857602061013954604051908152f35b3461033857604036600319011261033857600435611c0c81610555565b602435611c17613213565b61013b546001600160a01b039081163303611ce4578115611cae577f8f37daeecdc35f2a03da8794b025ea44e3f7c6f4e2265630836db89ff3f2f2b790611c79611c648461013954612e55565b611c738161013854101561351a565b61013955565b600093611c958580808088865af1611c8f612727565b50613558565b6040519384521691602090a2611cab600160c955565b80f35b60405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606490fd5b60405162461bcd60e51b815260206004820152601960248201527f4e6f7420666f72776172642066656520616c6c6f6361746f72000000000000006044820152606490fd5b34610338576040366003190112610338577fdfb8da952dba6c9ec993b8f2ca8cc6ac22596f6e179520fea3fc78202e87090c6040600435602435611d7960018060a01b0361012d541633146129bf565b8160005261013760205280836000205582519182526020820152a1005b3461033857600319608036820112610338576044356001600160401b03918282116103385760609082360301126103385760405190611dd48261099a565b611de08160040161039a565b82526024810135611df081610555565b6020830152604481013590838211610338576004611e119236920101610ae2565b604082015260643591821161033857611e4061049291611e386104a49436906004016103a9565b929091613854565b602435600435613907565b60e036600319011261033857600435611e6381610555565b602435906001600160401b039060443582811161033857611e8890369060040161118d565b9091606435906084359460a43590811161033857611eaa9036906004016103a9565b9060c43591611eb883610555565b611ec0613213565b611ec861293d565b61012d8054909890611ee2906001600160a01b03166112be565b9560409889519889986314aa259d60e31b8a5289600460209c8d935afa8015611084578a99600091612244575b5015612235575b8c3360003282146122195750611fb081611f51611f4c611259611fb69560018060a01b031660005261012f602052604060002090565b612d60565b61111161111160901b0160018060a01b0391011692611f8260019d5b611f7a6103208b14612dac565b8a1115612df7565b611fa7611fa0611f99896118ee8c610130546135b6565b9283612e55565b3414612e62565b61013854612e55565b61013855565b6001600160a01b0397808916612213575080975b88803b6121fc575b5050610132549c548c5163388e611f60e11b81529a908c908c906001600160a01b0316815a91600492fa9a8b156110845760009b6121dd575b50612014610a43565b6001600160a01b03909b168b5215158a8c01526001600160a01b0316898c0152606089018c81526001600160a01b0390981660808a01528c60a08a0152369061205c92610aab565b60c088015260e0870152610100860152369061207792612ece565b6101208401526001600160a01b031661014083015261209582613789565b845190816120a582878301612f99565b0391601f199283810182526120ba9082610a06565b6101315460681c63ffffffff1663ffffffff16906120d792614007565b846120e184613d18565b9687926120ec61309a565b6104a49a7fbf5630c2adfa5e47b882a9ead657ffc6a22ce010513a3efac7245066bcad17dd986121579661215196610e2a958761218157505083528201525b61214083600052610134602052604060002090565b906020600191805184550151910155565b61013255565b51612166845192839283613149565b0390a1612173600160c955565b519081529081906020820190565b6121d6939295506121c76121bb9161219e611a3e611a2d8c6130b3565b978851945193849187830196879091604092825260208201520190565b03908101835282610a06565b51902084528301918251612e55565b905261212b565b6121f5919b508c8d3d106113dd576113c38183610a06565b993861200b565b811661111161111160901b01011697503880611fd2565b97611fca565b9a611fb69192611f82611fb0926122308715612d14565b611f6d565b61223f8d15612cd3565b611f16565b61225b91508a3d8c1161107d5761106f8183610a06565b38611f0f565b346103385760203660031901126103385760043561227e81610555565b612286612335565b6001600160a01b0381161561229e5761070f9061238d565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346103385760203660031901126103385760043561230f81610555565b60018060a01b031660005261012e602052602060ff604060002054166040519015158152f35b6033546001600160a01b0316330361234957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b156123dd57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561243e57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b604051602081018181106001600160401b038211176109955760405260008152906000368137565b90816020910312610338575190565b6040513d6000823e3d90fd5b156124e257565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b803b156125bd5760008051602061414583398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b9061262282612588565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28051158015906126cc575b612664575050565b6126c991600080604051936126788561099a565b602785527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020860152660819985a5b195960ca1b6040860152602081519101845af46126c3612727565b91612757565b50565b50600061265c565b906126de82612588565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a280511580159061271f57612664575050565b50600161265c565b3d15612752573d9061273882610a90565b916127466040519384610a06565b82523d6000602084013e565b606090565b919290156127b9575081511561276b575090565b3b156127745790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156127cc5750805190602001fd5b60405162461bcd60e51b8152602060048201529081906107559060248301905b919082519283825260005b848110612818575050826000602080949584010152601f8019910116010190565b6020818301810151848301820152016127f7565b1561283357565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b6128a060ff60005460081c166128dd565b6128a93361238d565b6128d160ff60005460081c166128be816128dd565b6128c7816128dd565b600160c9556128dd565b60ff1960fb541660fb55565b156128e457565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b60ff60fb541661294957565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b1561298857565b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206761746577617960881b6044820152606490fd5b156129c657565b60405162461bcd60e51b815260206004820152600b60248201526a4e6f74206761746577617960a81b6044820152606490fd5b63ffffffff81160361033857565b60405190612a14826109b5565b8160a06001600160401b036101315460ff8116612a308161181a565b845263ffffffff808260081c166020860152808260281c166040860152808260481c1660608601528160681c16608085015260881c16910152565b6001600160401b0381160361033857565b60a43561089581612a6b565b600435612a94816103d9565b612a9d8161181a565b6101319081546cffffffff000000000000000000602435612abd816129f9565b68ffffffff000000000060443591612ad4836129f9565b64ffffffff0060643595612ae7876129f9565b60ff608435612af5816129f9565b63ffffffff60681b9060681b1698169070ffffffffffffffffffffffffffffffffff1916179160081b16179160281b16179160481b1617179055610a34612b3a612a7c565b610131805467ffffffffffffffff60881b191660889290921b67ffffffffffffffff60881b16919091179055565b60843590610a34826129f9565b60a43590610a3482612a6b565b815161018082019392610a349291612b998161181a565b82526001600160401b0360a063ffffffff9283602082015116602086015283604082015116604086015283606082015116606086015283608082015116608086015201511660a0830152600435612bef816103d9565b612bf88161181a565b60c083015280602435612c0a816129f9565b1660e083015280604435612c1d816129f9565b16610100830152606435612c30816129f9565b16610120820152612c50612c42612b68565b63ffffffff16610140830152565b610160612c5b612b75565b6001600160401b0316910152565b634e487b7160e01b600052601160045260246000fd5b9081605802916058830403612c9057565b612c69565b908160061b9180830460401490151715612c9057565b81810292918115918404141715612c9057565b90816020910312610338575161089581610866565b15612cda57565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420616c6c6f77206c322076616c756560701b6044820152606490fd5b15612d1b57565b60405162461bcd60e51b815260206004820152601a60248201527f4e6f7420616c6c6f7720746f2063616c6c20636f6e74726163740000000000006044820152606490fd5b15612d6757565b60405162461bcd60e51b815260206004820152601c60248201527f4e6f7420616c6c6f7720746f2073656e64204c322072657175657374000000006044820152606490fd5b15612db357565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206c3247617350657250756264617461427974654c696d69746044820152fd5b15612dfe57565b60405162461bcd60e51b8152602060048201526013602482015272496e76616c696420666163746f72794465707360681b6044820152606490fd5b9060018201809211612c9057565b9060208201809211612c9057565b91908201809211612c9057565b15612e6957565b60405162461bcd60e51b8152602060048201526011602482015270496e76616c6964206d73672076616c756560781b6044820152606490fd5b90816020910312610338575161089581610555565b6001600160401b0381116109955760051b60200190565b92919092612edb84612eb7565b91612ee96040519384610a06565b829480845260208094019060051b8301928284116103385780915b848310612f1357505050505050565b82356001600160401b038111610338578691612f328684938601610ae2565b815201920191612f04565b6000915b60048310612f4e57505050565b600190825181526020809101920192019190612f41565b90815180825260208080930193019160005b828110612f85575050505090565b835185529381019392810192600101612f77565b90610895916020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e082015260e082015161010090818301528201516101209081830152820151610140908183015282015161301b6101609182840190612f3d565b820151906102606130396101e09382858501526102808401906127ec565b9261308a61307461305e61018088015196601f199788888303016102008901526127ec565b6101a08801518787830301610220880152612f65565b6101c087015186868303016102408701526127ec565b94015192828503019101526127ec565b604051906130a7826109d0565b60006020838281520152565b600019810191908211612c9057565b91908203918211612c9057565b906040516130dc816109d0565b602060018294805484520154910152565b908082519081815260208091019281808460051b8301019501936000915b84831061311b5750505050505090565b9091929394958480613139600193601f198682030187528a516127ec565b980193019301919493929061310b565b90815260406020820181905282516001600160a01b0316908201526108959060208301511515606082015260408301516001600160a01b03166080820152606083015160a082015260808301516001600160a01b031660c082015260a083015160e082015261018060c08401516132026101606131d36101009382858801526101a08701906127ec565b9060e088015193610120948588015288015193610140948588015288015190603f1987840301908701526130ed565b9401516001600160a01b0316910152565b600260c9541461322457600260c955565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b1561327057565b60405162461bcd60e51b8152602060048201526002602482015261353560f11b6044820152606490fd5b156132a157565b60405162461bcd60e51b8152602060048201526002602482015261726760f01b6044820152606490fd5b156132d257565b60405162461bcd60e51b8152602060048201526002602482015261706960f01b6044820152606490fd5b1561330357565b60405162461bcd60e51b815260206004820152600d60248201526c2737ba103b30b634b230ba37b960991b6044820152606490fd5b1561333f57565b60405162461bcd60e51b8152602060048201526012602482015271125b9d985b1a59081cde5b98c81c1bda5b9d60721b6044820152606490fd5b6040906108959392815281602082015201906127ec565b1561339757565b60405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908199bdc9dd85c9908185b5bdd5b9d60521b6044820152606490fd5b156133dc57565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b6044820152606490fd5b1561341857565b60405162461bcd60e51b815260206004820152601f60248201527f52616e676520626174636820726f6f742068617368206e6f74206578697374006044820152606490fd5b1561346457565b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726f6f7420686173686573206c656e6774680000000000006044820152606490fd5b90156134b25790565b634e487b7160e01b600052603260045260246000fd5b91908110156134b25760051b0190565b156134df57565b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dee4e4cac6e840e4dedee840d0c2e6d606b1b6044820152606490fd5b1561352157565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc8195e18d95959608a1b6044820152606490fd5b1561355f57565b60405162461bcd60e51b815260206004820152600f60248201526e15da5d1a191c985dc819985a5b1959608a1b6044820152606490fd5b81156135a0570490565b634e487b7160e01b600052601260045260246000fd5b6135be612a07565b9160009183516135cd8161181a565b6135d68161181a565b15613690575b906136856136808261367a876001600160401b0361367361364461361761368a9a6118ee63ffffffff6108959f602001511663ffffffff1690565b9a61363e61363861362f604088015163ffffffff1690565b63ffffffff1690565b8d613596565b90612e55565b9961366d61362f606061366160a08801516001600160401b031690565b96015163ffffffff1690565b90613596565b9116612e55565b95612e55565b6130b3565b613596565b906136bd565b80925060110290601182048303612c905790916135dc565b6202a5ac808211156136b8575090565b905090565b90808211156136b8575090565b604051906136d7826109eb565b6080368337565b6136e6610a63565b90600080835280602084015280604084015260609080828501528060808501528060a08501528060c08501528060e08501528061010085015261012084015261372d6136ca565b6101408401528061016084015280610180840152806101a0840152806101c08401526101e0830152565b9061376182612eb7565b61376e6040519182610a06565b828152809261377f601f1991612eb7565b0190602036910137565b6040906137946136de565b5060e08101519061010080820151916137ab610a83565b600090818152816020820152818782015281606082015260c0830151916137d0612498565b93816137e26101208093015151613757565b966137eb612498565b986137f4612498565b9a836137fe610a63565b9d8e828152826020820152015260608d015260808c01528160a08c01528160c08c01528160e08c01528a01528801526101408701526101608601526101808501526101a08401526101c08301526101e082015290565b60a090604051613863816109b5565b6000928184809352826020820152826040820152826060820152826080820152015261ffff81511690604060018060a01b036020830151169101516020815191012091604051936138b3856109b5565b84526001602085015260408401526180086060840152608083015260a082015290565b156138dd57565b60405162461bcd60e51b8152602060048201526002602482015261747760f01b6044820152606490fd5b939290610135548511613a1a57613a159383613927613a03955160ff1690565b906139ce6139386020830151151590565b610de661394a604085015161ffff1690565b60608501519094906001600160a01b0316608082015160a09092015160405160f898891b6001600160f81b0319166020820190815295151590981b602189015260f09690961b6001600160f01b031916602288015260601b6bffffffffffffffffffffffff1916602487015260388601526058850193909352929182906078820190565b519020926139fe7f72abee45b59e344af8a6e520241c4744aff26ed411f4c4b00f8af09adada43ba8514156138d6565b613ea8565b91600052610136602052604060002090565b541490565b60405162461bcd60e51b81526020600482015260026024820152610f0f60f31b6044820152606490fd5b606c815103613ad95760048101516393f69f0760e01b60e09190911b6001600160e01b03191601613aaf57613a9691613aab82613a87613a9e9460188091015191565b60208184018101519297910190565b949094612e47565b6014908181019201015191565b5090565b60405162461bcd60e51b8152602060048201526002602482015261697360f01b6044820152606490fd5b60405162461bcd60e51b8152602060048201526002602482015261706d60f01b6044820152606490fd5b15613b0a57565b60405162461bcd60e51b8152602060048201526002602482015261383d60f11b6044820152606490fd5b61012d54909190613b4d906001600160a01b03166112be565b6040516314aa259d60e31b815260209391908481600481855afa90811561108457600091613bde575b5015613b905750610a349250600080809381935af1613b03565b8360049160405192838092637bf1a62760e01b82525afa90811561108457610a3494600092613bc1575b5050613bfb565b613bd79250803d106113dd576113c38183610a06565b3880613bba565b613bf59150853d871161107d5761106f8183610a06565b38613b76565b9190613c7f91600080604051936020968786019463a9059cbb60e01b865260018060a01b038093166024880152604487015260448652613c3a866109eb565b169260405194613c49866109d0565b8786527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488870152519082855af16126c3612727565b805190828215928315613cef575b50505015613c985750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b613cff9350820181019101612cbe565b388281613c8d565b9060206108959281815201906130ed565b80516001600160a01b03166020820151151560408301519092906001600160a01b0316606082015160808301519093906001600160a01b031660a08401519360c08101518051906020012060e0820151610100830151916101208401519760405198896020810191613d8a9083613d07565b0399601f199a8b81018252613d9f9082610a06565b51902061014095860151604080517fe0aaca1722ef50bb0c9b032e5b16ce2b79fa9f23638835456b27fd6894f8292c602082019081526001600160a01b039b8c16928201929092529d151560608f015299891660808e015260a08d019b909b5295871660c08c015260e08b01526101008a0152610120890152908701526101608601529092166101808401526101a09081018352909190613e409082610a06565b51902090565b15613e4d57565b60405162461bcd60e51b8152602060048201526002602482015261189d60f21b6044820152606490fd5b15613e7e57565b60405162461bcd60e51b81526020600482015260026024820152610e0f60f31b6044820152606490fd5b9092918315613f4a57919092613ec16101008210613e46565b600191613ed183831b8510613e77565b9360009182915b818310613ee85750505050505090565b9091929380959681881615600014613f2757613f1990613f098686866134c8565b3590600052602052604060002090565b96811c959493019190613ed8565b613f4590613f368686866134c8565b35600052602052604060002090565b613f19565b60405162461bcd60e51b8152602060048201526002602482015261786360f01b6044820152606490fd5b15613f7b57565b60405162461bcd60e51b8152602060048201526002602482015261756960f01b6044820152606490fd5b15613fac57565b60405162461bcd60e51b8152602060048201526002602482015261756b60f01b6044820152606490fd5b15613fdd57565b60405162461bcd60e51b8152602060048201526002602482015261075760f41b6044820152606490fd5b91606083015192825180600a0290600a820403612c905761271090808211156140a95750915b82851061407f576101a061407893610a3496039461405163044aa200871115613f74565b61406b6080850193614064855189613596565b1115613fa5565b51920151519051916140b1565b1115613fd6565b60405162461bcd60e51b81526020600482015260026024820152616d7960f01b6044820152606490fd5b90509161402d565b91909161067890818102918183041490151715612c90578061412257506000915b62028cf5928301809311612c90576109a990818102918183041481151715612c905761363e61410f61410a61363e9461089597612e55565b6136a8565b936118ee61411c82612c7f565b93612c95565b6000198101908111612c9057610220900460018101809111612c9057916140d256fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220f73902d9069be8d7f5da094bc62a928bcca78cb473220bc97aa5a61889d7516464736f6c63430008120033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.