ETH Price: $2,038.44 (-1.77%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

> 10 Internal Transactions found.

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Send Message178715432023-08-08 16:58:23933 days ago1691513903
0x4c8d4Ce7...E793cd6b3
0.03068525 ETH
Send Message178715432023-08-08 16:58:23933 days ago1691513903
0x4c8d4Ce7...E793cd6b3
0.03070622 ETH
Send Message178715432023-08-08 16:58:23933 days ago1691513903
0x4c8d4Ce7...E793cd6b3
0.03070622 ETH
Send Message178715402023-08-08 16:57:47933 days ago1691513867
0x4c8d4Ce7...E793cd6b3
0.00470622 ETH
Send Message178715392023-08-08 16:57:35933 days ago1691513855
0x4c8d4Ce7...E793cd6b3
4.20479881 ETH
Claim Message178715392023-08-08 16:57:35933 days ago1691513855
0x4c8d4Ce7...E793cd6b3
0 ETH
Send Message178715342023-08-08 16:56:35933 days ago1691513795
0x4c8d4Ce7...E793cd6b3
0.12673767 ETH
Claim Message178715172023-08-08 16:53:11933 days ago1691513591
0x4c8d4Ce7...E793cd6b3
0 ETH
Send Message178715142023-08-08 16:52:35933 days ago1691513555
0x4c8d4Ce7...E793cd6b3
0.00082206 ETH
Send Message178715082023-08-08 16:51:23933 days ago1691513483
0x4c8d4Ce7...E793cd6b3
0.03072206 ETH
Send Message178715082023-08-08 16:51:23933 days ago1691513483
0x4c8d4Ce7...E793cd6b3
0.03072206 ETH
Send Message178715042023-08-08 16:50:35933 days ago1691513435
0x4c8d4Ce7...E793cd6b3
0.03069765 ETH
Send Message178715032023-08-08 16:50:23933 days ago1691513423
0x4c8d4Ce7...E793cd6b3
0.03071664 ETH
Send Message178715032023-08-08 16:50:23933 days ago1691513423
0x4c8d4Ce7...E793cd6b3
0.01071425 ETH
Send Message178715032023-08-08 16:50:23933 days ago1691513423
0x4c8d4Ce7...E793cd6b3
0.03071664 ETH
Send Message178714882023-08-08 16:47:23933 days ago1691513243
0x4c8d4Ce7...E793cd6b3
0.13073183 ETH
Send Message178714782023-08-08 16:45:23933 days ago1691513123
0x4c8d4Ce7...E793cd6b3
0.00969491 ETH
Send Message178714782023-08-08 16:45:23933 days ago1691513123
0x4c8d4Ce7...E793cd6b3
0.03069491 ETH
Send Message178714782023-08-08 16:45:23933 days ago1691513123
0x4c8d4Ce7...E793cd6b3
0.03069491 ETH
Send Message178714752023-08-08 16:44:47933 days ago1691513087
0x4c8d4Ce7...E793cd6b3
0.03069491 ETH
Send Message178714752023-08-08 16:44:47933 days ago1691513087
0x4c8d4Ce7...E793cd6b3
0.03069491 ETH
Send Message178714752023-08-08 16:44:47933 days ago1691513087
0x4c8d4Ce7...E793cd6b3
0.03069491 ETH
Send Message178714732023-08-08 16:44:23933 days ago1691513063
0x4c8d4Ce7...E793cd6b3
0.00369491 ETH
Send Message178714632023-08-08 16:42:23933 days ago1691512943
0x4c8d4Ce7...E793cd6b3
0.01575897 ETH
Send Message178714632023-08-08 16:42:23933 days ago1691512943
0x4c8d4Ce7...E793cd6b3
0.20075897 ETH
View All Internal Transactions
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

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

Contract Source Code Verified (Exact Match)

Contract Name:
ZkEvmV2

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { L1MessageService } from "./messageService/l1/L1MessageService.sol";
import { TransactionDecoder } from "./messageService/lib/TransactionDecoder.sol";
import { IZkEvmV2 } from "./interfaces/IZkEvmV2.sol";
import { IPlonkVerifier } from "./interfaces/IPlonkVerifier.sol";
import { CodecV2 } from "./messageService/lib/Codec.sol";

/**
 * @title Contract to manage cross-chain messaging on L1 and rollup proving.
 * @author ConsenSys Software Inc.
 */
contract ZkEvmV2 is IZkEvmV2, Initializable, AccessControlUpgradeable, L1MessageService {
  using TransactionDecoder for *;
  using CodecV2 for *;

  uint256 private constant MODULO_R = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
  bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

  uint256 public currentTimestamp;
  uint256 public currentL2BlockNumber;

  mapping(uint256 => bytes32) public stateRootHashes;
  mapping(uint256 => address) public verifiers;

  uint256[50] private __gap;

  /// @custom:oz-upgrades-unsafe-allow constructor
  constructor() {
    _disableInitializers();
  }

  /**
   * @notice Initializes zkEvm and underlying service dependencies.
   * @dev DEFAULT_ADMIN_ROLE is set for the security council.
   * @dev OPERATOR_ROLE is set for operators.
   * @param _initialStateRootHash The initial hash at migration used for proof verification.
   * @param _initialL2BlockNumber The initial block number at migration.
   * @param _defaultVerifier The default verifier for rollup proofs.
   * @param _securityCouncil The address for the security council performing admin operations.
   * @param _operators The allowed rollup operators at initialization.
   * @param _rateLimitPeriodInSeconds The period in which withdrawal amounts and fees will be accumulated.
   * @param _rateLimitAmountInWei The limit allowed for withdrawing in the period.
   **/
  function initialize(
    bytes32 _initialStateRootHash,
    uint256 _initialL2BlockNumber,
    address _defaultVerifier,
    address _securityCouncil,
    address[] calldata _operators,
    uint256 _rateLimitPeriodInSeconds,
    uint256 _rateLimitAmountInWei
  ) public initializer {
    if (_defaultVerifier == address(0)) {
      revert ZeroAddressNotAllowed();
    }

    for (uint256 i; i < _operators.length; ) {
      if (_operators[i] == address(0)) {
        revert ZeroAddressNotAllowed();
      }
      _grantRole(OPERATOR_ROLE, _operators[i]);
      unchecked {
        i++;
      }
    }

    _grantRole(DEFAULT_ADMIN_ROLE, _securityCouncil);

    __MessageService_init(_securityCouncil, _securityCouncil, _rateLimitPeriodInSeconds, _rateLimitAmountInWei);

    verifiers[0] = _defaultVerifier;
    currentL2BlockNumber = _initialL2BlockNumber;
    stateRootHashes[_initialL2BlockNumber] = _initialStateRootHash;
  }

  /**
   * @notice Adds or updates the verifier contract address for a proof type.
   * @dev DEFAULT_ADMIN_ROLE is required to execute.
   * @param _newVerifierAddress The address for the verifier contract.
   * @param _proofType The proof type being set/updated.
   **/
  function setVerifierAddress(address _newVerifierAddress, uint256 _proofType) external onlyRole(DEFAULT_ADMIN_ROLE) {
    if (_newVerifierAddress == address(0)) {
      revert ZeroAddressNotAllowed();
    }

    emit VerifierAddressChanged(_newVerifierAddress, _proofType, msg.sender);

    verifiers[_proofType] = _newVerifierAddress;
  }

  /**
   * @notice Finalizes blocks without using a proof.
   * @dev DEFAULT_ADMIN_ROLE is required to execute.
   * @param _blocksData The full BlockData collection - block, transaction and log data.
   **/
  function finalizeBlocksWithoutProof(
    BlockData[] calldata _blocksData
  ) external whenTypeNotPaused(GENERAL_PAUSE_TYPE) onlyRole(DEFAULT_ADMIN_ROLE) {
    _finalizeBlocks(_blocksData, new bytes(0), 0, bytes32(0), false);
  }

  /**
   * @notice Finalizes blocks using a proof.
   * @dev OPERATOR_ROLE is required to execute.
   * @dev If the verifier based on proof type is not found, it reverts.
   * @param _blocksData The full BlockData collection - block, transaction and log data.
   * @param _proof The proof to be verified with the proof type verifier contract.
   * @param _proofType The proof type to determine which verifier contract to use.
   * @param _parentStateRootHash The starting roothash for the last known block.
   **/
  function finalizeBlocks(
    BlockData[] calldata _blocksData,
    bytes calldata _proof,
    uint256 _proofType,
    bytes32 _parentStateRootHash
  )
    external
    whenTypeNotPaused(PROVING_SYSTEM_PAUSE_TYPE)
    whenTypeNotPaused(GENERAL_PAUSE_TYPE)
    onlyRole(OPERATOR_ROLE)
  {
    if (stateRootHashes[currentL2BlockNumber] != _parentStateRootHash) {
      revert StartingRootHashDoesNotMatch();
    }

    _finalizeBlocks(_blocksData, _proof, _proofType, _parentStateRootHash, true);
  }

  /**
   * @notice Finalizes blocks with or without using a proof depending on _shouldProve
   * @dev If the verifier based on proof type is not found, it reverts.
   * @param _blocksData The full BlockData collection - block, transaction and log data.
   * @param _proof The proof to be verified with the proof type verifier contract.
   * @param _proofType The proof type to determine which verifier contract to use.
   * @param _parentStateRootHash The starting roothash for the last known block.
   **/
  function _finalizeBlocks(
    BlockData[] calldata _blocksData,
    bytes memory _proof,
    uint256 _proofType,
    bytes32 _parentStateRootHash,
    bool _shouldProve
  ) private {
    uint256 currentBlockNumberTemp = currentL2BlockNumber;
    uint256 firstBlockNumber = currentBlockNumberTemp + 1;

    uint256[] memory timestamps = new uint256[](_blocksData.length);
    bytes32[] memory blockHashes = new bytes32[](_blocksData.length);
    bytes32[] memory hashOfRootHashes = new bytes32[](_blocksData.length + 1);

    hashOfRootHashes[0] = _parentStateRootHash;

    bytes32 hashOfTxHashes;
    bytes32 hashOfMessageHashes;

    for (uint256 i; i < _blocksData.length; ) {
      BlockData calldata blockInfo = _blocksData[i];

      if (blockInfo.l2BlockTimestamp >= block.timestamp) {
        revert BlockTimestampError();
      }

      hashOfTxHashes = _processBlockTransactions(blockInfo.transactions, blockInfo.batchReceptionIndices);
      hashOfMessageHashes = _processMessageHashes(blockInfo.l2ToL1MsgHashes);

      ++currentBlockNumberTemp;

      blockHashes[i] = keccak256(
        abi.encodePacked(
          hashOfTxHashes,
          hashOfMessageHashes,
          keccak256(abi.encodePacked(blockInfo.batchReceptionIndices)),
          keccak256(blockInfo.fromAddresses)
        )
      );

      timestamps[i] = blockInfo.l2BlockTimestamp;
      hashOfRootHashes[i + 1] = blockInfo.blockRootHash;

      emit BlockFinalized(currentBlockNumberTemp, blockInfo.blockRootHash);

      unchecked {
        i++;
      }
    }

    stateRootHashes[currentBlockNumberTemp] = _blocksData[_blocksData.length - 1].blockRootHash;
    currentTimestamp = _blocksData[_blocksData.length - 1].l2BlockTimestamp;
    currentL2BlockNumber = currentBlockNumberTemp;

    if (_shouldProve) {
      _verifyProof(
        uint256(
          keccak256(
            abi.encode(
              keccak256(abi.encodePacked(blockHashes)),
              firstBlockNumber,
              keccak256(abi.encodePacked(timestamps)),
              keccak256(abi.encodePacked(hashOfRootHashes))
            )
          )
        ) % MODULO_R,
        _proofType,
        _proof,
        _parentStateRootHash
      );
    }
  }

  /**
   * @notice Hashes all transactions individually and then hashes the packed hash array.
   * @dev Updates the outbox status on L1 as received.
   * @param _transactions The transactions in a particular block.
   * @param _batchReceptionIndices The indexes where the transaction type is the L1->L2 achoring message hashes transaction.
   **/
  function _processBlockTransactions(
    bytes[] calldata _transactions,
    uint16[] calldata _batchReceptionIndices
  ) internal returns (bytes32 hashOfTxHashes) {
    bytes32[] memory transactionHashes = new bytes32[](_transactions.length);

    if (_transactions.length == 0) {
      revert EmptyBlock();
    }

    for (uint256 i; i < _batchReceptionIndices.length; ) {
      _updateL1L2MessageStatusToReceived(
        TransactionDecoder.decodeTransaction(_transactions[_batchReceptionIndices[i]])._extractXDomainAddHashes()
      );

      unchecked {
        i++;
      }
    }

    for (uint256 i; i < _transactions.length; ) {
      transactionHashes[i] = keccak256(_transactions[i]);

      unchecked {
        i++;
      }
    }
    hashOfTxHashes = keccak256(abi.encodePacked(transactionHashes));
  }

  /**
   * @notice Anchors message hashes and hashes the packed hash array.
   * @dev Also adds L2->L1 sent message hashes for later claiming.
   * @param _messageHashes The hashes in the message sent event logs.
   **/
  function _processMessageHashes(bytes32[] calldata _messageHashes) internal returns (bytes32 hashOfLogHashes) {
    for (uint256 i; i < _messageHashes.length; ) {
      _addL2L1MessageHash(_messageHashes[i]);

      unchecked {
        i++;
      }
    }
    hashOfLogHashes = keccak256(abi.encodePacked(_messageHashes));
  }

  /**
   * @notice Verifies the proof with locally computed public inputs.
   * @dev If the verifier based on proof type is not found, it reverts with InvalidProofType.
   * @param _publicInputHash The full BlockData collection - block, transaction and log data.
   * @param _proofType The proof type to determine which verifier contract to use.
   * @param _proof The proof to be verified with the proof type verifier contract.
   * @param _parentStateRootHash The beginning roothash to start with.
   **/
  function _verifyProof(
    uint256 _publicInputHash,
    uint256 _proofType,
    bytes memory _proof,
    bytes32 _parentStateRootHash
  ) private {
    uint256[] memory input = new uint256[](1);
    input[0] = _publicInputHash;

    address verifierToUse = verifiers[_proofType];

    if (verifierToUse == address(0)) {
      revert InvalidProofType();
    }

    bool success = IPlonkVerifier(verifierToUse).Verify(_proof, input);
    if (!success) {
      revert InvalidProof();
    }

    emit BlocksVerificationDone(currentL2BlockNumber, _parentStateRootHash, stateRootHashes[currentL2BlockNumber]);
  }
}

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

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(account),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _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;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

// 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
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../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
// 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
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../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;
    }

    /**
     * @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 v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @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 v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// 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 MathUpgradeable {
    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
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMathUpgradeable {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 13 of 26 : IGenericErrors.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IGenericErrors {
  /**
   * @dev Thrown when a parameter is the zero address.
   */
  error ZeroAddressNotAllowed();
}

