ETH Price: $2,607.44 (-3.65%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Transfer Masters...102766072020-06-16 11:46:521701 days ago1592308012IN
zkSync: Upgrade Gatekeeper
0 ETH0.0011137240
Finish Upgrade102720402020-06-15 18:44:221702 days ago1592246662IN
zkSync: Upgrade Gatekeeper
0 ETH0.001809626
Start Preparatio...102719852020-06-15 18:32:561702 days ago1592245976IN
zkSync: Upgrade Gatekeeper
0 ETH0.0018013323
Start Upgrade102718122020-06-15 17:58:261702 days ago1592243906IN
zkSync: Upgrade Gatekeeper
0 ETH0.0049265133.5
Cancel Upgrade102714952020-06-15 16:46:481702 days ago1592239608IN
zkSync: Upgrade Gatekeeper
0 ETH0.0011568738
Start Upgrade102713172020-06-15 16:10:511702 days ago1592237451IN
zkSync: Upgrade Gatekeeper
0 ETH0.0070588848.00000145

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
104988262020-07-20 21:40:321667 days ago1595281232
zkSync: Upgrade Gatekeeper
0.000001 ETH
102698902020-06-15 10:58:271702 days ago1592218707  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UpgradeGatekeeper

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 8 : UpgradeGatekeeper.sol
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;

import "./SafeMath.sol";
import "./Events.sol";
import "./Ownable.sol";
import "./Upgradeable.sol";
import "./UpgradeableMaster.sol";

/// @title Upgrade Gatekeeper Contract
/// @author Matter Labs
contract UpgradeGatekeeper is UpgradeEvents, Ownable {
    using SafeMath for uint256;

    /// @notice Array of addresses of upgradeable contracts managed by the gatekeeper
    Upgradeable[] public managedContracts;

    /// @notice Upgrade mode statuses
    enum UpgradeStatus {
        Idle,
        NoticePeriod,
        Preparation
    }

    UpgradeStatus public upgradeStatus;

    /// @notice Notice period finish timestamp (as seconds since unix epoch)
    /// @dev Will be equal to zero in case of not active upgrade mode
    uint public noticePeriodFinishTimestamp;

    /// @notice Addresses of the next versions of the contracts to be upgraded (if element of this array is equal to zero address it means that appropriate upgradeable contract wouldn't be upgraded this time)
    /// @dev Will be empty in case of not active upgrade mode
    address[] public nextTargets;

    /// @notice Version id of contracts
    uint public versionId;

    /// @notice Contract which defines notice period duration and allows finish upgrade during preparation of it
    UpgradeableMaster public mainContract;

    /// @notice Contract constructor
    /// @param _mainContract Contract which defines notice period duration and allows finish upgrade during preparation of it
    /// @dev Calls Ownable contract constructor
    constructor(UpgradeableMaster _mainContract) Ownable(msg.sender) public {
        mainContract = _mainContract;
        versionId = 0;
    }

    /// @notice Adds a new upgradeable contract to the list of contracts managed by the gatekeeper
    /// @param addr Address of upgradeable contract to add
    function addUpgradeable(address addr) external {
        requireMaster(msg.sender);
        require(upgradeStatus == UpgradeStatus.Idle, "apc11"); /// apc11 - upgradeable contract can't be added during upgrade

        managedContracts.push(Upgradeable(addr));
        emit NewUpgradable(versionId, addr);
    }

    /// @notice Starts upgrade (activates notice period)
    /// @param newTargets New managed contracts targets (if element of this array is equal to zero address it means that appropriate upgradeable contract wouldn't be upgraded this time)
    function startUpgrade(address[] calldata newTargets) external {
        requireMaster(msg.sender);
        require(upgradeStatus == UpgradeStatus.Idle, "spu11"); // spu11 - unable to activate active upgrade mode
        require(newTargets.length == managedContracts.length, "spu12"); // spu12 - number of new targets must be equal to the number of managed contracts

        uint noticePeriod = mainContract.getNoticePeriod();
        mainContract.upgradeNoticePeriodStarted();
        upgradeStatus = UpgradeStatus.NoticePeriod;
        noticePeriodFinishTimestamp = now.add(noticePeriod);
        nextTargets = newTargets;
        emit NoticePeriodStart(versionId, newTargets, noticePeriod);
    }

    /// @notice Cancels upgrade
    function cancelUpgrade() external {
        requireMaster(msg.sender);
        require(upgradeStatus != UpgradeStatus.Idle, "cpu11"); // cpu11 - unable to cancel not active upgrade mode

        mainContract.upgradeCanceled();
        upgradeStatus = UpgradeStatus.Idle;
        noticePeriodFinishTimestamp = 0;
        delete nextTargets;
        emit UpgradeCancel(versionId);
    }

    /// @notice Activates preparation status
    /// @return Bool flag indicating that preparation status has been successfully activated
    function startPreparation() external returns (bool) {
        requireMaster(msg.sender);
        require(upgradeStatus == UpgradeStatus.NoticePeriod, "ugp11"); // ugp11 - unable to activate preparation status in case of not active notice period status

        if (now >= noticePeriodFinishTimestamp) {
            upgradeStatus = UpgradeStatus.Preparation;
            mainContract.upgradePreparationStarted();
            emit PreparationStart(versionId);
            return true;
        } else {
            return false;
        }
    }

    /// @notice Finishes upgrade
    /// @param targetsUpgradeParameters New targets upgrade parameters per each upgradeable contract
    function finishUpgrade(bytes[] calldata targetsUpgradeParameters) external {
        requireMaster(msg.sender);
        require(upgradeStatus == UpgradeStatus.Preparation, "fpu11"); // fpu11 - unable to finish upgrade without preparation status active
        require(targetsUpgradeParameters.length == managedContracts.length, "fpu12"); // fpu12 - number of new targets upgrade parameters must be equal to the number of managed contracts
        require(mainContract.isReadyForUpgrade(), "fpu13"); // fpu13 - main contract is not ready for upgrade
        mainContract.upgradeFinishes();

        for (uint64 i = 0; i < managedContracts.length; i++) {
            address newTarget = nextTargets[i];
            if (newTarget != address(0)) {
                managedContracts[i].upgradeTarget(newTarget, targetsUpgradeParameters[i]);
            }
        }
        versionId++;
        emit UpgradeComplete(versionId, nextTargets);

        upgradeStatus = UpgradeStatus.Idle;
        noticePeriodFinishTimestamp = 0;
        delete nextTargets;
    }

}

File 2 of 8 : SafeMath.sol
pragma solidity ^0.5.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 3 of 8 : Events.sol
pragma solidity ^0.5.0;

import "./Upgradeable.sol";
import "./Operations.sol";


/// @title zkSync events
/// @author Matter Labs
interface Events {

    /// @notice Event emitted when a block is committed
    event BlockCommit(uint32 indexed blockNumber);

    /// @notice Event emitted when a block is verified
    event BlockVerification(uint32 indexed blockNumber);

    /// @notice Event emitted when user send a transaction to withdraw her funds from onchain balance
    event OnchainWithdrawal(
        address indexed owner,
        uint16 indexed tokenId,
        uint128 amount
    );

    /// @notice Event emitted when user send a transaction to deposit her funds
    event OnchainDeposit(
        address indexed sender,
        uint16 indexed tokenId,
        uint128 amount,
        address indexed owner
    );

    /// @notice Event emitted when user sends a authentication fact (e.g. pub-key hash)
    event FactAuth(
        address indexed sender,
        uint32 nonce,
        bytes fact
    );

    /// @notice Event emitted when blocks are reverted
    event BlocksRevert(
        uint32 totalBlocksVerified,
        uint32 totalBlocksCommitted
    );

    /// @notice Exodus mode entered event
    event ExodusMode();

    /// @notice New priority request event. Emitted when a request is placed into mapping
    event NewPriorityRequest(
        address sender,
        uint64 serialId,
        Operations.OpType opType,
        bytes pubData,
        uint256 expirationBlock
    );

    event DepositCommit(
        uint32 indexed franklinBlockId,
        uint32 indexed accountId,
        address owner,
        uint16 indexed tokenId,
        uint128 amount
    );

    event FullExitCommit(
        uint32 indexed franklinBlockId,
        uint32 indexed accountId,
        address owner,
        uint16 indexed tokenId,
        uint128 amount
    );
}

/// @title Upgrade events
/// @author Matter Labs
interface UpgradeEvents {

    /// @notice Event emitted when new upgradeable contract is added to upgrade gatekeeper's list of managed contracts
    event NewUpgradable(
        uint indexed versionId,
        address indexed upgradeable
    );

    /// @notice Upgrade mode enter event
    event NoticePeriodStart(
        uint indexed versionId,
        address[] newTargets,
        uint noticePeriod // notice period (in seconds)
    );

    /// @notice Upgrade mode cancel event
    event UpgradeCancel(
        uint indexed versionId
    );

    /// @notice Upgrade mode preparation status event
    event PreparationStart(
        uint indexed versionId
    );

    /// @notice Upgrade mode complete event
    event UpgradeComplete(
        uint indexed versionId,
        address[] newTargets
    );

}

File 4 of 8 : Ownable.sol
pragma solidity ^0.5.0;

/// @title Ownable Contract
/// @author Matter Labs
contract Ownable {

    /// @notice Storage position of the masters address (keccak256('eip1967.proxy.admin') - 1)
    bytes32 private constant masterPosition = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /// @notice Contract constructor
    /// @dev Sets msg sender address as masters address
    /// @param masterAddress Master address
    constructor(address masterAddress) public {
        setMaster(masterAddress);
    }

    /// @notice Check if specified address is master
    /// @param _address Address to check
    function requireMaster(address _address) internal view {
        require(_address == getMaster(), "oro11"); // oro11 - only by master
    }

    /// @notice Returns contract masters address
    /// @return Masters address
    function getMaster() public view returns (address master) {
        bytes32 position = masterPosition;
        assembly {
            master := sload(position)
        }
    }

    /// @notice Sets new masters address
    /// @param _newMaster New masters address
    function setMaster(address _newMaster) internal {
        bytes32 position = masterPosition;
        assembly {
            sstore(position, _newMaster)
        }
    }

    /// @notice Transfer mastership of the contract to new master
    /// @param _newMaster New masters address
    function transferMastership(address _newMaster) external {
        requireMaster(msg.sender);
        require(_newMaster != address(0), "otp11"); // otp11 - new masters address can't be zero address
        setMaster(_newMaster);
    }

}

File 5 of 8 : Upgradeable.sol
pragma solidity ^0.5.0;


/// @title Interface of the upgradeable contract
/// @author Matter Labs
interface Upgradeable {

    /// @notice Upgrades target of upgradeable contract
    /// @param newTarget New target
    /// @param newTargetInitializationParameters New target initialization parameters
    function upgradeTarget(address newTarget, bytes calldata newTargetInitializationParameters) external;

}

File 6 of 8 : UpgradeableMaster.sol
pragma solidity ^0.5.0;


/// @title Interface of the upgradeable master contract (defines notice period duration and allows finish upgrade during preparation of it)
/// @author Matter Labs
interface UpgradeableMaster {

    /// @notice Notice period before activation preparation status of upgrade mode
    function getNoticePeriod() external returns (uint);

    /// @notice Notifies contract that notice period started
    function upgradeNoticePeriodStarted() external;

    /// @notice Notifies contract that upgrade preparation status is activated
    function upgradePreparationStarted() external;

    /// @notice Notifies contract that upgrade canceled
    function upgradeCanceled() external;

    /// @notice Notifies contract that upgrade finishes
    function upgradeFinishes() external;

    /// @notice Checks that contract is ready for upgrade
    /// @return bool flag indicating that contract is ready for upgrade
    function isReadyForUpgrade() external returns (bool);

}

File 7 of 8 : Operations.sol
pragma solidity ^0.5.0;

import "./Bytes.sol";


/// @title zkSync operations tools
library Operations {

    // Circuit ops and their pubdata (chunks * bytes)

    /// @notice zkSync circuit operation type
    enum OpType {
        Noop,
        Deposit,
        TransferToNew,
        PartialExit,
        _CloseAccount, // used for correct op id offset
        Transfer,
        FullExit,
        ChangePubKey
    }

    // Byte lengths

    uint8 constant TOKEN_BYTES = 2;

    uint8 constant PUBKEY_BYTES = 32;

    uint8 constant NONCE_BYTES = 4;

    uint8 constant PUBKEY_HASH_BYTES = 20;

    uint8 constant ADDRESS_BYTES = 20;

    /// @notice Packed fee bytes lengths
    uint8 constant FEE_BYTES = 2;

    /// @notice zkSync account id bytes lengths
    uint8 constant ACCOUNT_ID_BYTES = 4;

    uint8 constant AMOUNT_BYTES = 16;

    /// @notice Signature (for example full exit signature) bytes length
    uint8 constant SIGNATURE_BYTES = 64;

    // Deposit pubdata
    struct Deposit {
        uint32 accountId;
        uint16 tokenId;
        uint128 amount;
        address owner;
    }

    uint public constant PACKED_DEPOSIT_PUBDATA_BYTES = 
        ACCOUNT_ID_BYTES + TOKEN_BYTES + AMOUNT_BYTES + ADDRESS_BYTES;

    /// Deserialize deposit pubdata
    function readDepositPubdata(bytes memory _data) internal pure
        returns (Deposit memory parsed)
    {
        // NOTE: there is no check that variable sizes are same as constants (i.e. TOKEN_BYTES), fix if possible.
        uint offset = 0;
        (offset, parsed.accountId) = Bytes.readUInt32(_data, offset); // accountId
        (offset, parsed.tokenId) = Bytes.readUInt16(_data, offset);   // tokenId
        (offset, parsed.amount) = Bytes.readUInt128(_data, offset);   // amount
        (offset, parsed.owner) = Bytes.readAddress(_data, offset);    // owner

        require(offset == PACKED_DEPOSIT_PUBDATA_BYTES, "rdp10"); // reading invalid deposit pubdata size
    }

    /// Serialize deposit pubdata
    function writeDepositPubdata(Deposit memory op) internal pure returns (bytes memory buf) {
        buf = abi.encodePacked(
            bytes4(0),   // accountId (ignored) (update when ACCOUNT_ID_BYTES is changed)
            op.tokenId,  // tokenId
            op.amount,   // amount
            op.owner     // owner
        );
    }

    /// @notice Check that deposit pubdata from request and block matches
    function depositPubdataMatch(bytes memory _lhs, bytes memory _rhs) internal pure returns (bool) {
        // We must ignore `accountId` because it is present in block pubdata but not in priority queue
        bytes memory lhs_trimmed = Bytes.slice(_lhs, ACCOUNT_ID_BYTES, PACKED_DEPOSIT_PUBDATA_BYTES - ACCOUNT_ID_BYTES);
        bytes memory rhs_trimmed = Bytes.slice(_rhs, ACCOUNT_ID_BYTES, PACKED_DEPOSIT_PUBDATA_BYTES - ACCOUNT_ID_BYTES);
        return keccak256(lhs_trimmed) == keccak256(rhs_trimmed);
    }

    // FullExit pubdata

    struct FullExit {
        uint32 accountId;
        address owner;
        uint16 tokenId;
        uint128 amount;
    }

    uint public constant PACKED_FULL_EXIT_PUBDATA_BYTES = 
        ACCOUNT_ID_BYTES + ADDRESS_BYTES + TOKEN_BYTES + AMOUNT_BYTES;

    function readFullExitPubdata(bytes memory _data) internal pure
        returns (FullExit memory parsed)
    {
        // NOTE: there is no check that variable sizes are same as constants (i.e. TOKEN_BYTES), fix if possible.
        uint offset = 0;
        (offset, parsed.accountId) = Bytes.readUInt32(_data, offset);      // accountId
        (offset, parsed.owner) = Bytes.readAddress(_data, offset);         // owner
        (offset, parsed.tokenId) = Bytes.readUInt16(_data, offset);        // tokenId
        (offset, parsed.amount) = Bytes.readUInt128(_data, offset);        // amount

        require(offset == PACKED_FULL_EXIT_PUBDATA_BYTES, "rfp10"); // reading invalid full exit pubdata size
    }

    function writeFullExitPubdata(FullExit memory op) internal pure returns (bytes memory buf) {
        buf = abi.encodePacked(
            op.accountId,  // accountId
            op.owner,      // owner
            op.tokenId,    // tokenId
            op.amount      // amount
        );
    }

    /// @notice Check that full exit pubdata from request and block matches
    function fullExitPubdataMatch(bytes memory _lhs, bytes memory _rhs) internal pure returns (bool) {
        // `amount` is ignored because it is present in block pubdata but not in priority queue
        uint lhs = Bytes.trim(_lhs, PACKED_FULL_EXIT_PUBDATA_BYTES - AMOUNT_BYTES);
        uint rhs = Bytes.trim(_rhs, PACKED_FULL_EXIT_PUBDATA_BYTES - AMOUNT_BYTES);
        return lhs == rhs;
    }

    // PartialExit pubdata
    
    struct PartialExit {
        //uint32 accountId; -- present in pubdata, ignored at serialization
        uint16 tokenId;
        uint128 amount;
        //uint16 fee; -- present in pubdata, ignored at serialization
        address owner;
    }

    function readPartialExitPubdata(bytes memory _data, uint _offset) internal pure
        returns (PartialExit memory parsed)
    {
        // NOTE: there is no check that variable sizes are same as constants (i.e. TOKEN_BYTES), fix if possible.
        uint offset = _offset + ACCOUNT_ID_BYTES;                   // accountId (ignored)
        (offset, parsed.tokenId) = Bytes.readUInt16(_data, offset); // tokenId
        (offset, parsed.amount) = Bytes.readUInt128(_data, offset); // amount
        offset += FEE_BYTES;                                        // fee (ignored)
        (offset, parsed.owner) = Bytes.readAddress(_data, offset);  // owner
    }

    function writePartialExitPubdata(PartialExit memory op) internal pure returns (bytes memory buf) {
        buf = abi.encodePacked(
            bytes4(0),  // accountId (ignored) (update when ACCOUNT_ID_BYTES is changed)
            op.tokenId, // tokenId
            op.amount,  // amount
            bytes2(0),  // fee (ignored)  (update when FEE_BYTES is changed)
            op.owner    // owner
        );
    }

    // ChangePubKey

    struct ChangePubKey {
        uint32 accountId;
        bytes20 pubKeyHash;
        address owner;
        uint32 nonce;
    }

    function readChangePubKeyPubdata(bytes memory _data, uint _offset) internal pure
        returns (ChangePubKey memory parsed)
    {
        uint offset = _offset;
        (offset, parsed.accountId) = Bytes.readUInt32(_data, offset);                // accountId
        (offset, parsed.pubKeyHash) = Bytes.readBytes20(_data, offset);              // pubKeyHash
        (offset, parsed.owner) = Bytes.readAddress(_data, offset);                   // owner
        (offset, parsed.nonce) = Bytes.readUInt32(_data, offset);                    // nonce
    }

    // Withdrawal data process

    function readWithdrawalData(bytes memory _data, uint _offset) internal pure
        returns (bool _addToPendingWithdrawalsQueue, address _to, uint16 _tokenId, uint128 _amount)
    {
        uint offset = _offset;
        (offset, _addToPendingWithdrawalsQueue) = Bytes.readBool(_data, offset);
        (offset, _to) = Bytes.readAddress(_data, offset);
        (offset, _tokenId) = Bytes.readUInt16(_data, offset);
        (offset, _amount) = Bytes.readUInt128(_data, offset);
    }

}

File 8 of 8 : Bytes.sol
pragma solidity ^0.5.0;

// Functions named bytesToX, except bytesToBytes20, where X is some type of size N < 32 (size of one word)
// implements the following algorithm:
// f(bytes memory input, uint offset) -> X out
// where byte representation of out is N bytes from input at the given offset
// 1) We compute memory location of the word W such that last N bytes of W is input[offset..offset+N]
// W_address = input + 32 (skip stored length of bytes) + offset - (32 - N) == input + offset + N
// 2) We load W from memory into out, last N bytes of W are placed into out

library Bytes {

    function toBytesFromUInt16(uint16 self) internal pure returns (bytes memory _bts) {
        return toBytesFromUIntTruncated(uint(self), 2);
    }

    function toBytesFromUInt24(uint24 self) internal pure returns (bytes memory _bts) {
        return toBytesFromUIntTruncated(uint(self), 3);
    }

    function toBytesFromUInt32(uint32 self) internal pure returns (bytes memory _bts) {
        return toBytesFromUIntTruncated(uint(self), 4);
    }

    function toBytesFromUInt128(uint128 self) internal pure returns (bytes memory _bts) {
        return toBytesFromUIntTruncated(uint(self), 16);
    }

    // Copies 'len' lower bytes from 'self' into a new 'bytes memory'.
    // Returns the newly created 'bytes memory'. The returned bytes will be of length 'len'.
    function toBytesFromUIntTruncated(uint self, uint8 byteLength) private pure returns (bytes memory bts) {
        require(byteLength <= 32, "bt211");
        bts = new bytes(byteLength);
        // Even though the bytes will allocate a full word, we don't want
        // any potential garbage bytes in there.
        uint data = self << ((32 - byteLength) * 8);
        assembly {
            mstore(add(bts, /*BYTES_HEADER_SIZE*/32), data)
        }
    }

    // Copies 'self' into a new 'bytes memory'.
    // Returns the newly created 'bytes memory'. The returned bytes will be of length '20'.
    function toBytesFromAddress(address self) internal pure returns (bytes memory bts) {
        bts = toBytesFromUIntTruncated(uint(self), 20);
    }

    // See comment at the top of this file for explanation of how this function works.
    // NOTE: theoretically possible overflow of (_start + 20)
    function bytesToAddress(bytes memory self, uint256 _start) internal pure returns (address addr) {
        uint256 offset = _start + 20;
        require(self.length >= offset, "bta11");
        assembly {
            addr := mload(add(self, offset))
        }
    }

    // Reasoning about why this function works is similar to that of other similar functions, except NOTE below.
    // NOTE: that bytes1..32 is stored in the beginning of the word unlike other primitive types
    // NOTE: theoretically possible overflow of (_start + 20)
    function bytesToBytes20(bytes memory self, uint256 _start) internal pure returns (bytes20 r) {
        require(self.length >= (_start + 20), "btb20");
        assembly {
            r := mload(add(add(self, 0x20), _start))
        }
    }

    // See comment at the top of this file for explanation of how this function works.
    // NOTE: theoretically possible overflow of (_start + 0x2)
    function bytesToUInt16(bytes memory _bytes, uint256 _start) internal pure returns (uint16 r) {
        uint256 offset = _start + 0x2;
        require(_bytes.length >= offset, "btu02");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

    // See comment at the top of this file for explanation of how this function works.
    // NOTE: theoretically possible overflow of (_start + 0x3)
    function bytesToUInt24(bytes memory _bytes, uint256 _start) internal pure returns (uint24 r) {
        uint256 offset = _start + 0x3;
        require(_bytes.length >= offset, "btu03");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

    // NOTE: theoretically possible overflow of (_start + 0x4)
    function bytesToUInt32(bytes memory _bytes, uint256 _start) internal pure returns (uint32 r) {
        uint256 offset = _start + 0x4;
        require(_bytes.length >= offset, "btu04");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

    // NOTE: theoretically possible overflow of (_start + 0x10)
    function bytesToUInt128(bytes memory _bytes, uint256 _start) internal pure returns (uint128 r) {
        uint256 offset = _start + 0x10;
        require(_bytes.length >= offset, "btu16");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

    // See comment at the top of this file for explanation of how this function works.
    // NOTE: theoretically possible overflow of (_start + 0x14)
    function bytesToUInt160(bytes memory _bytes, uint256 _start) internal pure returns (uint160 r) {
        uint256 offset = _start + 0x14;
        require(_bytes.length >= offset, "btu20");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

    // NOTE: theoretically possible overflow of (_start + 0x20)
    function bytesToBytes32(bytes memory  _bytes, uint256 _start) internal pure returns (bytes32 r) {
        uint256 offset = _start + 0x20;
        require(_bytes.length >= offset, "btb32");
        assembly {
            r := mload(add(_bytes, offset))
        }
    }

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

        bytes memory tempBytes = new bytes(_length);

        if (_length != 0) {
            // TODO: Review this thoroughly.
            assembly {
                let slice_curr := add(tempBytes, 0x20)
                let slice_end := add(slice_curr, _length)

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

        return tempBytes;
    }

    /// Reads byte stream
    /// @return new_offset - offset + amount of bytes read
    /// @return data - actually read data
    // NOTE: theoretically possible overflow of (_offset + _length)
    function read(bytes memory _data, uint _offset, uint _length) internal pure returns (uint new_offset, bytes memory data) {
        data = slice(_data, _offset, _length);
        new_offset = _offset + _length;
    }

    // NOTE: theoretically possible overflow of (_offset + 1)
    function readBool(bytes memory _data, uint _offset) internal pure returns (uint new_offset, bool r) {
        new_offset = _offset + 1;
        r = uint8(_data[_offset]) != 0;
    }

    // NOTE: theoretically possible overflow of (_offset + 1)
    function readUint8(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint8 r) {
        new_offset = _offset + 1;
        r = uint8(_data[_offset]);
    }

    // NOTE: theoretically possible overflow of (_offset + 2)
    function readUInt16(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint16 r) {
        new_offset = _offset + 2;
        r = bytesToUInt16(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 3)
    function readUInt24(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint24 r) {
        new_offset = _offset + 3;
        r = bytesToUInt24(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 4)
    function readUInt32(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint32 r) {
        new_offset = _offset + 4;
        r = bytesToUInt32(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 16)
    function readUInt128(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint128 r) {
        new_offset = _offset + 16;
        r = bytesToUInt128(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 20)
    function readUInt160(bytes memory _data, uint _offset) internal pure returns (uint new_offset, uint160 r) {
        new_offset = _offset + 20;
        r = bytesToUInt160(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 20)
    function readAddress(bytes memory _data, uint _offset) internal pure returns (uint new_offset, address r) {
        new_offset = _offset + 20;
        r = bytesToAddress(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 20)
    function readBytes20(bytes memory _data, uint _offset) internal pure returns (uint new_offset, bytes20 r) {
        new_offset = _offset + 20;
        r = bytesToBytes20(_data, _offset);
    }

    // NOTE: theoretically possible overflow of (_offset + 32)
    function readBytes32(bytes memory _data, uint _offset) internal pure returns (uint new_offset, bytes32 r) {
        new_offset = _offset + 32;
        r = bytesToBytes32(_data, _offset);
    }

    // Helper function for hex conversion.
    function halfByteToHex(byte _byte) internal pure returns (byte _hexByte) {
        require(uint8(_byte) < 0x10, "hbh11");  // half byte's value is out of 0..15 range.

        // "FEDCBA9876543210" ASCII-encoded, shifted and automatically truncated.
        return byte (uint8 (0x66656463626139383736353433323130 >> (uint8 (_byte) * 8)));
    }

    // Convert bytes to ASCII hex representation
    function bytesToHexASCIIBytes(bytes memory  _input) internal pure returns (bytes memory _output) {
        bytes memory outStringBytes = new bytes(_input.length * 2);

        // code in `assembly` construction is equivalent of the next code:
        // for (uint i = 0; i < _input.length; ++i) {
        //     outStringBytes[i*2] = halfByteToHex(_input[i] >> 4);
        //     outStringBytes[i*2+1] = halfByteToHex(_input[i] & 0x0f);
        // }
        assembly {
            let input_curr := add(_input, 0x20)
            let input_end := add(input_curr, mload(_input))

            for {
                let out_curr := add(outStringBytes, 0x20)
            } lt(input_curr, input_end) {
                input_curr := add(input_curr, 0x01)
                out_curr := add(out_curr, 0x02)
            } {
                let curr_input_byte := shr(0xf8, mload(input_curr))
                // here outStringByte from each half of input byte calculates by the next:
                //
                // "FEDCBA9876543210" ASCII-encoded, shifted and automatically truncated.
                // outStringByte = byte (uint8 (0x66656463626139383736353433323130 >> (uint8 (_byteHalf) * 8)))
                mstore(out_curr,            shl(0xf8, shr(mul(shr(0x04, curr_input_byte), 0x08), 0x66656463626139383736353433323130)))
                mstore(add(out_curr, 0x01), shl(0xf8, shr(mul(and(0x0f, curr_input_byte), 0x08), 0x66656463626139383736353433323130)))
            }
        }
        return outStringBytes;
    }

    /// Trim bytes into single word
    function trim(bytes memory _data, uint _new_length) internal pure returns (uint r) {
        require(_new_length <= 0x20, "trm10");  // new_length is longer than word
        require(_data.length >= _new_length, "trm11");  // data is to short

        uint a;
        assembly {
            a := mload(add(_data, 0x20)) // load bytes into uint256
        }

        return a >> ((0x20 - _new_length) * 8);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract UpgradeableMaster","name":"_mainContract","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"versionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"upgradeable","type":"address"}],"name":"NewUpgradable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"versionId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"newTargets","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"noticePeriod","type":"uint256"}],"name":"NoticePeriodStart","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"versionId","type":"uint256"}],"name":"PreparationStart","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"versionId","type":"uint256"}],"name":"UpgradeCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"versionId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"newTargets","type":"address[]"}],"name":"UpgradeComplete","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"addUpgradeable","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"cancelUpgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes[]","name":"targetsUpgradeParameters","type":"bytes[]"}],"name":"finishUpgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getMaster","outputs":[{"internalType":"address","name":"master","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"mainContract","outputs":[{"internalType":"contract UpgradeableMaster","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"managedContracts","outputs":[{"internalType":"contract Upgradeable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nextTargets","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"noticePeriodFinishTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startPreparation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"newTargets","type":"address[]"}],"name":"startUpgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newMaster","type":"address"}],"name":"transferMastership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"upgradeStatus","outputs":[{"internalType":"enum UpgradeGatekeeper.UpgradeStatus","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"versionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b5060405162001289380380620012898339810160408190526200003491620000ac565b3362000049816001600160e01b036200007516565b50600580546001600160a01b0319166001600160a01b0392909216919091179055600060045562000115565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b8051620000a681620000fb565b92915050565b600060208284031215620000bf57600080fd5b6000620000cd848462000099565b949350505050565b6000620000a682620000ef565b6000620000a682620000d5565b6001600160a01b031690565b6200010681620000e2565b81146200011257600080fd5b50565b61116480620001256000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063999f0be21161008c578063c3f5968711610066578063c3f596871461017a578063d270e7ab1461018d578063d4d543c5146101a2578063f1ce598e146101b7576100cf565b8063999f0be21461014c578063ac0d925c1461015f578063c3d1770614610167576100cf565b806325391624146100d4578063253b153b146100f257806331a94da31461010757806355f291661461011a5780635a99719e146101225780636b131e0614610137575b600080fd5b6100dc6101ca565b6040516100e99190611039565b60405180910390f35b610105610100366004610baf565b6101d0565b005b610105610115366004610baf565b6104e0565b61010561068c565b61012a610779565b6040516100e99190610eee565b61013f61079e565b6040516100e99190610f5f565b61010561015a366004610b89565b610889565b6100dc61093e565b61012a610175366004610c0f565b610944565b610105610188366004610b89565b61096b565b6101956109a6565b6040516100e99190610f6d565b6101aa6109b5565b6040516100e99190610f7b565b6101956101c5366004610c0f565b6109be565b60025481565b6101d9336109cb565b600260015460ff1660028111156101ec57fe5b146102125760405162461bcd60e51b815260040161020990610f89565b60405180910390fd5b60005481146102335760405162461bcd60e51b815260040161020990611029565b600560009054906101000a90046001600160a01b03166001600160a01b0316638773334c6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561028357600080fd5b505af1158015610297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102bb9190810190610bf1565b6102d75760405162461bcd60e51b815260040161020990611019565b600560009054906101000a90046001600160a01b03166001600160a01b031663b269b9ae6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561032757600080fd5b505af115801561033b573d6000803e3d6000fd5b506000925050505b60005467ffffffffffffffff8216101561047a57600060038267ffffffffffffffff168154811061037057fe5b6000918252602090912001546001600160a01b0316905080156104715760008267ffffffffffffffff16815481106103a457fe5b6000918252602090912001546001600160a01b0316636fc4914082868667ffffffffffffffff87168181106103d557fe5b602002820190508035601e19368490030181126103f157600080fd5b9091016020810191503567ffffffffffffffff81111561041057600080fd5b3681900382131561042057600080fd5b6040518463ffffffff1660e01b815260040161043e93929190610efc565b600060405180830381600087803b15801561045857600080fd5b505af115801561046c573d6000803e3d6000fd5b505050505b50600101610343565b5060048054600101908190556040517f48bc8be43b04d57da4f0d65c05db98278a94d9e90b7348d5d2705cc78c9a9d2e906104b790600390610f47565b60405180910390a26001805460ff19169055600060028190556104dc90600390610a55565b5050565b6104e9336109cb565b600060015460ff1660028111156104fc57fe5b146105195760405162461bcd60e51b815260040161020990610fb9565b600054811461053a5760405162461bcd60e51b815260040161020990610fe9565b60055460408051630a8c5d3d60e21b815290516000926001600160a01b031691632a3174f491600480830192602092919082900301818787803b15801561058057600080fd5b505af1158015610594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105b89190810190610c2d565b9050600560009054906101000a90046001600160a01b03166001600160a01b0316633b154b736040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561060a57600080fd5b505af115801561061e573d6000803e3d6000fd5b50506001805460ff1916811790555061063990504282610a03565b60025561064860038484610a73565b506004547fabce748366d7d01473824f1bee75dc176759f56b88f00253e4a10d7528ca806f84848460405161067f93929190610f26565b60405180910390a2505050565b610695336109cb565b600060015460ff1660028111156106a857fe5b14156106c65760405162461bcd60e51b815260040161020990610f99565b600560009054906101000a90046001600160a01b03166001600160a01b031663871b8ff16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561071657600080fd5b505af115801561072a573d6000803e3d6000fd5b50506001805460ff1916905550506000600281905561074b90600390610a55565b6004546040517f55cd34119fd31f1a8cc60aad1098023b450274eef2294e3e1b6dd452d58ce6fd90600090a2565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b60006107a9336109cb565b6001805460ff1660028111156107bb57fe5b146107d85760405162461bcd60e51b815260040161020990611009565b6002544210610882576001805460ff191660021790556005546040805163078b91e760e41b815290516001600160a01b03909216916378b91e709160048082019260009290919082900301818387803b15801561083457600080fd5b505af1158015610848573d6000803e3d6000fd5b50506004546040519092507fd2b7d4a4a2b38481e36a9b8198af8b427261011fd199b7a1b7cb8f437aa25acd9150600090a2506001610886565b5060005b90565b610892336109cb565b600060015460ff1660028111156108a557fe5b146108c25760405162461bcd60e51b815260040161020990610fd9565b600080546001810182558180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630180546001600160a01b0319166001600160a01b038416908117909155600454604051919290917fecfd8b4d8bfc0590001d923f6db32faaad4c3d96097734fe5950f43980dabfc49190a350565b60045481565b6003818154811061095157fe5b6000918252602090912001546001600160a01b0316905081565b610974336109cb565b6001600160a01b03811661099a5760405162461bcd60e51b815260040161020990610ff9565b6109a381610a31565b50565b6005546001600160a01b031681565b60015460ff1681565b6000818154811061095157fe5b6109d3610779565b6001600160a01b0316816001600160a01b0316146109a35760405162461bcd60e51b815260040161020990610fa9565b600082820183811015610a285760405162461bcd60e51b815260040161020990610fc9565b90505b92915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b50805460008255906000526020600020908101906109a39190610ad6565b828054828255906000526020600020908101928215610ac6579160200282015b82811115610ac65781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190610a93565b50610ad2929150610af0565b5090565b61088691905b80821115610ad25760008155600101610adc565b61088691905b80821115610ad25780546001600160a01b0319168155600101610af6565b8035610a2b816110fb565b60008083601f840112610b3157600080fd5b50813567ffffffffffffffff811115610b4957600080fd5b602083019150836020820283011115610b6157600080fd5b9250929050565b8051610a2b8161110f565b8035610a2b81611118565b8051610a2b81611118565b600060208284031215610b9b57600080fd5b6000610ba78484610b14565b949350505050565b60008060208385031215610bc257600080fd5b823567ffffffffffffffff811115610bd957600080fd5b610be585828601610b1f565b92509250509250929050565b600060208284031215610c0357600080fd5b6000610ba78484610b68565b600060208284031215610c2157600080fd5b6000610ba78484610b73565b600060208284031215610c3f57600080fd5b6000610ba78484610b7e565b6000610c578383610c5f565b505060200190565b610c6881611087565b82525050565b6000610c7a8385611063565b9350610c8582610886565b8060005b85811015610cbb57610c9b828461106c565b610ca58882610c4b565b9750610cb083611057565b925050600101610c89565b509495945050505050565b6000610cd182611053565b610cdb8185611063565b9350610ce683611047565b8060005b83811015610cbb57610cfb826110db565b610d058882610c4b565b9750610d108361105d565b925050600101610cea565b610c6881611092565b6000610d308385611063565b9350610d3d8385846110bc565b610d46836110e7565b9093019392505050565b610c68816110a6565b610c68816110b1565b6000610d6f600583611063565b64667075313160d81b815260200192915050565b6000610d90600583611063565b64637075313160d81b815260200192915050565b6000610db1600583611063565b646f726f313160d81b815260200192915050565b6000610dd2600583611063565b64737075313160d81b815260200192915050565b6000610df3601b83611063565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000610e2c600583611063565b64617063313160d81b815260200192915050565b6000610e4d600583611063565b6439b83a989960d91b815260200192915050565b6000610e6e600583611063565b646f7470313160d81b815260200192915050565b6000610e8f600583611063565b64756770313160d81b815260200192915050565b6000610eb0600583611063565b64667075313360d81b815260200192915050565b6000610ed1600583611063565b6433383a989960d91b815260200192915050565b610c6881610886565b60208101610a2b8284610c5f565b60408101610f0a8286610c5f565b8181036020830152610f1d818486610d24565b95945050505050565b60408082528101610f38818587610c6e565b9050610ba76020830184610ee5565b60208082528101610f588184610cc6565b9392505050565b60208101610a2b8284610d1b565b60208101610a2b8284610d50565b60208101610a2b8284610d59565b60208082528101610a2b81610d62565b60208082528101610a2b81610d83565b60208082528101610a2b81610da4565b60208082528101610a2b81610dc5565b60208082528101610a2b81610de6565b60208082528101610a2b81610e1f565b60208082528101610a2b81610e40565b60208082528101610a2b81610e61565b60208082528101610a2b81610e82565b60208082528101610a2b81610ea3565b60208082528101610a2b81610ec4565b60208101610a2b8284610ee5565b60009081526020902090565b5490565b60200190565b60010190565b90815260200190565b6000610f586020840184610b14565b6001600160a01b031690565b6000610a2b8261107b565b151590565b806110a1816110f1565b919050565b6000610a2b82611087565b6000610a2b82611097565b82818337506000910152565b6000610a2b6110d683610886565b61107b565b6000610a2b82546110c8565b601f01601f191690565b600381106109a357fe5b61110481611087565b81146109a357600080fd5b61110481611092565b6111048161088656fea365627a7a723158209444a3f40806a32aea5c3b6851f8e2e00bfb90c9e9552a7660010e48c75f17ae6c6578706572696d656e74616cf564736f6c63430005100040000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063999f0be21161008c578063c3f5968711610066578063c3f596871461017a578063d270e7ab1461018d578063d4d543c5146101a2578063f1ce598e146101b7576100cf565b8063999f0be21461014c578063ac0d925c1461015f578063c3d1770614610167576100cf565b806325391624146100d4578063253b153b146100f257806331a94da31461010757806355f291661461011a5780635a99719e146101225780636b131e0614610137575b600080fd5b6100dc6101ca565b6040516100e99190611039565b60405180910390f35b610105610100366004610baf565b6101d0565b005b610105610115366004610baf565b6104e0565b61010561068c565b61012a610779565b6040516100e99190610eee565b61013f61079e565b6040516100e99190610f5f565b61010561015a366004610b89565b610889565b6100dc61093e565b61012a610175366004610c0f565b610944565b610105610188366004610b89565b61096b565b6101956109a6565b6040516100e99190610f6d565b6101aa6109b5565b6040516100e99190610f7b565b6101956101c5366004610c0f565b6109be565b60025481565b6101d9336109cb565b600260015460ff1660028111156101ec57fe5b146102125760405162461bcd60e51b815260040161020990610f89565b60405180910390fd5b60005481146102335760405162461bcd60e51b815260040161020990611029565b600560009054906101000a90046001600160a01b03166001600160a01b0316638773334c6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561028357600080fd5b505af1158015610297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102bb9190810190610bf1565b6102d75760405162461bcd60e51b815260040161020990611019565b600560009054906101000a90046001600160a01b03166001600160a01b031663b269b9ae6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561032757600080fd5b505af115801561033b573d6000803e3d6000fd5b506000925050505b60005467ffffffffffffffff8216101561047a57600060038267ffffffffffffffff168154811061037057fe5b6000918252602090912001546001600160a01b0316905080156104715760008267ffffffffffffffff16815481106103a457fe5b6000918252602090912001546001600160a01b0316636fc4914082868667ffffffffffffffff87168181106103d557fe5b602002820190508035601e19368490030181126103f157600080fd5b9091016020810191503567ffffffffffffffff81111561041057600080fd5b3681900382131561042057600080fd5b6040518463ffffffff1660e01b815260040161043e93929190610efc565b600060405180830381600087803b15801561045857600080fd5b505af115801561046c573d6000803e3d6000fd5b505050505b50600101610343565b5060048054600101908190556040517f48bc8be43b04d57da4f0d65c05db98278a94d9e90b7348d5d2705cc78c9a9d2e906104b790600390610f47565b60405180910390a26001805460ff19169055600060028190556104dc90600390610a55565b5050565b6104e9336109cb565b600060015460ff1660028111156104fc57fe5b146105195760405162461bcd60e51b815260040161020990610fb9565b600054811461053a5760405162461bcd60e51b815260040161020990610fe9565b60055460408051630a8c5d3d60e21b815290516000926001600160a01b031691632a3174f491600480830192602092919082900301818787803b15801561058057600080fd5b505af1158015610594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506105b89190810190610c2d565b9050600560009054906101000a90046001600160a01b03166001600160a01b0316633b154b736040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561060a57600080fd5b505af115801561061e573d6000803e3d6000fd5b50506001805460ff1916811790555061063990504282610a03565b60025561064860038484610a73565b506004547fabce748366d7d01473824f1bee75dc176759f56b88f00253e4a10d7528ca806f84848460405161067f93929190610f26565b60405180910390a2505050565b610695336109cb565b600060015460ff1660028111156106a857fe5b14156106c65760405162461bcd60e51b815260040161020990610f99565b600560009054906101000a90046001600160a01b03166001600160a01b031663871b8ff16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561071657600080fd5b505af115801561072a573d6000803e3d6000fd5b50506001805460ff1916905550506000600281905561074b90600390610a55565b6004546040517f55cd34119fd31f1a8cc60aad1098023b450274eef2294e3e1b6dd452d58ce6fd90600090a2565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b60006107a9336109cb565b6001805460ff1660028111156107bb57fe5b146107d85760405162461bcd60e51b815260040161020990611009565b6002544210610882576001805460ff191660021790556005546040805163078b91e760e41b815290516001600160a01b03909216916378b91e709160048082019260009290919082900301818387803b15801561083457600080fd5b505af1158015610848573d6000803e3d6000fd5b50506004546040519092507fd2b7d4a4a2b38481e36a9b8198af8b427261011fd199b7a1b7cb8f437aa25acd9150600090a2506001610886565b5060005b90565b610892336109cb565b600060015460ff1660028111156108a557fe5b146108c25760405162461bcd60e51b815260040161020990610fd9565b600080546001810182558180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630180546001600160a01b0319166001600160a01b038416908117909155600454604051919290917fecfd8b4d8bfc0590001d923f6db32faaad4c3d96097734fe5950f43980dabfc49190a350565b60045481565b6003818154811061095157fe5b6000918252602090912001546001600160a01b0316905081565b610974336109cb565b6001600160a01b03811661099a5760405162461bcd60e51b815260040161020990610ff9565b6109a381610a31565b50565b6005546001600160a01b031681565b60015460ff1681565b6000818154811061095157fe5b6109d3610779565b6001600160a01b0316816001600160a01b0316146109a35760405162461bcd60e51b815260040161020990610fa9565b600082820183811015610a285760405162461bcd60e51b815260040161020990610fc9565b90505b92915050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b50805460008255906000526020600020908101906109a39190610ad6565b828054828255906000526020600020908101928215610ac6579160200282015b82811115610ac65781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190610a93565b50610ad2929150610af0565b5090565b61088691905b80821115610ad25760008155600101610adc565b61088691905b80821115610ad25780546001600160a01b0319168155600101610af6565b8035610a2b816110fb565b60008083601f840112610b3157600080fd5b50813567ffffffffffffffff811115610b4957600080fd5b602083019150836020820283011115610b6157600080fd5b9250929050565b8051610a2b8161110f565b8035610a2b81611118565b8051610a2b81611118565b600060208284031215610b9b57600080fd5b6000610ba78484610b14565b949350505050565b60008060208385031215610bc257600080fd5b823567ffffffffffffffff811115610bd957600080fd5b610be585828601610b1f565b92509250509250929050565b600060208284031215610c0357600080fd5b6000610ba78484610b68565b600060208284031215610c2157600080fd5b6000610ba78484610b73565b600060208284031215610c3f57600080fd5b6000610ba78484610b7e565b6000610c578383610c5f565b505060200190565b610c6881611087565b82525050565b6000610c7a8385611063565b9350610c8582610886565b8060005b85811015610cbb57610c9b828461106c565b610ca58882610c4b565b9750610cb083611057565b925050600101610c89565b509495945050505050565b6000610cd182611053565b610cdb8185611063565b9350610ce683611047565b8060005b83811015610cbb57610cfb826110db565b610d058882610c4b565b9750610d108361105d565b925050600101610cea565b610c6881611092565b6000610d308385611063565b9350610d3d8385846110bc565b610d46836110e7565b9093019392505050565b610c68816110a6565b610c68816110b1565b6000610d6f600583611063565b64667075313160d81b815260200192915050565b6000610d90600583611063565b64637075313160d81b815260200192915050565b6000610db1600583611063565b646f726f313160d81b815260200192915050565b6000610dd2600583611063565b64737075313160d81b815260200192915050565b6000610df3601b83611063565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000610e2c600583611063565b64617063313160d81b815260200192915050565b6000610e4d600583611063565b6439b83a989960d91b815260200192915050565b6000610e6e600583611063565b646f7470313160d81b815260200192915050565b6000610e8f600583611063565b64756770313160d81b815260200192915050565b6000610eb0600583611063565b64667075313360d81b815260200192915050565b6000610ed1600583611063565b6433383a989960d91b815260200192915050565b610c6881610886565b60208101610a2b8284610c5f565b60408101610f0a8286610c5f565b8181036020830152610f1d818486610d24565b95945050505050565b60408082528101610f38818587610c6e565b9050610ba76020830184610ee5565b60208082528101610f588184610cc6565b9392505050565b60208101610a2b8284610d1b565b60208101610a2b8284610d50565b60208101610a2b8284610d59565b60208082528101610a2b81610d62565b60208082528101610a2b81610d83565b60208082528101610a2b81610da4565b60208082528101610a2b81610dc5565b60208082528101610a2b81610de6565b60208082528101610a2b81610e1f565b60208082528101610a2b81610e40565b60208082528101610a2b81610e61565b60208082528101610a2b81610e82565b60208082528101610a2b81610ea3565b60208082528101610a2b81610ec4565b60208101610a2b8284610ee5565b60009081526020902090565b5490565b60200190565b60010190565b90815260200190565b6000610f586020840184610b14565b6001600160a01b031690565b6000610a2b8261107b565b151590565b806110a1816110f1565b919050565b6000610a2b82611087565b6000610a2b82611097565b82818337506000910152565b6000610a2b6110d683610886565b61107b565b6000610a2b82546110c8565b601f01601f191690565b600381106109a357fe5b61110481611087565b81146109a357600080fd5b61110481611092565b6111048161088656fea365627a7a723158209444a3f40806a32aea5c3b6851f8e2e00bfb90c9e9552a7660010e48c75f17ae6c6578706572696d656e74616cf564736f6c63430005100040

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef

-----Decoded View---------------
Arg [0] : _mainContract (address): 0xaBEA9132b05A70803a4E85094fD0e1800777fBEF

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000abea9132b05a70803a4e85094fd0e1800777fbef


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

OVERVIEW

This is the contract that implements the upgrade mechanism for Governance, Verifier and ZkSync.

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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.