File 14 of 26 : IL1MessageManager.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IL1MessageManager {
  /**
   * @dev Emitted when L2->L1 message hashes have been added to L1 storage.
   */
  event L2L1MessageHashAddedToInbox(bytes32 indexed messageHash);

  /**
   * @dev Emitted when L1->L2 messages have been anchored on L2 and updated on L1.
   */
  event L1L2MessagesReceivedOnL2(bytes32[] messageHashes);

  /**
   * @dev Thrown when the message has been already sent.
   */
  error MessageAlreadySent();

  /**
   * @dev Thrown when the message has already been claimed.
   */
  error MessageDoesNotExistOrHasAlreadyBeenClaimed();

  /**
   * @dev Thrown when the message has already been received.
   */
  error MessageAlreadyReceived(bytes32 messageHash);

  /**
   * @dev Thrown when the L1->L2 message has not been sent.
   */
  error L1L2MessageNotSent(bytes32 messageHash);
}

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IMessageService {
  /**
   * @dev Emitted when a message is sent.
   * @dev We include the message hash to save hashing costs on the rollup.
   */
  event MessageSent(
    address indexed _from,
    address indexed _to,
    uint256 _fee,
    uint256 _value,
    uint256 _nonce,
    bytes _calldata,
    bytes32 indexed _messageHash
  );

  /**
   * @dev Emitted when a message is claimed.
   */
  event MessageClaimed(bytes32 indexed _messageHash);

  /**
   * @dev Thrown when fees are lower than the minimum fee.
   */
  error FeeTooLow();

  /**
   * @dev Thrown when fees are lower than value.
   */
  error ValueShouldBeGreaterThanFee();

  /**
   * @dev Thrown when the value sent is less than the fee.
   * @dev Value to forward on is msg.value - _fee.
   */
  error ValueSentTooLow();

  /**
   * @dev Thrown when the destination address reverts.
   */
  error MessageSendingFailed(address destination);

  /**
   * @dev Thrown when the destination address reverts.
   */
  error FeePaymentFailed(address recipient);

  /**
   * @notice Sends a message for transporting from the given chain.
   * @dev This function should be called with a msg.value = _value + _fee. The fee will be paid on the destination chain.
   * @param _to The destination address on the destination chain.
   * @param _fee The message service fee on the origin chain.
   * @param _calldata The calldata used by the destination message service to call the destination contract.
   */
  function sendMessage(address _to, uint256 _fee, bytes calldata _calldata) external payable;

  /**
   * @notice Deliver a message to the destination chain.
   * @notice Is called automatically by the Postman, dApp or end user.
   * @param _from The msg.sender calling the origin message service.
   * @param _to The destination address on the destination chain.
   * @param _value The value to be transferred to the destination address.
   * @param _fee The message service fee on the origin chain.
   * @param _feeRecipient Address that will receive the fees.
   * @param _calldata The calldata used by the destination message service to call/forward to the destination contract.
   * @param _nonce Unique message number.
   */
  function claimMessage(
    address _from,
    address _to,
    uint256 _fee,
    uint256 _value,
    address payable _feeRecipient,
    bytes calldata _calldata,
    uint256 _nonce
  ) external;

  /**
   * @notice Returns the original sender of the message on the origin layer.
   * @return The original sender of the message on the origin layer.
   */
  function sender() external view returns (address);
}

File 16 of 26 : IPauseManager.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IPauseManager {
  /**
   * @dev Thrown when a specific pause type is paused.
   */
  error IsPaused(bytes32 pauseType);

  /**
   * @dev Thrown when a specific pause type is not paused and expected to be.
   */
  error IsNotPaused(bytes32 pauseType);

  /**
   * @dev Emitted when a pause type is paused.
   */
  event Paused(address messageSender, bytes32 pauseType);

  /**
   * @dev Emitted when a pause type is unpaused.
   */
  event UnPaused(address messageSender, bytes32 pauseType);
}

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

/**
 * @title Contract to manage cross-chain messaging on L1 and rollup proving
 * @author ConsenSys Software Inc.
 */
interface IPlonkVerifier {
  /**
   * @notice Interface for verifier contracts.
   * @param _proof The proof used to verify.
   * @param _public_inputs The computed public inputs for the proof verification.
   */
  function Verify(bytes memory _proof, uint256[] memory _public_inputs) external returns (bool);
}

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IRateLimiter {
  /**
   * @dev Thrown when an amount breaches the limit in the period.
   */
  error RateLimitExceeded();

  /**
   * @dev Thrown when the period is initialised to zero.
   */
  error PeriodIsZero();

  /**
   * @dev Thrown when the limit is initialised to zero.
   */
  error LimitIsZero();

  /**
   * @dev Emitted when the amount in the period is reset to zero.
   */
  event AmountUsedInPeriodReset(address indexed resettingAddress);

  /**
   * @dev Emitted when the limit is changed.
   * @dev If the current used amount is higher than the new limit, the used amount is lowered to the limit.
   */
  event LimitAmountChanged(
    address indexed amountChangeBy,
    uint256 amount,
    bool amountUsedLoweredToLimit,
    bool usedAmountResetToZero
  );

  /**
   * @notice Resets the rate limit amount to the amount specified.
   * @param _amount New message hashes.
   */
  function resetRateLimitAmount(uint256 _amount) external;

  /**
   * @notice Resets the amount used in the period to zero.
   */
  function resetAmountUsedInPeriod() external;
}

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;

interface IZkEvmV2 {
  struct BlockData {
    bytes32 blockRootHash;
    uint32 l2BlockTimestamp;
    bytes[] transactions;
    bytes32[] l2ToL1MsgHashes;
    bytes fromAddresses;
    uint16[] batchReceptionIndices;
  }

  /**
   * @dev Emitted when a L2 block has been finalized on L1
   */
  event BlockFinalized(uint256 indexed blockNumber, bytes32 indexed stateRootHash);
  /**
   * @dev Emitted when a L2 blocks have been finalized on L1
   */
  event BlocksVerificationDone(uint256 indexed lastBlockFinalized, bytes32 startingRootHash, bytes32 finalRootHash);

  /**
   * @dev Emitted when a verifier is set for a particular proof type
   */
  event VerifierAddressChanged(
    address indexed verifierAddress,
    uint256 indexed proofType,
    address indexed verifierSetBy
  );

  /**
   * @dev Thrown when l2 block timestamp is not correct
   */
  error BlockTimestampError();

  /**
   * @dev Thrown when the starting rootHash does not match the existing state
   */
  error StartingRootHashDoesNotMatch();

  /**
   * @dev Thrown when block contains zero transactions
   */
  error EmptyBlock();

  /**
   * @dev Thrown when zk proof is empty bytes
   */
  error ProofIsEmpty();

  /**
   * @dev Thrown when zk proof type is invalid
   */
  error InvalidProofType();

  /**
   * @dev Thrown when zk proof is invalid
   */
  error InvalidProof();

  /**
   * @notice Adds or updated the verifier contract address for a proof type
   * @dev DEFAULT_ADMIN_ROLE is required to execute
   * @param _newVerifierAddress The address for the verifier contract
   * @param _proofType The proof type being set/updated
   **/
  function setVerifierAddress(address _newVerifierAddress, uint256 _proofType) external;

  /**
   * @notice Finalizes blocks without using a proof
   * @dev DEFAULT_ADMIN_ROLE is required to execute
   * @param _calldata The full BlockData collection - block, transaction and log data
   **/
  function finalizeBlocksWithoutProof(BlockData[] calldata _calldata) external;

  /**
   * @notice Finalizes blocks without using a proof
   * @dev OPERATOR_ROLE is required to execute
   * @dev If the verifier based on proof type is not found, it defaults to the default verifier type
   * @param _calldata The full BlockData collection - block, transaction and log data
   * @param _proof The proof to verified with the proof type verifier contract
   * @param _proofType The proof type to determine which verifier contract to use
   * @param _parentStateRootHash The beginning roothash to start with
   **/
  function finalizeBlocks(
    BlockData[] calldata _calldata,
    bytes calldata _proof,
    uint256 _proofType,
    bytes32 _parentStateRootHash
  ) external;
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

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

/**
 * @title Contract to manage cross-chain message hashes storage and status on L1.
 * @author ConsenSys Software Inc.
 */
abstract contract L1MessageManager is IL1MessageManager {
  uint8 public constant INBOX_STATUS_UNKNOWN = 0;
  uint8 public constant INBOX_STATUS_RECEIVED = 1;

  uint8 public constant OUTBOX_STATUS_UNKNOWN = 0;
  uint8 public constant OUTBOX_STATUS_SENT = 1;
  uint8 public constant OUTBOX_STATUS_RECEIVED = 2;

  /// @dev There is a uint216 worth of storage layout here.

  /// @dev Mapping to store L1->L2 message hashes status.
  /// @dev messageHash => messageStatus (0: unknown, 1: sent, 2: received).
  mapping(bytes32 => uint256) public outboxL1L2MessageStatus;

  /// @dev Mapping to store L2->L1 message hashes status.
  /// @dev messageHash => messageStatus (0: unknown, 1: received).
  mapping(bytes32 => uint256) public inboxL2L1MessageStatus;

  /// @dev Keep free storage slots for future implementation updates to avoid storage collision.
  // *******************************************************************************************
  // NB: THIS GAP HAS BEEN PUSHED OUT IN FAVOUR OF THE GAP INSIDE THE REENTRANCY CODE
  //uint256[50] private __gap;
  // NB: DO NOT USE THIS GAP
  // *******************************************************************************************

  /**
   * @notice Add a cross-chain L2->L1 message hash in storage.
   * @dev Once the event is emitted, it should be ready for claiming (post block finalization).
   * @param  _messageHash Hash of the message.
   */
  function _addL2L1MessageHash(bytes32 _messageHash) internal {
    if (inboxL2L1MessageStatus[_messageHash] != INBOX_STATUS_UNKNOWN) {
      revert MessageAlreadyReceived(_messageHash);
    }

    inboxL2L1MessageStatus[_messageHash] = INBOX_STATUS_RECEIVED;

    emit L2L1MessageHashAddedToInbox(_messageHash);
  }

  /**
   * @notice Update the status of L2->L1 message when a user claims a message on L1.
   * @dev The L2->L1 message is removed from storage.
   * @dev Due to the nature of the rollup, we should not get a second entry of this.
   * @param  _messageHash Hash of the message.
   */
  function _updateL2L1MessageStatusToClaimed(bytes32 _messageHash) internal {
    if (inboxL2L1MessageStatus[_messageHash] != INBOX_STATUS_RECEIVED) {
      revert MessageDoesNotExistOrHasAlreadyBeenClaimed();
    }

    delete inboxL2L1MessageStatus[_messageHash];
  }

  /**
   * @notice Add L1->L2 message hash in storage when a message is sent on L1.
   * @param  _messageHash Hash of the message.
   */
  function _addL1L2MessageHash(bytes32 _messageHash) internal {
    outboxL1L2MessageStatus[_messageHash] = OUTBOX_STATUS_SENT;
  }

  /**
   * @notice Update the status of L1->L2 messages as received when messages has been stored on L2.
   * @dev The expectation here is that the rollup is limited to 100 hashes being added here - array is not open ended.
   * @param  _messageHashes List of message hashes.
   */
  function _updateL1L2MessageStatusToReceived(bytes32[] memory _messageHashes) internal {
    uint256 messageHashArrayLength = _messageHashes.length;

    for (uint256 i; i < messageHashArrayLength; ) {
      bytes32 messageHash = _messageHashes[i];
      uint256 existingStatus = outboxL1L2MessageStatus[messageHash];

      if (existingStatus == OUTBOX_STATUS_UNKNOWN) {
        revert L1L2MessageNotSent(messageHash);
      }

      if (existingStatus != OUTBOX_STATUS_RECEIVED) {
        outboxL1L2MessageStatus[messageHash] = OUTBOX_STATUS_RECEIVED;
      }

      unchecked {
        i++;
      }
    }

    emit L1L2MessagesReceivedOnL2(_messageHashes);
  }
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

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

import { IMessageService } from "../../interfaces/IMessageService.sol";
import { IGenericErrors } from "../../interfaces/IGenericErrors.sol";
import { PauseManager } from "../lib/PauseManager.sol";
import { RateLimiter } from "../lib/RateLimiter.sol";
import { L1MessageManager } from "./L1MessageManager.sol";

/**
 * @title Contract to manage cross-chain messaging on L1.
 * @author ConsenSys Software Inc.
 */
abstract contract L1MessageService is
  Initializable,
  RateLimiter,
  L1MessageManager,
  ReentrancyGuardUpgradeable,
  PauseManager,
  IMessageService,
  IGenericErrors
{
  // @dev This is initialised to save user cost with existing slot.
  uint256 public nextMessageNumber;

  address private _messageSender;

  // Keep free storage slots for future implementation updates to avoid storage collision.
  uint256[50] private __gap;

  // @dev adding these should not affect storage as they are constants and are store in bytecode
  uint256 private constant REFUND_OVERHEAD_IN_GAS = 42000;

  /**
   * @notice Initialises underlying message service dependencies.
   * @dev _messageSender is initialised to a non-zero value for gas efficiency on claiming.
   * @param _limitManagerAddress The address owning the rate limiting management role.
   * @param _pauseManagerAddress The address owning the pause management role.
   * @param _rateLimitPeriod The period to rate limit against.
   * @param _rateLimitAmount The limit allowed for withdrawing the period.
   **/
  function __MessageService_init(
    address _limitManagerAddress,
    address _pauseManagerAddress,
    uint256 _rateLimitPeriod,
    uint256 _rateLimitAmount
  ) internal onlyInitializing {
    if (_limitManagerAddress == address(0)) {
      revert ZeroAddressNotAllowed();
    }

    if (_pauseManagerAddress == address(0)) {
      revert ZeroAddressNotAllowed();
    }

    __ERC165_init();
    __Context_init();
    __AccessControl_init();
    __RateLimiter_init(_rateLimitPeriod, _rateLimitAmount);

    _grantRole(RATE_LIMIT_SETTER_ROLE, _limitManagerAddress);
    _grantRole(PAUSE_MANAGER_ROLE, _pauseManagerAddress);

    nextMessageNumber = 1;
    _messageSender = address(123456789);
  }

  /**
   * @notice Adds a message for sending cross-chain and emits MessageSent.
   * @dev The message number is preset (nextMessageNumber) and only incremented at the end if successful for the next caller.
   * @dev This function should be called with a msg.value = _value + _fee. The fee will be paid on the destination chain.
   * @param _to The address the message is intended for.
   * @param _fee The fee being paid for the message delivery.
   * @param _calldata The calldata to pass to the recipient.
   **/
  function sendMessage(
    address _to,
    uint256 _fee,
    bytes calldata _calldata
  ) external payable whenTypeNotPaused(L1_L2_PAUSE_TYPE) whenTypeNotPaused(GENERAL_PAUSE_TYPE) {
    if (_to == address(0)) {
      revert ZeroAddressNotAllowed();
    }

    if (_fee > msg.value) {
      revert ValueSentTooLow();
    }

    uint256 messageNumber = nextMessageNumber;
    uint256 valueSent = msg.value - _fee;

    bytes32 messageHash = keccak256(abi.encode(msg.sender, _to, _fee, valueSent, messageNumber, _calldata));

    // @dev Status check and revert is in the message manager
    _addL1L2MessageHash(messageHash);

    nextMessageNumber++;

    emit MessageSent(msg.sender, _to, _fee, valueSent, messageNumber, _calldata, messageHash);
  }

  /**
   * @notice Claims and delivers a cross-chain message.
   * @dev _feeRecipient can be set to address(0) to receive as msg.sender.
   * @dev _messageSender is set temporarily when claiming and reset post. Used in sender().
   * @dev _messageSender is reset to address(123456789) to be more gas efficient.
   * @param _from The address of the original sender.
   * @param _to The address the message is intended for.
   * @param _fee The fee being paid for the message delivery.
   * @param _value The value to be transferred to the destination address.
   * @param _feeRecipient The recipient for the fee.
   * @param _calldata The calldata to pass to the recipient.
   * @param _nonce The unique auto generated nonce used when sending the message.
   **/
  function claimMessage(
    address _from,
    address _to,
    uint256 _fee,
    uint256 _value,
    address payable _feeRecipient,
    bytes calldata _calldata,
    uint256 _nonce
  ) external nonReentrant distributeFees(_fee, _to, _calldata, _feeRecipient) {
    _requireTypeNotPaused(L2_L1_PAUSE_TYPE);
    _requireTypeNotPaused(GENERAL_PAUSE_TYPE);

    bytes32 messageHash = keccak256(abi.encode(_from, _to, _fee, _value, _nonce, _calldata));

    // @dev Status check and revert is in the message manager.
    _updateL2L1MessageStatusToClaimed(messageHash);

    _addUsedAmount(_fee + _value);

    _messageSender = _from;

    (bool callSuccess, bytes memory returnData) = _to.call{ value: _value }(_calldata);
    if (!callSuccess) {
      if (returnData.length > 0) {
        assembly {
          let data_size := mload(returnData)
          revert(add(32, returnData), data_size)
        }
      } else {
        revert MessageSendingFailed(_to);
      }
    }

    _messageSender = address(123456789);

    emit MessageClaimed(messageHash);
  }

  /**
   * @notice Claims and delivers a cross-chain message.
   * @dev _messageSender is set temporarily when claiming.
   **/
  function sender() external view returns (address) {
    return _messageSender;
  }

  /**
   * @notice Function to receive funds for liquidity purposes.
   **/
  receive() external payable virtual {}

  /**
   * @notice The unspent fee is refunded if applicable.
   * @param _feeInWei The fee paid for delivery in Wei.
   * @param _to The recipient of the message and gas refund.
   * @param _calldata The calldata of the message.
   **/
  modifier distributeFees(
    uint256 _feeInWei,
    address _to,
    bytes calldata _calldata,
    address _feeRecipient
  ) {
    //pre-execution
    uint256 startingGas = gasleft();
    _;
    //post-execution

    // we have a fee
    if (_feeInWei > 0) {
      // default postman fee
      uint256 deliveryFee = _feeInWei;

      // do we have empty calldata?
      if (_calldata.length == 0) {
        bool isDestinationEOA;

        assembly {
          isDestinationEOA := iszero(extcodesize(_to))
        }

        // are we calling an EOA
        if (isDestinationEOA) {
          // initial + cost to call and refund minus gasleft
          deliveryFee = (startingGas + REFUND_OVERHEAD_IN_GAS - gasleft()) * tx.gasprice;

          if (_feeInWei > deliveryFee) {
            payable(_to).send(_feeInWei - deliveryFee);
          } else {
            deliveryFee = _feeInWei;
          }
        }
      }

      address feeReceiver = _feeRecipient == address(0) ? msg.sender : _feeRecipient;

      bool callSuccess = payable(feeReceiver).send(deliveryFee);
      if (!callSuccess) {
        revert FeePaymentFailed(feeReceiver);
      }
    }
  }
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

/**
 * @title Decoding functions for message service anchoring and bytes slicing.
 * @author ConsenSys Software Inc.
 * @notice You can use this to slice bytes and extract anchoring hashes from calldata.
 **/
library CodecV2 {
  /**
   * @notice Decodes a collection of bytes32 (hashes) from the calldata of a transaction.
   * @dev Extracts and decodes skipping the function selector (selector is expected in the input).
   * @dev A check beforehand must be performed to confirm this is the correct type of transaction.
   * @param _calldataWithSelector The calldata for the transaction.
   * @return bytes32[] - array of message hashes.
   **/
  function _extractXDomainAddHashes(bytes memory _calldataWithSelector) internal pure returns (bytes32[] memory) {
    assembly {
      let len := sub(mload(_calldataWithSelector), 4)
      _calldataWithSelector := add(_calldataWithSelector, 0x4)
      mstore(_calldataWithSelector, len)
    }

    return abi.decode(_calldataWithSelector, (bytes32[]));
  }
}

// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.19;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IPauseManager } from "../../interfaces/IPauseManager.sol";

/**
 * @title Contract to manage cross-chain function pausing.
 * @author ConsenSys Software Inc.
 */
abstract contract PauseManager is Initializable, IPauseManager, AccessControlUpgradeable {
  bytes32 public constant PAUSE_MANAGER_ROLE = keccak256("PAUSE_MANAGER_ROLE");

  bytes32 public constant GENERAL_PAUSE_TYPE = keccak256("GENERAL_PAUSE_TYPE");
  bytes32 public constant L1_L2_PAUSE_TYPE = keccak256("L1_L2_PAUSE_TYPE");
  bytes32 public constant L2_L1_PAUSE_TYPE = keccak256("L2_L1_PAUSE_TYPE");
  bytes32 public constant PROVING_SYSTEM_PAUSE_TYPE = keccak256("PROVING_SYSTEM_PAUSE_TYPE");

  mapping(bytes32 => bool) public pauseTypeStatuses;

  uint256[10] private _gap;

  /**
   * @dev Modifier to make a function callable only when the type is not paused.
   *
   * Requirements:
   *
   * - The type must not be paused.
   */
  modifier whenTypeNotPaused(bytes32 _pauseType) {
    _requireTypeNotPaused(_pauseType);
    _;
  }

  /**
   * @dev Modifier to make a function callable only when the type is paused.
   *
   * Requirements:
   *
   * - The type must not be paused.
   */
  modifier whenTypePaused(bytes32 _pauseType) {
    _requireTypePaused(_pauseType);
    _;
  }

  /**
   * @dev Throws if the type is not paused.
   * @param _pauseType The keccak256 pause type being checked,
   */
  function _requireTypePaused(bytes32 _pauseType) internal view virtual {
    if (!pauseTypeStatuses[_pauseType]) {
      revert IsNotPaused(_pauseType);
    }
  }

  /**
   * @dev Throws if the type is paused.
   * @param _pauseType The keccak256 pause type being checked,
   */
  function _requireTypeNotPaused(bytes32 _pauseType) internal view virtual {
    if (pauseTypeStatuses[_pauseType]) {
      revert IsPaused(_pauseType);
    }
  }

  /**
   * @notice Pauses functionality by specific type.
   * @dev Requires PAUSE_MANAGER_ROLE.
   * @param _pauseType keccak256 pause type.
   **/
  function pauseByType(bytes32 _pauseType) external whenTypeNotPaused(_pauseType) onlyRole(PAUSE_MANAGER_ROLE) {
    pauseTypeStatuses[_pauseType] = true;
    emit Paused(_msgSender(), _pauseType);
  }

  /**
   * @notice Unpauses functionality by specific type.
   * @dev Requires PAUSE_MANAGER_ROLE.
   * @param _pauseType keccak256 pause type.
   **/
  function unPauseByType(bytes32 _pauseType) external whenTypePaused(_pauseType) onlyRole(PAUSE_MANAGER_ROLE) {
    pauseTypeStatuses[_pauseType] = false;
    emit UnPaused(_msgSender(), _pauseType);
  }
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { IRateLimiter } from "../../interfaces/IRateLimiter.sol";

/**
 * @title Rate Limiter by period and amount using the block timestamp.
 * @author ConsenSys Software Inc.
 * @notice You can use this control numeric limits over a period using timestamp.
 **/
contract RateLimiter is Initializable, IRateLimiter, AccessControlUpgradeable {
  bytes32 public constant RATE_LIMIT_SETTER_ROLE = keccak256("RATE_LIMIT_SETTER_ROLE");

  uint256 public periodInSeconds; // how much time before limit resets.
  uint256 public limitInWei; // max ether to withdraw per period.

  // @dev Public for ease of consumption.
  // @notice The time at which the current period ends at.
  uint256 public currentPeriodEnd;

  // @dev Public for ease of consumption.
  // @notice Amounts already withdrawn this period.
  uint256 public currentPeriodAmountInWei;

  uint256[10] private _gap;

  /**
   * @notice Initialises the limits and period for the rate limiter.
   * @param _periodInSeconds The length of the period in seconds.
   * @param _limitInWei The limit allowed in the period in Wei.
   **/
  function __RateLimiter_init(uint256 _periodInSeconds, uint256 _limitInWei) internal onlyInitializing {
    if (_periodInSeconds == 0) {
      revert PeriodIsZero();
    }

    if (_limitInWei == 0) {
      revert LimitIsZero();
    }

    periodInSeconds = _periodInSeconds;
    limitInWei = _limitInWei;
    currentPeriodEnd = block.timestamp + _periodInSeconds;
  }

  /**
   * @notice Increments the amount used in the period.
   * @dev The amount determining logic is external to this (e.g. fees are included when calling here).
   * @dev Reverts if the limit is breached.
   * @param _usedAmount The amount used to be added.
   **/
  function _addUsedAmount(uint256 _usedAmount) internal {
    uint256 currentPeriodAmountTemp;

    if (currentPeriodEnd < block.timestamp) {
      currentPeriodEnd = block.timestamp + periodInSeconds;
      currentPeriodAmountTemp = _usedAmount;
    } else {
      currentPeriodAmountTemp = currentPeriodAmountInWei + _usedAmount;
    }

    if (currentPeriodAmountTemp > limitInWei) {
      revert RateLimitExceeded();
    }

    currentPeriodAmountInWei = currentPeriodAmountTemp;
  }

  /**
   * @notice Resets the rate limit amount.
   * @dev If the used amount is higher, it is set to the limit to avoid confusion/issues.
   * @dev Only the RATE_LIMIT_SETTER_ROLE is allowed to execute this function.
   * @dev Emits the LimitAmountChanged event.
   * @dev usedLimitAmountToSet will use the default value of zero if period has expired
   * @param _amount The amount to reset the limit to.
   **/
  function resetRateLimitAmount(uint256 _amount) external onlyRole(RATE_LIMIT_SETTER_ROLE) {
    uint256 usedLimitAmountToSet;
    bool amountUsedLoweredToLimit;
    bool usedAmountResetToZero;

    if (currentPeriodEnd < block.timestamp) {
      currentPeriodEnd = block.timestamp + periodInSeconds;
      usedAmountResetToZero = true;
    } else {
      if (_amount < currentPeriodAmountInWei) {
        usedLimitAmountToSet = _amount;
        amountUsedLoweredToLimit = true;
      }
    }

    limitInWei = _amount;

    if (usedAmountResetToZero || amountUsedLoweredToLimit) {
      currentPeriodAmountInWei = usedLimitAmountToSet;
    }

    emit LimitAmountChanged(_msgSender(), _amount, amountUsedLoweredToLimit, usedAmountResetToZero);
  }

  /**
   * @notice Resets the amount used to zero.
   * @dev Only the RATE_LIMIT_SETTER_ROLE is allowed to execute this function.
   * @dev Emits the AmountUsedInPeriodReset event.
   **/
  function resetAmountUsedInPeriod() external onlyRole(RATE_LIMIT_SETTER_ROLE) {
    currentPeriodAmountInWei = 0;

    emit AmountUsedInPeriodReset(_msgSender());
  }
}

// SPDX-License-Identifier: Apache-2.0

/**
 * @author Hamdi Allam hamdi.allam97@gmail.com
 * @notice Please reach out with any questions or concerns.
 */
pragma solidity ^0.8.19;

error NotList();
error WrongBytesLength();
error NoNext();
error MemoryOutOfBounds(uint256 inde);

library RLPReader {
  uint8 internal constant STRING_SHORT_START = 0x80;
  uint8 internal constant STRING_LONG_START = 0xb8;
  uint8 internal constant LIST_SHORT_START = 0xc0;
  uint8 internal constant LIST_LONG_START = 0xf8;
  uint8 internal constant LIST_SHORT_START_MAX = 0xf7;
  uint8 internal constant WORD_SIZE = 32;

  struct RLPItem {
    uint256 len;
    uint256 memPtr;
  }

  struct Iterator {
    RLPItem item; // Item that's being iterated over.
    uint256 nextPtr; // Position of the next item in the list.
  }

  /**
   * @dev Returns the next element in the iteration. Reverts if it has no next element.
   * @param _self The iterator.
   * @return nextItem The next element in the iteration.
   */
  function _next(Iterator memory _self) internal pure returns (RLPItem memory nextItem) {
    if (!_hasNext(_self)) {
      revert NoNext();
    }

    uint256 ptr = _self.nextPtr;
    uint256 itemLength = _itemLength(ptr);
    _self.nextPtr = ptr + itemLength;

    nextItem.len = itemLength;
    nextItem.memPtr = ptr;
  }

  /**
   * @dev Returns the number 'skiptoNum' element in the iteration.
   * @param _self The iterator.
   * @param _skipToNum Element position in the RLP item iterator to return.
   * @return item The number 'skipToNum' element in the iteration.
   */
  function _skipTo(Iterator memory _self, uint256 _skipToNum) internal pure returns (RLPItem memory item) {
    uint256 lenX;
    uint256 memPtrStart = _self.item.memPtr;
    uint256 endPtr;
    uint256 byte0;
    uint256 byteLen;

    assembly {
      // get first byte to know if it is a short/long list
      byte0 := byte(0, mload(memPtrStart))

      // yul has no if/else so if it a short list ( < long list start )
      switch lt(byte0, LIST_LONG_START)
      case 1 {
        // the length is just the difference in bytes
        lenX := sub(byte0, 0xc0)
      }
      case 0 {
        // at this point we care only about lists, so this is the default
        // get how many next bytes indicate the list length
        byteLen := sub(byte0, 0xf7)

        // move one over to the list length start
        memPtrStart := add(memPtrStart, 1)

        // shift over grabbing the bytelen elements
        lenX := div(mload(memPtrStart), exp(256, sub(32, byteLen)))
      }

      // get the end
      endPtr := add(memPtrStart, lenX)
    }

    uint256 ptr = _self.nextPtr;
    uint256 itemLength = _itemLength(ptr);
    _self.nextPtr = ptr + itemLength;

    for (uint256 i; i < _skipToNum - 1; ) {
      ptr = _self.nextPtr;
      if (ptr > endPtr) revert MemoryOutOfBounds(endPtr);
      itemLength = _itemLength(ptr);
      _self.nextPtr = ptr + itemLength;

      unchecked {
        i++;
      }
    }

    item.len = itemLength;
    item.memPtr = ptr;
  }

  /**
   * @dev Returns true if the iteration has more elements.
   * @param _self The iterator.
   * @return True if the iteration has more elements.
   */
  function _hasNext(Iterator memory _self) internal pure returns (bool) {
    RLPItem memory item = _self.item;
    return _self.nextPtr < item.memPtr + item.len;
  }

  /**
   * @param item RLP encoded bytes.
   * @return newItem The RLP item.
   */
  function _toRlpItem(bytes memory item) internal pure returns (RLPItem memory newItem) {
    uint256 memPtr;

    assembly {
      memPtr := add(item, 0x20)
    }

    newItem.len = item.length;
    newItem.memPtr = memPtr;
  }

  /**
   * @dev Creates an iterator. Reverts if item is not a list.
   * @param _self The RLP item.
   * @return iterator 'Iterator' over the item.
   */
  function _iterator(RLPItem memory _self) internal pure returns (Iterator memory iterator) {
    if (!_isList(_self)) {
      revert NotList();
    }

    uint256 ptr = _self.memPtr + _payloadOffset(_self.memPtr);
    iterator.item = _self;
    iterator.nextPtr = ptr;
  }

  /**
   * @param _item The RLP item.
   * @return (memPtr, len) Tuple: Location of the item's payload in memory.
   */
  function _payloadLocation(RLPItem memory _item) internal pure returns (uint256, uint256) {
    uint256 offset = _payloadOffset(_item.memPtr);
    uint256 memPtr = _item.memPtr + offset;
    uint256 len = _item.len - offset; // data length
    return (memPtr, len);
  }

  /**
   * @param _item The RLP item.
   * @return Indicator whether encoded payload is a list.
   */
  function _isList(RLPItem memory _item) internal pure returns (bool) {
    if (_item.len == 0) return false;

    uint8 byte0;
    uint256 memPtr = _item.memPtr;
    assembly {
      byte0 := byte(0, mload(memPtr))
    }

    if (byte0 < LIST_SHORT_START) return false;
    return true;
  }

  /**
   * @param _item The RLP item.
   * @return result Returns the item as an address.
   */
  function _toAddress(RLPItem memory _item) internal pure returns (address) {
    // 1 byte for the length prefix
    if (_item.len != 21) {
      revert WrongBytesLength();
    }

    return address(uint160(_toUint(_item)));
  }

  /**
   * @param _item The RLP item.
   * @return result Returns the item as a uint256.
   */
  function _toUint(RLPItem memory _item) internal pure returns (uint256 result) {
    if (_item.len == 0 || _item.len > 33) {
      revert WrongBytesLength();
    }

    (uint256 memPtr, uint256 len) = _payloadLocation(_item);

    assembly {
      result := mload(memPtr)

      // Shfit to the correct location if neccesary.
      if lt(len, 32) {
        result := div(result, exp(256, sub(32, len)))
      }
    }
  }

  /**
   * @param _item The RLP item.
   * @return result Returns the item as bytes.
   */
  function _toBytes(RLPItem memory _item) internal pure returns (bytes memory result) {
    if (_item.len == 0) {
      revert WrongBytesLength();
    }

    (uint256 memPtr, uint256 len) = _payloadLocation(_item);
    result = new bytes(len);

    uint256 destPtr;
    assembly {
      destPtr := add(0x20, result)
    }

    _copy(memPtr, destPtr, len);
  }

  /*
   * Private Helpers
   */

  /**
   * @param _memPtr Item memory pointer.
   * @return Entire RLP item byte length.
   */
  function _itemLength(uint256 _memPtr) private pure returns (uint256) {
    uint256 itemLen;
    uint256 dataLen;
    uint256 byte0;
    assembly {
      byte0 := byte(0, mload(_memPtr))
    }

    if (byte0 < STRING_SHORT_START) itemLen = 1;
    else if (byte0 < STRING_LONG_START) itemLen = byte0 - STRING_SHORT_START + 1;
    else if (byte0 < LIST_SHORT_START) {
      assembly {
        let byteLen := sub(byte0, 0xb7) // # Of bytes the actual length is.
        _memPtr := add(_memPtr, 1) // Skip over the first byte.

        /* 32 byte word size */
        dataLen := div(mload(_memPtr), exp(256, sub(32, byteLen))) // Right shifting to get the len.
        itemLen := add(dataLen, add(byteLen, 1))
      }
    } else if (byte0 < LIST_LONG_START) {
      itemLen = byte0 - LIST_SHORT_START + 1;
    } else {
      assembly {
        let byteLen := sub(byte0, 0xf7)
        _memPtr := add(_memPtr, 1)

        dataLen := div(mload(_memPtr), exp(256, sub(32, byteLen))) // Right shifting to the correct length.
        itemLen := add(dataLen, add(byteLen, 1))
      }
    }

    return itemLen;
  }

  /**
   * @param _memPtr Item memory pointer.
   * @return Number of bytes until the data.
   */
  function _payloadOffset(uint256 _memPtr) private pure returns (uint256) {
    uint256 byte0;
    assembly {
      byte0 := byte(0, mload(_memPtr))
    }

    if (byte0 < STRING_SHORT_START) return 0;
    else if (byte0 < STRING_LONG_START || (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)) return 1;
    else if (byte0 < LIST_SHORT_START)
      // being explicit
      return byte0 - (STRING_LONG_START - 1) + 1;
    else return byte0 - (LIST_LONG_START - 1) + 1;
  }

  /**
   * @param _src Pointer to source.
   * @param _dest Pointer to destination.
   * @param _len Amount of memory to copy from the source.
   */
  function _copy(uint256 _src, uint256 _dest, uint256 _len) private pure {
    if (_len == 0) return;

    // copy as many word sizes as possible
    for (; _len >= WORD_SIZE; _len -= WORD_SIZE) {
      assembly {
        mstore(_dest, mload(_src))
      }

      _src += WORD_SIZE;
      _dest += WORD_SIZE;
    }

    if (_len > 0) {
      // Left over bytes. Mask is used to remove unwanted bytes from the word.
      uint256 mask = 256 ** (WORD_SIZE - _len) - 1;
      assembly {
        let srcpart := and(mload(_src), not(mask)) // Zero out src.
        let destpart := and(mload(_dest), mask) // Retrieve the bytes.
        mstore(_dest, or(destpart, srcpart))
      }
    }
  }
}

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.19;

import { RLPReader } from "./Rlp.sol";

using RLPReader for RLPReader.RLPItem;
using RLPReader for RLPReader.Iterator;
using RLPReader for bytes;

/*
 * dev Thrown when the transaction data length is too short.
 */
error TransactionShort();

/*
 * dev Thrown when the transaction type is unknown.
 */
error UnknownTransactionType();

/**
 * @title Contract to decode RLP formatted transactions.
 * @author ConsenSys Software Inc.
 */
library TransactionDecoder {
  /**
   * @notice Decodes the transaction extracting the calldata.
   * @param _transaction The RLP transaction.
   * @return data Returns the transaction calldata as bytes.
   */
  function decodeTransaction(bytes calldata _transaction) internal pure returns (bytes memory) {
    if (_transaction.length < 1) {
      revert TransactionShort();
    }

    bytes1 version = _transaction[0];

    if (version == 0x01) {
      return _decodeEIP2930Transaction(_transaction);
    }

    if (version == 0x02) {
      return _decodeEIP1559Transaction(_transaction);
    }

    if (version >= 0xc0) {
      return _decodeLegacyTransaction(_transaction);
    }

    revert UnknownTransactionType();
  }

  /**
   * @notice Decodes the EIP1559 transaction extracting the calldata.
   * @param _transaction The RLP transaction.
   * @return data Returns the transaction calldata as bytes.
   */
  function _decodeEIP1559Transaction(bytes calldata _transaction) private pure returns (bytes memory data) {
    bytes memory txData = _transaction[1:]; // skip the version byte

    RLPReader.RLPItem memory rlp = txData._toRlpItem();
    RLPReader.Iterator memory it = rlp._iterator();

    data = it._skipTo(8)._toBytes();
  }

  /**
   * @notice Decodes the EIP29230 transaction extracting the calldata.
   * @param _transaction The RLP transaction.
   * @return data Returns the transaction calldata as bytes.
   */
  function _decodeEIP2930Transaction(bytes calldata _transaction) private pure returns (bytes memory data) {
    bytes memory txData = _transaction[1:]; // skip the version byte

    RLPReader.RLPItem memory rlp = txData._toRlpItem();
    RLPReader.Iterator memory it = rlp._iterator();

    data = it._skipTo(7)._toBytes();
  }

  /**
   * @notice Decodes the legacy transaction extracting the calldata.
   * @param _transaction The RLP transaction.
   * @return data Returns the transaction calldata as bytes.
   */
  function _decodeLegacyTransaction(bytes calldata _transaction) private pure returns (bytes memory data) {
    bytes memory txData = _transaction;

    RLPReader.RLPItem memory rlp = txData._toRlpItem();
    RLPReader.Iterator memory it = rlp._iterator();

    data = it._skipTo(6)._toBytes();
  }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BlockTimestampError","type":"error"},{"inputs":[],"name":"EmptyBlock","type":"error"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"FeePaymentFailed","type":"error"},{"inputs":[],"name":"FeeTooLow","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidProofType","type":"error"},{"inputs":[{"internalType":"bytes32","name":"pauseType","type":"bytes32"}],"name":"IsNotPaused","type":"error"},{"inputs":[{"internalType":"bytes32","name":"pauseType","type":"bytes32"}],"name":"IsPaused","type":"error"},{"inputs":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"L1L2MessageNotSent","type":"error"},{"inputs":[],"name":"LimitIsZero","type":"error"},{"inputs":[{"internalType":"uint256","name":"inde","type":"uint256"}],"name":"MemoryOutOfBounds","type":"error"},{"inputs":[{"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"MessageAlreadyReceived","type":"error"},{"inputs":[],"name":"MessageAlreadySent","type":"error"},{"inputs":[],"name":"MessageDoesNotExistOrHasAlreadyBeenClaimed","type":"error"},{"inputs":[{"internalType":"address","name":"destination","type":"address"}],"name":"MessageSendingFailed","type":"error"},{"inputs":[],"name":"NotList","type":"error"},{"inputs":[],"name":"PeriodIsZero","type":"error"},{"inputs":[],"name":"ProofIsEmpty","type":"error"},{"inputs":[],"name":"RateLimitExceeded","type":"error"},{"inputs":[],"name":"StartingRootHashDoesNotMatch","type":"error"},{"inputs":[],"name":"TransactionShort","type":"error"},{"inputs":[],"name":"UnknownTransactionType","type":"error"},{"inputs":[],"name":"ValueSentTooLow","type":"error"},{"inputs":[],"name":"ValueShouldBeGreaterThanFee","type":"error"},{"inputs":[],"name":"WrongBytesLength","type":"error"},{"inputs":[],"name":"ZeroAddressNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"resettingAddress","type":"address"}],"name":"AmountUsedInPeriodReset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"stateRootHash","type":"bytes32"}],"name":"BlockFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lastBlockFinalized","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"startingRootHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"finalRootHash","type":"bytes32"}],"name":"BlocksVerificationDone","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32[]","name":"messageHashes","type":"bytes32[]"}],"name":"L1L2MessagesReceivedOnL2","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"L2L1MessageHashAddedToInbox","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"amountChangeBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"amountUsedLoweredToLimit","type":"bool"},{"indexed":false,"internalType":"bool","name":"usedAmountResetToZero","type":"bool"}],"name":"LimitAmountChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_messageHash","type":"bytes32"}],"name":"MessageClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_calldata","type":"bytes"},{"indexed":true,"internalType":"bytes32","name":"_messageHash","type":"bytes32"}],"name":"MessageSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"messageSender","type":"address"},{"indexed":false,"internalType":"bytes32","name":"pauseType","type":"bytes32"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"messageSender","type":"address"},{"indexed":false,"internalType":"bytes32","name":"pauseType","type":"bytes32"}],"name":"UnPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"verifierAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"proofType","type":"uint256"},{"indexed":true,"internalType":"address","name":"verifierSetBy","type":"address"}],"name":"VerifierAddressChanged","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GENERAL_PAUSE_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INBOX_STATUS_RECEIVED","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INBOX_STATUS_UNKNOWN","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L1_L2_PAUSE_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_L1_PAUSE_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OUTBOX_STATUS_RECEIVED","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OUTBOX_STATUS_SENT","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OUTBOX_STATUS_UNKNOWN","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSE_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROVING_SYSTEM_PAUSE_TYPE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_LIMIT_SETTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"address payable","name":"_feeRecipient","type":"address"},{"internalType":"bytes","name":"_calldata","type":"bytes"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"claimMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentL2BlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentPeriodAmountInWei","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentPeriodEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"blockRootHash","type":"bytes32"},{"internalType":"uint32","name":"l2BlockTimestamp","type":"uint32"},{"internalType":"bytes[]","name":"transactions","type":"bytes[]"},{"internalType":"bytes32[]","name":"l2ToL1MsgHashes","type":"bytes32[]"},{"internalType":"bytes","name":"fromAddresses","type":"bytes"},{"internalType":"uint16[]","name":"batchReceptionIndices","type":"uint16[]"}],"internalType":"struct IZkEvmV2.BlockData[]","name":"_blocksData","type":"tuple[]"},{"internalType":"bytes","name":"_proof","type":"bytes"},{"internalType":"uint256","name":"_proofType","type":"uint256"},{"internalType":"bytes32","name":"_parentStateRootHash","type":"bytes32"}],"name":"finalizeBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"blockRootHash","type":"bytes32"},{"internalType":"uint32","name":"l2BlockTimestamp","type":"uint32"},{"internalType":"bytes[]","name":"transactions","type":"bytes[]"},{"internalType":"bytes32[]","name":"l2ToL1MsgHashes","type":"bytes32[]"},{"internalType":"bytes","name":"fromAddresses","type":"bytes"},{"internalType":"uint16[]","name":"batchReceptionIndices","type":"uint16[]"}],"internalType":"struct IZkEvmV2.BlockData[]","name":"_blocksData","type":"tuple[]"}],"name":"finalizeBlocksWithoutProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"inboxL2L1MessageStatus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_initialStateRootHash","type":"bytes32"},{"internalType":"uint256","name":"_initialL2BlockNumber","type":"uint256"},{"internalType":"address","name":"_defaultVerifier","type":"address"},{"internalType":"address","name":"_securityCouncil","type":"address"},{"internalType":"address[]","name":"_operators","type":"address[]"},{"internalType":"uint256","name":"_rateLimitPeriodInSeconds","type":"uint256"},{"internalType":"uint256","name":"_rateLimitAmountInWei","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"limitInWei","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextMessageNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"outboxL1L2MessageStatus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_pauseType","type":"bytes32"}],"name":"pauseByType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"pauseTypeStatuses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodInSeconds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resetAmountUsedInPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"resetRateLimitAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"sender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newVerifierAddress","type":"address"},{"internalType":"uint256","name":"_proofType","type":"uint256"}],"name":"setVerifierAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stateRootHashes","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_pauseType","type":"bytes32"}],"name":"unPauseByType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"verifiers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61409b80620000f36000396000f3fe6080604052600436106102d55760003560e01c80638be745d111610179578063b45a4f2c116100d6578063c1dc0f071161008a578063d547741f11610064578063d547741f1461085f578063d84f91e81461087f578063f5b541a6146108b357600080fd5b8063c1dc0f07146107f9578063c21169741461080f578063cc5782f61461082f57600080fd5b8063b837dbe9116100bb578063b837dbe914610799578063bf3e7505146107af578063c0729ab1146107e357600080fd5b8063b45a4f2c14610745578063b4a5a4b71461076557600080fd5b8063a217fddf1161012d578063ac1eff6811610112578063ac1eff68146106d6578063ad422ff01461071a578063aea4f7451461073057600080fd5b8063a217fddf1461068d578063abd6230d146106a257600080fd5b806391d148541161015e57806391d1485414610627578063986fcddd146105a45780639f3ce55a1461067a57600080fd5b80638be745d1146105d957806390dad3f61461060757600080fd5b8063557eac7311610232578063695378f5116101e65780637973ead6116101c05780637973ead6146105845780637d1e8c55146105a45780638264bd82146105b957600080fd5b8063695378f5146105245780636a6379671461053b57806373bd07b71461056f57600080fd5b80635b7eb4bd116102175780635b7eb4bd1461042e5780635c721a0c146104ab57806367e404ce146104d857600080fd5b8063557eac7314610475578063587944561461049557600080fd5b806336568abe116102895780634165d6dd1161026e5780634165d6dd1461040e57806348922ab71461042e578063491e09361461045557600080fd5b806336568abe146103c15780633fc08b65146103e157600080fd5b80631e2ff94f116102ba5780631e2ff94f14610358578063248a9ca31461036f5780632f2ff15d1461039f57600080fd5b806301ffc9a7146102e157806311314d0f1461031657600080fd5b366102dc57005b600080fd5b3480156102ed57600080fd5b506103016102fc36600461342f565b6108e7565b60405190151581526020015b60405180910390f35b34801561032257600080fd5b5061034a7f9a80e24e463f00a8763c4dcec6a92d07d33272fa5db895d8589be70dccb002df81565b60405190815260200161030d565b34801561036457600080fd5b5061034a6101185481565b34801561037b57600080fd5b5061034a61038a366004613471565b60009081526065602052604090206001015490565b3480156103ab57600080fd5b506103bf6103ba3660046134ac565b610980565b005b3480156103cd57600080fd5b506103bf6103dc3660046134ac565b6109aa565b3480156103ed57600080fd5b5061034a6103fc366004613471565b60a56020526000908152604090205481565b34801561041a57600080fd5b506103bf61042936600461356a565b610a62565b34801561043a57600080fd5b50610443600181565b60405160ff909116815260200161030d565b34801561046157600080fd5b506103bf6104703660046135e8565b610b7e565b34801561048157600080fd5b506103bf610490366004613471565b610f03565b3480156104a157600080fd5b5061034a60995481565b3480156104b757600080fd5b5061034a6104c6366004613471565b60a66020526000908152604090205481565b3480156104e457600080fd5b5060e55473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161030d565b34801561053057600080fd5b5061034a6101195481565b34801561054757600080fd5b5061034a7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b081565b34801561057b57600080fd5b50610443600281565b34801561059057600080fd5b506103bf61059f36600461367e565b610fcb565b3480156105b057600080fd5b50610443600081565b3480156105c557600080fd5b506103bf6105d4366004613471565b611311565b3480156105e557600080fd5b5061034a6105f4366004613471565b61011a6020526000908152604090205481565b34801561061357600080fd5b506103bf610622366004613709565b6113d7565b34801561063357600080fd5b506103016106423660046134ac565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6103bf61068836600461374b565b611431565b34801561069957600080fd5b5061034a600081565b3480156106ae57600080fd5b5061034a7f21ea2f4fee4bcb623de15ac222ea5c1464307d884f23394b78ddc07f9c9c7cd881565b3480156106e257600080fd5b506104ff6106f1366004613471565b61011b6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561072657600080fd5b5061034a60985481565b34801561073c57600080fd5b506103bf6115fa565b34801561075157600080fd5b506103bf610760366004613471565b611656565b34801561077157600080fd5b5061034a7f3a56b1bd788a764cbd923badb6d0719f21f520455285bf6877e636d08708878d81565b3480156107a557600080fd5b5061034a60e45481565b3480156107bb57600080fd5b5061034a7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d8281565b3480156107ef57600080fd5b5061034a609a5481565b34801561080557600080fd5b5061034a60975481565b34801561081b57600080fd5b506103bf61082a3660046137a7565b6116e5565b34801561083b57600080fd5b5061030161084a366004613471565b60d96020526000908152604090205460ff1681565b34801561086b57600080fd5b506103bf61087a3660046134ac565b6117d7565b34801561088b57600080fd5b5061034a7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2681565b3480156108bf57600080fd5b5061034a7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061097a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60008281526065602052604090206001015461099b816117fc565b6109a58383611809565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610a54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610a5e82826118fd565b5050565b7f3a56b1bd788a764cbd923badb6d0719f21f520455285bf6877e636d08708878d610a8c816119b8565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0610ab6816119b8565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610ae0816117fc565b61011954600090815261011a60205260409020548414610b2c576040517fead4c30e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b73898989898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b92508a915060019050611a04565b505050505050505050565b610b86611ef0565b858784848760005a9050610bb97f21ea2f4fee4bcb623de15ac222ea5c1464307d884f23394b78ddc07f9c9c7cd86119b8565b610be27f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b06119b8565b60008e8e8e8e8b8e8e604051602001610c01979695949392919061381c565b604051602081830303815290604052805190602001209050610c2281611f63565b610c34610c2f8d8f6138a4565b611fbc565b8e60e560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808f73ffffffffffffffffffffffffffffffffffffffff168e8d8d604051610ca09291906138b7565b60006040518083038185875af1925050503d8060008114610cdd576040519150601f19603f3d011682016040523d82523d6000602084013e610ce2565b606091505b509150915081610d4c57805115610cfc5780518082602001fd5b8f6040517f54613443000000000000000000000000000000000000000000000000000000008152600401610a4b919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b60e580547fffffffffffffffffffffffff00000000000000000000000000000000000000001663075bcd1517905560405183907fa4c827e719e911e8f19393ccdb85b5102f08f0910604d340ba38390b7ff2ab0e90600090a2505086159050610ee957856000849003610e3557853b158015610e33573a5a610dd061a410866138a4565b610dda91906138c7565b610de491906138da565b915081881115610e2f5773ffffffffffffffffffffffffffffffffffffffff87166108fc610e12848b6138c7565b6040518115909202916000818181858888f1935050505050610e33565b8791505b505b600073ffffffffffffffffffffffffffffffffffffffff841615610e595783610e5b565b335b905060008173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050905080610ee5576040517fa57c4df400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610a4b565b5050505b505050505050610ef9600160a755565b5050505050505050565b7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d82610f2d816117fc565b6000806000426099541015610f5457609754610f4990426138a4565b609955506001610f66565b609a54851015610f6657849250600191505b60988590558080610f745750815b15610f7f57609a8390555b60408051868152831515602082015282151581830152905133917fbc3dc0cb5c15c51c81316450d44048838bb478b9809447d01c766a06f3e9f2c8919081900360600190a25050505050565b600054610100900460ff1615808015610feb5750600054600160ff909116105b806110055750303b158015611005575060005460ff166001145b611091576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610a4b565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156110ef57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff871661113c576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8481101561121557600086868381811061115b5761115b6138f1565b90506020020160208101906111709190613920565b73ffffffffffffffffffffffffffffffffffffffff16036111bd576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61120d7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298787848181106111f3576111f36138f1565b90506020020160208101906112089190613920565b611809565b60010161113f565b50611221600087611809565b61122d86878585612032565b7f033d11f27e62ab919708ec716731da80d261a6e4253259b7acde9bf89d28ec1880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8916179055610119889055600088815261011a602052604090208990558015610b7357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b8061131b816119b8565b7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a26611345816117fc565b600083815260d96020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557fc343aefb875672fb1857ecda2bdf9fa822ff1e924e3714f6a3d88c5199dee2616113a43390565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252602082018690520160405180910390a1505050565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0611401816119b8565b600061140c816117fc565b6040805160008082526020820190925261142b91869186918080611a04565b50505050565b7f9a80e24e463f00a8763c4dcec6a92d07d33272fa5db895d8589be70dccb002df61145b816119b8565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0611485816119b8565b73ffffffffffffffffffffffffffffffffffffffff86166114d2576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3485111561150c576040517fb03b693200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e454600061151b87346138c7565b9050600033898984868b8b60405160200161153c979695949392919061381c565b60405160208183030381529060405280519060200120905061156c81600090815260a56020526040902060019055565b60e4805490600061157c8361396c565b9190505550808973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe856c2b8bd4eb0027ce32eeaf595c21b0b6b4644b326e5b7bd80a1cf8db72e6c8b86888d8d6040516115e79594939291906139a4565b60405180910390a4505050505050505050565b7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d82611624816117fc565b6000609a81905560405133917fba88c025b0cbb77022c0c487beef24f759f1e4be2f51a205bc427cee19c2eaa691a250565b8061166081612212565b7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2661168a816117fc565b600083815260d96020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557fb54c82d9fabaaa460c07181bb36c08c0e72d79293e77a42ac273c81d2a54281b336113a4565b60006116f0816117fc565b73ffffffffffffffffffffffffffffffffffffffff831661173d576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040513390839073ffffffffffffffffffffffffffffffffffffffff8616907f4ea861139068e7701a770b8975bb54b6f8f446897fac206dd29424035b4a61eb90600090a450600090815261011b6020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000828152606560205260409020600101546117f2816117fc565b6109a583836118fd565b611806813361225d565b50565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a5e57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561189f3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610a5e57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260d9602052604090205460ff1615611806576040517f8698dd2b00000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b610119546000611a158260016138a4565b905060008767ffffffffffffffff811115611a3257611a3261393d565b604051908082528060200260200182016040528015611a5b578160200160208202803683370190505b50905060008867ffffffffffffffff811115611a7957611a7961393d565b604051908082528060200260200182016040528015611aa2578160200160208202803683370190505b5090506000611ab28a60016138a4565b67ffffffffffffffff811115611aca57611aca61393d565b604051908082528060200260200182016040528015611af3578160200160208202803683370190505b5090508681600081518110611b0a57611b0a6138f1565b60200260200101818152505060008060005b8c811015611d4857368e8e83818110611b3757611b376138f1565b9050602002810190611b4991906139d5565b905042611b5c6040830160208401613a13565b63ffffffff1610611b99576040517fd4a3081200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bbb611ba96040830183613a39565b611bb660a0850185613a39565b612317565b9350611bd2611bcd6060830183613a39565b6124b1565b9250611bdd8961396c565b98508383611bee60a0840184613a39565b604051602001611bff929190613ab8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528051602090910120611c426080850185613af3565b604051611c509291906138b7565b604051908190038120611c7e9493929160200193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120868381518110611ca657611ca66138f1565b602002602001018181525050806020016020810190611cc59190613a13565b63ffffffff16878381518110611cdd57611cdd6138f1565b6020908102919091010152803585611cf68460016138a4565b81518110611d0657611d066138f1565b60209081029190910101526040518135908a907ff2c535759092d16e9334a11dd9b52eca543f1d9cca5ba9d16c472aef009de43290600090a350600101611b1c565b508c8c611d566001826138c7565b818110611d6557611d656138f1565b9050602002810190611d7791906139d5565b600088815261011a60205260409020903590558c8c611d976001826138c7565b818110611da657611da66138f1565b9050602002810190611db891906139d5565b611dc9906040810190602001613a13565b63ffffffff16610118556101198790558715611ee157611ee17f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000185604051602001611e149190613b58565b604051602081830303815290604052805190602001208888604051602001611e3c9190613b58565b6040516020818303038152906040528051906020012087604051602001611e639190613b58565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120908301959095528101929092526060820152608081019190915260a0016040516020818303038152906040528051906020012060001c611ed99190613b8e565b8b8d8c612518565b50505050505050505050505050565b600260a75403611f5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a4b565b600260a755565b600081815260a66020526040902054600114611fab576040517fa273b9e600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600090815260a66020526040812055565b6000426099541015611fdf57609754611fd590426138a4565b6099555080611ff0565b81609a54611fed91906138a4565b90505b60985481111561202c576040517fa74c1c5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609a5550565b600054610100900460ff166120c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b73ffffffffffffffffffffffffffffffffffffffff8416612116576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316612163576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61216b6126e2565b6121736126e2565b61217b6126e2565b612185828261277b565b6121af7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d8285611809565b6121d97f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2684611809565b5050600160e455505060e580547fffffffffffffffffffffffff00000000000000000000000000000000000000001663075bcd15179055565b600081815260d9602052604090205460ff16611806576040517f15d8d2e100000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a5e5761229d816128a1565b6122a88360206128c0565b6040516020016122b9929190613bed565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610a4b91600401613cb8565b6000808467ffffffffffffffff8111156123335761233361393d565b60405190808252806020026020018201604052801561235c578160200160208202803683370190505b509050600085900361239a576040517f8999649c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156124135761240b61240661240189898989878181106123c2576123c26138f1565b90506020020160208101906123d79190613ccb565b61ffff168181106123ea576123ea6138f1565b90506020028101906123fc9190613af3565b612b0a565b612c97565b612cda565b60010161239d565b5060005b8581101561247e57868682818110612431576124316138f1565b90506020028101906124439190613af3565b6040516124519291906138b7565b604051809103902082828151811061246b5761246b6138f1565b6020908102919091010152600101612417565b50806040516020016124909190613b58565b60405160208183030381529060405280519060200120915050949350505050565b6000805b828110156124e6576124de8484838181106124d2576124d26138f1565b90506020020135612db5565b6001016124b5565b5082826040516020016124fa929190613ce6565b60405160208183030381529060405280519060200120905092915050565b60408051600180825281830190925260009160208083019080368337019050509050848160008151811061254e5761254e6138f1565b602090810291909101810191909152600085815261011b909152604090205473ffffffffffffffffffffffffffffffffffffffff16806125ba576040517f69ed70ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f7e4f7a8a00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff831690637e4f7a8a906126119088908790600401613d28565b6020604051808303816000875af1158015612630573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126549190613d7f565b90508061268d576040517f09bde33900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61011954600081815261011a6020908152604091829020548251888152918201527f5c885a794662ebe3b08ae0874fc2c88b5343b0223ba9cd2cad92b69c0d0c901f910160405180910390a250505050505050565b600054610100900460ff16612779576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b565b600054610100900460ff16612812576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b8160000361284c576040517fb5ed5a3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003612886576040517fd10d72bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6097829055609881905561289a82426138a4565b6099555050565b606061097a73ffffffffffffffffffffffffffffffffffffffff831660145b606060006128cf8360026138da565b6128da9060026138a4565b67ffffffffffffffff8111156128f2576128f261393d565b6040519080825280601f01601f19166020018201604052801561291c576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612953576129536138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106129b6576129b66138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006129f28460026138da565b6129fd9060016138a4565b90505b6001811115612a9a577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612a3e57612a3e6138f1565b1a60f81b828281518110612a5457612a546138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93612a9381613da1565b9050612a00565b508315612b03576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a4b565b9392505050565b60606001821015612b47576040517fbac5bf1b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083836000818110612b5c57612b5c6138f1565b909101357fff00000000000000000000000000000000000000000000000000000000000000169150507f0100000000000000000000000000000000000000000000000000000000000000819003612bbf57612bb78484612e3a565b91505061097a565b7fff0000000000000000000000000000000000000000000000000000000000000081167f020000000000000000000000000000000000000000000000000000000000000003612c1257612bb78484612eb9565b7fc0000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000821610612c6557612bb78484612f29565b6040517fe95a14a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8101600483019081529160609161097a9190810160200190602401613dd6565b805160005b81811015612d79576000838281518110612cfb57612cfb6138f1565b602090810291909101810151600081815260a590925260409091205490915080612d54576040517f62a064c500000000000000000000000000000000000000000000000000000000815260048101839052602401610a4b565b60028114612d6f57600082815260a560205260409020600290555b5050600101612cdf565b507f95e84bb4317676921a29fd1d13f8f0153508473b899c12b3cd08314348801d6482604051612da99190613eb2565b60405180910390a15050565b600081815260a6602052604090205415612dfe576040517fee49e00100000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b600081815260a66020526040808220600190555182917f810484e22f73d8f099aaee1edb851ec6be6d84d43045d0a7803e5f7b3612edce91a250565b60606000612e4b8360018187613ef6565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612e8d9250849150612f8e9050565b90506000612e9a82612fb3565b9050612eaf612eaa826007613042565b613156565b9695505050505050565b60606000612eca8360018187613ef6565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612f0c9250849150612f8e9050565b90506000612f1982612fb3565b9050612eaf612eaa826008613042565b6060600083838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612f719250849150612f8e9050565b90506000612f7e82612fb3565b9050612eaf612eaa826006613042565b6040805180820190915260008082526020808301918252835183529290920190915290565b6040805160808101825260009181018281526060820183905281526020810191909152612fdf82613201565b613015576040517f0600783200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613024836020015161323c565b836020015161303391906138a4565b92825250602081019190915290565b60408051808201909152600080825260208083018290528451015180518290811a8160f882106001811461307b578015613086576130a0565b60c0830395506130a0565b60f783039150600185019450816020036101000a85510495505b506020880151848601935060006130b6826132b7565b90506130c281836138a4565b60208b015260005b6130d560018b6138c7565b811015613142578a60200151925085831115613120576040517f78268bbb00000000000000000000000000000000000000000000000000000000815260048101879052602401610a4b565b613129836132b7565b915061313582846138a4565b60208c01526001016130ca565b508752602087015250939695505050505050565b8051606090600003613194576040517f5780864900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806131a084613366565b915091508067ffffffffffffffff8111156131bd576131bd61393d565b6040519080825280601f01601f1916602001820160405280156131e7576020820181803683370190505b509250602083016131f98382846133ad565b505050919050565b8051600090810361321457506000919050565b6020820151805160001a9060c0821015613232575060009392505050565b5060019392505050565b8051600090811a60808110156132555750600092915050565b60b8811080613270575060c08110801590613270575060f881105b1561327e5750600192915050565b60c08110156132ab57613293600160b8613f20565b6132a09060ff16826138c7565b612b039060016138a4565b613293600160f8613f20565b805160009081908190811a60808110156132d4576001925061335d565b60b88110156132fa576132e86080826138c7565b6132f39060016138a4565b925061335d565b60c08110156133285760b78103600186019550806020036101000a865104925060018101830193505061335d565b60f881101561333c576132e860c0826138c7565b60f78103600186019550806020036101000a86510492506001810183019350505b50909392505050565b6000806000613378846020015161323c565b9050600081856020015161338c91906138a4565b905060008286600001516133a091906138c7565b9196919550909350505050565b806000036133ba57505050565b602081106133f257825182526133d16020846138a4565b92506133de6020836138a4565b91506133eb6020826138c7565b90506133ba565b80156109a557600060016134078360206138c7565b61341390610100614059565b61341d91906138c7565b84518451821691191617835250505050565b60006020828403121561344157600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612b0357600080fd5b60006020828403121561348357600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461180657600080fd5b600080604083850312156134bf57600080fd5b8235915060208301356134d18161348a565b809150509250929050565b60008083601f8401126134ee57600080fd5b50813567ffffffffffffffff81111561350657600080fd5b6020830191508360208260051b850101111561352157600080fd5b9250929050565b60008083601f84011261353a57600080fd5b50813567ffffffffffffffff81111561355257600080fd5b60208301915083602082850101111561352157600080fd5b6000806000806000806080878903121561358357600080fd5b863567ffffffffffffffff8082111561359b57600080fd5b6135a78a838b016134dc565b909850965060208901359150808211156135c057600080fd5b506135cd89828a01613528565b979a9699509760408101359660609091013595509350505050565b60008060008060008060008060e0898b03121561360457600080fd5b883561360f8161348a565b9750602089013561361f8161348a565b96506040890135955060608901359450608089013561363d8161348a565b935060a089013567ffffffffffffffff81111561365957600080fd5b6136658b828c01613528565b999c989b50969995989497949560c00135949350505050565b60008060008060008060008060e0898b03121561369a57600080fd5b883597506020890135965060408901356136b38161348a565b955060608901356136c38161348a565b9450608089013567ffffffffffffffff8111156136df57600080fd5b6136eb8b828c016134dc565b999c989b5096999598969760a08701359660c0013595509350505050565b6000806020838503121561371c57600080fd5b823567ffffffffffffffff81111561373357600080fd5b61373f858286016134dc565b90969095509350505050565b6000806000806060858703121561376157600080fd5b843561376c8161348a565b935060208501359250604085013567ffffffffffffffff81111561378f57600080fd5b61379b87828801613528565b95989497509550505050565b600080604083850312156137ba57600080fd5b82356137c58161348a565b946020939093013593505050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401525086604083015285606083015284608083015260c060a083015261386860c0830184866137d3565b9998505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561097a5761097a613875565b8183823760009101908152919050565b8181038181111561097a5761097a613875565b808202811582820484141761097a5761097a613875565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561393257600080fd5b8135612b038161348a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361399d5761399d613875565b5060010190565b8581528460208201528360408201526080606082015260006139ca6080830184866137d3565b979650505050505050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff41833603018112613a0957600080fd5b9190910192915050565b600060208284031215613a2557600080fd5b813563ffffffff81168114612b0357600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613a6e57600080fd5b83018035915067ffffffffffffffff821115613a8957600080fd5b6020019150600581901b360382131561352157600080fd5b803561ffff81168114613ab357600080fd5b919050565b60008184825b85811015613ae85761ffff613ad283613aa1565b1683526020928301929190910190600101613abe565b509095945050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b60200191503681900382131561352157600080fd5b815160009082906020808601845b83811015613b8257815185529382019390820190600101613b66565b50929695505050505050565b600082613bc4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b60005b83811015613be4578181015183820152602001613bcc565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613c25816017850160208801613bc9565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613c62816028840160208801613bc9565b01602801949350505050565b60008151808452613c86816020860160208601613bc9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000612b036020830184613c6e565b600060208284031215613cdd57600080fd5b612b0382613aa1565b60007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115613d1557600080fd5b8260051b80858437919091019392505050565b604081526000613d3b6040830185613c6e565b82810360208481019190915284518083528582019282019060005b81811015613d7257845183529383019391830191600101613d56565b5090979650505050505050565b600060208284031215613d9157600080fd5b81518015158114612b0357600080fd5b600081613db057613db0613875565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020808385031215613de957600080fd5b825167ffffffffffffffff80821115613e0157600080fd5b818501915085601f830112613e1557600080fd5b815181811115613e2757613e2761393d565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715613e6a57613e6a61393d565b604052918252848201925083810185019188831115613e8857600080fd5b938501935b82851015613ea657845184529385019392850192613e8d565b98975050505050505050565b6020808252825182820181905260009190848201906040850190845b81811015613eea57835183529284019291840191600101613ece565b50909695505050505050565b60008085851115613f0657600080fd5b83861115613f1357600080fd5b5050820193919092039150565b60ff828116828216039081111561097a5761097a613875565b600181815b80851115613f9257817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613f7857613f78613875565b80851615613f8557918102915b93841c9390800290613f3e565b509250929050565b600082613fa95750600161097a565b81613fb65750600061097a565b8160018114613fcc5760028114613fd657613ff2565b600191505061097a565b60ff841115613fe757613fe7613875565b50506001821b61097a565b5060208310610133831016604e8410600b8410161715614015575081810a61097a565b61401f8383613f39565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561405157614051613875565b029392505050565b6000612b038383613f9a56fea2646970667358221220fc720209f3e373ea184efa97c32233767c7ea1942a89a001c98c4b17bd191a0d64736f6c63430008130033

Deployed Bytecode

0x6080604052600436106102d55760003560e01c80638be745d111610179578063b45a4f2c116100d6578063c1dc0f071161008a578063d547741f11610064578063d547741f1461085f578063d84f91e81461087f578063f5b541a6146108b357600080fd5b8063c1dc0f07146107f9578063c21169741461080f578063cc5782f61461082f57600080fd5b8063b837dbe9116100bb578063b837dbe914610799578063bf3e7505146107af578063c0729ab1146107e357600080fd5b8063b45a4f2c14610745578063b4a5a4b71461076557600080fd5b8063a217fddf1161012d578063ac1eff6811610112578063ac1eff68146106d6578063ad422ff01461071a578063aea4f7451461073057600080fd5b8063a217fddf1461068d578063abd6230d146106a257600080fd5b806391d148541161015e57806391d1485414610627578063986fcddd146105a45780639f3ce55a1461067a57600080fd5b80638be745d1146105d957806390dad3f61461060757600080fd5b8063557eac7311610232578063695378f5116101e65780637973ead6116101c05780637973ead6146105845780637d1e8c55146105a45780638264bd82146105b957600080fd5b8063695378f5146105245780636a6379671461053b57806373bd07b71461056f57600080fd5b80635b7eb4bd116102175780635b7eb4bd1461042e5780635c721a0c146104ab57806367e404ce146104d857600080fd5b8063557eac7314610475578063587944561461049557600080fd5b806336568abe116102895780634165d6dd1161026e5780634165d6dd1461040e57806348922ab71461042e578063491e09361461045557600080fd5b806336568abe146103c15780633fc08b65146103e157600080fd5b80631e2ff94f116102ba5780631e2ff94f14610358578063248a9ca31461036f5780632f2ff15d1461039f57600080fd5b806301ffc9a7146102e157806311314d0f1461031657600080fd5b366102dc57005b600080fd5b3480156102ed57600080fd5b506103016102fc36600461342f565b6108e7565b60405190151581526020015b60405180910390f35b34801561032257600080fd5b5061034a7f9a80e24e463f00a8763c4dcec6a92d07d33272fa5db895d8589be70dccb002df81565b60405190815260200161030d565b34801561036457600080fd5b5061034a6101185481565b34801561037b57600080fd5b5061034a61038a366004613471565b60009081526065602052604090206001015490565b3480156103ab57600080fd5b506103bf6103ba3660046134ac565b610980565b005b3480156103cd57600080fd5b506103bf6103dc3660046134ac565b6109aa565b3480156103ed57600080fd5b5061034a6103fc366004613471565b60a56020526000908152604090205481565b34801561041a57600080fd5b506103bf61042936600461356a565b610a62565b34801561043a57600080fd5b50610443600181565b60405160ff909116815260200161030d565b34801561046157600080fd5b506103bf6104703660046135e8565b610b7e565b34801561048157600080fd5b506103bf610490366004613471565b610f03565b3480156104a157600080fd5b5061034a60995481565b3480156104b757600080fd5b5061034a6104c6366004613471565b60a66020526000908152604090205481565b3480156104e457600080fd5b5060e55473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161030d565b34801561053057600080fd5b5061034a6101195481565b34801561054757600080fd5b5061034a7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b081565b34801561057b57600080fd5b50610443600281565b34801561059057600080fd5b506103bf61059f36600461367e565b610fcb565b3480156105b057600080fd5b50610443600081565b3480156105c557600080fd5b506103bf6105d4366004613471565b611311565b3480156105e557600080fd5b5061034a6105f4366004613471565b61011a6020526000908152604090205481565b34801561061357600080fd5b506103bf610622366004613709565b6113d7565b34801561063357600080fd5b506103016106423660046134ac565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6103bf61068836600461374b565b611431565b34801561069957600080fd5b5061034a600081565b3480156106ae57600080fd5b5061034a7f21ea2f4fee4bcb623de15ac222ea5c1464307d884f23394b78ddc07f9c9c7cd881565b3480156106e257600080fd5b506104ff6106f1366004613471565b61011b6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561072657600080fd5b5061034a60985481565b34801561073c57600080fd5b506103bf6115fa565b34801561075157600080fd5b506103bf610760366004613471565b611656565b34801561077157600080fd5b5061034a7f3a56b1bd788a764cbd923badb6d0719f21f520455285bf6877e636d08708878d81565b3480156107a557600080fd5b5061034a60e45481565b3480156107bb57600080fd5b5061034a7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d8281565b3480156107ef57600080fd5b5061034a609a5481565b34801561080557600080fd5b5061034a60975481565b34801561081b57600080fd5b506103bf61082a3660046137a7565b6116e5565b34801561083b57600080fd5b5061030161084a366004613471565b60d96020526000908152604090205460ff1681565b34801561086b57600080fd5b506103bf61087a3660046134ac565b6117d7565b34801561088b57600080fd5b5061034a7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2681565b3480156108bf57600080fd5b5061034a7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061097a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60008281526065602052604090206001015461099b816117fc565b6109a58383611809565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610a54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610a5e82826118fd565b5050565b7f3a56b1bd788a764cbd923badb6d0719f21f520455285bf6877e636d08708878d610a8c816119b8565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0610ab6816119b8565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929610ae0816117fc565b61011954600090815261011a60205260409020548414610b2c576040517fead4c30e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610b73898989898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b92508a915060019050611a04565b505050505050505050565b610b86611ef0565b858784848760005a9050610bb97f21ea2f4fee4bcb623de15ac222ea5c1464307d884f23394b78ddc07f9c9c7cd86119b8565b610be27f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b06119b8565b60008e8e8e8e8b8e8e604051602001610c01979695949392919061381c565b604051602081830303815290604052805190602001209050610c2281611f63565b610c34610c2f8d8f6138a4565b611fbc565b8e60e560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808f73ffffffffffffffffffffffffffffffffffffffff168e8d8d604051610ca09291906138b7565b60006040518083038185875af1925050503d8060008114610cdd576040519150601f19603f3d011682016040523d82523d6000602084013e610ce2565b606091505b509150915081610d4c57805115610cfc5780518082602001fd5b8f6040517f54613443000000000000000000000000000000000000000000000000000000008152600401610a4b919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b60e580547fffffffffffffffffffffffff00000000000000000000000000000000000000001663075bcd1517905560405183907fa4c827e719e911e8f19393ccdb85b5102f08f0910604d340ba38390b7ff2ab0e90600090a2505086159050610ee957856000849003610e3557853b158015610e33573a5a610dd061a410866138a4565b610dda91906138c7565b610de491906138da565b915081881115610e2f5773ffffffffffffffffffffffffffffffffffffffff87166108fc610e12848b6138c7565b6040518115909202916000818181858888f1935050505050610e33565b8791505b505b600073ffffffffffffffffffffffffffffffffffffffff841615610e595783610e5b565b335b905060008173ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050905080610ee5576040517fa57c4df400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610a4b565b5050505b505050505050610ef9600160a755565b5050505050505050565b7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d82610f2d816117fc565b6000806000426099541015610f5457609754610f4990426138a4565b609955506001610f66565b609a54851015610f6657849250600191505b60988590558080610f745750815b15610f7f57609a8390555b60408051868152831515602082015282151581830152905133917fbc3dc0cb5c15c51c81316450d44048838bb478b9809447d01c766a06f3e9f2c8919081900360600190a25050505050565b600054610100900460ff1615808015610feb5750600054600160ff909116105b806110055750303b158015611005575060005460ff166001145b611091576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610a4b565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156110ef57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff871661113c576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8481101561121557600086868381811061115b5761115b6138f1565b90506020020160208101906111709190613920565b73ffffffffffffffffffffffffffffffffffffffff16036111bd576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61120d7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298787848181106111f3576111f36138f1565b90506020020160208101906112089190613920565b611809565b60010161113f565b50611221600087611809565b61122d86878585612032565b7f033d11f27e62ab919708ec716731da80d261a6e4253259b7acde9bf89d28ec1880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8916179055610119889055600088815261011a602052604090208990558015610b7357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b8061131b816119b8565b7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a26611345816117fc565b600083815260d96020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557fc343aefb875672fb1857ecda2bdf9fa822ff1e924e3714f6a3d88c5199dee2616113a43390565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252602082018690520160405180910390a1505050565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0611401816119b8565b600061140c816117fc565b6040805160008082526020820190925261142b91869186918080611a04565b50505050565b7f9a80e24e463f00a8763c4dcec6a92d07d33272fa5db895d8589be70dccb002df61145b816119b8565b7f06193bb948d6b7a6fcbe51c193ccf2183bb5d979b6ae5d3a6971b8851461d3b0611485816119b8565b73ffffffffffffffffffffffffffffffffffffffff86166114d2576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3485111561150c576040517fb03b693200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e454600061151b87346138c7565b9050600033898984868b8b60405160200161153c979695949392919061381c565b60405160208183030381529060405280519060200120905061156c81600090815260a56020526040902060019055565b60e4805490600061157c8361396c565b9190505550808973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe856c2b8bd4eb0027ce32eeaf595c21b0b6b4644b326e5b7bd80a1cf8db72e6c8b86888d8d6040516115e79594939291906139a4565b60405180910390a4505050505050505050565b7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d82611624816117fc565b6000609a81905560405133917fba88c025b0cbb77022c0c487beef24f759f1e4be2f51a205bc427cee19c2eaa691a250565b8061166081612212565b7f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2661168a816117fc565b600083815260d96020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557fb54c82d9fabaaa460c07181bb36c08c0e72d79293e77a42ac273c81d2a54281b336113a4565b60006116f0816117fc565b73ffffffffffffffffffffffffffffffffffffffff831661173d576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040513390839073ffffffffffffffffffffffffffffffffffffffff8616907f4ea861139068e7701a770b8975bb54b6f8f446897fac206dd29424035b4a61eb90600090a450600090815261011b6020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000828152606560205260409020600101546117f2816117fc565b6109a583836118fd565b611806813361225d565b50565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a5e57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561189f3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610a5e57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260d9602052604090205460ff1615611806576040517f8698dd2b00000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b610119546000611a158260016138a4565b905060008767ffffffffffffffff811115611a3257611a3261393d565b604051908082528060200260200182016040528015611a5b578160200160208202803683370190505b50905060008867ffffffffffffffff811115611a7957611a7961393d565b604051908082528060200260200182016040528015611aa2578160200160208202803683370190505b5090506000611ab28a60016138a4565b67ffffffffffffffff811115611aca57611aca61393d565b604051908082528060200260200182016040528015611af3578160200160208202803683370190505b5090508681600081518110611b0a57611b0a6138f1565b60200260200101818152505060008060005b8c811015611d4857368e8e83818110611b3757611b376138f1565b9050602002810190611b4991906139d5565b905042611b5c6040830160208401613a13565b63ffffffff1610611b99576040517fd4a3081200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bbb611ba96040830183613a39565b611bb660a0850185613a39565b612317565b9350611bd2611bcd6060830183613a39565b6124b1565b9250611bdd8961396c565b98508383611bee60a0840184613a39565b604051602001611bff929190613ab8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190528051602090910120611c426080850185613af3565b604051611c509291906138b7565b604051908190038120611c7e9493929160200193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120868381518110611ca657611ca66138f1565b602002602001018181525050806020016020810190611cc59190613a13565b63ffffffff16878381518110611cdd57611cdd6138f1565b6020908102919091010152803585611cf68460016138a4565b81518110611d0657611d066138f1565b60209081029190910101526040518135908a907ff2c535759092d16e9334a11dd9b52eca543f1d9cca5ba9d16c472aef009de43290600090a350600101611b1c565b508c8c611d566001826138c7565b818110611d6557611d656138f1565b9050602002810190611d7791906139d5565b600088815261011a60205260409020903590558c8c611d976001826138c7565b818110611da657611da66138f1565b9050602002810190611db891906139d5565b611dc9906040810190602001613a13565b63ffffffff16610118556101198790558715611ee157611ee17f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000185604051602001611e149190613b58565b604051602081830303815290604052805190602001208888604051602001611e3c9190613b58565b6040516020818303038152906040528051906020012087604051602001611e639190613b58565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120908301959095528101929092526060820152608081019190915260a0016040516020818303038152906040528051906020012060001c611ed99190613b8e565b8b8d8c612518565b50505050505050505050505050565b600260a75403611f5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a4b565b600260a755565b600081815260a66020526040902054600114611fab576040517fa273b9e600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600090815260a66020526040812055565b6000426099541015611fdf57609754611fd590426138a4565b6099555080611ff0565b81609a54611fed91906138a4565b90505b60985481111561202c576040517fa74c1c5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609a5550565b600054610100900460ff166120c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b73ffffffffffffffffffffffffffffffffffffffff8416612116576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316612163576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61216b6126e2565b6121736126e2565b61217b6126e2565b612185828261277b565b6121af7f1185e52d62bfbbea270e57d3d09733d221b53ab7a18bae82bb3c6c74bab16d8285611809565b6121d97f356a809dfdea9198dd76fb76bf6d403ecf13ea675eb89e1eda2db2c4a4676a2684611809565b5050600160e455505060e580547fffffffffffffffffffffffff00000000000000000000000000000000000000001663075bcd15179055565b600081815260d9602052604090205460ff16611806576040517f15d8d2e100000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a5e5761229d816128a1565b6122a88360206128c0565b6040516020016122b9929190613bed565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a0000000000000000000000000000000000000000000000000000000008252610a4b91600401613cb8565b6000808467ffffffffffffffff8111156123335761233361393d565b60405190808252806020026020018201604052801561235c578160200160208202803683370190505b509050600085900361239a576040517f8999649c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b838110156124135761240b61240661240189898989878181106123c2576123c26138f1565b90506020020160208101906123d79190613ccb565b61ffff168181106123ea576123ea6138f1565b90506020028101906123fc9190613af3565b612b0a565b612c97565b612cda565b60010161239d565b5060005b8581101561247e57868682818110612431576124316138f1565b90506020028101906124439190613af3565b6040516124519291906138b7565b604051809103902082828151811061246b5761246b6138f1565b6020908102919091010152600101612417565b50806040516020016124909190613b58565b60405160208183030381529060405280519060200120915050949350505050565b6000805b828110156124e6576124de8484838181106124d2576124d26138f1565b90506020020135612db5565b6001016124b5565b5082826040516020016124fa929190613ce6565b60405160208183030381529060405280519060200120905092915050565b60408051600180825281830190925260009160208083019080368337019050509050848160008151811061254e5761254e6138f1565b602090810291909101810191909152600085815261011b909152604090205473ffffffffffffffffffffffffffffffffffffffff16806125ba576040517f69ed70ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f7e4f7a8a00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff831690637e4f7a8a906126119088908790600401613d28565b6020604051808303816000875af1158015612630573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126549190613d7f565b90508061268d576040517f09bde33900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61011954600081815261011a6020908152604091829020548251888152918201527f5c885a794662ebe3b08ae0874fc2c88b5343b0223ba9cd2cad92b69c0d0c901f910160405180910390a250505050505050565b600054610100900460ff16612779576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b565b600054610100900460ff16612812576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610a4b565b8160000361284c576040517fb5ed5a3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003612886576040517fd10d72bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6097829055609881905561289a82426138a4565b6099555050565b606061097a73ffffffffffffffffffffffffffffffffffffffff831660145b606060006128cf8360026138da565b6128da9060026138a4565b67ffffffffffffffff8111156128f2576128f261393d565b6040519080825280601f01601f19166020018201604052801561291c576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612953576129536138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106129b6576129b66138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006129f28460026138da565b6129fd9060016138a4565b90505b6001811115612a9a577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612a3e57612a3e6138f1565b1a60f81b828281518110612a5457612a546138f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93612a9381613da1565b9050612a00565b508315612b03576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a4b565b9392505050565b60606001821015612b47576040517fbac5bf1b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083836000818110612b5c57612b5c6138f1565b909101357fff00000000000000000000000000000000000000000000000000000000000000169150507f0100000000000000000000000000000000000000000000000000000000000000819003612bbf57612bb78484612e3a565b91505061097a565b7fff0000000000000000000000000000000000000000000000000000000000000081167f020000000000000000000000000000000000000000000000000000000000000003612c1257612bb78484612eb9565b7fc0000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000821610612c6557612bb78484612f29565b6040517fe95a14a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8101600483019081529160609161097a9190810160200190602401613dd6565b805160005b81811015612d79576000838281518110612cfb57612cfb6138f1565b602090810291909101810151600081815260a590925260409091205490915080612d54576040517f62a064c500000000000000000000000000000000000000000000000000000000815260048101839052602401610a4b565b60028114612d6f57600082815260a560205260409020600290555b5050600101612cdf565b507f95e84bb4317676921a29fd1d13f8f0153508473b899c12b3cd08314348801d6482604051612da99190613eb2565b60405180910390a15050565b600081815260a6602052604090205415612dfe576040517fee49e00100000000000000000000000000000000000000000000000000000000815260048101829052602401610a4b565b600081815260a66020526040808220600190555182917f810484e22f73d8f099aaee1edb851ec6be6d84d43045d0a7803e5f7b3612edce91a250565b60606000612e4b8360018187613ef6565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612e8d9250849150612f8e9050565b90506000612e9a82612fb3565b9050612eaf612eaa826007613042565b613156565b9695505050505050565b60606000612eca8360018187613ef6565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612f0c9250849150612f8e9050565b90506000612f1982612fb3565b9050612eaf612eaa826008613042565b6060600083838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939450612f719250849150612f8e9050565b90506000612f7e82612fb3565b9050612eaf612eaa826006613042565b6040805180820190915260008082526020808301918252835183529290920190915290565b6040805160808101825260009181018281526060820183905281526020810191909152612fdf82613201565b613015576040517f0600783200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613024836020015161323c565b836020015161303391906138a4565b92825250602081019190915290565b60408051808201909152600080825260208083018290528451015180518290811a8160f882106001811461307b578015613086576130a0565b60c0830395506130a0565b60f783039150600185019450816020036101000a85510495505b506020880151848601935060006130b6826132b7565b90506130c281836138a4565b60208b015260005b6130d560018b6138c7565b811015613142578a60200151925085831115613120576040517f78268bbb00000000000000000000000000000000000000000000000000000000815260048101879052602401610a4b565b613129836132b7565b915061313582846138a4565b60208c01526001016130ca565b508752602087015250939695505050505050565b8051606090600003613194576040517f5780864900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806131a084613366565b915091508067ffffffffffffffff8111156131bd576131bd61393d565b6040519080825280601f01601f1916602001820160405280156131e7576020820181803683370190505b509250602083016131f98382846133ad565b505050919050565b8051600090810361321457506000919050565b6020820151805160001a9060c0821015613232575060009392505050565b5060019392505050565b8051600090811a60808110156132555750600092915050565b60b8811080613270575060c08110801590613270575060f881105b1561327e5750600192915050565b60c08110156132ab57613293600160b8613f20565b6132a09060ff16826138c7565b612b039060016138a4565b613293600160f8613f20565b805160009081908190811a60808110156132d4576001925061335d565b60b88110156132fa576132e86080826138c7565b6132f39060016138a4565b925061335d565b60c08110156133285760b78103600186019550806020036101000a865104925060018101830193505061335d565b60f881101561333c576132e860c0826138c7565b60f78103600186019550806020036101000a86510492506001810183019350505b50909392505050565b6000806000613378846020015161323c565b9050600081856020015161338c91906138a4565b905060008286600001516133a091906138c7565b9196919550909350505050565b806000036133ba57505050565b602081106133f257825182526133d16020846138a4565b92506133de6020836138a4565b91506133eb6020826138c7565b90506133ba565b80156109a557600060016134078360206138c7565b61341390610100614059565b61341d91906138c7565b84518451821691191617835250505050565b60006020828403121561344157600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612b0357600080fd5b60006020828403121561348357600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461180657600080fd5b600080604083850312156134bf57600080fd5b8235915060208301356134d18161348a565b809150509250929050565b60008083601f8401126134ee57600080fd5b50813567ffffffffffffffff81111561350657600080fd5b6020830191508360208260051b850101111561352157600080fd5b9250929050565b60008083601f84011261353a57600080fd5b50813567ffffffffffffffff81111561355257600080fd5b60208301915083602082850101111561352157600080fd5b6000806000806000806080878903121561358357600080fd5b863567ffffffffffffffff8082111561359b57600080fd5b6135a78a838b016134dc565b909850965060208901359150808211156135c057600080fd5b506135cd89828a01613528565b979a9699509760408101359660609091013595509350505050565b60008060008060008060008060e0898b03121561360457600080fd5b883561360f8161348a565b9750602089013561361f8161348a565b96506040890135955060608901359450608089013561363d8161348a565b935060a089013567ffffffffffffffff81111561365957600080fd5b6136658b828c01613528565b999c989b50969995989497949560c00135949350505050565b60008060008060008060008060e0898b03121561369a57600080fd5b883597506020890135965060408901356136b38161348a565b955060608901356136c38161348a565b9450608089013567ffffffffffffffff8111156136df57600080fd5b6136eb8b828c016134dc565b999c989b5096999598969760a08701359660c0013595509350505050565b6000806020838503121561371c57600080fd5b823567ffffffffffffffff81111561373357600080fd5b61373f858286016134dc565b90969095509350505050565b6000806000806060858703121561376157600080fd5b843561376c8161348a565b935060208501359250604085013567ffffffffffffffff81111561378f57600080fd5b61379b87828801613528565b95989497509550505050565b600080604083850312156137ba57600080fd5b82356137c58161348a565b946020939093013593505050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600073ffffffffffffffffffffffffffffffffffffffff808a16835280891660208401525086604083015285606083015284608083015260c060a083015261386860c0830184866137d3565b9998505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561097a5761097a613875565b8183823760009101908152919050565b8181038181111561097a5761097a613875565b808202811582820484141761097a5761097a613875565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561393257600080fd5b8135612b038161348a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361399d5761399d613875565b5060010190565b8581528460208201528360408201526080606082015260006139ca6080830184866137d3565b979650505050505050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff41833603018112613a0957600080fd5b9190910192915050565b600060208284031215613a2557600080fd5b813563ffffffff81168114612b0357600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613a6e57600080fd5b83018035915067ffffffffffffffff821115613a8957600080fd5b6020019150600581901b360382131561352157600080fd5b803561ffff81168114613ab357600080fd5b919050565b60008184825b85811015613ae85761ffff613ad283613aa1565b1683526020928301929190910190600101613abe565b509095945050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613b2857600080fd5b83018035915067ffffffffffffffff821115613b4357600080fd5b60200191503681900382131561352157600080fd5b815160009082906020808601845b83811015613b8257815185529382019390820190600101613b66565b50929695505050505050565b600082613bc4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b60005b83811015613be4578181015183820152602001613bcc565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613c25816017850160208801613bc9565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613c62816028840160208801613bc9565b01602801949350505050565b60008151808452613c86816020860160208601613bc9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000612b036020830184613c6e565b600060208284031215613cdd57600080fd5b612b0382613aa1565b60007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115613d1557600080fd5b8260051b80858437919091019392505050565b604081526000613d3b6040830185613c6e565b82810360208481019190915284518083528582019282019060005b81811015613d7257845183529383019391830191600101613d56565b5090979650505050505050565b600060208284031215613d9157600080fd5b81518015158114612b0357600080fd5b600081613db057613db0613875565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60006020808385031215613de957600080fd5b825167ffffffffffffffff80821115613e0157600080fd5b818501915085601f830112613e1557600080fd5b815181811115613e2757613e2761393d565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715613e6a57613e6a61393d565b604052918252848201925083810185019188831115613e8857600080fd5b938501935b82851015613ea657845184529385019392850192613e8d565b98975050505050505050565b6020808252825182820181905260009190848201906040850190845b81811015613eea57835183529284019291840191600101613ece565b50909695505050505050565b60008085851115613f0657600080fd5b83861115613f1357600080fd5b5050820193919092039150565b60ff828116828216039081111561097a5761097a613875565b600181815b80851115613f9257817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613f7857613f78613875565b80851615613f8557918102915b93841c9390800290613f3e565b509250929050565b600082613fa95750600161097a565b81613fb65750600061097a565b8160018114613fcc5760028114613fd657613ff2565b600191505061097a565b60ff841115613fe757613fe7613875565b50506001821b61097a565b5060208310610133831016604e8410600b8410161715614015575081810a61097a565b61401f8383613f39565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561405157614051613875565b029392505050565b6000612b038383613f9a56fea2646970667358221220fc720209f3e373ea184efa97c32233767c7ea1942a89a001c98c4b17bd191a0d64736f6c63430008130033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
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.